trepanning 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +214 -0
- data/NEWS +12 -0
- data/README.textile +1 -7
- data/Rakefile +13 -0
- data/app/default.rb +5 -4
- data/app/disassemble.rb +25 -3
- data/app/run.rb +0 -18
- data/bin/trepan +4 -6
- data/data/irbrc +3 -17
- data/io/base_io.rb +3 -1
- data/io/null_output.rb +41 -0
- data/lib/trepanning.rb +10 -13
- data/processor/command/backtrace.rb +7 -6
- data/processor/command/base/subcmd.rb +4 -0
- data/processor/command/base/submgr.rb +1 -1
- data/processor/command/base/subsubmgr.rb +1 -1
- data/processor/command/break.rb +12 -4
- data/processor/command/continue.rb +2 -2
- data/processor/command/delete.rb +1 -1
- data/processor/command/disable.rb +1 -1
- data/processor/command/disassemble.rb +1 -1
- data/processor/command/finish.rb +3 -3
- data/processor/command/info_subcmd/iseq.rb +9 -0
- data/processor/command/info_subcmd/registers_subcmd/dfp.rb +7 -16
- data/processor/command/info_subcmd/registers_subcmd/lfp.rb +5 -17
- data/processor/command/info_subcmd/registers_subcmd/pc.rb +6 -19
- data/processor/command/info_subcmd/registers_subcmd/sp.rb +14 -24
- data/processor/command/list.rb +34 -19
- data/processor/command/reload.rb +1 -1
- data/processor/command/restart.rb +8 -9
- data/processor/command/set_subcmd/auto.rb +1 -2
- data/processor/command/set_subcmd/auto_subcmd/eval.rb +6 -19
- data/processor/command/set_subcmd/auto_subcmd/irb.rb +7 -23
- data/processor/command/set_subcmd/auto_subcmd/list.rb +5 -22
- data/processor/command/set_subcmd/basename.rb +6 -20
- data/processor/command/set_subcmd/debug.rb +1 -1
- data/processor/command/set_subcmd/debug_subcmd/dbgr.rb +9 -22
- data/processor/command/set_subcmd/debug_subcmd/except.rb +8 -20
- data/processor/command/set_subcmd/debug_subcmd/macro.rb +7 -19
- data/processor/command/set_subcmd/debug_subcmd/skip.rb +5 -18
- data/processor/command/set_subcmd/debug_subcmd/stack.rb +5 -18
- data/processor/command/set_subcmd/hidelevel.rb +60 -0
- data/processor/command/set_subcmd/max.rb +1 -1
- data/processor/command/set_subcmd/max_subcmd/list.rb +12 -23
- data/processor/command/set_subcmd/max_subcmd/stack.rb +8 -31
- data/processor/command/set_subcmd/substitute.rb +1 -1
- data/processor/command/set_subcmd/substitute_subcmd/eval.rb +1 -1
- data/processor/command/set_subcmd/substitute_subcmd/path.rb +1 -1
- data/processor/command/set_subcmd/substitute_subcmd/string.rb +6 -18
- data/processor/command/set_subcmd/timer.rb +1 -1
- data/processor/command/set_subcmd/trace.rb +1 -1
- data/processor/command/set_subcmd/trace_subcmd/buffer.rb +1 -1
- data/processor/command/set_subcmd/trace_subcmd/print.rb +5 -21
- data/processor/command/set_subcmd/trace_subcmd/var.rb +1 -1
- data/processor/command/show_subcmd/args.rb +9 -27
- data/processor/command/show_subcmd/auto_subcmd/eval.rb +3 -15
- data/processor/command/show_subcmd/auto_subcmd/irb.rb +3 -15
- data/processor/command/show_subcmd/auto_subcmd/list.rb +3 -18
- data/processor/command/show_subcmd/basename.rb +3 -1
- data/processor/command/show_subcmd/hidelevel.rb +41 -0
- data/processor/command/show_subcmd/max.rb +1 -1
- data/processor/command/show_subcmd/trace_subcmd/buffer.rb +1 -1
- data/processor/command/show_subcmd/trace_subcmd/print.rb +1 -1
- data/processor/command/source.rb +6 -5
- data/processor/command/undisplay.rb +0 -1
- data/processor/default.rb +6 -2
- data/processor/frame.rb +2 -21
- data/processor/location.rb +44 -18
- data/processor/main.rb +0 -11
- data/processor/mock.rb +25 -0
- data/processor/validate.rb +34 -18
- data/test/functional/fn_helper.rb +14 -4
- data/test/functional/test-break.rb +35 -73
- data/test/functional/test-condition.rb +9 -10
- data/test/functional/test-delete.rb +5 -3
- data/test/unit/test-app-disassemble.rb +15 -3
- data/test/unit/test-app-run.rb +0 -4
- data/test/unit/test-cmd-break.rb +3 -0
- metadata +15 -11
@@ -15,22 +15,7 @@ end
|
|
15
15
|
if __FILE__ == $0
|
16
16
|
# Demo it.
|
17
17
|
require_relative '../../../mock'
|
18
|
-
require_relative '
|
19
|
-
|
20
|
-
|
21
|
-
# FIXME: DRY the below code
|
22
|
-
dbgr, show_cmd = MockDebugger::setup('show')
|
23
|
-
testcmdMgr = Trepan::Subcmd.new(show_cmd)
|
24
|
-
auto_cmd = Trepan::SubSubcommand::ShowAuto.new(dbgr.core.processor,
|
25
|
-
show_cmd)
|
26
|
-
|
27
|
-
# FIXME: remove the 'join' below
|
28
|
-
cmd_name = Trepan::SubSubcommand::ShowAutoList::PREFIX.join('')
|
29
|
-
autox_cmd = Trepan::SubSubcommand::ShowAutoList.new(show_cmd.proc, auto_cmd,
|
30
|
-
cmd_name)
|
31
|
-
# require_relative '../../../../lib/trepanning'
|
32
|
-
# dbgr = Trepan.new(:set_restart => true)
|
33
|
-
# dbgr.debugger
|
34
|
-
autox_cmd.run([])
|
35
|
-
|
18
|
+
require_relative '../auto'
|
19
|
+
cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::ShowAuto,
|
20
|
+
Trepan::SubSubcommand::ShowAutoList)
|
36
21
|
end
|
@@ -4,8 +4,10 @@ require_relative '../base/subcmd'
|
|
4
4
|
|
5
5
|
class Trepan::Subcommand::ShowBasename < Trepan::ShowBoolSubcommand
|
6
6
|
unless defined?(HELP)
|
7
|
-
HELP
|
7
|
+
HELP = "Show only file basename in showing file names"
|
8
8
|
MIN_ABBREV = 'ba'.size
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
PREFIX = %W(show #{NAME})
|
9
11
|
end
|
10
12
|
|
11
13
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require_relative '../base/subsubcmd'
|
4
|
+
|
5
|
+
class Trepan::Subcommand::ShowHidelevel < Trepan::ShowIntSubcommand
|
6
|
+
unless defined?(HELP)
|
7
|
+
HELP = 'Show the number of stack levels to hide'
|
8
|
+
MIN_ABBREV = 'hide'.size
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
PREFIX = %w(show hidelevel)
|
11
|
+
end
|
12
|
+
def run(args)
|
13
|
+
if @proc.settings[:hidelevel]
|
14
|
+
super
|
15
|
+
else
|
16
|
+
help = self.class.const_get(:HELP)
|
17
|
+
msg "%s is auto selection." % help[5..-1].capitalize
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
if __FILE__ == $0
|
24
|
+
# Demo it.
|
25
|
+
require_relative '../../mock'
|
26
|
+
|
27
|
+
# FIXME: DRY the below code
|
28
|
+
dbgr, cmd = MockDebugger::setup('show')
|
29
|
+
subcommand = Trepan::Subcommand::ShowHidelevel.new(cmd)
|
30
|
+
|
31
|
+
subcommand.run(subcommand.name)
|
32
|
+
subcommand.proc.settings[:hidelevel] = 1
|
33
|
+
subcommand.run(subcommand.name)
|
34
|
+
|
35
|
+
# require_relative '../../../../lib/trepanning'
|
36
|
+
# dbgr = Trepan.new
|
37
|
+
# dbgr.debugger
|
38
|
+
subcommand.summary_help(subcommand.name)
|
39
|
+
puts
|
40
|
+
puts '-' * 20
|
41
|
+
end
|
data/processor/command/source.rb
CHANGED
@@ -10,7 +10,7 @@ class Trepan::Command::SourceCommand < Trepan::Command
|
|
10
10
|
unless defined?(HELP)
|
11
11
|
NAME = File.basename(__FILE__, '.rb')
|
12
12
|
HELP = <<-HELP
|
13
|
-
#{NAME} [-v][-Y|-N][-c] FILE
|
13
|
+
#{NAME} [-v][-Y|-N][-c][q] FILE
|
14
14
|
|
15
15
|
Read debugger commands from a file named FILE. Optional -v switch
|
16
16
|
(before the filename) causes each command in FILE to be echoed as it
|
@@ -33,6 +33,8 @@ unless option -c is given.
|
|
33
33
|
verbose = false
|
34
34
|
parms = args[1..-1]
|
35
35
|
opts = {}
|
36
|
+
intf = @proc.dbgr.intf
|
37
|
+
output = intf[-1].output
|
36
38
|
parms.each do |arg|
|
37
39
|
case arg
|
38
40
|
when '-v'
|
@@ -43,6 +45,8 @@ unless option -c is given.
|
|
43
45
|
opts[:confirm_val] = false
|
44
46
|
when '-c'
|
45
47
|
opts[:abort_on_error] = false
|
48
|
+
when '-q'
|
49
|
+
output = Trepan::OutputNull.new(nil)
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
@@ -55,10 +59,7 @@ unless option -c is given.
|
|
55
59
|
end
|
56
60
|
|
57
61
|
# Push a new debugger interface.
|
58
|
-
|
59
|
-
script_intf = Trepan::ScriptInterface.new(expanded_file,
|
60
|
-
intf[-1].output,
|
61
|
-
opts)
|
62
|
+
script_intf = Trepan::ScriptInterface.new(expanded_file, output, opts)
|
62
63
|
intf << script_intf
|
63
64
|
return false
|
64
65
|
end
|
@@ -8,7 +8,6 @@ class Trepan::Command::UndisplayCommand < Trepan::Command
|
|
8
8
|
unless defined?(HELP)
|
9
9
|
NAME = File.basename(__FILE__, '.rb')
|
10
10
|
HELP = <<EOH
|
11
|
-
|
12
11
|
undisplay DISPLAY_NUMBER ...
|
13
12
|
Cancel some expressions to be displayed when program stops.
|
14
13
|
Arguments are the code numbers of the expressions to stop displaying.
|
data/processor/default.rb
CHANGED
@@ -15,10 +15,14 @@ class Trepan
|
|
15
15
|
:debugexcept => true, # Internal debugging of command exceptions
|
16
16
|
:debugmacro => false, # debugging macros
|
17
17
|
:debugskip => false, # Internal debugging of step/next skipping
|
18
|
-
:debugstack => false, # How hidden outer debugger stack frames
|
19
18
|
:directory => # last-resort path-search for files
|
20
19
|
'$cdir:$cwd', # that are not fully qualified.
|
21
20
|
|
21
|
+
:hidestack => nil, # Fixnum. How many hidden outer
|
22
|
+
# debugger stack frames to hide?
|
23
|
+
# nil or -1 means compute value. 0
|
24
|
+
# means hide none. Less than 0 means show
|
25
|
+
# all stack entries.
|
22
26
|
:maxlist => 10, # Number of source lines to list
|
23
27
|
:maxstack => 10, # backtrace limit
|
24
28
|
:maxstring => 150, # Strings which are larger than this
|
@@ -34,7 +38,7 @@ class Trepan
|
|
34
38
|
:tracebuffer => false, # save events to a trace buffer.
|
35
39
|
:user_cmd_dir => File.join(Trepanning::HOME_DIR, 'trepan', 'command'),
|
36
40
|
# User command directory
|
37
|
-
}
|
41
|
+
}
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
data/processor/frame.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
-
require 'tempfile'
|
3
2
|
require 'linecache'
|
4
3
|
require_relative '../app/frame'
|
5
4
|
class Trepan
|
@@ -44,8 +43,7 @@ class Trepan
|
|
44
43
|
if frame
|
45
44
|
@frame = frame
|
46
45
|
@frame_index = frame_num
|
47
|
-
|
48
|
-
print_location
|
46
|
+
print_location unless @settings[:traceprint]
|
49
47
|
@line_no = frame_line() - 1
|
50
48
|
@frame
|
51
49
|
else
|
@@ -67,23 +65,6 @@ class Trepan
|
|
67
65
|
container
|
68
66
|
end
|
69
67
|
|
70
|
-
# If frame type is EVAL, set up to remap the string to a temporary file.
|
71
|
-
def frame_eval_remap
|
72
|
-
to_str = Trepan::Frame::eval_string(@frame)
|
73
|
-
return nil unless to_str.is_a?(String)
|
74
|
-
|
75
|
-
# All systems go!
|
76
|
-
unless @remap_iseq.member?(@frame.iseq.sha1)
|
77
|
-
tempfile = Tempfile.new(['eval-', '.rb'])
|
78
|
-
tempfile.open.puts(to_str)
|
79
|
-
|
80
|
-
@remap_iseq[@frame.iseq.sha1] = ['file', tempfile.path]
|
81
|
-
tempfile.close
|
82
|
-
LineCache::cache(tempfile.path)
|
83
|
-
end
|
84
|
-
return true
|
85
|
-
end
|
86
|
-
|
87
68
|
def frame_line
|
88
69
|
if @event == 'vm-insn' && @frame.iseq
|
89
70
|
pc_offset = @frame.pc_offset
|
@@ -111,7 +92,6 @@ class Trepan
|
|
111
92
|
@hidelevels[@current_thread]
|
112
93
|
end
|
113
94
|
|
114
|
-
frame_eval_remap if 'EVAL' == @frame.type
|
115
95
|
end
|
116
96
|
|
117
97
|
# Remove access to thread and frame variables
|
@@ -230,6 +210,7 @@ if __FILE__ == $0
|
|
230
210
|
proc.adjust_frame(0, true)
|
231
211
|
puts '*' * 10
|
232
212
|
proc.top_frame.stack_size.times { proc.adjust_frame(1, false) }
|
213
|
+
puts '*' * 10
|
233
214
|
proc.adjust_frame(proc.top_frame.stack_size-1, true)
|
234
215
|
proc.top_frame.stack_size.times { proc.adjust_frame(-1, false) }
|
235
216
|
|
data/processor/location.rb
CHANGED
@@ -11,13 +11,24 @@ class Trepan
|
|
11
11
|
@reload_on_change = nil
|
12
12
|
end
|
13
13
|
|
14
|
+
def canonic_container(container)
|
15
|
+
[container[0], canonic_file(container[1])]
|
16
|
+
end
|
17
|
+
|
18
|
+
def canonic_file(filename)
|
19
|
+
# For now we want resolved filenames
|
20
|
+
@settings[:basename] ? File.basename(filename) :
|
21
|
+
# Cache this?
|
22
|
+
Pathname.new(filename).cleanpath.to_s
|
23
|
+
end
|
24
|
+
|
14
25
|
def resolve_file_with_dir(path_suffix)
|
15
|
-
settings[:directory].split(/:/).each do |dir|
|
26
|
+
@settings[:directory].split(/:/).each do |dir|
|
16
27
|
dir =
|
17
28
|
if '$cwd' == dir
|
18
29
|
Dir.pwd
|
19
30
|
elsif '$cdir' == dir
|
20
|
-
|
31
|
+
RubyVM::OS_STARTUP_DIR
|
21
32
|
else
|
22
33
|
dir
|
23
34
|
end
|
@@ -28,10 +39,11 @@ class Trepan
|
|
28
39
|
nil
|
29
40
|
end
|
30
41
|
|
31
|
-
# Get line +line_number+ from file named +filename+. Return
|
32
|
-
# there was a problem. Leading blanks are stripped off.
|
42
|
+
# Get line +line_number+ from file named +filename+. Return ''
|
43
|
+
# if there was a problem. Leading blanks are stripped off.
|
33
44
|
def line_at(filename, line_number) # :nodoc:
|
34
45
|
line = LineCache::getline(filename, line_number, @reload_on_change)
|
46
|
+
|
35
47
|
unless line
|
36
48
|
# Try using search directories (set with command "directory")
|
37
49
|
if filename[0..0] != File::SEPARATOR
|
@@ -43,22 +55,28 @@ class Trepan
|
|
43
55
|
end
|
44
56
|
end
|
45
57
|
end
|
46
|
-
|
47
|
-
return line.lstrip.chomp
|
58
|
+
line ? line.lstrip.chomp : line
|
48
59
|
end
|
49
60
|
|
50
61
|
def loc_and_text(loc, frame, line_no, source_container)
|
51
|
-
|
62
|
+
found_line = true
|
63
|
+
## FIXME: condition is too long.
|
64
|
+
if source_container[0] == 'string' && frame.iseq && frame.iseq.source
|
65
|
+
file = LineCache::map_iseq(frame.iseq)
|
66
|
+
text = LineCache::getline(frame.iseq, line_no)
|
67
|
+
loc += " remapped #{canonic_file(file)}:#{line_no}"
|
68
|
+
elsif source_container[0] != 'file'
|
52
69
|
via = loc
|
53
70
|
while source_container[0] != 'file' && frame.prev do
|
54
71
|
frame = frame.prev
|
55
72
|
source_container = frame_container(frame, false)
|
56
73
|
end
|
57
74
|
if source_container[0] == 'file'
|
58
|
-
line_no
|
59
|
-
filename
|
60
|
-
loc
|
61
|
-
text
|
75
|
+
line_no = frame.source_location[0]
|
76
|
+
filename = source_container[1]
|
77
|
+
loc += " via #{canonic_file(filename)}:#{line_no}"
|
78
|
+
text = line_at(filename, line_no)
|
79
|
+
found_line = false
|
62
80
|
end
|
63
81
|
else
|
64
82
|
container = source_container[1]
|
@@ -69,7 +87,7 @@ class Trepan
|
|
69
87
|
|
70
88
|
text = line_at(container, line_no)
|
71
89
|
end
|
72
|
-
[loc, line_no, text]
|
90
|
+
[loc, line_no, text, found_line]
|
73
91
|
end
|
74
92
|
|
75
93
|
def print_location
|
@@ -94,9 +112,11 @@ class Trepan
|
|
94
112
|
@line_no = frame_line
|
95
113
|
|
96
114
|
loc = source_location_info(source_container, @line_no, @frame)
|
97
|
-
loc, @line_no, text
|
98
|
-
|
99
|
-
|
115
|
+
loc, @line_no, text, found_line =
|
116
|
+
loc_and_text(loc, @frame, @line_no, source_container)
|
117
|
+
|
118
|
+
ip_str = @frame.iseq ? " @#{frame.pc_offset}" : ''
|
119
|
+
msg "#{ev} (#{loc}#{ip_str})"
|
100
120
|
|
101
121
|
if %w(return c-return).member?(@event)
|
102
122
|
retval = Trepan::Frame.value_returned(@frame, @event)
|
@@ -107,14 +127,20 @@ class Trepan
|
|
107
127
|
msg text
|
108
128
|
@line_no -= 1
|
109
129
|
end
|
130
|
+
unless found_line
|
131
|
+
# Can't find source line, so give assembly as consolation.
|
132
|
+
# This great idea comes from the Rubinius reference debugger.
|
133
|
+
run_command('disassemble')
|
134
|
+
end
|
110
135
|
end
|
111
136
|
|
112
137
|
def source_location_info(source_container, line_no, frame)
|
113
138
|
filename = source_container[1]
|
139
|
+
## FIXME: condition is too long.
|
114
140
|
canonic_filename =
|
115
|
-
if
|
116
|
-
|
117
|
-
'eval ' + safe_repr(eval_str, 15)
|
141
|
+
if 'string' == source_container[0] && frame.iseq && frame.iseq.source
|
142
|
+
eval_str = frame.iseq.source
|
143
|
+
'eval "' + safe_repr(eval_str.gsub(/\n/,';'), 15) + '"'
|
118
144
|
else
|
119
145
|
canonic_file(filename)
|
120
146
|
end
|
data/processor/main.rb
CHANGED
@@ -122,17 +122,6 @@ class Trepan
|
|
122
122
|
# FIXME: run start file and start commands.
|
123
123
|
end
|
124
124
|
|
125
|
-
def canonic_container(container)
|
126
|
-
[container[0], canonic_file(container[1])]
|
127
|
-
end
|
128
|
-
|
129
|
-
def canonic_file(filename)
|
130
|
-
# For now we want resolved filenames
|
131
|
-
@settings[:basename] ? File.basename(filename) :
|
132
|
-
# Cache this?
|
133
|
-
Pathname.new(filename).cleanpath.to_s
|
134
|
-
end
|
135
|
-
|
136
125
|
def compute_prompt
|
137
126
|
thread_str =
|
138
127
|
if 1 == Thread.list.size
|
data/processor/mock.rb
CHANGED
@@ -72,6 +72,31 @@ module MockDebugger
|
|
72
72
|
end
|
73
73
|
module_function :setup
|
74
74
|
|
75
|
+
def sub_setup(sub_class, run=true)
|
76
|
+
sub_name = sub_class.const_get('PREFIX')
|
77
|
+
dbgr, cmd = setup(sub_name[0], false)
|
78
|
+
cmd.proc.frame_setup(RubyVM::ThreadFrame::current.prev)
|
79
|
+
sub_cmd = sub_class.new(cmd)
|
80
|
+
sub_cmd.summary_help(sub_cmd.name)
|
81
|
+
puts
|
82
|
+
sub_cmd.run([cmd.name]) if run
|
83
|
+
return sub_cmd
|
84
|
+
end
|
85
|
+
module_function :sub_setup
|
86
|
+
|
87
|
+
def subsub_setup(sub_class, subsub_class, run=true)
|
88
|
+
subsub_name = subsub_class.const_get('PREFIX')
|
89
|
+
dbgr, cmd = setup(subsub_name[0], false)
|
90
|
+
cmd.proc.frame_setup(RubyVM::ThreadFrame::current.prev)
|
91
|
+
sub_cmd = sub_class.new(dbgr.core.processor, cmd)
|
92
|
+
subsub_cmd = subsub_class.new(cmd.proc, sub_cmd, subsub_name.join(''))
|
93
|
+
subsub_cmd.summary_help(subsub_cmd.name)
|
94
|
+
puts
|
95
|
+
subsub_cmd.run([]) if run
|
96
|
+
return subsub_cmd
|
97
|
+
end
|
98
|
+
module_function :subsub_setup
|
99
|
+
|
75
100
|
def show_special_class_constants(cmd)
|
76
101
|
puts 'ALIASES: %s' % [cmd.class.const_get('ALIASES').inspect] if
|
77
102
|
cmd.class.constants.member?(:ALIASES)
|
data/processor/validate.rb
CHANGED
@@ -151,6 +151,24 @@ class Trepan
|
|
151
151
|
nil
|
152
152
|
end
|
153
153
|
|
154
|
+
def parse_num_or_offset(position_str)
|
155
|
+
opts = {
|
156
|
+
:msg_on_error =>
|
157
|
+
"argument '%s' does not seem to eval to a method or an integer." %
|
158
|
+
position_str,
|
159
|
+
:min_value => 0
|
160
|
+
}
|
161
|
+
use_offset =
|
162
|
+
if position_str.size > 0 && position_str[0].downcase == 'o'
|
163
|
+
position_str[0] = ''
|
164
|
+
true
|
165
|
+
else
|
166
|
+
false
|
167
|
+
end
|
168
|
+
position = get_an_int(position_str, opts)
|
169
|
+
[position, use_offset]
|
170
|
+
end
|
171
|
+
|
154
172
|
# Parse a breakpoint position. Return
|
155
173
|
# - the position - a Fixnum
|
156
174
|
# - the instruction sequence to use
|
@@ -167,11 +185,16 @@ class Trepan
|
|
167
185
|
File.basename(container[1])
|
168
186
|
iseq = @frame.iseq
|
169
187
|
else
|
170
|
-
errmsg
|
188
|
+
errmsg("Unable to find instruction sequence for" +
|
189
|
+
" position #{position} in #{container[1]}")
|
171
190
|
return [nil, nil, nil, true]
|
172
191
|
end
|
173
192
|
end
|
174
|
-
|
193
|
+
if args.empty? || 'if' == args[0]
|
194
|
+
use_offset = false
|
195
|
+
else
|
196
|
+
position, use_offset = parse_num_or_offset(args[0])
|
197
|
+
end
|
175
198
|
else
|
176
199
|
iseq = object_iseq(first)
|
177
200
|
position_str =
|
@@ -190,20 +213,7 @@ class Trepan
|
|
190
213
|
iseq = @frame.iseq unless container
|
191
214
|
first
|
192
215
|
end
|
193
|
-
use_offset =
|
194
|
-
if position_str.size > 0 && position_str[0].downcase == 'o'
|
195
|
-
position_str[0] = ''
|
196
|
-
true
|
197
|
-
else
|
198
|
-
false
|
199
|
-
end
|
200
|
-
opts = {
|
201
|
-
:msg_on_error =>
|
202
|
-
"argument '%s' does not seem to eval to a method or an integer." %
|
203
|
-
position_str,
|
204
|
-
:min_value => 0
|
205
|
-
}
|
206
|
-
position = get_an_int(position_str, opts)
|
216
|
+
position, use_offset = parse_num_or_offset(position_str)
|
207
217
|
end
|
208
218
|
condition = 'true'
|
209
219
|
if args.size > 0 && 'if' == args[0]
|
@@ -344,11 +354,15 @@ if __FILE__ == $0
|
|
344
354
|
else
|
345
355
|
require 'thread_frame'
|
346
356
|
require_relative '../app/mock'
|
357
|
+
require_relative './default'
|
358
|
+
require_relative 'frame'
|
347
359
|
require_relative 'main' # Have to include before defining CmdProcessor!
|
348
360
|
# FIXME
|
349
361
|
|
350
362
|
proc = Trepan::CmdProcessor.new(Trepan::MockCore.new())
|
351
|
-
proc.
|
363
|
+
proc.frame_initialize
|
364
|
+
proc.instance_variable_set('@settings',
|
365
|
+
Trepan::CmdProcessor::DEFAULT_SETTINGS)
|
352
366
|
proc.frame_setup(RubyVM::ThreadFrame.current)
|
353
367
|
onoff = %w(1 0 on off)
|
354
368
|
onoff.each { |val| puts "onoff(#{val}) = #{proc.get_onoff(val)}" }
|
@@ -374,7 +388,7 @@ if __FILE__ == $0
|
|
374
388
|
end
|
375
389
|
puts '=' * 40
|
376
390
|
# require_relative '../lib/trepanning'
|
377
|
-
# dbgr = Trepan.new
|
391
|
+
# dbgr = Trepan.new
|
378
392
|
# dbgr.debugger
|
379
393
|
|
380
394
|
# FIXME:
|
@@ -389,6 +403,8 @@ if __FILE__ == $0
|
|
389
403
|
p proc.breakpoint_position(%w(1))
|
390
404
|
p proc.breakpoint_position(%w(2 if a > b))
|
391
405
|
p proc.get_int_list(%w(1+0 3-1 3))
|
406
|
+
require 'trepanning'
|
407
|
+
debugger
|
392
408
|
p proc.get_int_list(%w(a 2 3))
|
393
409
|
end
|
394
410
|
end
|