rbx-trepanning 0.2.0-universal-rubinius-2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/ChangeLog +2967 -0
- data/LICENSE +25 -0
- data/Makefile +13 -0
- data/NEWS +105 -0
- data/README.textile +34 -0
- data/Rakefile +244 -0
- data/THANKS +14 -0
- data/app/.gitignore +2 -0
- data/app/breakpoint.rb +242 -0
- data/app/brkptmgr.rb +153 -0
- data/app/client.rb +71 -0
- data/app/cmd_parse.kpeg +242 -0
- data/app/cmd_parse.rb +209 -0
- data/app/cmd_parser.rb +2083 -0
- data/app/complete.rb +79 -0
- data/app/condition.rb +22 -0
- data/app/default.rb +71 -0
- data/app/display.rb +186 -0
- data/app/eventbuffer.rb +147 -0
- data/app/file.rb +24 -0
- data/app/frame.rb +120 -0
- data/app/irb.rb +113 -0
- data/app/iseq.rb +188 -0
- data/app/method.rb +178 -0
- data/app/mock.rb +13 -0
- data/app/options.rb +154 -0
- data/app/rbx-llvm.rb +163 -0
- data/app/run.rb +92 -0
- data/app/util.rb +99 -0
- data/app/validate.rb +30 -0
- data/bin/.gitignore +2 -0
- data/bin/trepanx +69 -0
- data/data/.gitignore +2 -0
- data/data/irbrc +41 -0
- data/interface/.gitignore +2 -0
- data/interface/client.rb +84 -0
- data/interface/comcodes.rb +20 -0
- data/interface/script.rb +112 -0
- data/interface/server.rb +147 -0
- data/interface/user.rb +158 -0
- data/interface.rb +109 -0
- data/io/.gitignore +3 -0
- data/io/input.rb +151 -0
- data/io/null_output.rb +46 -0
- data/io/string_array.rb +155 -0
- data/io/tcpclient.rb +129 -0
- data/io/tcpfns.rb +33 -0
- data/io/tcpserver.rb +141 -0
- data/io.rb +148 -0
- data/lib/.gitignore +2 -0
- data/lib/trepanning.rb +467 -0
- data/processor/.gitignore +3 -0
- data/processor/Makefile +7 -0
- data/processor/breakpoint.rb +167 -0
- data/processor/command/.gitignore +2 -0
- data/processor/command/alias.rb +65 -0
- data/processor/command/backtrace.rb +68 -0
- data/processor/command/base/.gitignore +2 -0
- data/processor/command/base/subcmd.rb +226 -0
- data/processor/command/base/submgr.rb +185 -0
- data/processor/command/base/subsubcmd.rb +125 -0
- data/processor/command/base/subsubmgr.rb +196 -0
- data/processor/command/break.rb +78 -0
- data/processor/command/complete.rb +39 -0
- data/processor/command/condition.rb +64 -0
- data/processor/command/continue.rb +61 -0
- data/processor/command/delete.rb +44 -0
- data/processor/command/directory.rb +51 -0
- data/processor/command/disable.rb +71 -0
- data/processor/command/disassemble.rb +180 -0
- data/processor/command/display.rb +84 -0
- data/processor/command/down.rb +54 -0
- data/processor/command/edit.rb +74 -0
- data/processor/command/enable.rb +43 -0
- data/processor/command/eval.rb +93 -0
- data/processor/command/exit.rb +83 -0
- data/processor/command/finish.rb +80 -0
- data/processor/command/frame.rb +93 -0
- data/processor/command/help/.gitignore +1 -0
- data/processor/command/help/README +10 -0
- data/processor/command/help/command.txt +58 -0
- data/processor/command/help/examples.txt +16 -0
- data/processor/command/help/filename.txt +40 -0
- data/processor/command/help/location.txt +37 -0
- data/processor/command/help/suffixes.txt +17 -0
- data/processor/command/help.rb +228 -0
- data/processor/command/info.rb +30 -0
- data/processor/command/info_subcmd/.gitignore +3 -0
- data/processor/command/info_subcmd/breakpoints.rb +103 -0
- data/processor/command/info_subcmd/files.rb +219 -0
- data/processor/command/info_subcmd/frame.rb +68 -0
- data/processor/command/info_subcmd/line.rb +75 -0
- data/processor/command/info_subcmd/locals.rb +22 -0
- data/processor/command/info_subcmd/macro.rb +62 -0
- data/processor/command/info_subcmd/method.rb +71 -0
- data/processor/command/info_subcmd/program.rb +51 -0
- data/processor/command/info_subcmd/ruby.rb +64 -0
- data/processor/command/info_subcmd/source.rb +75 -0
- data/processor/command/info_subcmd/stack.rb +25 -0
- data/processor/command/info_subcmd/variables.rb +35 -0
- data/processor/command/info_subcmd/variables_subcmd/.gitignore +2 -0
- data/processor/command/info_subcmd/variables_subcmd/class.rb +42 -0
- data/processor/command/info_subcmd/variables_subcmd/constant.rb +42 -0
- data/processor/command/info_subcmd/variables_subcmd/globals.rb +69 -0
- data/processor/command/info_subcmd/variables_subcmd/instance.rb +42 -0
- data/processor/command/info_subcmd/variables_subcmd/locals.rb +80 -0
- data/processor/command/kill.rb +79 -0
- data/processor/command/list.rb +234 -0
- data/processor/command/macro.rb +86 -0
- data/processor/command/next.rb +67 -0
- data/processor/command/nexti.rb +59 -0
- data/processor/command/parsetree.rb +51 -0
- data/processor/command/pr.rb +37 -0
- data/processor/command/ps.rb +40 -0
- data/processor/command/restart.rb +60 -0
- data/processor/command/save.rb +58 -0
- data/processor/command/server.rb +72 -0
- data/processor/command/set.rb +47 -0
- data/processor/command/set_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/abbrev.rb +25 -0
- data/processor/command/set_subcmd/auto.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/auto_subcmd/dis.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/eval.rb +53 -0
- data/processor/command/set_subcmd/auto_subcmd/irb.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/list.rb +33 -0
- data/processor/command/set_subcmd/basename.rb +25 -0
- data/processor/command/set_subcmd/confirm.rb +24 -0
- data/processor/command/set_subcmd/debug.rb +26 -0
- data/processor/command/set_subcmd/debug_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/debug_subcmd/dbgr.rb +36 -0
- data/processor/command/set_subcmd/debug_subcmd/skip.rb +23 -0
- data/processor/command/set_subcmd/debug_subcmd/step.rb +23 -0
- data/processor/command/set_subcmd/different.rb +61 -0
- data/processor/command/set_subcmd/hidelevel.rb +62 -0
- data/processor/command/set_subcmd/highlight.rb +39 -0
- data/processor/command/set_subcmd/kernelstep.rb +60 -0
- data/processor/command/set_subcmd/max.rb +26 -0
- data/processor/command/set_subcmd/max_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/max_subcmd/list.rb +49 -0
- data/processor/command/set_subcmd/max_subcmd/stack.rb +50 -0
- data/processor/command/set_subcmd/max_subcmd/string.rb +76 -0
- data/processor/command/set_subcmd/max_subcmd/width.rb +49 -0
- data/processor/command/set_subcmd/reload.rb +42 -0
- data/processor/command/set_subcmd/substitute.rb +24 -0
- data/processor/command/set_subcmd/substitute_subcmd/.gitignore +3 -0
- data/processor/command/set_subcmd/substitute_subcmd/path.rb +56 -0
- data/processor/command/set_subcmd/timer.rb +58 -0
- data/processor/command/set_subcmd/trace.rb +37 -0
- data/processor/command/set_subcmd/trace_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/trace_subcmd/buffer.rb +42 -0
- data/processor/command/set_subcmd/trace_subcmd/print.rb +41 -0
- data/processor/command/shell.rb +131 -0
- data/processor/command/show.rb +39 -0
- data/processor/command/show_subcmd/.gitignore +3 -0
- data/processor/command/show_subcmd/abbrev.rb +20 -0
- data/processor/command/show_subcmd/aliases.rb +46 -0
- data/processor/command/show_subcmd/args.rb +25 -0
- data/processor/command/show_subcmd/auto.rb +28 -0
- data/processor/command/show_subcmd/auto_subcmd/.gitignore +3 -0
- data/processor/command/show_subcmd/auto_subcmd/dis.rb +37 -0
- data/processor/command/show_subcmd/auto_subcmd/eval.rb +24 -0
- data/processor/command/show_subcmd/auto_subcmd/irb.rb +23 -0
- data/processor/command/show_subcmd/auto_subcmd/list.rb +22 -0
- data/processor/command/show_subcmd/basename.rb +20 -0
- data/processor/command/show_subcmd/confirm.rb +18 -0
- data/processor/command/show_subcmd/debug.rb +26 -0
- data/processor/command/show_subcmd/debug_subcmd/.gitignore +3 -0
- data/processor/command/show_subcmd/debug_subcmd/dbgr.rb +21 -0
- data/processor/command/show_subcmd/debug_subcmd/skip.rb +22 -0
- data/processor/command/show_subcmd/debug_subcmd/step.rb +22 -0
- data/processor/command/show_subcmd/different.rb +26 -0
- data/processor/command/show_subcmd/directories.rb +22 -0
- data/processor/command/show_subcmd/hidelevel.rb +41 -0
- data/processor/command/show_subcmd/highlight.rb +25 -0
- data/processor/command/show_subcmd/kernelstep.rb +34 -0
- data/processor/command/show_subcmd/max.rb +27 -0
- data/processor/command/show_subcmd/max_subcmd/.gitignore +2 -0
- data/processor/command/show_subcmd/max_subcmd/list.rb +38 -0
- data/processor/command/show_subcmd/max_subcmd/stack.rb +36 -0
- data/processor/command/show_subcmd/max_subcmd/string.rb +42 -0
- data/processor/command/show_subcmd/max_subcmd/width.rb +37 -0
- data/processor/command/show_subcmd/reload.rb +18 -0
- data/processor/command/show_subcmd/timer.rb +18 -0
- data/processor/command/show_subcmd/trace.rb +27 -0
- data/processor/command/show_subcmd/trace_subcmd/.gitignore +2 -0
- data/processor/command/show_subcmd/trace_subcmd/buffer.rb +64 -0
- data/processor/command/show_subcmd/trace_subcmd/print.rb +23 -0
- data/processor/command/show_subcmd/version.rb +23 -0
- data/processor/command/source.rb +133 -0
- data/processor/command/step.rb +97 -0
- data/processor/command/tbreak.rb +20 -0
- data/processor/command/unalias.rb +49 -0
- data/processor/command/undisplay.rb +63 -0
- data/processor/command/up.rb +89 -0
- data/processor/command.rb +173 -0
- data/processor/default.rb +64 -0
- data/processor/disassemble.rb +59 -0
- data/processor/display.rb +53 -0
- data/processor/eval.rb +97 -0
- data/processor/eventbuf.rb +101 -0
- data/processor/frame.rb +265 -0
- data/processor/help.rb +94 -0
- data/processor/hook.rb +134 -0
- data/processor/list.rb +123 -0
- data/processor/load_cmds.rb +253 -0
- data/processor/location.rb +228 -0
- data/processor/mock.rb +138 -0
- data/processor/msg.rb +74 -0
- data/processor/running.rb +244 -0
- data/processor/stepping.rb +135 -0
- data/processor/subcmd.rb +136 -0
- data/processor/validate.rb +379 -0
- data/processor/virtual.rb +33 -0
- data/processor.rb +404 -0
- data/rbx-trepanning.gemspec +39 -0
- data/sample/.gitignore +2 -0
- data/sample/list-terminal-colors.rb +139 -0
- data/sample/rocky-dot-trepanxrc +14 -0
- data/sample/rocky-trepanx-colors.rb +46 -0
- data/test/data/.gitignore +1 -0
- data/test/data/enable.right +36 -0
- data/test/data/fname-with-blank.cmd +6 -0
- data/test/data/fname-with-blank.right +6 -0
- data/test/data/inline-call.cmd +6 -0
- data/test/data/inline-call.right +14 -0
- data/test/data/quit-Xdebug.right +3 -0
- data/test/data/quit.cmd +5 -0
- data/test/data/quit.right +3 -0
- data/test/data/quit2.cmd +6 -0
- data/test/data/quit2.right +3 -0
- data/test/example/.gitignore +2 -0
- data/test/example/debugger-stop.rb +16 -0
- data/test/example/factorial.rb +10 -0
- data/test/example/fname with blank.rb +1 -0
- data/test/example/gcd-server.rb +22 -0
- data/test/example/gcd.rb +19 -0
- data/test/example/goto2goto.rb +11 -0
- data/test/example/inline-call.rb +23 -0
- data/test/example/null.rb +1 -0
- data/test/example/thread1.rb +3 -0
- data/test/functional/.gitignore +3 -0
- data/test/functional/fn_helper.rb +112 -0
- data/test/functional/test-break-name.rb +52 -0
- data/test/functional/test-break.rb +85 -0
- data/test/functional/test-eval.rb +115 -0
- data/test/functional/test-finish.rb +70 -0
- data/test/functional/test-fn_helper.rb +43 -0
- data/test/functional/test-list.rb +56 -0
- data/test/functional/test-next-bug.rb +49 -0
- data/test/functional/test-next.rb +101 -0
- data/test/functional/test-recursive-bt.rb +94 -0
- data/test/functional/test-step.rb +272 -0
- data/test/functional/test-step2.rb +35 -0
- data/test/functional/test-tbreak.rb +41 -0
- data/test/integration/.gitignore +3 -0
- data/test/integration/file-diff.rb +89 -0
- data/test/integration/helper.rb +81 -0
- data/test/integration/test-fname-with-blank.rb +16 -0
- data/test/integration/test-inline-call.rb +20 -0
- data/test/integration/test-quit.rb +47 -0
- data/test/unit/.gitignore +3 -0
- data/test/unit/cmd-helper.rb +50 -0
- data/test/unit/mock-helper.rb +10 -0
- data/test/unit/test-app-brkpt.rb +31 -0
- data/test/unit/test-app-brkptmgr.rb +51 -0
- data/test/unit/test-app-cmd_parse.rb +97 -0
- data/test/unit/test-app-cmd_parser.rb +23 -0
- data/test/unit/test-app-complete.rb +39 -0
- data/test/unit/test-app-condition.rb +18 -0
- data/test/unit/test-app-display.rb +22 -0
- data/test/unit/test-app-iseq.rb +64 -0
- data/test/unit/test-app-method.rb +54 -0
- data/test/unit/test-app-options.rb +94 -0
- data/test/unit/test-app-run.rb +14 -0
- data/test/unit/test-app-util.rb +44 -0
- data/test/unit/test-app-validate.rb +18 -0
- data/test/unit/test-base-cmd.rb +45 -0
- data/test/unit/test-base-subcmd.rb +57 -0
- data/test/unit/test-base-submgr.rb +24 -0
- data/test/unit/test-base-subsubcmd.rb +17 -0
- data/test/unit/test-bin-trepanx.rb +48 -0
- data/test/unit/test-cmd-alias.rb +48 -0
- data/test/unit/test-cmd-break.rb +66 -0
- data/test/unit/test-cmd-edit.rb +34 -0
- data/test/unit/test-cmd-exit.rb +27 -0
- data/test/unit/test-cmd-finish.rb +31 -0
- data/test/unit/test-cmd-help.rb +104 -0
- data/test/unit/test-cmd-kill.rb +54 -0
- data/test/unit/test-cmd-parse_list_cmd.rb +36 -0
- data/test/unit/test-cmd-source.rb +34 -0
- data/test/unit/test-cmd-step.rb +29 -0
- data/test/unit/test-command.rb +45 -0
- data/test/unit/test-completion.rb +48 -0
- data/test/unit/test-intf-user.rb +46 -0
- data/test/unit/test-io-input.rb +27 -0
- data/test/unit/test-io-tcp.rb +33 -0
- data/test/unit/test-io-tcpclient.rb +54 -0
- data/test/unit/test-io-tcpfns.rb +17 -0
- data/test/unit/test-io-tcpserver.rb +50 -0
- data/test/unit/test-proc-eval.rb +35 -0
- data/test/unit/test-proc-frame.rb +81 -0
- data/test/unit/test-proc-help.rb +16 -0
- data/test/unit/test-proc-hook.rb +30 -0
- data/test/unit/test-proc-list.rb +55 -0
- data/test/unit/test-proc-load_cmds.rb +51 -0
- data/test/unit/test-proc-location.rb +67 -0
- data/test/unit/test-proc-main.rb +95 -0
- data/test/unit/test-proc-validate.rb +139 -0
- data/test/unit/test-subcmd-help.rb +43 -0
- metadata +545 -0
@@ -0,0 +1,234 @@
|
|
1
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
require 'rubygems'
|
4
|
+
require 'require_relative'
|
5
|
+
require 'linecache'
|
6
|
+
require_relative '../command'
|
7
|
+
require_relative '../list'
|
8
|
+
|
9
|
+
class Trepan::Command::ListCommand < Trepan::Command
|
10
|
+
unless defined?(HELP)
|
11
|
+
NAME = File.basename(__FILE__, '.rb')
|
12
|
+
HELP = <<-HELP
|
13
|
+
#{NAME}[>] [MODULE] [FIRST [NUM]]
|
14
|
+
#{NAME}[>] LOCATION [NUM]
|
15
|
+
|
16
|
+
#{NAME} source code.
|
17
|
+
|
18
|
+
Without arguments, prints lines centered around the current
|
19
|
+
line. If this is the first #{NAME} command issued since the debugger
|
20
|
+
command loop was entered, then the current line is the current
|
21
|
+
frame. If a subsequent #{NAME} command was issued with no intervening
|
22
|
+
frame changing, then that is start the line after we last one
|
23
|
+
previously shown.
|
24
|
+
|
25
|
+
If the command has a '>' suffix, then line centering is disabled and
|
26
|
+
listing begins at the specificed location.
|
27
|
+
|
28
|
+
The number of lines to show is controlled by the debugger "listsize"
|
29
|
+
setting. Use 'set max list' or 'show max list' to see or set the
|
30
|
+
value.
|
31
|
+
|
32
|
+
\"#{NAME} -\" shows lines before a previous listing.
|
33
|
+
|
34
|
+
A LOCATION is a either
|
35
|
+
- number, e.g. 5,
|
36
|
+
- a function, e.g. join or os.path.join
|
37
|
+
- a module, e.g. os or os.path
|
38
|
+
- a filename, colon, and a number, e.g. foo.rb:5,
|
39
|
+
- or a module name and a number, e.g,. os.path:5.
|
40
|
+
- a '.' for the current line number
|
41
|
+
- a '-' for the lines before the current line number
|
42
|
+
|
43
|
+
If the location form is used with a subsequent parameter, the
|
44
|
+
parameter is the starting line number. When there two numbers are
|
45
|
+
given, the last number value is treated as a stopping line unless it
|
46
|
+
is positive and less than the start line. In this case, it is taken to
|
47
|
+
mean the number of lines to list instead. If last is negative, we start
|
48
|
+
that many lines back from first and list to first.
|
49
|
+
|
50
|
+
Wherever a number is expected, it does not need to be a constant --
|
51
|
+
just something that evaluates to a positive integer.
|
52
|
+
|
53
|
+
Some examples:
|
54
|
+
|
55
|
+
#{NAME} 5 # List centered around line 5
|
56
|
+
#{NAME} @5 # List lines centered around bytecode offset 5.
|
57
|
+
#{NAME} 5> # List starting at line 5
|
58
|
+
#{NAME} foo.rb:5 # List centered around line 5 of foo.rb
|
59
|
+
#{NAME} foo.rb 5 # Same as above.
|
60
|
+
#{NAME}> foo.rb:5 # List starting around line 5 of foo.rb
|
61
|
+
#{NAME} foo.rb 5 6 # list lines 5 and 6 of foo.rb
|
62
|
+
#{NAME} foo.rb 5 2 # Same as above, since 2 < 5.
|
63
|
+
#{NAME} foo.rb:5 2 # Same as above
|
64
|
+
#{NAME} foo.rb 15 -5 # List lines 10..15 of foo
|
65
|
+
#{NAME} FileUtils.cp # List lines around the FileUtils.cp function.
|
66
|
+
#{NAME} . # List lines centered from where we currently are stopped
|
67
|
+
#{NAME} . 3 # List 3 lines starting from where we currently are stopped
|
68
|
+
# if . > 3. Otherwise we list from . to 3.
|
69
|
+
#{NAME} - # List lines previous to those just shown
|
70
|
+
|
71
|
+
The output of the #{NAME} command gives a line number, and some status
|
72
|
+
information about the line and the text of the line. Here is some
|
73
|
+
hypothetical #{NAME} output modeled roughly around line 251 of one
|
74
|
+
version of this code:
|
75
|
+
|
76
|
+
251 cmd.proc.frame_setup(tf)
|
77
|
+
252 -> brkpt_cmd.run(['break'])
|
78
|
+
253 B01 line = __LINE__
|
79
|
+
254 b02 cmd.run(['list', __LINE__.to_s])
|
80
|
+
255 t03 puts '--' * 10
|
81
|
+
|
82
|
+
Line 251 has nothing special about it. Line 252 is where we are
|
83
|
+
currently stopped. On line 253 there is a breakpoint 1 which is
|
84
|
+
enabled, while at line 255 there is an breakpoint 2 which is
|
85
|
+
disabled.
|
86
|
+
HELP
|
87
|
+
|
88
|
+
ALIASES = %W(l #{NAME}> l> cat)
|
89
|
+
CATEGORY = 'files'
|
90
|
+
MAX_ARGS = 3
|
91
|
+
SHORT_HELP = 'List source code'
|
92
|
+
end
|
93
|
+
|
94
|
+
def run(args)
|
95
|
+
if args.empty? and not frame
|
96
|
+
errmsg("No Ruby program loaded.")
|
97
|
+
return
|
98
|
+
end
|
99
|
+
listsize = settings[:maxlist]
|
100
|
+
center_correction =
|
101
|
+
if args[0][-1..-1] == '>'
|
102
|
+
0
|
103
|
+
else
|
104
|
+
(listsize-1) / 2
|
105
|
+
end
|
106
|
+
|
107
|
+
cm, filename, first, last =
|
108
|
+
@proc.parse_list_cmd(@proc.cmd_argstr, listsize, center_correction)
|
109
|
+
return unless filename
|
110
|
+
breaklist = @proc.brkpts.line_breaks(cm)
|
111
|
+
|
112
|
+
# We now have range information. Do the listing.
|
113
|
+
max_line = LineCache::size(filename)
|
114
|
+
unless max_line
|
115
|
+
errmsg('File "%s" not found.' % filename)
|
116
|
+
return
|
117
|
+
end
|
118
|
+
|
119
|
+
if first > max_line
|
120
|
+
errmsg('Bad line range [%d...%d]; file "%s" has only %d lines' %
|
121
|
+
[first, last, filename, max_line])
|
122
|
+
return
|
123
|
+
end
|
124
|
+
|
125
|
+
if last > max_line
|
126
|
+
# msg('End position changed to last line %d ' % max_line)
|
127
|
+
last = max_line
|
128
|
+
end
|
129
|
+
|
130
|
+
begin
|
131
|
+
opts = {
|
132
|
+
:reload_on_change => settings[:reload],
|
133
|
+
:output => settings[:highlight]
|
134
|
+
}
|
135
|
+
frame = @proc.frame
|
136
|
+
first.upto(last).each do |lineno|
|
137
|
+
line = LineCache::getline(filename, lineno, opts)
|
138
|
+
unless line
|
139
|
+
msg('[EOF]')
|
140
|
+
break
|
141
|
+
end
|
142
|
+
line.chomp!
|
143
|
+
s = '%3d' % lineno
|
144
|
+
s = s + ' ' if s.size < 4
|
145
|
+
s += if breaklist.member?(lineno)
|
146
|
+
bp = breaklist[lineno]
|
147
|
+
a_pad = '%02d' % bp.id
|
148
|
+
bp.icon_char
|
149
|
+
else
|
150
|
+
a_pad = ' '
|
151
|
+
' '
|
152
|
+
end
|
153
|
+
s += (frame && lineno == @proc.frame.line &&
|
154
|
+
filename == @proc.frame.file) ? '->' : a_pad
|
155
|
+
msg(s + "\t" + line, {:unlimited => true})
|
156
|
+
@proc.line_no = lineno
|
157
|
+
end
|
158
|
+
rescue => e
|
159
|
+
errmsg e.to_s if settings[:debugexcept]
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
if __FILE__ == $0
|
165
|
+
# require_relative '../../lib/trepanning'; debugger
|
166
|
+
require_relative '../location'
|
167
|
+
require_relative '../mock'
|
168
|
+
require_relative '../frame'
|
169
|
+
dbgr, cmd = MockDebugger::setup
|
170
|
+
cmd.proc.send('frame_initialize')
|
171
|
+
|
172
|
+
def run_cmd(cmd, args)
|
173
|
+
cmd.proc.instance_variable_set('@cmd_argstr', args[1..-1].join(' '))
|
174
|
+
cmd.run(args)
|
175
|
+
end
|
176
|
+
|
177
|
+
LineCache::cache(__FILE__)
|
178
|
+
run_cmd(cmd, [cmd.name])
|
179
|
+
run_cmd(cmd, [cmd.name, __FILE__ + ':10'])
|
180
|
+
|
181
|
+
def run_cmd2(cmd, args)
|
182
|
+
seps = '--' * 10
|
183
|
+
puts "%s %s %s" % [seps, args.join(' '), seps]
|
184
|
+
run_cmd(cmd,args)
|
185
|
+
end
|
186
|
+
|
187
|
+
require 'tmpdir.rb'
|
188
|
+
run_cmd2(cmd, %w(list tmpdir.rb 10))
|
189
|
+
run_cmd2(cmd, %w(list tmpdir.rb))
|
190
|
+
|
191
|
+
# cmd.proc.frame = sys._getframe()
|
192
|
+
# cmd.proc.setup()
|
193
|
+
# run_cmd2(['list'])
|
194
|
+
|
195
|
+
run_cmd2(cmd, %w(list .))
|
196
|
+
run_cmd2(cmd, %w(list 30))
|
197
|
+
|
198
|
+
# run_cmd2(['list', '9+1'])
|
199
|
+
|
200
|
+
run_cmd2(cmd, %w(list> 10))
|
201
|
+
run_cmd2(cmd, %w(list 3000))
|
202
|
+
run_cmd2(cmd, %w(list run_cmd2))
|
203
|
+
|
204
|
+
p = Proc.new do
|
205
|
+
|x,y| x + y
|
206
|
+
end
|
207
|
+
run_cmd2(cmd, %w(list p))
|
208
|
+
|
209
|
+
# Function from a file found via an instruction sequence
|
210
|
+
run_cmd2(cmd, %w(list Columnize.columnize))
|
211
|
+
|
212
|
+
# Use Class/method name. 15 isn't in the function - should this be okay?
|
213
|
+
run_cmd2(cmd, %W(#{cmd.name} Columnize.columnize 15))
|
214
|
+
|
215
|
+
# Start line and count, since 3 < 30
|
216
|
+
run_cmd2(cmd, %W(#{cmd.name} Columnize.columnize 30 3))
|
217
|
+
|
218
|
+
# Start line finish line
|
219
|
+
run_cmd2(cmd, %W(#{cmd.name} Columnize.columnize 40 50))
|
220
|
+
|
221
|
+
line = __LINE__
|
222
|
+
brkpt_cmd = cmd.proc.instance_variable_get('@commands')['break']
|
223
|
+
cmd.proc.instance_variable_set('@cmd_argstr', "#{__FILE__} #{line}")
|
224
|
+
brkpt_cmd.run(['break', __FILE__, line.to_s])
|
225
|
+
run_cmd2(cmd, [cmd.name, line.to_s])
|
226
|
+
|
227
|
+
# disable_cmd = cmd.proc.instance_variable_get('@commands')['disable']
|
228
|
+
# disable_cmd.run(['disable', '1'])
|
229
|
+
|
230
|
+
# run_cmd2(cmd, [cmd.name, line.to_s])
|
231
|
+
run_cmd2(cmd, %W(#{cmd.name} run_cmd2))
|
232
|
+
run_cmd2(cmd, %W(#{cmd.name} run_cmd2))
|
233
|
+
run_cmd2(cmd, %W(#{cmd.name} @713))
|
234
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../command'
|
5
|
+
require_relative '../eval'
|
6
|
+
class Trepan::Command::MacroCommand < Trepan::Command
|
7
|
+
|
8
|
+
unless defined?(HELP)
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
HELP = <<-HELP
|
11
|
+
#{NAME} MACRO-NAME PROC-OBJECT
|
12
|
+
|
13
|
+
Define MACRO-NAME as a debugger macro. Debugger macros get a list of
|
14
|
+
arguments. Debugger macros get a list of arguments which you supply
|
15
|
+
without parenthesis or commas. See below for an example.
|
16
|
+
|
17
|
+
The macro (really a Ruby Proc) should return either a String or an
|
18
|
+
Array of Strings. The string in both cases are strings of debugger
|
19
|
+
commands. If the return is a String, that gets tokenized by a simple
|
20
|
+
String#split . Note that macro processing is done right after
|
21
|
+
splitting on ;; so if the macro returns a string containing ;; this
|
22
|
+
will not be handled on the string returned.
|
23
|
+
|
24
|
+
If instead, Array of Strings is returned, then the first string is
|
25
|
+
shifted from the array and executed. The remaining strings are pushed
|
26
|
+
onto the command queue. In contrast to the first string, subsequent
|
27
|
+
strings can contain other macros, and ;; in those strings will be
|
28
|
+
split into separate commands.
|
29
|
+
|
30
|
+
Here is an example. The below creates a macro called fin+ which
|
31
|
+
issues two commands 'finish' followed by 'step':
|
32
|
+
|
33
|
+
macro fin+ Proc.new{|*args| %w(finish step)}
|
34
|
+
|
35
|
+
If you wanted to parameterize the argument of the 'finish' command
|
36
|
+
you could do that this way:
|
37
|
+
|
38
|
+
macro fin+ Proc.new{|*args| ['finish \#{args[0]}' 'step']}
|
39
|
+
|
40
|
+
Invoking with
|
41
|
+
fin+ 3
|
42
|
+
|
43
|
+
would expand to ["finish 3", "step"]
|
44
|
+
|
45
|
+
If you were to add another parameter for 'step', the note that the
|
46
|
+
invocation might be
|
47
|
+
fin+ 3 2
|
48
|
+
|
49
|
+
rather than 'fin+(3,2)' or 'fin+ 3, 2'.
|
50
|
+
|
51
|
+
See also 'info macro'.
|
52
|
+
HELP
|
53
|
+
|
54
|
+
CATEGORY = 'support'
|
55
|
+
MIN_ARGS = 2 # Need at least this many
|
56
|
+
SHORT_HELP = 'Define a macro'
|
57
|
+
end
|
58
|
+
|
59
|
+
def run(args)
|
60
|
+
cmd_name = args[1]
|
61
|
+
cmd_argstr = @proc.cmd_argstr[cmd_name.size..-1].lstrip
|
62
|
+
proc_obj = @proc.debug_eval(cmd_argstr, @proc.settings[:maxstring])
|
63
|
+
if proc_obj
|
64
|
+
if proc_obj.is_a?(Proc)
|
65
|
+
@proc.macros[cmd_name] = [proc_obj, cmd_argstr]
|
66
|
+
msg "Macro \"#{cmd_name}\" defined."
|
67
|
+
else
|
68
|
+
errmsg "Expecting a Proc object; got: #{cmd_argstr}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
if __FILE__ == $0
|
75
|
+
require_relative '../mock'
|
76
|
+
dbgr, cmd = MockDebugger::setup
|
77
|
+
cmdproc = cmd.proc
|
78
|
+
["#{cmd.name} foo Proc.new{|x, y| 'x+y'}",
|
79
|
+
"#{cmd.name} bad2 1+2"].each do |cmdline|
|
80
|
+
args = cmdline.split
|
81
|
+
cmd_argstr = cmdline[args[0].size..-1].lstrip
|
82
|
+
cmdproc.instance_variable_set('@cmd_argstr', cmd_argstr)
|
83
|
+
cmd.run(args)
|
84
|
+
end
|
85
|
+
p cmdproc.macros
|
86
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'rubygems'; require 'require_relative'
|
2
|
+
require_relative '../command'
|
3
|
+
require_relative '../stepping'
|
4
|
+
require_relative '../../app/breakpoint'
|
5
|
+
|
6
|
+
class Trepan::Command::NextCommand < Trepan::Command
|
7
|
+
|
8
|
+
ALIASES = %w(n)
|
9
|
+
CATEGORY = 'running'
|
10
|
+
NAME = File.basename(__FILE__, '.rb')
|
11
|
+
HELP= <<-HELP
|
12
|
+
#{NAME} [NUM]
|
13
|
+
|
14
|
+
Attempt to continue execution and stop at the next line. If there is
|
15
|
+
a conditional branch between the current position and the next line,
|
16
|
+
execution is stopped within the conditional branch instead.
|
17
|
+
|
18
|
+
The optional argument is a number which specifies how many lines to
|
19
|
+
attempt to skip past before stopping execution.
|
20
|
+
|
21
|
+
If the current line is the last in a method, execution is stopped
|
22
|
+
at the current position of the caller.
|
23
|
+
|
24
|
+
See also 'step' and 'nexti'.
|
25
|
+
HELP
|
26
|
+
NEED_RUNNING = true
|
27
|
+
SHORT_HELP = 'Move to the next line or conditional branch'
|
28
|
+
|
29
|
+
def run(args)
|
30
|
+
if args.size == 1
|
31
|
+
step_count = 1
|
32
|
+
else
|
33
|
+
step_str = args[1]
|
34
|
+
opts = {
|
35
|
+
:msg_on_error =>
|
36
|
+
"The #{NAME} command argument must eval to an integer. Got: %s" %
|
37
|
+
step_str,
|
38
|
+
:min_value => 1
|
39
|
+
}
|
40
|
+
step_count = @proc.get_an_int(step_str, opts)
|
41
|
+
return unless step_count
|
42
|
+
end
|
43
|
+
|
44
|
+
@proc.step('next', step_count)
|
45
|
+
# @proc.next(step_count)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
if __FILE__ == $0
|
51
|
+
require_relative '../mock'
|
52
|
+
dbgr, cmd = MockDebugger::setup
|
53
|
+
# [%w(n 5), %w(next 1+2), %w(n foo)].each do |c|
|
54
|
+
# dbgr.core.step_count = 0
|
55
|
+
# cmd.proc.leave_cmd_loop = false
|
56
|
+
# result = cmd.run(c)
|
57
|
+
# puts 'Run result: %s' % result
|
58
|
+
# puts 'step_count %d, leave_cmd_loop: %s' % [dbgr.core.step_count,
|
59
|
+
# cmd.proc.leave_cmd_loop]
|
60
|
+
# end
|
61
|
+
# [%w(n), %w(next+), %w(n-)].each do |c|
|
62
|
+
# dbgr.core.step_count = 0
|
63
|
+
# cmd.proc.leave_cmd_loop = false
|
64
|
+
# result = cmd.run(c)
|
65
|
+
# puts cmd.proc.different_pos
|
66
|
+
# end
|
67
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rubygems'; require 'require_relative'
|
2
|
+
require_relative '../command'
|
3
|
+
require_relative '../stepping'
|
4
|
+
require_relative '../../app/breakpoint'
|
5
|
+
require_relative '../../app/iseq'
|
6
|
+
|
7
|
+
class Trepan::Command::NextInstructionCommand < Trepan::Command
|
8
|
+
ALIASES = %w(ni)
|
9
|
+
CATEGORY = 'running'
|
10
|
+
HELP = <<-HELP
|
11
|
+
Continue but stop execution at the next bytecode instruction.
|
12
|
+
|
13
|
+
Does not step into send instructions.
|
14
|
+
|
15
|
+
See also 'continue', 'step', and 'next' commands.
|
16
|
+
HELP
|
17
|
+
NAME = File.basename(__FILE__, '.rb')
|
18
|
+
NEED_STACK = true
|
19
|
+
SHORT_HELP = 'Move to the next bytecode instruction'
|
20
|
+
|
21
|
+
def run(args)
|
22
|
+
if args.size == 1
|
23
|
+
step = 1
|
24
|
+
else
|
25
|
+
step_str = args[1]
|
26
|
+
opts = {
|
27
|
+
:msg_on_error =>
|
28
|
+
"The 'next' command argument must eval to an integer. Got: %s" %
|
29
|
+
step_str,
|
30
|
+
:min_value => 1
|
31
|
+
}
|
32
|
+
step = @proc.get_an_int(step_str, opts)
|
33
|
+
return unless step
|
34
|
+
end
|
35
|
+
|
36
|
+
exec = current_method
|
37
|
+
insn = Rubinius::InstructionSet[exec.iseq[@proc.frame.next_ip]]
|
38
|
+
|
39
|
+
next_ip = @proc.frame.next_ip + insn.width
|
40
|
+
|
41
|
+
if next_ip >= exec.iseq.size
|
42
|
+
@proc.step_to_parent
|
43
|
+
elsif ISeq.goto_op?(exec, @proc.frame.next_ip)
|
44
|
+
@proc.set_breakpoints_between(exec, @proc.frame.next_ip, next_ip)
|
45
|
+
else
|
46
|
+
line = exec.line_from_ip(next_ip)
|
47
|
+
|
48
|
+
bp = Breakpoint.for_ip(exec, next_ip, :event => 'vm-insn')
|
49
|
+
bp.scoped!(@proc.frame.scope)
|
50
|
+
bp.activate
|
51
|
+
end
|
52
|
+
@proc.continue('nexti')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
if __FILE__ == $0
|
57
|
+
require_relative '../mock'
|
58
|
+
dbgr, cmd = MockDebugger::setup
|
59
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require 'pp'
|
5
|
+
require_relative '../command'
|
6
|
+
require_relative '../../app/cmd_parse'
|
7
|
+
class Trepan::Command::ParseTreeCommand < Trepan::Command
|
8
|
+
|
9
|
+
unless defined?(HELP)
|
10
|
+
NAME = File.basename(__FILE__, '.rb')
|
11
|
+
HELP = <<-HELP
|
12
|
+
#{NAME} [FILE]
|
13
|
+
#{NAME}
|
14
|
+
|
15
|
+
In the first form, print a ParseTree S-expression of the current file
|
16
|
+
or FILE.
|
17
|
+
HELP
|
18
|
+
|
19
|
+
# ALIASES = %w(p)
|
20
|
+
MAX_ARGS = 1
|
21
|
+
CATEGORY = 'data'
|
22
|
+
SHORT_HELP = 'PrettyPrint a ParseTree S-expression for a file'
|
23
|
+
end
|
24
|
+
|
25
|
+
def run(args)
|
26
|
+
meth = nil
|
27
|
+
case args.size
|
28
|
+
when 1
|
29
|
+
file = @proc.frame.file
|
30
|
+
when 2
|
31
|
+
file = args[1]
|
32
|
+
else
|
33
|
+
errmsg 'Expecting a file name'
|
34
|
+
end
|
35
|
+
expanded_file = @proc.canonic_file(file)
|
36
|
+
if File.readable?(expanded_file)
|
37
|
+
section "ParseTree for file: #{expanded_file}"
|
38
|
+
msg File.to_sexp(expanded_file).pretty_inspect
|
39
|
+
else
|
40
|
+
errmsg "File #{expanded_file} is not readable."
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
if __FILE__ == $0
|
45
|
+
require 'pp'
|
46
|
+
require_relative '../mock'
|
47
|
+
dbgr, cmd = MockDebugger::setup
|
48
|
+
cmd.run([cmd.name, __FILE__])
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../command'
|
5
|
+
class Trepan::Command::PrCommand < Trepan::Command
|
6
|
+
|
7
|
+
unless defined?(HELP)
|
8
|
+
NAME = File.basename(__FILE__, '.rb')
|
9
|
+
HELP =
|
10
|
+
"#{NAME} EXPRESSION
|
11
|
+
|
12
|
+
Print the value of the EXPRESSION. Variables accessible are those of the
|
13
|
+
environment of the selected stack frame, plus globals.
|
14
|
+
|
15
|
+
If the length output string large, the first part of the value is
|
16
|
+
shown and ... indicates it has been truncated.
|
17
|
+
|
18
|
+
See 'set max string' to change the string truncation limit.
|
19
|
+
"
|
20
|
+
|
21
|
+
# ALIASES = %w(p)
|
22
|
+
CATEGORY = 'data'
|
23
|
+
SHORT_HELP = 'print expression truncating long output'
|
24
|
+
end
|
25
|
+
|
26
|
+
def run(args)
|
27
|
+
msg @proc.debug_eval(@proc.cmd_argstr, settings[:maxstring])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
if __FILE__ == $0
|
32
|
+
require_relative '../mock'
|
33
|
+
dbgr, cmd = MockDebugger::setup
|
34
|
+
arg_str = '1 + 2'
|
35
|
+
cmd.proc.instance_variable_set('@cmd_argstr', arg_str)
|
36
|
+
cmd.run([cmd.name, arg_str])
|
37
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../command'
|
5
|
+
require_relative '../eval'
|
6
|
+
class Trepan::Command::PsCommand < Trepan::Command
|
7
|
+
|
8
|
+
unless defined?(HELP)
|
9
|
+
HELP =
|
10
|
+
"ps ARRAY
|
11
|
+
|
12
|
+
Print the value of the ARRAY in columns and sorted."
|
13
|
+
|
14
|
+
CATEGORY = 'data'
|
15
|
+
MIN_ARGS = 1 # Need least this many
|
16
|
+
NAME = File.basename(__FILE__, '.rb')
|
17
|
+
SHORT_HELP = 'Print array sorted and in columns'
|
18
|
+
end
|
19
|
+
|
20
|
+
def run(args)
|
21
|
+
array = @proc.debug_eval(@proc.cmd_argstr, settings[:maxstring])
|
22
|
+
# FIXME: should test for enumerable
|
23
|
+
if array.is_a?(Array)
|
24
|
+
msg columnize_commands(array.sort)
|
25
|
+
else
|
26
|
+
errmsg "ps: #{@proc.cmd_argstr} should evaluate an Array not #{array.class}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
if __FILE__ == $0
|
32
|
+
require_relative '../mock'
|
33
|
+
dbgr, cmd = MockDebugger::setup
|
34
|
+
arg_str = '(1..30).to_a'
|
35
|
+
cmd.proc.instance_variable_set('@cmd_argstr', arg_str)
|
36
|
+
cmd.run([cmd.name, arg_str])
|
37
|
+
arg_str = '1'
|
38
|
+
cmd.proc.instance_variable_set('@cmd_argstr', arg_str)
|
39
|
+
cmd.run([cmd.name, arg_str])
|
40
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../command'
|
5
|
+
require_relative '../../app/run'
|
6
|
+
class Trepan::Command::RestartCommand < Trepan::Command
|
7
|
+
|
8
|
+
unless defined?(HELP)
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
ALIASES = %w(R run)
|
11
|
+
HELP = <<-HELP
|
12
|
+
#{NAME}
|
13
|
+
|
14
|
+
Restart debugger and program via an exec call. All state is lost, and
|
15
|
+
new copy of the debugger is used.
|
16
|
+
HELP
|
17
|
+
|
18
|
+
CATEGORY = 'running'
|
19
|
+
MAX_ARGS = 0 # Need at most this many
|
20
|
+
SHORT_HELP = '(Hard) restart of program via exec()'
|
21
|
+
end
|
22
|
+
|
23
|
+
# This method runs the command
|
24
|
+
def run(args)
|
25
|
+
|
26
|
+
dbgr = @proc.dbgr
|
27
|
+
argv = dbgr.restart_argv
|
28
|
+
if argv and argv.size > 0
|
29
|
+
@proc.run_cmd(%w(show args))
|
30
|
+
if not confirm('Restart (exec)?', false)
|
31
|
+
msg "Restart not confirmed"
|
32
|
+
else
|
33
|
+
if defined?(Trepan::PROG_UNRESOLVED_SCRIPT) &&
|
34
|
+
position = argv.index(Trepan::PROG_UNRESOLVED_SCRIPT)
|
35
|
+
save_filename = @proc.save_commands(:erase =>true)
|
36
|
+
argv.insert(position, '--command', save_filename) if save_filename
|
37
|
+
end
|
38
|
+
Dir.chdir(Rubinius::OS_STARTUP_DIR)
|
39
|
+
msg 'Restarting using...'
|
40
|
+
msg "\t #{argv.inspect}"
|
41
|
+
@proc.finalize
|
42
|
+
exec(*argv)
|
43
|
+
end
|
44
|
+
else
|
45
|
+
errmsg("No executable file and command options recorded.")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
if __FILE__ == $0
|
51
|
+
exit if ARGV[-1] == 'exit'
|
52
|
+
require_relative '../mock'
|
53
|
+
dbgr, cmd = MockDebugger::setup
|
54
|
+
dbgr.restart_argv = []
|
55
|
+
cmd.run([cmd.name])
|
56
|
+
dbgr.restart_argv = Rubinius::OS_ARGV + ['exit']
|
57
|
+
# require_relative '../../debugger'
|
58
|
+
# Trepan.start
|
59
|
+
cmd.run([cmd.name])
|
60
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../command'
|
5
|
+
class Trepan::Command::SaveCommand < Trepan::Command
|
6
|
+
|
7
|
+
unless defined?(HELP)
|
8
|
+
NAME = File.basename(__FILE__, '.rb')
|
9
|
+
HELP = <<-HELP
|
10
|
+
#{NAME} [--[no-]erase] [--output|-o FILENAME]
|
11
|
+
|
12
|
+
Save settings to file FILENAME. If FILENAME not given one will be made
|
13
|
+
selected.
|
14
|
+
HELP
|
15
|
+
|
16
|
+
CATEGORY = 'running'
|
17
|
+
MAX_ARGS = 1 # Need at most this many
|
18
|
+
SHORT_HELP = 'Send debugger state to a file'
|
19
|
+
|
20
|
+
DEFAULT_OPTIONS = { :erase => true, }
|
21
|
+
end
|
22
|
+
|
23
|
+
def parse_options(options, args) # :nodoc
|
24
|
+
parser = OptionParser.new do |opts|
|
25
|
+
opts.on("-e", "--[no-]erase",
|
26
|
+
"Add line to erase after reading") do
|
27
|
+
|v|
|
28
|
+
options[:erase] = v
|
29
|
+
end
|
30
|
+
opts.on("-o", "--output FILE", String,
|
31
|
+
"Save file to FILE. ") do
|
32
|
+
|filename|
|
33
|
+
options[:filename] = filename
|
34
|
+
end
|
35
|
+
end
|
36
|
+
parser.parse(args)
|
37
|
+
return options
|
38
|
+
end
|
39
|
+
|
40
|
+
# This method runs the command
|
41
|
+
def run(args)
|
42
|
+
options = parse_options(DEFAULT_OPTIONS.dup, args[1..-1])
|
43
|
+
save_filename = @proc.save_commands(options)
|
44
|
+
msg "Debugger commands written to file: #{save_filename}" if
|
45
|
+
save_filename
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
if __FILE__ == $0
|
50
|
+
require_relative '../mock'
|
51
|
+
dbgr, cmd = MockDebugger::setup
|
52
|
+
require 'tmpdir'
|
53
|
+
cmd.run([cmd.name])
|
54
|
+
# require_relative '../../lib/trepanning'; debugger
|
55
|
+
cmd.run([cmd.name, '--erase',
|
56
|
+
'--output', File.join(Dir.tmpdir, 'save_file.txt')])
|
57
|
+
# A good test would be to see we can read in those files without error.
|
58
|
+
end
|