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
@@ -0,0 +1,67 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2012, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require_relative '../../base/subsubcmd'
|
4
|
+
|
5
|
+
# Note: The class name has to end in Pc, not PC since it is
|
6
|
+
# auto-instantiated.
|
7
|
+
class Trepan::Subcommand::SetRegisterPc < Trepan::SubSubcommand
|
8
|
+
unless defined?(HELP)
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
SHORT_HELP = 'Set VM program counter (PC)'
|
11
|
+
IN_LIST = true
|
12
|
+
MIN_ABBREV = 'pc'.size
|
13
|
+
PREFIX = %w(set register #{name})
|
14
|
+
HELP = <<-EOH
|
15
|
+
**#{PREFIX.join(' ')}** *integer-expression*
|
16
|
+
|
17
|
+
Set VM program-counter register (PC) to *integer-expression*
|
18
|
+
|
19
|
+
Warning: this is potentially dangerous.
|
20
|
+
|
21
|
+
See also:
|
22
|
+
---------
|
23
|
+
`set register sp`, `info register sp`, `set return`
|
24
|
+
EOH
|
25
|
+
end
|
26
|
+
|
27
|
+
def run(args)
|
28
|
+
if args.size < 2
|
29
|
+
errmsg "Too few arguments - the 'pc' command requires a value"
|
30
|
+
return
|
31
|
+
end
|
32
|
+
new_val_str = args[1..-1].join(' ')
|
33
|
+
begin
|
34
|
+
new_val = @proc.debug_eval(new_val_str)
|
35
|
+
rescue StandardError, ScriptError => e
|
36
|
+
return
|
37
|
+
end
|
38
|
+
msg("Old value was: %s" % @proc.frame.pc_offset.inspect)
|
39
|
+
@proc.frame.pc_offset = new_val
|
40
|
+
msg("New value is: %s" % new_val.inspect)
|
41
|
+
end
|
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 = MockDebugger::setup('set')
|
52
|
+
# subcommand = Debugger::Subcommand::SetPC.new(cmd)
|
53
|
+
# testcmdMgr = Debugger::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
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010-2012, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require_relative '../../base/subsubcmd'
|
4
|
+
|
5
|
+
# Note: The class name has to end in Sp, not SP since it is
|
6
|
+
# auto-instantiated.
|
7
|
+
class Trepan::Subcommand::SetRegisterSp < Trepan::SubSubcommand
|
8
|
+
unless defined?(HELP)
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
SHORT_HELP = 'Set a stack pointer register'
|
11
|
+
IN_LIST = true
|
12
|
+
MIN_ABBREV = 'sp'.size
|
13
|
+
PREFIX = %w(set register #{name})
|
14
|
+
HELP = <<-EOH
|
15
|
+
**#{PREFIX.join(' ')}** *integer-expression*
|
16
|
+
|
17
|
+
Set VM stack-pointer register (SP) to *integer-expression*
|
18
|
+
|
19
|
+
Warning: this is potentially dangerous.
|
20
|
+
|
21
|
+
See also:
|
22
|
+
---------
|
23
|
+
|
24
|
+
`info register sp`, `set return`
|
25
|
+
EOH
|
26
|
+
end
|
27
|
+
|
28
|
+
def run(args)
|
29
|
+
# FIXME handle c-return
|
30
|
+
# unless %w(return c-return).member?(@proc.event)
|
31
|
+
if args.size < 3
|
32
|
+
errmsg "Too few arguments - the 'sp' command requires number and a value"
|
33
|
+
return
|
34
|
+
end
|
35
|
+
msg_on_error = "set SP requires an integer index"
|
36
|
+
index = @proc.get_an_int(args[1],
|
37
|
+
:msg_on_error => msg_on_error
|
38
|
+
)
|
39
|
+
return unless index
|
40
|
+
new_val_str = args[2..-1].join(' ')
|
41
|
+
begin
|
42
|
+
new_val = @proc.debug_eval(new_val_str)
|
43
|
+
rescue StandardError, ScriptError => e
|
44
|
+
return
|
45
|
+
end
|
46
|
+
msg("Old value was: %s" % @proc.frame.sp(index).inspect)
|
47
|
+
@proc.frame.sp_set(index, new_val)
|
48
|
+
msg("New value is: %s" % new_val.inspect)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
if __FILE__ == $0
|
53
|
+
# Demo it.
|
54
|
+
require_relative '../../../mock'
|
55
|
+
require_relative '../../../subcmd'
|
56
|
+
name = File.basename(__FILE__, '.rb')
|
57
|
+
|
58
|
+
# # FIXME: DRY the below code
|
59
|
+
# dbgr, cmd = MockTrepan::setup('set')
|
60
|
+
# subcommand = Trepan::Subcommand::SetSp.new(cmd)
|
61
|
+
# testcmdMgr = Trepan::Subcmd.new(subcommand)
|
62
|
+
|
63
|
+
# def subcommand.msg(message)
|
64
|
+
# puts message
|
65
|
+
# end
|
66
|
+
# def subcommand.msg_nocr(message)
|
67
|
+
# print message
|
68
|
+
# end
|
69
|
+
# def subcommand.errmsg(message)
|
70
|
+
# puts message
|
71
|
+
# end
|
72
|
+
# subcommand.run(%w(20))
|
73
|
+
# name = File.basename(__FILE__, '.rb')
|
74
|
+
# subcommand.summary_help(name)
|
75
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
# Copyright (C) 2011, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require_relative '../base/subcmd'
|
4
4
|
|
5
5
|
class Trepan::Subcommand::SetReload < Trepan::SetBoolSubcommand
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
unless defined?(HELP)
|
7
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
8
|
+
SHORT_HELP = "Set whether to reread source text when it changes."
|
9
|
+
IN_LIST = true
|
10
|
+
MIN_ABBREV = 'rel'.size
|
11
|
+
HELP = <<-EOH
|
12
|
+
**#{CMD}** {**on**|**off**}
|
13
13
|
|
14
14
|
Source text is cached on the first read. This ensures that if you
|
15
15
|
change the source text after the debugged program is runnning you will
|
@@ -23,10 +23,12 @@ will reload the source code. So here the debugger will be out of sync.
|
|
23
23
|
Set this to true, and the debugger will notice such changes and reread
|
24
24
|
the source text when it discovers it has changed.
|
25
25
|
|
26
|
-
See also
|
26
|
+
See also:
|
27
|
+
--------
|
28
|
+
`info source` and `info files` and note the SHA1
|
27
29
|
and file modification time.
|
28
30
|
EOH
|
29
|
-
|
31
|
+
end
|
30
32
|
end
|
31
33
|
|
32
34
|
if __FILE__ == $0
|
@@ -1,12 +1,27 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010,
|
2
|
+
# Copyright (C) 2010-2011, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require_relative '../base/subcmd'
|
4
4
|
require_relative '../../../app/frame'
|
5
5
|
|
6
6
|
class Trepan::Subcommand::SetReturn < Trepan::Subcommand
|
7
7
|
unless defined?(HELP)
|
8
8
|
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
9
|
-
HELP =
|
9
|
+
HELP = <<-EOH
|
10
|
+
**#{PREFIX.join(' ')}** *expression*
|
11
|
+
|
12
|
+
Set return value to *expression*
|
13
|
+
|
14
|
+
There are currently a number of restrictions here. First, you have to
|
15
|
+
be at some sort of return event. Second, the opcode you are stopped at
|
16
|
+
has to be a `leave` instruction.
|
17
|
+
|
18
|
+
Warning: this is potentially dangerous.
|
19
|
+
|
20
|
+
See also:
|
21
|
+
---------
|
22
|
+
|
23
|
+
`set register sp`, `info register sp`
|
24
|
+
EOH
|
10
25
|
IN_LIST = true
|
11
26
|
MIN_ABBREV = 'ret'.size
|
12
27
|
end
|
@@ -14,52 +29,61 @@ class Trepan::Subcommand::SetReturn < Trepan::Subcommand
|
|
14
29
|
include Trepan::Frame
|
15
30
|
|
16
31
|
def run(args)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
return
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
event = @proc.event.to_s
|
33
|
+
unless %w(return c_return b_return).member?(event)
|
34
|
+
errmsg('You need to be in a return event to do this. Event is %s' %
|
35
|
+
event)
|
36
|
+
return
|
37
|
+
end
|
38
|
+
unless @proc.core.trace_point
|
39
|
+
msg('We need a trace-point to get this information')
|
40
|
+
return
|
41
|
+
end
|
42
|
+
if args.size < 3
|
43
|
+
errmsg "Too few arguments - the 'return' command requires a return value"
|
44
|
+
return
|
45
|
+
end
|
46
|
+
frame = @proc.frame
|
47
|
+
if %w(return b_return).member?(event)
|
48
|
+
index = 1
|
49
|
+
opname = frame.iseq.op_at(frame.pc_offset)
|
50
|
+
if opname != 'leave'
|
51
|
+
msg("Need to be at a 'leave' instruction; at %s instruction" %
|
52
|
+
opname)
|
53
|
+
return
|
54
|
+
end
|
55
|
+
else
|
56
|
+
# FIXME: Probably not quite right. Doesn't handle receiver methods
|
57
|
+
# would like to do via end of stack-1.
|
58
|
+
index = frame.argc + 3
|
59
|
+
msg("C functions not handled yet")
|
60
|
+
return
|
61
|
+
end
|
62
|
+
@proc.commands['set'].run(['set', 'register', 'sp', index.to_s, *args[2..-1]])
|
38
63
|
end
|
39
|
-
|
40
64
|
end
|
41
65
|
|
42
66
|
if __FILE__ == $0
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
67
|
+
# Demo it.
|
68
|
+
require_relative '../../mock'
|
69
|
+
require_relative '../../subcmd'
|
70
|
+
name = File.basename(__FILE__, '.rb')
|
47
71
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
72
|
+
# FIXME: DRY the below code
|
73
|
+
dbgr, cmd = MockDebugger::setup('set')
|
74
|
+
subcommand = Trepan::Subcommand::SetReturn.new(cmd)
|
75
|
+
testcmdMgr = Trepan::Subcmd.new(subcommand)
|
52
76
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
77
|
+
def subcommand.msg(message)
|
78
|
+
puts message
|
79
|
+
end
|
80
|
+
def subcommand.msg_nocr(message)
|
81
|
+
print message
|
82
|
+
end
|
83
|
+
def subcommand.errmsg(message)
|
84
|
+
puts message
|
85
|
+
end
|
86
|
+
subcommand.run(%w(20))
|
87
|
+
name = File.basename(__FILE__, '.rb')
|
88
|
+
subcommand.summary_help(name)
|
65
89
|
end
|
data/processor/command/shell.rb
CHANGED
@@ -87,7 +87,8 @@ Here then is a loop to query VM stack values:
|
|
87
87
|
|
88
88
|
# And just when you thought, we'd never get around to
|
89
89
|
# actually running irb...
|
90
|
-
|
90
|
+
bind = @proc.frame ? @proc.frame.binding : binding
|
91
|
+
cont = IRB.start_session(bind, @proc, conf)
|
91
92
|
trap('SIGINT', save_trap) # Restore our old interrupt function.
|
92
93
|
|
93
94
|
# Restore the debuggers' Readline history and the Readline completion
|
@@ -117,7 +118,7 @@ Here then is a loop to query VM stack values:
|
|
117
118
|
when :step
|
118
119
|
@proc.step # (1, {})
|
119
120
|
else
|
120
|
-
@proc.print_location
|
121
|
+
@proc.print_location if @proc.frame
|
121
122
|
end
|
122
123
|
ensure
|
123
124
|
$trepan_in_irb = false
|
@@ -1,23 +1,26 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010,
|
2
|
+
# Copyright (C) 2010-2011, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require_relative '../base/subcmd'
|
4
4
|
|
5
5
|
class Trepan::Subcommand::ShowDifferent < Trepan::ShowBoolSubcommand
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
def run(args)
|
13
|
-
if 'nostack' == @proc.settings[:different]
|
14
|
-
msg("different is nostack.")
|
15
|
-
else
|
16
|
-
super
|
6
|
+
unless defined?(HELP)
|
7
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
8
|
+
HELP = "Show status of 'set different'"
|
9
|
+
MIN_ABBREV = 'dif'.size
|
17
10
|
end
|
18
|
-
end
|
19
|
-
|
20
11
|
|
12
|
+
def run(args)
|
13
|
+
case @proc.settings[:different]
|
14
|
+
when 'nostack'
|
15
|
+
msg("different is nostack.")
|
16
|
+
when 'off'
|
17
|
+
msg("different is off.")
|
18
|
+
when 'on'
|
19
|
+
msg("different is on.")
|
20
|
+
else
|
21
|
+
msg("Unknown value of different %s" % @proc.settings[:different].inspect)
|
22
|
+
end
|
23
|
+
end
|
21
24
|
end
|
22
25
|
|
23
26
|
if __FILE__ == $0
|
@@ -1,38 +1,38 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010,
|
2
|
+
# Copyright (C) 2010-2011, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require_relative '../base/subcmd'
|
4
4
|
|
5
5
|
class Trepan::Subcommand::ShowEvents < Trepan::Subcommand
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
unless defined?(HELP)
|
7
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
8
|
+
HELP = 'Show trace events we may stop on.'
|
9
|
+
MIN_ABBREV = 'ev'.size
|
10
|
+
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
# FIXME: this really should be a subcommand of "set trace"
|
13
|
+
def run(args)
|
14
|
+
step_events_list = @proc.core.step_events_list
|
15
|
+
if step_events_list
|
16
|
+
section 'Trace events we may stop on:'
|
17
|
+
msg columnize_commands(step_events_list.sort)
|
18
|
+
else
|
19
|
+
msg 'No events trapped.'
|
20
|
+
end
|
20
21
|
end
|
21
|
-
end
|
22
22
|
|
23
23
|
end
|
24
24
|
|
25
25
|
if __FILE__ == $0
|
26
|
-
|
27
|
-
|
26
|
+
# Demo it.
|
27
|
+
require_relative '../../mock'
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
# FIXME: DRY the below code
|
30
|
+
dbgr, cmd = MockDebugger::setup('exit')
|
31
|
+
subcommand = Trepan::Subcommand::ShowEvents.new(cmd)
|
32
|
+
testcmdMgr = Trepan::Subcmd.new(subcommand)
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
name = File.basename(__FILE__, '.rb')
|
35
|
+
subcommand.summary_help(name)
|
36
|
+
puts
|
37
|
+
subcommand.run([name])
|
38
38
|
end
|
data/processor/default.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2010-2011, 2013 Rocky Bernstein <rockyb@rubyforge.net>
|
1
|
+
# Copyright (C) 2010-2011, 2013, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
2
2
|
require_relative '../app/default'
|
3
3
|
require_relative 'virtual'
|
4
4
|
class Trepan::CmdProcessor < Trepan::VirtualCmdProcessor
|
data/processor/eval.rb
CHANGED
@@ -4,22 +4,21 @@ require_relative 'virtual'
|
|
4
4
|
class Trepan
|
5
5
|
class CmdProcessor < VirtualCmdProcessor
|
6
6
|
|
7
|
-
def debug_eval(str, max_fake_filename=15
|
8
|
-
ruby_193_hack=false) #FIXME: remove ruby_193_hack
|
7
|
+
def debug_eval(str, max_fake_filename=15)
|
9
8
|
begin
|
10
|
-
debug_eval_with_exception(str, max_fake_filename
|
9
|
+
debug_eval_with_exception(str, max_fake_filename)
|
11
10
|
rescue SyntaxError, StandardError, ScriptError => e
|
12
11
|
exception_dump(e, @settings[:stack_trace_on_error], $!.backtrace)
|
13
12
|
nil
|
14
13
|
end
|
15
14
|
end
|
16
15
|
|
17
|
-
def debug_eval_with_exception(str, max_fake_filename=15
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
def debug_eval_with_exception(str, max_fake_filename=15)
|
17
|
+
# FIXME: Do we need to set trace_off?
|
18
|
+
RubyVM::Frame.get.trace_off = true
|
19
|
+
filename, b = get_binding_and_filename(str, max_fake_filename)
|
20
|
+
RubyVM::Frame.get.trace_off = false
|
21
|
+
eval(str, b, filename)
|
23
22
|
end
|
24
23
|
|
25
24
|
def debug_eval_no_errmsg(str, max_fake_filename=15)
|
@@ -32,10 +31,10 @@ class Trepan
|
|
32
31
|
|
33
32
|
def eval_code(str, max_fake_filename)
|
34
33
|
obj = debug_eval(str, max_fake_filename)
|
35
|
-
|
34
|
+
|
36
35
|
# idx = @user_variables
|
37
36
|
# @user_variables += 1
|
38
|
-
|
37
|
+
|
39
38
|
# str = "$d#{idx}"
|
40
39
|
# Rubinius::Globals[str.to_sym] = obj
|
41
40
|
# msg "#{str} = #{obj.inspect}"
|
@@ -53,7 +52,7 @@ class Trepan
|
|
53
52
|
end
|
54
53
|
|
55
54
|
def fake_eval_filename(str, maxlen = 15)
|
56
|
-
fake_filename =
|
55
|
+
fake_filename =
|
57
56
|
if maxlen < str.size
|
58
57
|
# FIXME: Guard against \" in positions 13..15?
|
59
58
|
str.inspect[0..maxlen-1] + '"...'
|
@@ -62,9 +61,9 @@ class Trepan
|
|
62
61
|
end
|
63
62
|
"(eval #{fake_filename})"
|
64
63
|
end
|
65
|
-
|
64
|
+
|
66
65
|
def get_binding_and_filename(str, maxlen)
|
67
|
-
b =
|
66
|
+
b =
|
68
67
|
begin
|
69
68
|
@frame.binding
|
70
69
|
rescue
|
@@ -89,7 +88,7 @@ if __FILE__ == $0
|
|
89
88
|
def cmdp.msg(msg)
|
90
89
|
puts "** #{msg}"
|
91
90
|
end
|
92
|
-
begin
|
91
|
+
begin
|
93
92
|
1/0
|
94
93
|
rescue Exception => exc
|
95
94
|
cmdp.exception_dump(exc, true, $!.backtrace)
|