trepanning 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +161 -0
- data/NEWS +10 -0
- data/Rakefile +13 -19
- data/app/frame.rb +1 -1
- data/app/irb.rb +1 -1
- data/app/util.rb +3 -10
- data/data/irbrc +1 -1
- data/lib/trepanning.rb +2 -2
- data/processor/command/alias.rb +10 -11
- data/processor/command/backtrace.rb +8 -9
- data/processor/command/base/cmd.rb +4 -0
- data/processor/command/base/subcmd.rb +0 -1
- data/processor/command/base/submgr.rb +12 -3
- data/processor/command/break.rb +14 -15
- data/processor/command/condition.rb +11 -12
- data/processor/command/continue.rb +10 -11
- data/processor/command/debug.rb +7 -8
- data/processor/command/delete.rb +10 -9
- data/processor/command/directory.rb +1 -1
- data/processor/command/disable.rb +8 -9
- data/processor/command/disassemble.rb +7 -8
- data/processor/command/display.rb +10 -11
- data/processor/command/down.rb +8 -9
- data/processor/command/enable.rb +9 -10
- data/processor/command/exit.rb +11 -10
- data/processor/command/finish.rb +12 -11
- data/processor/command/frame.rb +3 -4
- data/processor/command/help.rb +14 -16
- data/processor/command/info.rb +7 -8
- data/processor/command/irb.rb +13 -14
- data/processor/command/kill.rb +21 -10
- data/processor/command/list.rb +36 -36
- data/processor/command/macro.rb +4 -5
- data/processor/command/next.rb +19 -20
- data/processor/command/nocache.rb +3 -4
- data/processor/command/{print.rb → pr.rb} +11 -9
- data/processor/command/ps.rb +8 -8
- data/processor/command/quit.rb +17 -15
- data/processor/command/raise.rb +11 -10
- data/processor/command/reload.rb +4 -5
- data/processor/command/restart.rb +11 -10
- data/processor/command/save.rb +12 -9
- data/processor/command/set.rb +14 -15
- data/processor/command/set_subcmd/debug_subcmd/dbgr.rb +1 -1
- data/processor/command/set_subcmd/debug_subcmd/skip.rb +1 -1
- data/processor/command/show.rb +7 -7
- data/processor/command/show_subcmd/alias.rb +3 -4
- data/processor/command/show_subcmd/args.rb +0 -2
- data/processor/command/show_subcmd/auto.rb +2 -3
- data/processor/command/show_subcmd/basename.rb +0 -3
- data/processor/command/show_subcmd/debug.rb +2 -1
- data/processor/command/show_subcmd/debug_subcmd/dbgr.rb +1 -1
- data/processor/command/show_subcmd/different.rb +0 -3
- data/processor/command/show_subcmd/events.rb +0 -2
- data/processor/command/show_subcmd/macro.rb +2 -5
- data/processor/command/show_subcmd/max.rb +2 -1
- data/processor/command/show_subcmd/trace.rb +2 -2
- data/processor/command/source.rb +9 -8
- data/processor/command/step.rb +28 -29
- data/processor/command/stepi.rb +1 -1
- data/processor/command/unalias.rb +4 -5
- data/processor/command/undisplay.rb +4 -5
- data/processor/command/up.rb +9 -10
- data/processor/eval.rb +6 -2
- data/processor/frame.rb +32 -26
- data/processor/main.rb +1 -1
- data/processor/mock.rb +9 -3
- data/processor/running.rb +11 -7
- data/processor/validate.rb +1 -2
- data/test/functional/test-fn_helper.rb +42 -0
- data/test/functional/test-raise.rb +1 -1
- data/test/functional/test-return.rb +2 -2
- data/test/unit/test-app-util.rb +3 -4
- data/test/unit/test-base-subcmd.rb +2 -1
- data/test/unit/test-cmd-help.rb +4 -4
- data/test/unit/test-proc-frame.rb +1 -2
- data/test/unit/test-proc-main.rb +1 -1
- metadata +10 -7
data/processor/eval.rb
CHANGED
@@ -67,6 +67,9 @@ if __FILE__ == $0
|
|
67
67
|
def cmdp.errmsg(msg)
|
68
68
|
puts "** #{msg}"
|
69
69
|
end
|
70
|
+
def cmdp.msg(msg)
|
71
|
+
puts "** #{msg}"
|
72
|
+
end
|
70
73
|
begin
|
71
74
|
1/0
|
72
75
|
rescue Exception => exc
|
@@ -74,12 +77,13 @@ if __FILE__ == $0
|
|
74
77
|
puts '=' * 40
|
75
78
|
end
|
76
79
|
|
77
|
-
x =
|
80
|
+
x = 10
|
78
81
|
require 'thread_frame'
|
79
82
|
cmdp.instance_variable_set('@frame', RubyVM::ThreadFrame.current)
|
80
83
|
cmdp.instance_variable_set('@settings', {:stack_trace_on_error => true})
|
81
|
-
def cmdp.
|
84
|
+
def cmdp.msg(mess) ; puts mess end
|
82
85
|
puts cmdp.debug_eval('x = "#{x}"')
|
86
|
+
puts '=' * 40
|
83
87
|
puts cmdp.debug_eval('x+')
|
84
88
|
puts cmdp.debug_eval_no_errmsg('y+')
|
85
89
|
puts '=' * 40
|
data/processor/frame.rb
CHANGED
@@ -6,31 +6,37 @@ class Trepan
|
|
6
6
|
class CmdProcessor
|
7
7
|
|
8
8
|
attr_reader :current_thread
|
9
|
-
|
10
|
-
|
11
|
-
attr_accessor :
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
attr_accessor :
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
attr_accessor :
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
9
|
+
|
10
|
+
# ThreadFrame, current frame
|
11
|
+
attr_accessor :frame
|
12
|
+
|
13
|
+
# frame index in a "backtrace" command
|
14
|
+
attr_accessor :frame_index
|
15
|
+
attr_accessor :hide_level
|
16
|
+
|
17
|
+
# Hash[thread_id] -> FixNum, the level of the last frame to
|
18
|
+
# show. If we called the debugger directly, then there is
|
19
|
+
# generally a portion of a backtrace we don't want to show. We
|
20
|
+
# don't need to store this for all threads, just those we want to
|
21
|
+
# hide frame on. A value of 1 means to hide just the oldest
|
22
|
+
# level. The default or showing all levels is 0.
|
23
|
+
attr_accessor :hidelevels
|
24
|
+
|
25
|
+
# Hash[container] -> file container. This gives us a way to map non-file
|
26
|
+
# container objects to a file container for display.
|
27
|
+
attr_accessor :remap_container
|
28
|
+
|
29
|
+
# Hash[iseq] -> file container. This gives as a way to map instruction
|
30
|
+
# sequences to a file container for display.
|
31
|
+
attr_accessor :remap_iseq
|
32
|
+
|
33
|
+
# top frame of current thread. Since right now the ThreadFrame
|
34
|
+
# method has "prev" but no way to move in the other direction. So
|
35
|
+
# we store the top frame.
|
36
|
+
attr_accessor :top_frame
|
37
|
+
|
38
|
+
# Hash[thread_id] -> top_frame
|
39
|
+
attr_reader :threads2frames
|
34
40
|
|
35
41
|
|
36
42
|
def adjust_frame(frame_num, absolute_pos)
|
@@ -216,7 +222,7 @@ if __FILE__ == $0
|
|
216
222
|
|
217
223
|
proc = Trepan::CmdProcessor.new(Trepan::MockCore.new())
|
218
224
|
proc.frame_setup(RubyVM::ThreadFrame.current)
|
219
|
-
proc.
|
225
|
+
proc.frame_initialize
|
220
226
|
puts "stack size: #{proc.top_frame.stack_size}"
|
221
227
|
0.upto(proc.top_frame.stack_size) { |i| proc.adjust_frame(i, true) }
|
222
228
|
puts '*' * 10
|
data/processor/main.rb
CHANGED
data/processor/mock.rb
CHANGED
@@ -37,7 +37,11 @@ module MockDebugger
|
|
37
37
|
end
|
38
38
|
|
39
39
|
# Common Mock debugger setup
|
40
|
-
def setup(name, show_constants=true)
|
40
|
+
def setup(name=nil, show_constants=true)
|
41
|
+
unless name
|
42
|
+
tf = RubyVM::ThreadFrame.current.prev
|
43
|
+
name = File.basename(tf.source_container[1], '.rb')
|
44
|
+
end
|
41
45
|
if ARGV.size > 0 && ARGV[0] == 'debug'
|
42
46
|
require_relative '../lib/trepanning'
|
43
47
|
dbgr = Trepan.new
|
@@ -71,11 +75,13 @@ module MockDebugger
|
|
71
75
|
def show_special_class_constants(cmd)
|
72
76
|
puts 'ALIASES: %s' % [cmd.class.const_get('ALIASES').inspect] if
|
73
77
|
cmd.class.constants.member?(:ALIASES)
|
74
|
-
%w(CATEGORY
|
78
|
+
%w(CATEGORY MIN_ARGS MAX_ARGS
|
75
79
|
NAME NEED_STACK SHORT_HELP).each do |name|
|
76
80
|
puts '%s: %s' % [name, cmd.class.const_get(name).inspect]
|
77
81
|
end
|
78
|
-
puts '-
|
82
|
+
puts '-' * 30
|
83
|
+
puts cmd.class.const_get('HELP')
|
84
|
+
puts '=' * 30
|
79
85
|
end
|
80
86
|
module_function :show_special_class_constants
|
81
87
|
|
data/processor/running.rb
CHANGED
@@ -28,8 +28,8 @@ class Trepan
|
|
28
28
|
@leave_cmd_loop = true # Break out of the processor command loop.
|
29
29
|
end
|
30
30
|
|
31
|
-
# Does whatever needs to be done to set to
|
32
|
-
#
|
31
|
+
# Does whatever setup needs to be done to set to ignore stepping
|
32
|
+
# to the finish of the current method.
|
33
33
|
def finish(level_count=0, opts={})
|
34
34
|
step(0, opts)
|
35
35
|
@next_level = @frame.stack_size - level_count
|
@@ -40,8 +40,12 @@ class Trepan
|
|
40
40
|
@frame.trace_off = true # No more tracing in this frame
|
41
41
|
@frame.return_stop = true # don't need to
|
42
42
|
end
|
43
|
-
|
44
|
-
#
|
43
|
+
|
44
|
+
# Does whatever needs to be done to set to do "step over" or ignore
|
45
|
+
# stepping into methods called from this stack but step into any in
|
46
|
+
# the same level. We do this by keeping track of the number of
|
47
|
+
# stack frames and the current thread. Elsewhere in "skipping_step?"
|
48
|
+
# we do the checking.
|
45
49
|
def next(step_count=1, opts={})
|
46
50
|
step(step_count, opts)
|
47
51
|
@next_level = @top_frame.stack_size
|
@@ -124,9 +128,9 @@ class Trepan
|
|
124
128
|
|
125
129
|
# If the last stop was a breakpoint, don't stop again if we are at
|
126
130
|
# the same location with a line event.
|
127
|
-
skip_val
|
128
|
-
|
129
|
-
|
131
|
+
skip_val ||= (@last_pos[4] == 'brkpt' &&
|
132
|
+
@event == 'line' &&
|
133
|
+
@frame.pc_offset == @last_pos[5])
|
130
134
|
|
131
135
|
if @settings[:'debugskip']
|
132
136
|
puts "skip: #{skip_val.inspect}, last: #{@last_pos}, new: #{new_pos}"
|
data/processor/validate.rb
CHANGED
@@ -154,8 +154,7 @@ class Trepan
|
|
154
154
|
# Parse a breakpoint position. Return
|
155
155
|
# - the position - a Fixnum
|
156
156
|
# - the instruction sequence to use
|
157
|
-
# - whether the
|
158
|
-
# - the condition (by default 'true') to use for this breakpoint
|
157
|
+
# - whether the position is an offset or a line number
|
159
158
|
# - the condition (by default 'true') to use for this breakpoint
|
160
159
|
def breakpoint_position(args)
|
161
160
|
first = args.shift
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require_relative 'fn_helper'
|
4
|
+
|
5
|
+
class TestFnTestHelper < Test::Unit::TestCase
|
6
|
+
|
7
|
+
include FnTestHelper
|
8
|
+
|
9
|
+
def test_basic
|
10
|
+
assert_equal(__LINE__, get_lineno, 'get_lineno()')
|
11
|
+
assert_equal(0,
|
12
|
+
'-- (/tmp/trepan/tmp/gcd.rb:4)' =~ TREPAN_LOC)
|
13
|
+
assert_equal(0, '(trepan): exit' =~ TREPAN_PROMPT)
|
14
|
+
|
15
|
+
output='
|
16
|
+
-- (/tmp/trepan/tmp/gcd.rb:4)
|
17
|
+
(trepan): s
|
18
|
+
-- (/tmp/trepan/tmp/gcd.rb:18)
|
19
|
+
(trepan): s
|
20
|
+
-- (/tmp/trepan/tmp/gcd.rb:19)
|
21
|
+
(trepan): s
|
22
|
+
.. (/tmp/trepan/tmp/gcd.rb:0)
|
23
|
+
(trepan): s
|
24
|
+
-> (/tmp/trepan/tmp/gcd.rb:4)
|
25
|
+
'.split(/\n/)
|
26
|
+
expect='
|
27
|
+
-- (/tmp/trepan/tmp/gcd.rb:4)
|
28
|
+
-- (/tmp/trepan/tmp/gcd.rb:18)
|
29
|
+
-- (/tmp/trepan/tmp/gcd.rb:19)
|
30
|
+
.. (/tmp/trepan/tmp/gcd.rb:0)
|
31
|
+
-> (/tmp/trepan/tmp/gcd.rb:4)
|
32
|
+
'.split(/\n/)
|
33
|
+
assert_equal(expect, filter_line_cmd(output))
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
@@ -18,7 +18,7 @@ class TestRaise < Test::Unit::TestCase
|
|
18
18
|
'set return 10',
|
19
19
|
'set events line',
|
20
20
|
'step',
|
21
|
-
'
|
21
|
+
'pr foo_retval',
|
22
22
|
]
|
23
23
|
d = strarray_setup(cmds)
|
24
24
|
d.start
|
@@ -65,7 +65,7 @@ class TestRaise < Test::Unit::TestCase
|
|
65
65
|
'set return "abc"',
|
66
66
|
'set events line',
|
67
67
|
'step',
|
68
|
-
'
|
68
|
+
'pr result',
|
69
69
|
]
|
70
70
|
d = strarray_setup(cmds)
|
71
71
|
d.start
|
data/test/unit/test-app-util.rb
CHANGED
@@ -7,11 +7,10 @@ class TestAppUtil < Test::Unit::TestCase
|
|
7
7
|
def test_safe_repr
|
8
8
|
string = 'The time has come to talk of many things.'
|
9
9
|
assert_equal(string, safe_repr(string, 50))
|
10
|
-
assert_equal('The time
|
11
|
-
assert_equal('The
|
12
|
-
assert_equal('"The time has co"...', safe_repr(string.inspect, 17))
|
10
|
+
assert_equal('The time... things.', safe_repr(string, 17))
|
11
|
+
assert_equal('"The tim... things."', safe_repr(string.inspect, 17))
|
13
12
|
string = "'The time has come to talk of many things.'"
|
14
|
-
assert_equal("'The
|
13
|
+
assert_equal("'The tim... things.'", safe_repr(string, 17))
|
15
14
|
end
|
16
15
|
|
17
16
|
end
|
@@ -12,6 +12,7 @@ end
|
|
12
12
|
$errors = []
|
13
13
|
class TestBaseCommandHelp < Test::Unit::TestCase
|
14
14
|
|
15
|
+
Trepan::Subcommand.const_set(:NAME, 'bogus')
|
15
16
|
def setup
|
16
17
|
$errors = []
|
17
18
|
$msgs = []
|
@@ -43,7 +44,7 @@ class TestBaseCommandHelp < Test::Unit::TestCase
|
|
43
44
|
cmd_obj.subcmds.subcmds.each do |subcmd_name, subcmd_obj|
|
44
45
|
%w(HELP NAME PREFIX).each do |attr|
|
45
46
|
assert_equal(true, subcmd_obj.class.constants.member?(attr.to_sym),
|
46
|
-
"Constant #{attr} should be defined in \"#{cmd_obj.name} #{subcmd_obj.
|
47
|
+
"Constant #{attr} should be defined in \"#{cmd_obj.name} #{subcmd_obj.class::NAME}\"")
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
data/test/unit/test-cmd-help.rb
CHANGED
@@ -21,11 +21,11 @@ class TestCommandHelp < Test::Unit::TestCase
|
|
21
21
|
msgs = @cmdproc.instance_variable_get('@msgs')
|
22
22
|
errmsgs = @cmdproc.instance_variable_get('@errmsgs')
|
23
23
|
assert_equal(should_not_have, msgs.empty?,
|
24
|
-
"Expecting %shelp for
|
25
|
-
shoulda[0])
|
24
|
+
"Expecting %shelp for %s.\n Got %s" %
|
25
|
+
[shoulda[0], arg_str, msgs])
|
26
26
|
assert_equal(!should_not_have, errmsgs.empty?,
|
27
|
-
"Expecting %serror for
|
28
|
-
shoulda[1])
|
27
|
+
"Expecting %serror for %s.\n Got %s" %
|
28
|
+
[shoulda[1], arg_str, msgs])
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_help_command
|
@@ -17,6 +17,7 @@ class TestCmdProcessorFrame < Test::Unit::TestCase
|
|
17
17
|
$msgs = []
|
18
18
|
@proc = Trepan::CmdProcessor.new(Trepan::MockCore.new())
|
19
19
|
@proc.frame_index = 0
|
20
|
+
@proc.frame_initialize
|
20
21
|
class << @proc
|
21
22
|
def errmsg(msg)
|
22
23
|
$errors << msg
|
@@ -32,7 +33,6 @@ class TestCmdProcessorFrame < Test::Unit::TestCase
|
|
32
33
|
# See that we have can load up commands
|
33
34
|
def test_basic
|
34
35
|
@proc.frame_setup(RubyVM::ThreadFrame.current)
|
35
|
-
@proc.hidelevels = {}
|
36
36
|
|
37
37
|
# Test absolute positioning. Should all be okay
|
38
38
|
0.upto(@proc.top_frame.stack_size-1) do |i|
|
@@ -52,7 +52,6 @@ class TestCmdProcessorFrame < Test::Unit::TestCase
|
|
52
52
|
|
53
53
|
setup
|
54
54
|
@proc.top_frame = @proc.frame = RubyVM::ThreadFrame.current
|
55
|
-
@proc.hidelevels = {}
|
56
55
|
@proc.adjust_frame(0, true)
|
57
56
|
|
58
57
|
@proc.top_frame.stack_size-1.times do
|
data/test/unit/test-proc-main.rb
CHANGED
@@ -86,7 +86,7 @@ class TestCmdProcessor < Test::Unit::TestCase
|
|
86
86
|
$errs << "#{mess}"
|
87
87
|
end
|
88
88
|
run_and_check('!s=1', ['D=> 1'], [], "! evaluation")
|
89
|
-
run_and_check('
|
89
|
+
run_and_check('pr "foo"', ['foo'], [], "print command")
|
90
90
|
run_and_check('set autoeval off',
|
91
91
|
['Evaluation of unrecognized debugger commands is off.'], [],
|
92
92
|
"autoeval set")
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 6
|
9
|
+
version: 0.0.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- R. Bernstein
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-27 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -27,8 +27,8 @@ dependencies:
|
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
segments:
|
29
29
|
- 0
|
30
|
-
-
|
31
|
-
version: "0.
|
30
|
+
- 33
|
31
|
+
version: "0.33"
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
@@ -90,6 +90,8 @@ description: |
|
|
90
90
|
Some of the core debugger concepts have been rethought. As a result, some of this may be experimental.
|
91
91
|
|
92
92
|
This version works only with a patched version of Ruby 1.9.2 and rb-threadframe.
|
93
|
+
|
94
|
+
See also rbx-trepanning for a version that works with Rubinius.
|
93
95
|
|
94
96
|
email: rockyb@rubyforge.net
|
95
97
|
executables:
|
@@ -148,6 +150,7 @@ files:
|
|
148
150
|
- processor/location.rb
|
149
151
|
- processor/load_cmds.rb
|
150
152
|
- processor/hook.rb
|
153
|
+
- processor/command/pr.rb
|
151
154
|
- processor/command/set_subcmd/debug_subcmd/dbgr.rb
|
152
155
|
- processor/command/set_subcmd/debug_subcmd/except.rb
|
153
156
|
- processor/command/set_subcmd/debug_subcmd/skip.rb
|
@@ -259,7 +262,6 @@ files:
|
|
259
262
|
- processor/command/continue.rb
|
260
263
|
- processor/command/backtrace.rb
|
261
264
|
- processor/command/condition.rb
|
262
|
-
- processor/command/print.rb
|
263
265
|
- processor/command/reload_subcmd/command.rb
|
264
266
|
- test/example/fname with blank.rb
|
265
267
|
- test/example/null.rb
|
@@ -311,6 +313,7 @@ files:
|
|
311
313
|
- test/functional/tmp/b1.rb
|
312
314
|
- test/functional/test-trace-var.rb
|
313
315
|
- test/functional/fn_helper.rb
|
316
|
+
- test/functional/test-fn_helper.rb
|
314
317
|
- test/functional/test-immediate-step-bug.rb
|
315
318
|
- test/functional/test-step.rb
|
316
319
|
- test/functional/test-finish.rb
|
@@ -326,7 +329,7 @@ rdoc_options:
|
|
326
329
|
- --main
|
327
330
|
- README
|
328
331
|
- --title
|
329
|
-
- Trepan 0.0.
|
332
|
+
- Trepan 0.0.6 Documentation
|
330
333
|
require_paths:
|
331
334
|
- lib
|
332
335
|
required_ruby_version: !ruby/object:Gem::Requirement
|