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
@@ -1,41 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
-
require_relative 'locals'
|
4
|
-
|
5
|
-
class Trepan::Subcommand::InfoVariablesConstant <
|
6
|
-
Trepan::Subcommand::InfoVariablesLocals
|
7
|
-
Trepan::Util.suppress_warnings {
|
8
|
-
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
9
|
-
HELP = <<-EOH
|
10
|
-
#{CMD}
|
11
|
-
#{CMD} [names]
|
12
|
-
|
13
|
-
Show class constants of the current stack frame.
|
14
|
-
Normally for each which show both the name and value. If you just
|
15
|
-
want a list of names add parameter 'names'.
|
16
|
-
EOH
|
17
|
-
SHORT_HELP = 'Show class constants via the current stack frame'
|
18
|
-
MIN_ABBREV = 'co'.size
|
19
|
-
MIN_ARGS = 0
|
20
|
-
MAX_ARGS = 1
|
21
|
-
NEED_STACK = true
|
22
|
-
}
|
23
|
-
|
24
|
-
def get_names
|
25
|
-
@proc.debug_eval_no_errmsg('self.class.constants.sort') || []
|
26
|
-
end
|
27
|
-
|
28
|
-
def run(args)
|
29
|
-
run_for_type(args, 'constant', @proc.debug_eval('self'))
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
if __FILE__ == $0
|
34
|
-
# Demo it.
|
35
|
-
require_relative '../../mock'
|
36
|
-
cmd =
|
37
|
-
MockDebugger::subsub_setup(Trepan::Subcommand::InfoVariables,
|
38
|
-
Trepan::Subcommand::InfoVariablesConstant)
|
39
|
-
cmd.run(cmd.prefix)
|
40
|
-
cmd.run(cmd.prefix + ['name'])
|
41
|
-
end
|
data/processor/command/raise.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
# Copyright (C) 2010, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
-
require_relative '../command'
|
3
|
-
class Trepan::Command::RaiseCommand < Trepan::Command
|
4
|
-
|
5
|
-
unless defined?(HELP)
|
6
|
-
NAME = File.basename(__FILE__, '.rb')
|
7
|
-
HELP = <<-HELP
|
8
|
-
**#{NAME}** [*exception-name*]
|
9
|
-
|
10
|
-
Raise an *execption-name* in the debugged program. If no exception name
|
11
|
-
is given, raise `RuntimeError`.
|
12
|
-
HELP
|
13
|
-
|
14
|
-
CATEGORY = 'running'
|
15
|
-
MAX_ARGS = 1 # Need at most this many
|
16
|
-
SHORT_HELP = 'Raise an exception in the debugged program'
|
17
|
-
end
|
18
|
-
|
19
|
-
# This method runs the command
|
20
|
-
def run(args)
|
21
|
-
exception =
|
22
|
-
if args.size > 1
|
23
|
-
except_str = args[1..-1].join(' ')
|
24
|
-
# Normally would need x.respond_to? && ..
|
25
|
-
# but since we catch errors with debug_eval.. not needed.
|
26
|
-
eval_str = ("%s.ancestors.include?(Exception)" %
|
27
|
-
[except_str])
|
28
|
-
unless @proc.debug_eval_no_errmsg(eval_str)
|
29
|
-
errmsg "\"#{except_str}\" does not inherit Exception."
|
30
|
-
return
|
31
|
-
end
|
32
|
-
@proc.debug_eval_no_errmsg(except_str)
|
33
|
-
else
|
34
|
-
RuntimeError
|
35
|
-
end
|
36
|
-
@proc.step(0)
|
37
|
-
@proc.leave_cmd_loop = true
|
38
|
-
@proc.core.exception = exception
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
if __FILE__ == $0
|
43
|
-
require_relative '../mock'
|
44
|
-
dbgr, cmd = MockDebugger::setup
|
45
|
-
puts cmd.run([cmd.name, 'NotanException'])
|
46
|
-
puts cmd.run([cmd.name, '[5]'])
|
47
|
-
puts cmd.run([cmd.name, 'RuntimeError'])
|
48
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2012 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
-
require_relative '../base/subcmd'
|
4
|
-
|
5
|
-
class Trepan::Subcommand::SetPc < Trepan::Subcommand
|
6
|
-
unless defined?(HELP)
|
7
|
-
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
8
|
-
HELP = 'set PC INTEGER-EXPRESSION
|
9
|
-
|
10
|
-
Set VM program-counter register (PC) to INTEGER-EXPRESSION.
|
11
|
-
|
12
|
-
Warning: this is potentially dangerous.
|
13
|
-
'
|
14
|
-
SHORT_HELP = 'Set VM program counter (PC)'
|
15
|
-
IN_LIST = true
|
16
|
-
MIN_ABBREV = 'pc'.size
|
17
|
-
end
|
18
|
-
|
19
|
-
def run(args)
|
20
|
-
# FIXME handle c-return
|
21
|
-
# unless %w(return c-return).member?(@proc.event)
|
22
|
-
if args.size < 3
|
23
|
-
errmsg "Too few arguments - the 'pc' command requires a value"
|
24
|
-
return
|
25
|
-
end
|
26
|
-
new_val_str = args[2..-1].join(' ')
|
27
|
-
begin
|
28
|
-
new_val = @proc.debug_eval(new_val_str)
|
29
|
-
rescue StandardError, ScriptError => e
|
30
|
-
return
|
31
|
-
end
|
32
|
-
msg("Old value was: %s" % @proc.frame.pc_offset.inspect)
|
33
|
-
@proc.frame.pc_offset = new_val
|
34
|
-
msg("New value is: %s" % new_val.inspect)
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
if __FILE__ == $0
|
40
|
-
# Demo it.
|
41
|
-
require_relative %w(.. .. mock)
|
42
|
-
require_relative %w(.. .. subcmd)
|
43
|
-
name = File.basename(__FILE__, '.rb')
|
44
|
-
|
45
|
-
# FIXME: DRY the below code
|
46
|
-
dbgr, cmd = MockDebugger::setup('set')
|
47
|
-
subcommand = Debugger::Subcommand::SetPc.new(cmd)
|
48
|
-
testcmdMgr = Debugger::Subcmd.new(subcommand)
|
49
|
-
|
50
|
-
def subcommand.msg(message)
|
51
|
-
puts message
|
52
|
-
end
|
53
|
-
def subcommand.msg_nocr(message)
|
54
|
-
print message
|
55
|
-
end
|
56
|
-
def subcommand.errmsg(message)
|
57
|
-
puts message
|
58
|
-
end
|
59
|
-
subcommand.run(%w(20))
|
60
|
-
name = File.basename(__FILE__, '.rb')
|
61
|
-
subcommand.summary_help(name)
|
62
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010-2012 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
-
require_relative '../base/subcmd'
|
4
|
-
|
5
|
-
class Trepan::Subcommand::SetSp < Trepan::Subcommand
|
6
|
-
unless defined?(HELP)
|
7
|
-
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
8
|
-
HELP = 'set sp INTEGER-EXPRESSION
|
9
|
-
|
10
|
-
Set VM stack-pointer register (SP) to INTEGER-EXPRESSION.
|
11
|
-
|
12
|
-
Warning: this is potentially dangerous.
|
13
|
-
'
|
14
|
-
SHORT_HELP = 'Set a stack pointer register'
|
15
|
-
IN_LIST = true
|
16
|
-
MIN_ABBREV = 'sp'.size
|
17
|
-
end
|
18
|
-
|
19
|
-
def run(args)
|
20
|
-
# FIXME handle c-return
|
21
|
-
# unless %w(return c-return).member?(@proc.event)
|
22
|
-
if args.size < 4
|
23
|
-
errmsg "Too few arguments - the 'sp' command requires number and a value"
|
24
|
-
return
|
25
|
-
end
|
26
|
-
msg_on_error = "set SP requires an integer index"
|
27
|
-
index = @proc.get_an_int(args[2],
|
28
|
-
:msg_on_error => msg_on_error
|
29
|
-
)
|
30
|
-
return unless index
|
31
|
-
new_val_str = args[3..-1].join(' ')
|
32
|
-
begin
|
33
|
-
new_val = @proc.debug_eval(new_val_str)
|
34
|
-
rescue StandardError, ScriptError => e
|
35
|
-
return
|
36
|
-
end
|
37
|
-
msg("Old value was: %s" % @proc.frame.sp(index).inspect)
|
38
|
-
@proc.frame.sp_set(index, new_val).inspect
|
39
|
-
msg("New value is: %s" % new_val.inspect)
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
if __FILE__ == $0
|
45
|
-
# Demo it.
|
46
|
-
require_relative '../../mock'
|
47
|
-
require_relative '../../subcmd'
|
48
|
-
name = File.basename(__FILE__, '.rb')
|
49
|
-
|
50
|
-
# FIXME: DRY the below code
|
51
|
-
dbgr, cmd = MockTrepan::setup('set')
|
52
|
-
subcommand = Trepan::Subcommand::SetSp.new(cmd)
|
53
|
-
testcmdMgr = Trepan::Subcmd.new(subcommand)
|
54
|
-
|
55
|
-
def subcommand.msg(message)
|
56
|
-
puts message
|
57
|
-
end
|
58
|
-
def subcommand.msg_nocr(message)
|
59
|
-
print message
|
60
|
-
end
|
61
|
-
def subcommand.errmsg(message)
|
62
|
-
puts message
|
63
|
-
end
|
64
|
-
subcommand.run(%w(20))
|
65
|
-
name = File.basename(__FILE__, '.rb')
|
66
|
-
subcommand.summary_help(name)
|
67
|
-
end
|
data/processor/eventbuf.rb
DELETED
@@ -1,133 +0,0 @@
|
|
1
|
-
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
-
# For recording hook events in a buffer for review later. Make use of
|
3
|
-
# Trace::Buffer for this prupose.
|
4
|
-
require 'trace'
|
5
|
-
require 'linecache'
|
6
|
-
require_relative 'virtual'
|
7
|
-
|
8
|
-
class Trepan
|
9
|
-
class CmdProcessor < VirtualCmdProcessor
|
10
|
-
|
11
|
-
attr_reader :eventbuf
|
12
|
-
attr_reader :event_tracefilter
|
13
|
-
|
14
|
-
def eventbuf_initialize(size=100)
|
15
|
-
@eventbuf = Trace::EventBuffer.new(size)
|
16
|
-
# @event_tracefilter = Trace::Filter.new
|
17
|
-
end
|
18
|
-
|
19
|
-
# def event_processor(event, frame, arg=nil)
|
20
|
-
# @eventbuf.append(event, frame, arg)
|
21
|
-
# end
|
22
|
-
|
23
|
-
# Print event buffer entries from FROM up to TO try to stay within
|
24
|
-
# WIDTH. We show source lines only the first time they are
|
25
|
-
# encountered. Also we use separators to indicate points that the
|
26
|
-
# debugger has stopped at.
|
27
|
-
def eventbuf_print(from=nil, to=nil, width=80)
|
28
|
-
sep = '-' * ((width - 7) / 2)
|
29
|
-
last_container, last_location = nil, nil
|
30
|
-
if from == nil || !@eventbuf.marks[-1]
|
31
|
-
mark_index = 0
|
32
|
-
else
|
33
|
-
mark_index = @eventbuf.marks.size-1
|
34
|
-
translated_from = @eventbuf.zero_pos + from
|
35
|
-
@eventbuf.marks.each_with_index do
|
36
|
-
|m, i|
|
37
|
-
if m > translated_from
|
38
|
-
mark_index = [0, i-1].max
|
39
|
-
break
|
40
|
-
elsif m == translated_from
|
41
|
-
mark_index = i
|
42
|
-
break
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
nextmark = @eventbuf.marks[mark_index]
|
48
|
-
@eventbuf.each_with_index(from, to) do |e, i|
|
49
|
-
if nextmark
|
50
|
-
if nextmark == i
|
51
|
-
msg "#{sep} %5d #{sep}" % (mark_index - @eventbuf.marks.size)
|
52
|
-
mark_index += 1 if mark_index < @eventbuf.marks.size - 1
|
53
|
-
nextmark = @eventbuf.marks[mark_index]
|
54
|
-
elsif nextmark < i
|
55
|
-
mark_index += 1 if mark_index < @eventbuf.marks.size - 1
|
56
|
-
nextmark = @eventbuf.marks[mark_index]
|
57
|
-
end
|
58
|
-
end
|
59
|
-
last_container, last_location, mess =
|
60
|
-
format_eventbuf_entry(e, last_container, last_location) if e
|
61
|
-
msg mess
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# Show event buffer entry. If the location is the same as the previous
|
66
|
-
# location we don't show the duplicated location information.
|
67
|
-
def format_eventbuf_entry(item, last_container, last_location)
|
68
|
-
container =
|
69
|
-
if item.source_container[0] == 'file'
|
70
|
-
item.source_container[1]
|
71
|
-
else
|
72
|
-
item.source_container
|
73
|
-
end
|
74
|
-
|
75
|
-
location =
|
76
|
-
if 1 == item.source_location.size
|
77
|
-
item.source_location[0]
|
78
|
-
else
|
79
|
-
item.source_location
|
80
|
-
end
|
81
|
-
|
82
|
-
same_loc = (container == last_container && location == last_location)
|
83
|
-
mess = "#{item.event} "
|
84
|
-
mess +=
|
85
|
-
if %w(c-return return).member?(item.event)
|
86
|
-
"#{item.method} => #{item.arg.inspect}" + (same_loc ? '' : "\n\t")
|
87
|
-
elsif 'c-call' == item.event
|
88
|
-
"#{item.method} "
|
89
|
-
else
|
90
|
-
"#{item.type} #{item.method} "
|
91
|
-
end
|
92
|
-
mess += "#{container} at line #{location}" unless same_loc
|
93
|
-
|
94
|
-
if item.iseq # && long_format
|
95
|
-
mess += "\n\tVM offset #{item.pc_offset}"
|
96
|
-
end
|
97
|
-
unless same_loc
|
98
|
-
text = LineCache::getline(container, location,
|
99
|
-
:reload_on_change => @reload_on_change)
|
100
|
-
mess += ":\n #{text.chomp}" if text
|
101
|
-
end
|
102
|
-
return container, location, mess
|
103
|
-
end
|
104
|
-
|
105
|
-
# FIXME: multiple hook mechanism needs work.
|
106
|
-
# def start_capture
|
107
|
-
# @event_tracefilter.add_trace_func(method(:event_processor).to_proc,
|
108
|
-
# Trace::DEFAULT_EVENT_MASK)
|
109
|
-
# end
|
110
|
-
|
111
|
-
# def stop_capture
|
112
|
-
# @event_tracefilter.set_trace_func(nil)
|
113
|
-
# end
|
114
|
-
|
115
|
-
end
|
116
|
-
end
|
117
|
-
if __FILE__ == $0
|
118
|
-
# Demo it.
|
119
|
-
cmdproc = Trepan::CmdProcessor.new([])
|
120
|
-
cmdproc.eventbuf_initialize(5)
|
121
|
-
|
122
|
-
def cmdproc.msg(mess)
|
123
|
-
puts mess
|
124
|
-
end
|
125
|
-
# cmdproc.start_capture
|
126
|
-
# z=5
|
127
|
-
# z.times do |i|
|
128
|
-
# x = i
|
129
|
-
# y = x+2
|
130
|
-
# end
|
131
|
-
# cmdproc.stop_capture
|
132
|
-
cmdproc.eventbuf_print
|
133
|
-
end
|