trepanning 1.93.35 → 2.15.33
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.
- checksums.yaml +7 -0
- data/ChangeLog +491 -55
- data/LICENSE +1 -1
- data/NEWS +18 -14
- data/README.md +5 -22
- data/Rakefile +22 -1
- data/app/breakpoint.rb +5 -3
- data/app/core.rb +147 -179
- data/app/default.rb +47 -46
- data/app/file.rb +6 -7
- data/app/frame.rb +183 -176
- data/app/markdown.rb +2 -9
- data/app/options.rb +1 -1
- data/app/run.rb +71 -37
- data/interface/script.rb +8 -8
- data/io.rb +19 -20
- data/lib/trepanning.rb +292 -297
- data/processor.rb +332 -344
- data/processor/breakpoint.rb +98 -96
- data/processor/command/base/submgr.rb +9 -9
- data/processor/command/break.rb +40 -38
- data/processor/command/continue.rb +15 -10
- data/processor/command/debug.rb +6 -25
- data/processor/command/delete.rb +21 -12
- data/processor/command/directory.rb +15 -13
- data/processor/command/disable.rb +12 -9
- data/processor/command/disassemble.rb +80 -74
- data/processor/command/display.rb +15 -12
- data/processor/command/down.rb +8 -3
- data/processor/command/edit.rb +37 -23
- data/processor/command/enable.rb +11 -8
- data/processor/command/eval.rb +24 -22
- data/processor/command/finish.rb +50 -48
- data/processor/command/help.rb +1 -1
- data/processor/command/info_subcmd/breakpoints.rb +7 -7
- data/processor/command/info_subcmd/files.rb +195 -196
- data/processor/command/info_subcmd/frame.rb +7 -4
- data/processor/command/info_subcmd/locals.rb +29 -12
- data/processor/command/info_subcmd/program.rb +48 -39
- data/processor/command/info_subcmd/registers_subcmd/ep.rb +46 -0
- data/processor/command/info_subcmd/registers_subcmd/helper.rb +32 -35
- data/processor/command/info_subcmd/registers_subcmd/sp.rb +29 -23
- data/processor/command/info_subcmd/return.rb +28 -10
- data/processor/command/info_subcmd/variables_subcmd/class.rb +3 -3
- data/processor/command/info_subcmd/variables_subcmd/constants.rb +77 -0
- data/processor/command/info_subcmd/variables_subcmd/globals.rb +7 -7
- data/processor/command/info_subcmd/variables_subcmd/instance.rb +68 -22
- data/processor/command/info_subcmd/variables_subcmd/locals.rb +148 -67
- data/processor/command/list.rb +14 -8
- data/processor/command/macro.rb +1 -1
- data/processor/command/next.rb +1 -0
- data/processor/command/set_subcmd/auto.rb +3 -3
- data/processor/command/set_subcmd/different.rb +30 -29
- data/processor/command/set_subcmd/events.rb +74 -48
- data/processor/command/set_subcmd/max_subcmd/list.rb +12 -5
- data/processor/command/set_subcmd/max_subcmd/width.rb +28 -19
- data/processor/command/set_subcmd/register.rb +37 -0
- data/processor/command/set_subcmd/register_subcmd/pc.rb +67 -0
- data/processor/command/set_subcmd/register_subcmd/sp.rb +75 -0
- data/processor/command/set_subcmd/reload.rb +12 -10
- data/processor/command/set_subcmd/return.rb +68 -44
- data/processor/command/shell.rb +3 -2
- data/processor/command/show_subcmd/different.rb +17 -14
- data/processor/command/show_subcmd/events.rb +25 -25
- data/processor/default.rb +1 -1
- data/processor/eval.rb +14 -15
- data/processor/frame.rb +43 -36
- data/processor/help.rb +5 -5
- data/processor/hook.rb +26 -29
- data/processor/location.rb +54 -51
- data/processor/mock.rb +4 -3
- data/processor/running.rb +113 -103
- data/processor/validate.rb +401 -373
- data/test/data/debug.cmd +8 -0
- data/test/data/debug.right +13 -0
- data/test/data/debugger-stop.right +6 -4
- data/test/data/fname-with-blank.cmd +1 -1
- data/test/data/fname-with-blank.right +5 -0
- data/test/data/pc.cmd +8 -0
- data/test/data/pc.right +10 -0
- data/test/data/quit.right +3 -1
- data/test/data/trace.cmd +2 -2
- data/test/data/trace.right +41 -20
- data/test/example/assign.rb +6 -0
- data/test/functional/fn_helper.rb +11 -17
- data/test/functional/test-break-long.rb +15 -16
- data/test/functional/test-break.rb +6 -8
- data/test/functional/test-condition.rb +8 -10
- data/test/functional/test-debugger-call-bug.rb +21 -22
- data/test/functional/test-delete.rb +57 -59
- data/test/functional/test-eval.rb +101 -103
- data/test/functional/test-finish.rb +24 -33
- data/test/functional/test-immediate-step-bug.rb +6 -10
- data/test/functional/test-next.rb +64 -65
- data/test/functional/test-raise.rb +63 -64
- data/test/functional/test-recursive-bt.rb +81 -76
- data/test/functional/test-remap.rb +6 -7
- data/test/functional/test-return.rb +44 -38
- data/test/functional/test-step.rb +55 -53
- data/test/functional/test-stepbug.rb +6 -9
- data/test/functional/test-watchg.rb +40 -39
- data/test/integration/test-debug.rb +12 -0
- data/test/integration/test-debugger-stop.rb +7 -7
- data/test/integration/test-pc.rb +24 -0
- data/test/integration/test-trace.rb +1 -1
- data/test/unit/cmd-helper.rb +0 -1
- data/test/unit/test-app-brkpt.rb +21 -21
- data/test/unit/test-app-brkptmgr.rb +7 -8
- data/test/unit/test-app-display.rb +3 -4
- data/test/unit/test-app-frame.rb +4 -5
- data/test/unit/test-base-subsubcmd.rb +2 -2
- data/test/unit/test-cmd-break.rb +6 -6
- data/test/unit/test-cmd-endisable.rb +7 -6
- data/test/unit/test-cmd-parse_list_cmd.rb +24 -24
- data/test/unit/test-io-tcpserver.rb +39 -35
- data/test/unit/test-proc-default.rb +23 -22
- data/test/unit/test-proc-eval.rb +1 -2
- data/test/unit/test-proc-frame.rb +8 -9
- data/test/unit/test-proc-list.rb +1 -1
- data/test/unit/test-proc-location.rb +2 -2
- data/test/unit/test-proc-main.rb +10 -10
- data/test/unit/test-proc-validate.rb +11 -13
- data/test/unit/test-subcmd-help.rb +1 -2
- data/trepanning.gemspec +8 -13
- metadata +44 -95
- data/COPYING +0 -57
- data/data/custom_require.rb +0 -44
- data/data/perldb.bindings +0 -17
- data/data/prelude.rb +0 -38
- data/processor/command/info_subcmd/variables_subcmd/constant.rb +0 -41
- data/processor/command/raise.rb +0 -48
- data/processor/command/set_subcmd/pc.rb +0 -62
- data/processor/command/set_subcmd/sp.rb +0 -67
- data/processor/eventbuf.rb +0 -133
data/processor/frame.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2010,
|
1
|
+
# Copyright (C) 2010-2011, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
2
2
|
require 'linecache'
|
3
3
|
require_relative '../app/complete'
|
4
4
|
require_relative '../app/frame'
|
@@ -21,7 +21,7 @@ class Trepan
|
|
21
21
|
# don't need to store this for all threads, just those we want to
|
22
22
|
# hide frame on. A value of 1 means to hide just the oldest
|
23
23
|
# level. The default or showing all levels is 0.
|
24
|
-
attr_accessor :hidelevels
|
24
|
+
attr_accessor :hidelevels
|
25
25
|
|
26
26
|
# Hash[container] -> file container. This gives us a way to map non-file
|
27
27
|
# container objects to a file container for display.
|
@@ -29,20 +29,20 @@ class Trepan
|
|
29
29
|
|
30
30
|
# Hash[iseq] -> file container. This gives as a way to map instruction
|
31
31
|
# sequences to a file container for display.
|
32
|
-
attr_accessor :remap_iseq
|
32
|
+
attr_accessor :remap_iseq
|
33
33
|
|
34
34
|
# top frame of current thread. Since right now the ThreadFrame
|
35
35
|
# method has "prev" but no way to move in the other direction. So
|
36
36
|
# we store the top frame.
|
37
|
-
attr_accessor :top_frame
|
37
|
+
attr_accessor :top_frame
|
38
38
|
|
39
39
|
# Hash[thread_id] -> top_frame
|
40
40
|
attr_reader :threads2frames
|
41
|
-
|
41
|
+
|
42
42
|
|
43
43
|
def adjust_frame(frame_num, absolute_pos)
|
44
44
|
frame, frame_num = get_frame(frame_num, absolute_pos)
|
45
|
-
if frame
|
45
|
+
if frame
|
46
46
|
@frame = frame
|
47
47
|
@frame_index = frame_num
|
48
48
|
unless @settings[:traceprint]
|
@@ -52,7 +52,7 @@ class Trepan
|
|
52
52
|
:maxwidth => settings[:maxwidth],
|
53
53
|
}
|
54
54
|
print_stack_trace_from_to(frame_num, frame_num, frame, opts)
|
55
|
-
print_location
|
55
|
+
print_location
|
56
56
|
end
|
57
57
|
@line_no = frame_line() - 1
|
58
58
|
@frame
|
@@ -64,7 +64,7 @@ class Trepan
|
|
64
64
|
def frame_low_high(direction)
|
65
65
|
stack_size = @top_frame.stack_size - @hide_level
|
66
66
|
if direction
|
67
|
-
low, high = [ @frame_index * -direction,
|
67
|
+
low, high = [ @frame_index * -direction,
|
68
68
|
(stack_size - 1 - @frame_index) * direction ]
|
69
69
|
low, high = [high, low] if direction < 0
|
70
70
|
[low, high]
|
@@ -72,7 +72,7 @@ class Trepan
|
|
72
72
|
[-stack_size, stack_size-1]
|
73
73
|
end
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
def frame_complete(prefix, direction)
|
77
77
|
low, high = frame_low_high(direction)
|
78
78
|
ary = (low..high).map{|i| i.to_s}
|
@@ -80,11 +80,11 @@ class Trepan
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def frame_container(frame, canonicalize=true)
|
83
|
-
container =
|
83
|
+
container =
|
84
84
|
if @remap_container.member?(frame.source_container)
|
85
85
|
@remap_container[frame.source_container]
|
86
|
-
elsif frame.iseq && @remap_iseq.member?(frame.iseq.sha1)
|
87
|
-
|
86
|
+
# elsif frame.iseq && @remap_iseq.member?(frame.iseq.sha1)
|
87
|
+
# @remap_iseq[frame.iseq.sha1]
|
88
88
|
else
|
89
89
|
frame.source_container
|
90
90
|
end
|
@@ -103,28 +103,35 @@ class Trepan
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
-
# Initializes the thread and frame variables: @frame, @top_frame,
|
106
|
+
# Initializes the thread and frame variables: @frame, @top_frame,
|
107
107
|
# @frame_index, @current_thread, and @threads2frames
|
108
|
-
def frame_setup(frame_thread)
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
@threads2frames[@current_thread] = @top_frame
|
116
|
-
@hide_level =
|
117
|
-
if @settings[:debugstack]
|
118
|
-
0
|
119
|
-
else
|
120
|
-
@hidelevels[@current_thread]
|
108
|
+
def frame_setup(frame_thread, top_skip=0)
|
109
|
+
@frame_index = 0
|
110
|
+
unless frame_thread
|
111
|
+
@stack_size = 0
|
112
|
+
@current_thread = nil
|
113
|
+
@top_frame = @frame = nil
|
114
|
+
return
|
121
115
|
end
|
122
|
-
|
116
|
+
|
117
|
+
@frame = @top_frame = frame_thread.prev(top_skip)
|
118
|
+
@current_thread = @frame.thread
|
119
|
+
@stack_size = @frame.stack_size
|
120
|
+
|
121
|
+
@threads2frames ||= {}
|
122
|
+
@threads2frames[@current_thread] = @top_frame
|
123
|
+
@hide_level =
|
124
|
+
if @settings[:debugstack]
|
125
|
+
0
|
126
|
+
else
|
127
|
+
@hidelevels[@current_thread]
|
128
|
+
end
|
129
|
+
|
123
130
|
end
|
124
131
|
|
125
132
|
# Remove access to thread and frame variables
|
126
133
|
def frame_teardown
|
127
|
-
@top_frame = @frame = @frame_index = @current_thread = nil
|
134
|
+
@top_frame = @frame = @frame_index = @current_thread = nil
|
128
135
|
@threads2frames = {}
|
129
136
|
end
|
130
137
|
|
@@ -164,7 +171,7 @@ class Trepan
|
|
164
171
|
def get_nonsync_frame(tf)
|
165
172
|
if (tf.stack_size > 10)
|
166
173
|
check_frames = (0..5).map{|i| tf.prev(i).method}
|
167
|
-
if check_frames ==
|
174
|
+
if check_frames ==
|
168
175
|
%w(synchronize event_processor IFUNC call trace_hook IFUNC)
|
169
176
|
return tf.prev(6)
|
170
177
|
end
|
@@ -187,14 +194,14 @@ class Trepan
|
|
187
194
|
# `frame', which is in the thread with id `thread_id'. We may
|
188
195
|
# need to the hide initial debugger frames.
|
189
196
|
def find_and_set_debugged_frame(th, position)
|
190
|
-
|
197
|
+
|
191
198
|
thread = threading._active[thread_id]
|
192
199
|
thread_name = thread.getName()
|
193
200
|
if (!@settings['dbg_pydbgr'] &&
|
194
201
|
thread_name == Mthread.current_thread_name())
|
195
202
|
# The frame we came in on ('current_thread_name') is
|
196
203
|
# the same as the one we want to switch to. In this case
|
197
|
-
# we need to some debugger frames are in this stack so
|
204
|
+
# we need to some debugger frames are in this stack so
|
198
205
|
# we need to remove them.
|
199
206
|
newframe = Mthread.find_debugged_frame(frame)
|
200
207
|
frame = newframe unless newframe
|
@@ -202,12 +209,12 @@ class Trepan
|
|
202
209
|
## FIXME: else: we might be blocked on other threads which are
|
203
210
|
# about to go into the debugger it not for the fact this one got there
|
204
211
|
# first. Possibly in the future we want
|
205
|
-
# to hide the blocks into threading of that locking code as well.
|
206
|
-
|
212
|
+
# to hide the blocks into threading of that locking code as well.
|
213
|
+
|
207
214
|
# Set stack to new frame
|
208
215
|
@frame, @curindex = Mcmdproc.get_stack(frame, nil, self.proc)
|
209
216
|
@proc.stack, @proc.curindex = self.stack, self.curindex
|
210
|
-
|
217
|
+
|
211
218
|
# @frame_thread_name = thread_name
|
212
219
|
end
|
213
220
|
end
|
@@ -229,7 +236,7 @@ if __FILE__ == $0
|
|
229
236
|
end
|
230
237
|
|
231
238
|
proc = Trepan::CmdProcessor.new(Trepan::MockCore.new())
|
232
|
-
proc.frame_setup(RubyVM::Frame.
|
239
|
+
proc.frame_setup(RubyVM::Frame.get)
|
233
240
|
proc.frame_initialize
|
234
241
|
puts "stack size: #{proc.top_frame.stack_size}"
|
235
242
|
0.upto(proc.top_frame.stack_size) { |i| proc.adjust_frame(i, true) }
|
@@ -241,5 +248,5 @@ if __FILE__ == $0
|
|
241
248
|
puts '*' * 10
|
242
249
|
proc.adjust_frame(proc.top_frame.stack_size-1, true)
|
243
250
|
proc.top_frame.stack_size.times { proc.adjust_frame(-1, false) }
|
244
|
-
|
251
|
+
|
245
252
|
end
|
data/processor/help.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2010,
|
1
|
+
# Copyright (C) 2010-2011, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
2
2
|
|
3
3
|
class Trepan
|
4
4
|
# class SubHelp
|
@@ -9,7 +9,7 @@ class Trepan
|
|
9
9
|
# end
|
10
10
|
|
11
11
|
# def load_sub_help_files(dir)
|
12
|
-
# Dir.glob(dir, '*.txt').each do |txt|
|
12
|
+
# Dir.glob(dir, '*.txt').each do |txt|
|
13
13
|
# basename = File.basename(txt, '.txt')
|
14
14
|
# @list << basename
|
15
15
|
# end
|
@@ -38,9 +38,9 @@ class Trepan
|
|
38
38
|
short_help = subcmd.class.const_get('HELP').split("\n")[0].chomp('.')
|
39
39
|
subcmd.class.const_set(:SHORT_HELP, short_help)
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
' %-12s -- %s' %
|
43
|
-
[abbrev_stringify(obj_const(subcmd, :NAME),
|
43
|
+
[abbrev_stringify(obj_const(subcmd, :NAME),
|
44
44
|
obj_const(subcmd, :MIN_ABBREV)),
|
45
45
|
obj_const(subcmd, :SHORT_HELP)]
|
46
46
|
end
|
@@ -77,7 +77,7 @@ Long description goes here.'
|
|
77
77
|
MIN_ABBREV = 1
|
78
78
|
NAME = File.basename(__FILE__)
|
79
79
|
def obj_const(obj, name)
|
80
|
-
obj.class.const_get(name)
|
80
|
+
obj.class.const_get(name)
|
81
81
|
end
|
82
82
|
def msg(mess)
|
83
83
|
puts mess
|
data/processor/hook.rb
CHANGED
@@ -13,63 +13,63 @@ class Trepan::CmdProcessor < Trepan::VirtualCmdProcessor
|
|
13
13
|
attr_reader :unconditional_prehooks
|
14
14
|
attr_reader :cmdloop_posthooks
|
15
15
|
attr_reader :cmdloop_prehooks
|
16
|
-
|
16
|
+
|
17
17
|
# Used to time how long a debugger action takes
|
18
18
|
attr_accessor :time_last
|
19
|
-
|
19
|
+
|
20
20
|
class Hook
|
21
21
|
attr_accessor :list
|
22
|
-
|
22
|
+
|
23
23
|
def initialize(list=[])
|
24
24
|
@list = list
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def delete_by_name(delete_name)
|
28
28
|
@list.delete_if {|hook_name, priority, hook| hook_name == delete_name}
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def empty?
|
32
32
|
@list.empty?
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
def insert(priority, name, hook)
|
36
36
|
insert_loc = @list.size # at end
|
37
37
|
@list.each_with_index do |entry, index|
|
38
38
|
n, p, h = entry
|
39
|
-
if priority > p
|
39
|
+
if priority > p
|
40
40
|
insert_loc = index
|
41
41
|
break
|
42
42
|
end
|
43
43
|
end
|
44
44
|
@list.insert(insert_loc, [name, priority, hook])
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
def insert_if_new(priority, name, hook)
|
48
48
|
insert(priority, name, hook) unless
|
49
49
|
@list.find {|try_name, try_priority, try_hook| try_name == name}
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
# Run each function in `hooks' with args
|
53
53
|
def run(*args)
|
54
|
-
@list.each do |name, priority, hook|
|
55
|
-
hook.call(name, *args)
|
54
|
+
@list.each do |name, priority, hook|
|
55
|
+
hook.call(name, *args)
|
56
56
|
end
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
# Could add delete_at and delete if necessary.
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
def hook_initialize(commands)
|
63
63
|
@cmdloop_posthooks = Hook.new
|
64
64
|
@cmdloop_prehooks = Hook.new
|
65
65
|
@unconditional_prehooks = Hook.new
|
66
|
-
|
66
|
+
|
67
67
|
irb_cmd = commands['shell']
|
68
|
-
@autoirb_hook = ['autoirb',
|
68
|
+
@autoirb_hook = ['autoirb',
|
69
69
|
Proc.new{|*args| irb_cmd.run(['shell']) if irb_cmd}]
|
70
|
-
|
70
|
+
|
71
71
|
@debug_dbgr_hook = ['dbgdbgr',
|
72
|
-
Proc.new{|*args|
|
72
|
+
Proc.new{|*args|
|
73
73
|
if settings[:debugdbgr]
|
74
74
|
$trepan_cmdproc = self
|
75
75
|
$trepan_frame = @frame
|
@@ -77,29 +77,26 @@ class Trepan::CmdProcessor < Trepan::VirtualCmdProcessor
|
|
77
77
|
$trepan_cmdproc = nil
|
78
78
|
$trepan_frame = nil
|
79
79
|
end}]
|
80
|
-
|
80
|
+
|
81
81
|
display_cmd = commands['display']
|
82
|
-
@display_hook = ['display',
|
83
|
-
Proc.new{|*args| display_cmd.run(['display']) if
|
82
|
+
@display_hook = ['display',
|
83
|
+
Proc.new{|*args| display_cmd.run(['display']) if
|
84
84
|
display_cmd}]
|
85
|
-
|
85
|
+
|
86
86
|
list_cmd = commands['list']
|
87
|
-
@autolist_hook = ['autolist',
|
87
|
+
@autolist_hook = ['autolist',
|
88
88
|
Proc.new{|*args| list_cmd.run(['list']) if list_cmd}]
|
89
|
-
|
90
|
-
@timer_hook = ['timer',
|
89
|
+
|
90
|
+
@timer_hook = ['timer',
|
91
91
|
Proc.new{|*args|
|
92
92
|
now = Time.now
|
93
|
-
msg("%g seconds" %
|
93
|
+
msg("%g seconds" %
|
94
94
|
(now - @time_last)) if @time_last
|
95
95
|
@time_last = now
|
96
96
|
}]
|
97
97
|
@timer_posthook = ['timer', Proc.new{|*args| @time_last = Time.now}]
|
98
|
-
@trace_hook = ['trace',
|
98
|
+
@trace_hook = ['trace',
|
99
99
|
Proc.new{|*args| print_location}]
|
100
|
-
@tracebuf_hook = ['tracebuffer',
|
101
|
-
Proc.new{|*args| @eventbuf.append(@event, @frame,
|
102
|
-
@core.hook_arg)}]
|
103
100
|
end
|
104
101
|
end
|
105
102
|
|
data/processor/location.rb
CHANGED
@@ -13,8 +13,8 @@ class Trepan::CmdProcessor < Trepan::VirtualCmdProcessor
|
|
13
13
|
EVENT2ICON = {
|
14
14
|
'brkpt' => 'xx',
|
15
15
|
'tbrkpt' => 'x1',
|
16
|
-
'
|
17
|
-
'
|
16
|
+
'c_call' => 'C>',
|
17
|
+
'c_return' => '<C',
|
18
18
|
'call' => '->',
|
19
19
|
'send' => '=>',
|
20
20
|
'leave' => '<=',
|
@@ -35,9 +35,9 @@ class Trepan::CmdProcessor < Trepan::VirtualCmdProcessor
|
|
35
35
|
}
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
def canonic_container(container)
|
39
|
+
[container[0], canonic_file(container[1])]
|
40
|
+
end
|
41
41
|
|
42
42
|
def canonic_file(filename, resolve=true)
|
43
43
|
# For now we want resolved filenames
|
@@ -141,41 +141,39 @@ class Trepan::CmdProcessor < Trepan::VirtualCmdProcessor
|
|
141
141
|
end
|
142
142
|
|
143
143
|
def print_location
|
144
|
-
if %w(c-call call).member?(@event)
|
145
|
-
# FIXME: Fix Ruby so we don't need this workaround?
|
146
|
-
# See also where.rb
|
147
|
-
opts = {}
|
148
|
-
opts[:class] = @core.hook_arg if
|
149
|
-
'CFUNC' == @frame.type && @core.hook_arg && 0 == @frame_index
|
150
|
-
msg format_stack_call(@frame, opts)
|
151
|
-
elsif 'raise' == @event
|
152
|
-
msg @core.hook_arg.inspect if @core.hook_arg # Exception object
|
153
|
-
end
|
154
|
-
|
155
144
|
text = nil
|
156
|
-
|
145
|
+
|
157
146
|
ev = if @event.nil? || 0 != @frame_index
|
158
147
|
' '
|
159
148
|
else
|
160
|
-
|
149
|
+
@event
|
150
|
+
# (EVENT2ICON[@event] || @event)
|
161
151
|
end
|
162
|
-
@
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
msg
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
152
|
+
if @frame
|
153
|
+
source_container = frame_container(@frame, false)
|
154
|
+
@line_no = frame_line
|
155
|
+
|
156
|
+
loc = source_location_info(source_container, @line_no, @frame)
|
157
|
+
loc, @line_no, text, found_line =
|
158
|
+
loc_and_text(loc, @frame, @line_no, source_container)
|
159
|
+
|
160
|
+
ip_str = @frame.iseq ? " @#{frame.pc_offset}" : ''
|
161
|
+
msg "#{ev} (#{loc}#{ip_str})"
|
162
|
+
else
|
163
|
+
msg "#{ev}"
|
164
|
+
end
|
165
|
+
|
166
|
+
if @core.trace_point
|
167
|
+
if %w(return c_return b_return).member?(@event.to_s)
|
168
|
+
retval = @core.trace_point.return_value
|
169
|
+
msg 'R=> %s' % retval.inspect
|
170
|
+
elsif @event == :raise
|
171
|
+
exc = @core.trace_point.raised_exception
|
172
|
+
msg "#{exc.class}: #{exc}"
|
173
|
+
if @frame.iseq and @frame.iseq.catch_table_size == 0
|
174
|
+
msg "Warning: exception raised is non-local!"
|
175
|
+
end
|
176
|
+
end
|
179
177
|
end
|
180
178
|
|
181
179
|
if text && !text.strip.empty?
|
@@ -183,25 +181,30 @@ class Trepan::CmdProcessor < Trepan::VirtualCmdProcessor
|
|
183
181
|
@line_no -= 1
|
184
182
|
end
|
185
183
|
unless found_line
|
186
|
-
|
187
|
-
|
188
|
-
|
184
|
+
if @frame
|
185
|
+
# Can't find source line, so give assembly as consolation.
|
186
|
+
# This great idea comes from the Rubinius reference debugger.
|
187
|
+
run_command('disassemble') unless source_container[0] == 'binary'
|
188
|
+
end
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
192
192
|
def source_location_info(source_container, line_no, frame)
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
frame.iseq.eval_source
|
198
|
-
eval_str = frame.iseq.eval_source
|
199
|
-
'eval "' + safe_repr(eval_str.gsub(/\n/,';'), 15) + '"'
|
200
|
-
else
|
201
|
-
canonic_file(filename, false)
|
193
|
+
filename = source_container[1]
|
194
|
+
## FIXME: condition is too long.
|
195
|
+
if 'binary' == source_container[0]
|
196
|
+
return "address 0x%x" % line_no
|
202
197
|
end
|
203
|
-
|
204
|
-
|
198
|
+
canonic_filename =
|
199
|
+
if 'string' == source_container[0] && frame.iseq &&
|
200
|
+
frame.iseq.eval_source
|
201
|
+
eval_str = frame.iseq.eval_source
|
202
|
+
'eval "' + safe_repr(eval_str.gsub(/\n/,';'), 15) + '"'
|
203
|
+
else
|
204
|
+
canonic_file(filename, false)
|
205
|
+
end
|
206
|
+
loc = "#{canonic_filename}:#{line_no}"
|
207
|
+
return loc
|
205
208
|
end # source_location_info
|
206
209
|
end
|
207
210
|
|
@@ -222,7 +225,7 @@ if __FILE__ == $0 && caller.size == 0
|
|
222
225
|
proc = Trepan::CmdProcessor.new(Trepan::MockCore.new())
|
223
226
|
proc.instance_variable_set('@settings', {})
|
224
227
|
proc.frame_initialize
|
225
|
-
proc.frame_setup(RubyVM::Frame.
|
228
|
+
proc.frame_setup(RubyVM::Frame.get)
|
226
229
|
proc.frame_initialize
|
227
230
|
|
228
231
|
puts proc.canonic_file(__FILE__)
|
@@ -231,7 +234,7 @@ if __FILE__ == $0 && caller.size == 0
|
|
231
234
|
puts proc.current_source_text
|
232
235
|
xx = eval <<-END
|
233
236
|
proc.frame_initialize
|
234
|
-
proc.frame_setup(RubyVM::Frame.
|
237
|
+
proc.frame_setup(RubyVM::Frame.get)
|
235
238
|
puts proc.current_source_text
|
236
239
|
END
|
237
240
|
end
|