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/command/delete.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010-2012 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
# Copyright (C) 2010-2012, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require_relative '../command'
|
4
4
|
require_relative '../breakpoint'
|
5
5
|
require_relative '../../app/breakpoint'
|
@@ -8,26 +8,35 @@ class Trepan::Command::DeleteCommand < Trepan::Command
|
|
8
8
|
unless defined?(HELP)
|
9
9
|
NAME = File.basename(__FILE__, '.rb')
|
10
10
|
HELP = <<-HELP
|
11
|
-
|
11
|
+
**#{NAME}** [*bpnumber* [*bpnumber*...]]
|
12
12
|
|
13
13
|
Delete some breakpoints.
|
14
14
|
|
15
15
|
Arguments are breakpoint numbers with spaces in between. To delete
|
16
|
-
all breakpoints, give no argument.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
all breakpoints, give no argument. When deleting all breakpoints
|
17
|
+
confirmation is asked for, unless the command is suffixed with "!".
|
18
|
+
|
19
|
+
Examples:
|
20
|
+
|
21
|
+
delete 1 # delete breakpoint 1
|
22
|
+
delete # delete all breakpoints
|
23
|
+
delete! # Same as above, no questions asked.
|
24
|
+
|
25
|
+
See also:
|
26
|
+
---------
|
27
|
+
|
28
|
+
The `clear` command clears breakpoints by line/file number; `set confirm`
|
29
|
+
sets whether we confirm potentially destructive operations like this.
|
21
30
|
HELP
|
22
31
|
|
23
32
|
CATEGORY = 'breakpoints'
|
24
33
|
SHORT_HELP = 'Delete some breakpoints'
|
25
|
-
ALIASES = %w(d)
|
34
|
+
ALIASES = %w(d d! delete!)
|
26
35
|
end
|
27
|
-
|
36
|
+
|
28
37
|
def run(args)
|
29
38
|
if args.size == 1
|
30
|
-
if confirm('Delete all breakpoints?', false)
|
39
|
+
if args[0][-1] == '!' or confirm('Delete all breakpoints?', false)
|
31
40
|
@proc.brkpts.reset
|
32
41
|
return
|
33
42
|
end
|
@@ -36,14 +45,14 @@ number.
|
|
36
45
|
args.each do |num_str|
|
37
46
|
opts = {:msg_on_error => '%s must be a number' % num_str}
|
38
47
|
i = @proc.get_an_int(num_str, opts)
|
39
|
-
if i
|
48
|
+
if i
|
40
49
|
success = @proc.delete_breakpoint_by_number(num_str.to_i, false) if i
|
41
50
|
msg('Deleted breakpoint %d.' % i) if success
|
42
51
|
end
|
43
52
|
end
|
44
53
|
end
|
45
54
|
end
|
46
|
-
|
55
|
+
|
47
56
|
if __FILE__ == $0
|
48
57
|
require_relative '../mock'
|
49
58
|
dbgr, cmd = MockDebugger::setup
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
1
|
+
# Copyright (C) 2010, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
2
2
|
require_relative '../command'
|
3
3
|
class Trepan::Command::DirectoryCommand < Trepan::Command
|
4
4
|
|
@@ -8,25 +8,27 @@ class Trepan::Command::DirectoryCommand < Trepan::Command
|
|
8
8
|
MAX_ARGS = 1 # Need at most this many
|
9
9
|
NAME = File.basename(__FILE__, '.rb')
|
10
10
|
HELP = <<-HELP
|
11
|
-
|
11
|
+
**#{NAME}** [*dir*]
|
12
12
|
|
13
|
-
Add directory
|
14
|
-
|
15
|
-
directory in which the debugged file start.
|
16
|
-
|
13
|
+
Add directory *dir* to beginning of search path for source files.
|
14
|
+
*dir* can also be `$cwd` for the current working directory, or `$cdir`
|
15
|
+
for the directory in which the debugged file start. With no argument,
|
16
|
+
reset the search path to `$cdir:$cwd`, the default.
|
17
17
|
|
18
|
-
This command may be useful if for some reason the debugger can't find
|
19
|
-
source files because directories have been moved.
|
18
|
+
This command may be useful if for some reason the debugger can't find
|
19
|
+
source files because directories have been moved.
|
20
20
|
|
21
21
|
Examples:
|
22
|
-
|
23
|
-
|
22
|
+
---------
|
23
|
+
|
24
|
+
#{NAME} ~/.rvm/src/ruby-head # Adds an rvm-like directory to path
|
25
|
+
#{NAME} # reset to $cdir:$cwd
|
24
26
|
HELP
|
25
27
|
|
26
|
-
SHORT_HELP =
|
27
|
-
'Add directory
|
28
|
+
SHORT_HELP =
|
29
|
+
'Add directory *dir* to beginning of search path for source files'
|
28
30
|
end
|
29
|
-
|
31
|
+
|
30
32
|
# This method runs the command
|
31
33
|
def run(args) # :nodoc
|
32
34
|
if args.size > 1
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
# Copyright (C) 2010, 2011, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require_relative '../command'
|
4
4
|
require_relative '../breakpoint'
|
5
5
|
require_relative '../../app/breakpoint'
|
@@ -9,29 +9,32 @@ require_relative '../../app/util'
|
|
9
9
|
# parameter to @proc.en_disable_breakpoint_by_number is different (set
|
10
10
|
# as ENABLE_PARM below).
|
11
11
|
#
|
12
|
-
# NOTE: The enable command subclasses this, so beware when changing!
|
12
|
+
# NOTE: The enable command subclasses this, so beware when changing!
|
13
13
|
class Trepan::Command::DisableCommand < Trepan::Command
|
14
14
|
|
15
15
|
Trepan::Util.suppress_warnings {
|
16
16
|
NAME = File.basename(__FILE__, '.rb')
|
17
17
|
HELP = <<-HELP
|
18
|
-
|
18
|
+
**#{NAME}** [*display*] *num1* [*num2* ...]
|
19
19
|
|
20
20
|
Disables the breakpoints or display given as a space separated list of
|
21
|
-
numbers.
|
21
|
+
numbers.
|
22
22
|
|
23
|
-
See also
|
23
|
+
See also:
|
24
|
+
---------
|
25
|
+
|
26
|
+
`enable` and `info break`.
|
24
27
|
HELP
|
25
|
-
|
28
|
+
|
26
29
|
CATEGORY = 'breakpoints'
|
27
30
|
SHORT_HELP = 'Disable some breakpoints or displays'
|
28
31
|
}
|
29
32
|
|
30
33
|
def initialize(proc)
|
31
34
|
super
|
32
|
-
@enable_parm = false # true if enable
|
35
|
+
@enable_parm = false # true if enable
|
33
36
|
end
|
34
|
-
|
37
|
+
|
35
38
|
def run(args)
|
36
39
|
if args.size == 1
|
37
40
|
errmsg('No breakpoint or display number given.')
|
@@ -54,7 +57,7 @@ See also "enable" and "info break".
|
|
54
57
|
end
|
55
58
|
end
|
56
59
|
end
|
57
|
-
|
60
|
+
|
58
61
|
if __FILE__ == $0
|
59
62
|
require_relative '../mock'
|
60
63
|
dbgr, cmd = MockDebugger::setup
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
# Copyright (C) 2010, 2011, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require_relative '../command'
|
4
4
|
require_relative '../../app/disassemble'
|
5
5
|
require_relative '../../app/file'
|
@@ -8,12 +8,12 @@ class Trepan::Command::DisassembleCommand < Trepan::Command
|
|
8
8
|
include Trepan::Disassemble
|
9
9
|
include Trepanning
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
unless defined?(HELP)
|
12
|
+
NAME = File.basename(__FILE__, '.rb')
|
13
|
+
ALIASES = %w(disasm) # Note we have disable
|
14
|
+
CATEGORY = 'data'
|
15
|
+
HELP = <<-HELP
|
16
|
+
**#{NAME}** [*thing*] [**full**]
|
17
17
|
|
18
18
|
With no argument, disassemble the current frame. With a method,
|
19
19
|
disassemble that method. '.' can be used to indicate the instruction
|
@@ -25,83 +25,89 @@ instruction sequence might have. If 'full' is given, all instruction
|
|
25
25
|
sequences are include.
|
26
26
|
|
27
27
|
Examples:
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
---------
|
29
|
+
|
30
|
+
#{NAME}
|
31
|
+
#{NAME} . # Same as above
|
32
|
+
#{NAME} . full # At least the instruction sequence above but maybe more
|
33
|
+
#{NAME} require_relative # disassemble method 'require_relative'
|
34
|
+
|
35
|
+
See also:
|
36
|
+
---------
|
37
|
+
|
38
|
+
`list`
|
32
39
|
HELP
|
33
40
|
|
34
|
-
|
35
|
-
|
36
|
-
|
41
|
+
NEED_STACK = true
|
42
|
+
SHORT_HELP = 'Disassemble Ruby VM instructions'
|
43
|
+
end
|
37
44
|
|
38
|
-
|
45
|
+
completion %w(. full)
|
39
46
|
|
40
|
-
|
47
|
+
# FIXME: put in processor/data.rb?
|
41
48
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
def marked_disassemble(iseq_param, include_children)
|
50
|
+
iseqs = include_children ? iseq_param.child_iseqs : [iseq_param]
|
51
|
+
iseqs.each do |iseq|
|
52
|
+
ary = mark_disassembly(iseq.disasm_nochildren,
|
53
|
+
@proc.frame.iseq.equal?(iseq),
|
54
|
+
@proc.frame.pc_offset,
|
55
|
+
iseq.brkpts, settings[:maxwidth],
|
56
|
+
settings[:highlight])
|
57
|
+
msg ary
|
58
|
+
end
|
51
59
|
end
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
60
|
+
|
61
|
+
# Run command.
|
62
|
+
def run(args)
|
63
|
+
|
64
|
+
obj = nil
|
65
|
+
include_children =
|
66
|
+
if args.size > 1 && args[-1] == 'full'
|
67
|
+
args.pop
|
68
|
+
true
|
69
|
+
else
|
70
|
+
false
|
71
|
+
end
|
72
|
+
if args.size == 1 || '.' == args[1]
|
73
|
+
# Form is: "disassemble" or "disassemble ."
|
74
|
+
if @proc.frame.type == 'CFUNC'
|
75
|
+
errmsg "Can't handle C functions yet."
|
76
|
+
return
|
77
|
+
elsif @proc.frame.iseq
|
78
|
+
marked_disassemble(@proc.frame.iseq, include_children)
|
79
|
+
return
|
80
|
+
end
|
81
|
+
else
|
82
|
+
if !(matches = find_iseqs(ISEQS__, args[1])).empty?
|
83
|
+
# FIXME: do something if there is more than one
|
84
|
+
iseq = matches[0]
|
85
|
+
else
|
86
|
+
iseq = @proc.object_iseq(args[1])
|
87
|
+
end
|
88
|
+
marked_disassemble(iseq, include_children) if iseq
|
89
|
+
return
|
90
|
+
end
|
91
|
+
errmsg("Sorry can't handle right now.")
|
83
92
|
end
|
84
|
-
errmsg("Sorry can't handle right now.")
|
85
|
-
end
|
86
93
|
end
|
87
94
|
|
88
95
|
if __FILE__ == $0
|
89
|
-
|
90
|
-
require 'thread_frame'
|
96
|
+
# Demo it.
|
91
97
|
|
92
|
-
|
93
|
-
|
94
|
-
|
98
|
+
require_relative '../mock'
|
99
|
+
dbgr, cmd = MockDebugger::setup
|
100
|
+
def small_fn(cmd, name)
|
101
|
+
cmd.proc.frame_setup(RubyVM::Frame::current)
|
102
|
+
cmd.run [name]
|
103
|
+
end
|
104
|
+
small_fn(cmd, cmd.name)
|
105
|
+
p = Proc.new do
|
106
|
+
|x,y| x + y
|
107
|
+
end
|
95
108
|
cmd.proc.frame_setup(RubyVM::Frame::current)
|
96
|
-
cmd.run
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|x,y| x + y
|
101
|
-
end
|
102
|
-
cmd.proc.frame_setup(RubyVM::Frame::current)
|
103
|
-
cmd.run([cmd.name, 'p'])
|
104
|
-
puts cmd.complete('f')
|
105
|
-
require 'irb'
|
106
|
-
cmd.run([cmd.name, 'IRB.start'])
|
109
|
+
cmd.run([cmd.name, 'p'])
|
110
|
+
puts cmd.complete('f')
|
111
|
+
require 'irb'
|
112
|
+
cmd.run([cmd.name, 'IRB.start'])
|
107
113
|
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
# Copyright (C) 2010, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require_relative '../command'
|
4
4
|
|
5
5
|
class Trepan::Command::DisplayCommand < Trepan::Command
|
6
|
-
|
6
|
+
|
7
7
|
unless defined?(HELP)
|
8
8
|
NAME = File.basename(__FILE__, '.rb')
|
9
9
|
HELP = <<-HELP
|
10
|
-
|
11
|
-
|
12
|
-
Print value of expression
|
13
|
-
used
|
14
|
-
octal, 'f' for float or 's' for string.
|
10
|
+
**#{name}** [*format*] *expression*
|
11
|
+
|
12
|
+
Print value of expression *expression* each time the program stops;
|
13
|
+
*format* may be used to specify how to pring and may be one of 'c' for
|
14
|
+
char, 'x' for hex, 'o' for octal, 'f' for float or 's' for string.
|
15
15
|
|
16
16
|
For now, display expressions are only evaluated when in the same
|
17
17
|
instruction sequence as the frame that was in effect when the display
|
@@ -20,12 +20,15 @@ more flexibility in the future to specify whether this should be the
|
|
20
20
|
case or not.
|
21
21
|
|
22
22
|
With no argument, evaluate and display all currently requested
|
23
|
-
auto-display expressions. Use
|
23
|
+
auto-display expressions. Use `undisplay` to cancel display
|
24
24
|
requests previously made.
|
25
25
|
|
26
|
-
See also
|
26
|
+
See also:
|
27
|
+
---------
|
28
|
+
|
29
|
+
`undisplay`, `enable`, and `disable`.
|
27
30
|
HELP
|
28
|
-
|
31
|
+
|
29
32
|
CATEGORY = 'data'
|
30
33
|
NEED_STACK = false
|
31
34
|
SHORT_HELP = 'Display expressions when entering debugger'
|
@@ -37,7 +40,7 @@ end
|
|
37
40
|
#end
|
38
41
|
|
39
42
|
def run(args)
|
40
|
-
|
43
|
+
|
41
44
|
if args.size == 1
|
42
45
|
# Display anything active
|
43
46
|
@proc.run_eval_display
|
@@ -53,7 +56,7 @@ def run(args)
|
|
53
56
|
format = nil
|
54
57
|
expr = args[1..-1].join(' ')
|
55
58
|
end
|
56
|
-
|
59
|
+
|
57
60
|
dp = @proc.displays.add(@proc.frame, expr, format)
|
58
61
|
unless dp
|
59
62
|
errmsg('Error evaluating "%s" in the current frame' % expr)
|
data/processor/command/down.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010
|
2
|
+
# Copyright (C) 2010-2011, 2013, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require_relative 'up'
|
4
4
|
|
5
5
|
# Debugger "down" command. Is the same as the "up" command with the
|
@@ -10,12 +10,17 @@ class Trepan::Command::DownCommand < Trepan::Command::UpCommand
|
|
10
10
|
old_verbose = $VERBOSE
|
11
11
|
$VERBOSE = nil
|
12
12
|
HELP = <<-HELP
|
13
|
-
|
13
|
+
**#{NAME}** [*count*]
|
14
14
|
|
15
15
|
Move the current frame down in the stack trace (to a newer frame). 0
|
16
16
|
is the most-recent frame. If no count is given, move down 1.
|
17
17
|
|
18
|
-
|
18
|
+
A negative number moves in the opposite direction.
|
19
|
+
|
20
|
+
See also:
|
21
|
+
---------
|
22
|
+
|
23
|
+
`up` and `frame`.
|
19
24
|
HELP
|
20
25
|
|
21
26
|
NAME = File.basename(__FILE__, '.rb')
|
data/processor/command/edit.rb
CHANGED
@@ -1,27 +1,31 @@
|
|
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 './../command'
|
4
4
|
|
5
5
|
class Trepan::Command::EditCommand < Trepan::Command
|
6
6
|
|
7
|
-
old_verbose = $VERBOSE
|
7
|
+
old_verbose = $VERBOSE
|
8
8
|
$VERBOSE = nil
|
9
9
|
NAME = File.basename(__FILE__, '.rb')
|
10
10
|
HELP = <<-HELP
|
11
|
-
|
11
|
+
**#{NAME}** [[*file*] [*line*]]
|
12
12
|
|
13
13
|
With no argument, edits file containing most recent line listed.
|
14
|
-
The value of the environment variable EDITOR is used for the
|
15
|
-
editor to run. If no EDITOR environment variable is set
|
16
|
-
is used. The editor should support line and file positioning via
|
17
|
-
|
14
|
+
The value of the environment variable `EDITOR` is used for the
|
15
|
+
editor to run. If no `EDITOR` environment variable is set `/bin/ex`
|
16
|
+
is used. The editor should support line and file positioning via:
|
17
|
+
|
18
|
+
editor-name +line file-name
|
19
|
+
|
18
20
|
(Most editors do.)
|
19
21
|
|
20
22
|
Examples:
|
21
|
-
|
22
|
-
|
23
|
-
#{NAME}
|
24
|
-
#{NAME}
|
23
|
+
---------
|
24
|
+
|
25
|
+
#{NAME} # Edit current location
|
26
|
+
#{NAME} 7 # Edit current file at line 7
|
27
|
+
#{NAME} test.rb # Edit test.rb, line 1
|
28
|
+
#{NAME} test.rb 10 # Edit test.rb line 10
|
25
29
|
HELP
|
26
30
|
|
27
31
|
ALIASES = %w(e)
|
@@ -29,30 +33,40 @@ Examples:
|
|
29
33
|
NEED_STACK = false
|
30
34
|
SHORT_HELP = 'Invoke an editor on some source code'
|
31
35
|
MAX_ARGS = 2
|
32
|
-
$VERBOSE = old_verbose
|
36
|
+
$VERBOSE = old_verbose
|
33
37
|
|
34
38
|
# FIXME: redo with locations and kparse.
|
35
39
|
def run(args)
|
36
40
|
case args.size
|
37
41
|
when 1
|
38
|
-
|
39
|
-
|
42
|
+
if @proc.frame
|
43
|
+
file = @proc.frame.source_container[1]
|
44
|
+
line = @proc.frame.source_location[0]
|
45
|
+
else
|
46
|
+
errmsg("No Ruby program loaded.")
|
47
|
+
return
|
48
|
+
end
|
40
49
|
when 2
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
50
|
+
line = Integer(args[1]) rescue nil
|
51
|
+
if line
|
52
|
+
if @proc.frame
|
53
|
+
file = @proc.frame.source_container[1]
|
54
|
+
else
|
55
|
+
errmsg("No Ruby program loaded.")
|
56
|
+
return
|
57
|
+
end
|
58
|
+
else
|
45
59
|
file = args[1]
|
46
60
|
line = 1
|
47
61
|
end
|
48
62
|
when 3
|
49
63
|
line, file = args[2], args[1]
|
50
64
|
else
|
51
|
-
errmsg "edit needs at most 2 args."
|
65
|
+
errmsg "edit needs at most 2 args."
|
52
66
|
end
|
53
67
|
editor = ENV['EDITOR'] || '/bin/ex'
|
54
68
|
unless File.executable?(editor)
|
55
|
-
errmsg "Editor #{editor} is not executable. Trying anyway..."
|
69
|
+
errmsg "Editor #{editor} is not executable. Trying anyway..."
|
56
70
|
end
|
57
71
|
|
58
72
|
if File.readable?(file)
|
@@ -71,7 +85,7 @@ if __FILE__ == $0
|
|
71
85
|
require_relative '../mock'
|
72
86
|
dbgr, cmd = MockDebugger::setup
|
73
87
|
ENV['EDITOR'] = 'echo FAKE-EDITOR'
|
74
|
-
cmd.run [cmd.name]
|
75
|
-
cmd.run [cmd.name, '7']
|
76
|
-
cmd.run [cmd.name, __FILE__, '10']
|
88
|
+
cmd.run [cmd.name]
|
89
|
+
cmd.run [cmd.name, '7']
|
90
|
+
cmd.run [cmd.name, __FILE__, '10']
|
77
91
|
end
|