rb8-trepanning 0.1.3-universal-ruby-1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/CHANGES +34 -0
- data/ChangeLog +875 -0
- data/README.textile +59 -0
- data/Rakefile +215 -0
- data/app/.gitignore +1 -0
- data/app/cmd_parse.kpeg +241 -0
- data/app/cmd_parse.rb +212 -0
- data/app/cmd_parser.rb +1948 -0
- data/app/complete.rb +79 -0
- data/app/default.rb +90 -0
- data/app/display.rb +148 -0
- data/app/eventbuffer.rb +147 -0
- data/app/frame.rb +166 -0
- data/app/irb.rb +114 -0
- data/app/options.rb +200 -0
- data/app/run.rb +74 -0
- data/app/util.rb +65 -0
- data/bin/.gitignore +1 -0
- data/bin/trepan8 +115 -0
- data/data/.gitignore +1 -0
- data/data/irbrc +41 -0
- data/interface/.gitignore +1 -0
- data/interface/base_intf.rb +109 -0
- data/interface/client.rb +82 -0
- data/interface/comcodes.rb +20 -0
- data/interface/script.rb +110 -0
- data/interface/server.rb +147 -0
- data/interface/user.rb +165 -0
- data/io/base_io.rb +148 -0
- data/io/input.rb +158 -0
- data/io/null_output.rb +46 -0
- data/io/string_array.rb +156 -0
- data/io/tcpclient.rb +129 -0
- data/io/tcpfns.rb +33 -0
- data/io/tcpserver.rb +141 -0
- data/lib/debugger.rb +8 -0
- data/lib/trepanning.rb +283 -0
- data/processor/.gitignore +1 -0
- data/processor/command-ruby-debug/breakpoints.rb +155 -0
- data/processor/command-ruby-debug/catchpoint.rb +55 -0
- data/processor/command-ruby-debug/condition.rb +49 -0
- data/processor/command-ruby-debug/control.rb +31 -0
- data/processor/command-ruby-debug/display.rb +120 -0
- data/processor/command-ruby-debug/enable.rb +202 -0
- data/processor/command-ruby-debug/frame.rb +199 -0
- data/processor/command-ruby-debug/help.rb +63 -0
- data/processor/command-ruby-debug/info.rb +359 -0
- data/processor/command-ruby-debug/method.rb +84 -0
- data/processor/command-ruby-debug/reload.rb +40 -0
- data/processor/command-ruby-debug/save.rb +90 -0
- data/processor/command-ruby-debug/set.rb +237 -0
- data/processor/command-ruby-debug/show.rb +251 -0
- data/processor/command-ruby-debug/source.rb +36 -0
- data/processor/command-ruby-debug/threads.rb +189 -0
- data/processor/command-ruby-debug/trace.rb +57 -0
- data/processor/command-ruby-debug/variables.rb +199 -0
- data/processor/command.rb +270 -0
- data/processor/command/.gitignore +1 -0
- data/processor/command/alias.rb +54 -0
- data/processor/command/backtrace.rb +123 -0
- data/processor/command/base/cmd.rb +177 -0
- data/processor/command/base/subcmd.rb +230 -0
- data/processor/command/base/submgr.rb +188 -0
- data/processor/command/base/subsubcmd.rb +128 -0
- data/processor/command/base/subsubmgr.rb +199 -0
- data/processor/command/break.rb +114 -0
- data/processor/command/catch.rb +71 -0
- data/processor/command/complete.rb +39 -0
- data/processor/command/continue.rb +57 -0
- data/processor/command/directory.rb +50 -0
- data/processor/command/disable.rb +85 -0
- data/processor/command/display.rb +78 -0
- data/processor/command/down.rb +54 -0
- data/processor/command/edit.rb +79 -0
- data/processor/command/enable.rb +48 -0
- data/processor/command/eval.rb +90 -0
- data/processor/command/exit.rb +66 -0
- data/processor/command/finish.rb +59 -0
- data/processor/command/frame.rb +97 -0
- data/processor/command/help.rb +230 -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/info.rb +28 -0
- data/processor/command/info_subcmd/.gitignore +1 -0
- data/processor/command/info_subcmd/args.rb +39 -0
- data/processor/command/info_subcmd/breakpoints.rb +80 -0
- data/processor/command/info_subcmd/catch.rb +36 -0
- data/processor/command/info_subcmd/files.rb +39 -0
- data/processor/command/info_subcmd/globals.rb +64 -0
- data/processor/command/info_subcmd/line.rb +30 -0
- data/processor/command/info_subcmd/locals.rb +69 -0
- data/processor/command/info_subcmd/macro.rb +62 -0
- data/processor/command/info_subcmd/program.rb +51 -0
- data/processor/command/info_subcmd/ruby.rb +57 -0
- data/processor/command/info_subcmd/source.rb +74 -0
- data/processor/command/info_subcmd/stack.rb +25 -0
- data/processor/command/info_subcmd/threads.rb +75 -0
- data/processor/command/kill.rb +78 -0
- data/processor/command/list.rb +117 -0
- data/processor/command/macro.rb +68 -0
- data/processor/command/next.rb +79 -0
- data/processor/command/parsetree.rb +56 -0
- data/processor/command/pp.rb +40 -0
- data/processor/command/pr.rb +37 -0
- data/processor/command/ps.rb +40 -0
- data/processor/command/restart.rb +86 -0
- data/processor/command/save.rb +58 -0
- data/processor/command/set.rb +47 -0
- data/processor/command/set_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/abbrev.rb +25 -0
- data/processor/command/set_subcmd/auto.rb +27 -0
- data/processor/command/set_subcmd/auto_subcmd/.gitignore +1 -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/callstyle.rb +46 -0
- data/processor/command/set_subcmd/confirm.rb +24 -0
- data/processor/command/set_subcmd/debug.rb +47 -0
- data/processor/command/set_subcmd/different.rb +61 -0
- data/processor/command/set_subcmd/highlight.rb +43 -0
- data/processor/command/set_subcmd/max.rb +26 -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/timer.rb +58 -0
- data/processor/command/set_subcmd/trace.rb +37 -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 +139 -0
- data/processor/command/show.rb +39 -0
- data/processor/command/show_subcmd/.gitignore +1 -0
- data/processor/command/show_subcmd/abbrev.rb +20 -0
- data/processor/command/show_subcmd/alias.rb +46 -0
- data/processor/command/show_subcmd/args.rb +34 -0
- data/processor/command/show_subcmd/auto.rb +28 -0
- data/processor/command/show_subcmd/auto_subcmd/eval.rb +27 -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/callstyle.rb +22 -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/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/highlight.rb +24 -0
- data/processor/command/show_subcmd/max.rb +27 -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 +29 -0
- data/processor/command/show_subcmd/trace_subcmd/buffer.rb +65 -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 +134 -0
- data/processor/command/step.rb +81 -0
- data/processor/command/tbreak.rb +19 -0
- data/processor/command/unalias.rb +44 -0
- data/processor/command/undisplay.rb +59 -0
- data/processor/command/up.rb +72 -0
- data/processor/default.rb +56 -0
- data/processor/display.rb +17 -0
- data/processor/eval.rb +113 -0
- data/processor/eventbuf.rb +105 -0
- data/processor/frame.rb +172 -0
- data/processor/help.rb +92 -0
- data/processor/helper.rb +76 -0
- data/processor/hook.rb +134 -0
- data/processor/load_cmds.rb +258 -0
- data/processor/location.rb +174 -0
- data/processor/main.rb +455 -0
- data/processor/mock.rb +136 -0
- data/processor/msg.rb +61 -0
- data/processor/processor.rb +674 -0
- data/processor/running.rb +168 -0
- data/processor/stepping.rb +18 -0
- data/processor/subcmd.rb +161 -0
- data/processor/validate.rb +355 -0
- data/processor/virtual.rb +34 -0
- data/test/data/.gitignore +1 -0
- data/test/data/break_bad.cmd +19 -0
- data/test/data/break_bad.right +29 -0
- data/test/data/break_loop_bug.cmd +5 -0
- data/test/data/break_loop_bug.right +15 -0
- data/test/data/dollar-0.right +2 -0
- data/test/data/dollar-0a.right +2 -0
- data/test/data/dollar-0b.right +2 -0
- data/test/data/edit.cmd +14 -0
- data/test/data/edit.right +24 -0
- data/test/data/file-with-space.cmd +6 -0
- data/test/data/file-with-space.right +4 -0
- data/test/data/printvar.cmd +17 -0
- data/test/data/printvar.right +31 -0
- data/test/data/raise.cmd +11 -0
- data/test/data/raise.right +19 -0
- data/test/data/source.cmd +5 -0
- data/test/data/source.right +18 -0
- data/test/data/stepping-1.9.right +50 -0
- data/test/data/stepping.cmd +21 -0
- data/test/data/stepping.right +48 -0
- data/test/data/trepan8-save.1 +6 -0
- data/test/example/bp_loop_issue.rb +3 -0
- data/test/example/break-bug.rb +7 -0
- data/test/example/brkpt-class-bug.rb +8 -0
- data/test/example/classes.rb +11 -0
- data/test/example/dollar-0.rb +5 -0
- data/test/example/except-bug1.rb +4 -0
- data/test/example/except-bug2.rb +7 -0
- data/test/example/file with space.rb +1 -0
- data/test/example/gcd.rb +18 -0
- data/test/example/info-var-bug.rb +47 -0
- data/test/example/info-var-bug2.rb +2 -0
- data/test/example/null.rb +1 -0
- data/test/example/pm-bug.rb +3 -0
- data/test/example/pm.rb +11 -0
- data/test/example/raise.rb +3 -0
- data/test/integration/.gitignore +4 -0
- data/test/integration/config.yaml +8 -0
- data/test/integration/helper.rb +154 -0
- data/test/integration/test-break_bad.rb +26 -0
- data/test/integration/test-dollar-0.rb +31 -0
- data/test/integration/test-edit.rb +17 -0
- data/test/integration/test-file-with-space.rb +26 -0
- data/test/integration/test-printvar.rb +17 -0
- data/test/integration/test-raise.rb +21 -0
- data/test/integration/test-source.rb +16 -0
- data/test/integration/test-stepping.rb +24 -0
- data/test/unit/.gitignore +1 -0
- data/test/unit/cmd-helper.rb +52 -0
- data/test/unit/mock-helper.rb +12 -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-frame.rb +32 -0
- data/test/unit/test-app-options.rb +92 -0
- data/test/unit/test-app-run.rb +14 -0
- data/test/unit/test-app-util.rb +44 -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 +23 -0
- data/test/unit/test-base-subsubcmd.rb +17 -0
- data/test/unit/test-cmd-alias.rb +48 -0
- data/test/unit/test-cmd-exit.rb +27 -0
- data/test/unit/test-cmd-help.rb +104 -0
- data/test/unit/test-cmd-kill.rb +46 -0
- data/test/unit/test-cmd-source.rb +34 -0
- data/test/unit/test-completion.rb +42 -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 +36 -0
- data/test/unit/test-proc-hook.rb +30 -0
- data/test/unit/test-proc-load_cmds.rb +50 -0
- data/test/unit/test-proc-location.rb +79 -0
- data/test/unit/test-subcmd-help.rb +44 -0
- data/trepan8.gemspec +58 -0
- metadata +388 -0
@@ -0,0 +1,114 @@
|
|
1
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative './base/cmd'
|
4
|
+
|
5
|
+
class Trepan::Command::BreakCommand < Trepan::Command
|
6
|
+
|
7
|
+
ALIASES = %w(b)
|
8
|
+
CATEGORY = 'breakpoints'
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
HELP = <<-HELP
|
11
|
+
#{NAME} LOCATION [ {if|unless} CONDITION ]
|
12
|
+
|
13
|
+
Set a breakpoint. In the second form where CONDITIOn is given, the
|
14
|
+
condition is evaluated in the context of the position. We stop only If
|
15
|
+
CONDITION evalutes to non-false/nil and the "if" form used, or it is
|
16
|
+
false and the "unless" form used.\
|
17
|
+
|
18
|
+
Examples:
|
19
|
+
#{NAME}
|
20
|
+
#{NAME} 10 # set breakpoint on line 10
|
21
|
+
#{NAME} 10 if 1 == a # like above but only if a is equal to 1
|
22
|
+
#{NAME} 10 unless 1 == a # like above but only if a is equal to 1
|
23
|
+
#{NAME} me.rb:10
|
24
|
+
#{NAME} Kernel.pp # Set a breakpoint at the beginning of Kernel.pp
|
25
|
+
|
26
|
+
See also condition, continue and "help location".
|
27
|
+
HELP
|
28
|
+
SHORT_HELP = 'Set a breakpoint at a point in a method'
|
29
|
+
|
30
|
+
# This method runs the command
|
31
|
+
def run(args, temp=false)
|
32
|
+
|
33
|
+
arg_str = args.size == 1 ? @proc.frame.line.to_s : @proc.cmd_argstr
|
34
|
+
cm, file, line, position_type, expr, negate =
|
35
|
+
@proc.breakpoint_position(arg_str, true)
|
36
|
+
if file.nil?
|
37
|
+
unless @proc.context
|
38
|
+
errmsg 'We are not in a state that has an associated file.'
|
39
|
+
return
|
40
|
+
end
|
41
|
+
file = @proc.frame.file
|
42
|
+
if line.nil?
|
43
|
+
# Set breakpoint at current line
|
44
|
+
line = @proc.frame.line
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
if line
|
49
|
+
if LineCache.cache(file, settings[:reload_source_on_change])
|
50
|
+
last_line = LineCache.size(file)
|
51
|
+
if line > last_line
|
52
|
+
errmsg("There are only %d lines in file \"%s\"." % [last_line,
|
53
|
+
@proc.canonic_file(file)])
|
54
|
+
return
|
55
|
+
end
|
56
|
+
unless LineCache.trace_line_numbers(file).member?(line)
|
57
|
+
errmsg('Line %d is not a stopping point in file "%s".' %
|
58
|
+
[line, @proc.canonic_file(file)])
|
59
|
+
return
|
60
|
+
end
|
61
|
+
else
|
62
|
+
errmsg('No source file named %s' % @proc.canonic_file(file))
|
63
|
+
return unless confirm('Set breakpoint anyway?', false)
|
64
|
+
end
|
65
|
+
|
66
|
+
unless @proc.context
|
67
|
+
errmsg 'We are not in a state we can add breakpoints.'
|
68
|
+
return
|
69
|
+
end
|
70
|
+
|
71
|
+
expr = "!(#{expr})" if negate
|
72
|
+
if temp
|
73
|
+
@proc.state.context.set_breakpoint(file, line, expr)
|
74
|
+
msg("Temporary breakpoint set at file %s, line %d" % [file, line])
|
75
|
+
else
|
76
|
+
b = Debugger.add_breakpoint file, line, expr
|
77
|
+
msg("Breakpoint %d file %s, line %d" %
|
78
|
+
[b.id, @proc.canonic_file(file), line])
|
79
|
+
end
|
80
|
+
# unless syntax_valid?(expr)
|
81
|
+
# errmsg("Expression \"#{expr}\" syntactically incorrect; breakpoint disabled.\n")
|
82
|
+
# b.enabled = false
|
83
|
+
# end
|
84
|
+
# else
|
85
|
+
# method = line.intern.id2name
|
86
|
+
# b = Debugger.add_breakpoint class_name, method, expr
|
87
|
+
# print "Breakpoint %d at %s::%s\n", b.id, class_name, method.to_s
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
if __FILE__ == $0
|
93
|
+
require_relative '../mock'
|
94
|
+
dbgr, cmd = MockDebugger::setup
|
95
|
+
# require_relative '../../lib/trepanning'
|
96
|
+
def run_cmd(cmd, args)
|
97
|
+
cmd.proc.instance_variable_set('@cmd_argstr', args[1..-1].join(' '))
|
98
|
+
cmd.run(args)
|
99
|
+
end
|
100
|
+
|
101
|
+
run_cmd(cmd, [cmd.name, 2])
|
102
|
+
# run_cmd(cmd, [cmd.name])
|
103
|
+
# run_cmd(cmd, [cmd.name, __LINE__.to_s])
|
104
|
+
|
105
|
+
# def foo
|
106
|
+
# 5
|
107
|
+
# end
|
108
|
+
# run_cmd(cmd, [cmd.name, 'foo', (__LINE__-2).to_s])
|
109
|
+
# run_cmd(cmd, [cmd.name, 'foo'])
|
110
|
+
# run_cmd(cmd, [cmd.name, "MockDebugger::setup"])
|
111
|
+
# require 'irb'
|
112
|
+
# run_cmd(cmd, [cmd.name, "IRB.start"])
|
113
|
+
# run_cmd(cmd, [cmd.name, 'foo93'])
|
114
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative 'base/cmd'
|
4
|
+
require_relative '../stepping'
|
5
|
+
|
6
|
+
class Trepan::Command::CatchCommand < Trepan::Command
|
7
|
+
unless defined?(HELP)
|
8
|
+
NAME = File.basename(__FILE__, '.rb')
|
9
|
+
HELP = <<-HELP
|
10
|
+
#{NAME} EXCEPTION-NAME
|
11
|
+
#{NAME} EXCEPTION-NAME off
|
12
|
+
#{NAME}
|
13
|
+
#{NAME} off
|
14
|
+
|
15
|
+
The first form intercepts EXCEPTION-NAME when.
|
16
|
+
The second form removes the debugger handling for EXCEPTION-NAME.
|
17
|
+
The third form is the the same as "info catch".
|
18
|
+
The last form deletes all debugger catchpoints.
|
19
|
+
|
20
|
+
Examples:
|
21
|
+
#{NAME} # same as "info catch"
|
22
|
+
#{NAME} ZeroDivisionError # Handle dividing by zero exceptions.
|
23
|
+
#{NAME} off # Turns off all debugger exception handling
|
24
|
+
|
25
|
+
See also "info catch" and post-mortem debugging.
|
26
|
+
HELP
|
27
|
+
|
28
|
+
ALIASES = %w()
|
29
|
+
CATEGORY = 'running'
|
30
|
+
MAX_ARGS = 2 # Need at most this many
|
31
|
+
NEED_RUNNING = true
|
32
|
+
SHORT_HELP = 'Catch exceptions'
|
33
|
+
end
|
34
|
+
|
35
|
+
# This is the method that runs the command
|
36
|
+
def run(args)
|
37
|
+
case args.size
|
38
|
+
when 1
|
39
|
+
@proc.commands['info'].run(%W(info catch))
|
40
|
+
when 2
|
41
|
+
exception = args[1]
|
42
|
+
if args[1] == 'off'
|
43
|
+
Debugger.catchpoints.clear if
|
44
|
+
confirm('Delete all catchpoints?', false)
|
45
|
+
else
|
46
|
+
unless @proc.debug_eval_no_errmsg("#{exception}.is_a?(Class)")
|
47
|
+
msg "Warning #{exception} is not known to be a Class"
|
48
|
+
end
|
49
|
+
Debugger.add_catchpoint(exception)
|
50
|
+
msg "Catch exception %s." % exception
|
51
|
+
end
|
52
|
+
when 3
|
53
|
+
exception = args[1]
|
54
|
+
if Debugger.catchpoints.member?(exception)
|
55
|
+
Debugger.catchpoints.delete(exception)
|
56
|
+
msg "Catch for exception %s removed." % exception
|
57
|
+
else
|
58
|
+
errmsg "Catch for exception %s not found." % exception
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
if __FILE__ == $0
|
65
|
+
require_relative '../mock'
|
66
|
+
dbgr, cmd = MockDebugger::setup
|
67
|
+
cmd.run([cmd.name])
|
68
|
+
cmd.run([cmd.name, 'ZeroDivisionError'])
|
69
|
+
cmd.run([cmd.name])
|
70
|
+
cmd.run([cmd.name, 'ZeroDivisionError', 'off'])
|
71
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative 'base/cmd'
|
4
|
+
require_relative '../load_cmds'
|
5
|
+
class Trepan::Command::CompleteCommand < Trepan::Command
|
6
|
+
|
7
|
+
unless defined?(HELP)
|
8
|
+
NAME = File.basename(__FILE__, '.rb')
|
9
|
+
HELP = <<-HELP
|
10
|
+
#{NAME} COMMAND-PREFIX
|
11
|
+
|
12
|
+
List the completions for the rest of the line as a command.
|
13
|
+
HELP
|
14
|
+
CATEGORY = 'support'
|
15
|
+
NEED_STACK = false
|
16
|
+
SHORT_HELP = 'List the completions for the rest of the line as a command'
|
17
|
+
end
|
18
|
+
|
19
|
+
# This method runs the command
|
20
|
+
def run(args) # :nodoc
|
21
|
+
last_arg = @proc.cmd_argstr.end_with?(' ') ? '' : args[-1]
|
22
|
+
@proc.complete(@proc.cmd_argstr, last_arg).each do |match|
|
23
|
+
msg match
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
if __FILE__ == $0
|
29
|
+
# Demo it.
|
30
|
+
require_relative '../mock'
|
31
|
+
dbgr, cmd = MockDebugger::setup
|
32
|
+
%w(k b bt).each do |prefix|
|
33
|
+
cmd.proc.instance_variable_set('@cmd_argstr', prefix)
|
34
|
+
cmd.run [cmd.name, prefix]
|
35
|
+
puts '=' * 40
|
36
|
+
end
|
37
|
+
cmd.run %w(#{cmd.name} fdafsasfda)
|
38
|
+
puts '=' * 40
|
39
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative 'base/cmd'
|
4
|
+
require_relative '../stepping'
|
5
|
+
|
6
|
+
class Trepan::Command::ContinueCommand < Trepan::Command
|
7
|
+
unless defined?(HELP)
|
8
|
+
NAME = File.basename(__FILE__, '.rb')
|
9
|
+
HELP = <<-HELP
|
10
|
+
#{NAME} [LOCATION]
|
11
|
+
|
12
|
+
Leave the debugger loop and continue execution. Subsequent entry to
|
13
|
+
the debugger however may occur via breakpoints or explicit calls, or
|
14
|
+
exceptions.
|
15
|
+
|
16
|
+
If a parameter is given, a temporary breakpoint is set at that position
|
17
|
+
before continuing.
|
18
|
+
|
19
|
+
Examples:
|
20
|
+
#{NAME}
|
21
|
+
#{NAME} 10 # continue to line 10
|
22
|
+
|
23
|
+
See also 'step', 'next', 'finish', 'nexti' commands and "help location".
|
24
|
+
HELP
|
25
|
+
|
26
|
+
ALIASES = %w(c cont)
|
27
|
+
CATEGORY = 'running'
|
28
|
+
MAX_ARGS = 1 # Need at most this many
|
29
|
+
NEED_RUNNING = true
|
30
|
+
SHORT_HELP = 'Continue execution of the debugged program'
|
31
|
+
end
|
32
|
+
|
33
|
+
# This is the method that runs the command
|
34
|
+
def run(args)
|
35
|
+
|
36
|
+
## FIXME: DRY this code, tbreak and break.
|
37
|
+
unless args.size == 1
|
38
|
+
filename = @proc.frame.file
|
39
|
+
line_number = @proc.get_an_int(args[1])
|
40
|
+
return unless line_number
|
41
|
+
unless LineCache.trace_line_numbers(filename).member?(line_number)
|
42
|
+
errmsg("Line %d is not a stopping point in file \"%s\".\n" %
|
43
|
+
[line_number, filename])
|
44
|
+
return
|
45
|
+
end
|
46
|
+
@proc.state.context.set_breakpoint(filename, line_number)
|
47
|
+
end
|
48
|
+
@proc.continue
|
49
|
+
@proc.leave_cmd_loop = true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
if __FILE__ == $0
|
54
|
+
require_relative '../mock'
|
55
|
+
dbgr, cmd = MockDebugger::setup
|
56
|
+
cmd.run([cmd.name])
|
57
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative 'base/cmd'
|
4
|
+
class Trepan::Command::DirectoryCommand < Trepan::Command
|
5
|
+
|
6
|
+
unless defined?(HELP)
|
7
|
+
ALIASES = %w(dir)
|
8
|
+
CATEGORY = 'files'
|
9
|
+
MAX_ARGS = 1 # Need at most this many
|
10
|
+
NAME = File.basename(__FILE__, '.rb')
|
11
|
+
HELP = <<-HELP
|
12
|
+
#{NAME} [DIR]
|
13
|
+
|
14
|
+
Add directory DIR to beginning of search path for source files.
|
15
|
+
DIR can also be $cwd for the current working directory, or $cdir for the
|
16
|
+
directory in which the debugged file start.
|
17
|
+
With no argument, reset the search path to $cdir:$cwd, the default.
|
18
|
+
|
19
|
+
This command may be useful for debugging into Rubinius methods such as
|
20
|
+
kernel/common/module.rb if have the source code somewhere.
|
21
|
+
|
22
|
+
Examples:
|
23
|
+
#{NAME} # reset to $cdir:$cwd
|
24
|
+
HELP
|
25
|
+
|
26
|
+
SHORT_HELP =
|
27
|
+
'Add directory DIR to beginning of search path for source files'
|
28
|
+
end
|
29
|
+
|
30
|
+
# This method runs the command
|
31
|
+
def run(args) # :nodoc
|
32
|
+
if args.size > 1
|
33
|
+
path = File.expand_path(args[1])
|
34
|
+
settings[:directory] = "#{path}:#{settings[:directory]}"
|
35
|
+
msg "Source directories searched: #{settings[:directory]}"
|
36
|
+
else
|
37
|
+
if confirm('Reintialize source path to empty?', false)
|
38
|
+
settings[:directory] = '$cdir:$cwd'
|
39
|
+
msg "Source directories searched: #{settings[:directory]}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
if __FILE__ == $0
|
46
|
+
require_relative '../mock'
|
47
|
+
dbgr, cmd = MockDebugger::setup
|
48
|
+
cmd.run([cmd.name])
|
49
|
+
cmd.run([cmd.name, '/tmp'])
|
50
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'base/cmd'
|
5
|
+
# require_relative '../breakpoint'
|
6
|
+
# require_relative '../../app/breakpoint'
|
7
|
+
|
8
|
+
# disable breakpoint command. The difference however is that the
|
9
|
+
# parameter to @proc.en_disable_breakpoint_by_number is different (set
|
10
|
+
# as ENABLE_PARM below).
|
11
|
+
#
|
12
|
+
# NOTE: The enable command subclasses this, so beware when changing!
|
13
|
+
class Trepan::Command::DisableCommand < Trepan::Command
|
14
|
+
|
15
|
+
# Silence already initialized constant .. warnings
|
16
|
+
old_verbose = $VERBOSE
|
17
|
+
$VERBOSE = nil
|
18
|
+
NAME = File.basename(__FILE__, '.rb')
|
19
|
+
HELP = <<-HELP
|
20
|
+
#{NAME} bpnumber [bpnumber ...]
|
21
|
+
|
22
|
+
Disables the breakpoints given as a space separated list of breakpoint
|
23
|
+
numbers. See also "info break" to get a list.
|
24
|
+
HELP
|
25
|
+
|
26
|
+
CATEGORY = 'breakpoints'
|
27
|
+
SHORT_HELP = 'Disable some breakpoints'
|
28
|
+
|
29
|
+
$VERBOSE = old_verbose
|
30
|
+
|
31
|
+
def initialize(proc)
|
32
|
+
super
|
33
|
+
@enable_parm = false # true if enable
|
34
|
+
end
|
35
|
+
|
36
|
+
def enable_disable_breakpoints(is_enable, args)
|
37
|
+
breakpoints = Debugger.breakpoints.sort_by{|b| b.id }
|
38
|
+
largest = breakpoints.inject(0) do |largest, b|
|
39
|
+
largest = b.id if b.id > largest
|
40
|
+
end
|
41
|
+
if 0 == largest
|
42
|
+
errmsg "No breakpoints have been set.\n"
|
43
|
+
return
|
44
|
+
end
|
45
|
+
args.each do |num_str|
|
46
|
+
pos = @proc.get_an_int(num_str)
|
47
|
+
return nil unless pos
|
48
|
+
breakpoints.each do |b|
|
49
|
+
if b.id == pos
|
50
|
+
enabled = ("Enable" == is_enable)
|
51
|
+
if enabled
|
52
|
+
unless syntax_valid?(b.expr)
|
53
|
+
errmsg("Expression \"#{b.expr}\" syntactically incorrect; breakpoint remains disabled.\n")
|
54
|
+
break
|
55
|
+
end
|
56
|
+
end
|
57
|
+
b.enabled = ("Enable" == is_enable)
|
58
|
+
break
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def run(args)
|
65
|
+
if args.size == 1
|
66
|
+
errmsg('No breakpoint number given.')
|
67
|
+
return
|
68
|
+
end
|
69
|
+
enable_disable_breakpoints("Disable", args[1..-1])
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
if __FILE__ == $0
|
75
|
+
require_relative '../mock'
|
76
|
+
dbgr, cmd = MockDebugger::setup
|
77
|
+
cmd.run([cmd.name])
|
78
|
+
cmd.run([cmd.name, '1'])
|
79
|
+
cmds = cmd.proc.commands
|
80
|
+
puts "To be continued..."
|
81
|
+
#
|
82
|
+
# break_cmd = cmds['break']
|
83
|
+
# break_cmd.run(['break', cmdproc.frame.line])
|
84
|
+
# cmd.run([cmd.name, '1'])
|
85
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'base/cmd'
|
5
|
+
|
6
|
+
class Trepan::Command::DisplayCommand < Trepan::Command
|
7
|
+
|
8
|
+
unless defined?(HELP)
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
HELP = <<-HELP
|
11
|
+
#{name} [format] EXP
|
12
|
+
|
13
|
+
Print value of expression EXP each time the program stops. FMT may be
|
14
|
+
used before EXP and may be one of 'c' for char, 'x' for hex, 'o' for
|
15
|
+
octal, 'f' for float or 's' for string.
|
16
|
+
|
17
|
+
For now, display expressions are only evaluated when in the same
|
18
|
+
instruction sequence as the frame that was in effect when the display
|
19
|
+
expression was set. This is a departure from gdb and we may allow for
|
20
|
+
more flexibility in the future to specify whether this should be the
|
21
|
+
case or not.
|
22
|
+
|
23
|
+
With no argument, evaluate and display all currently requested
|
24
|
+
auto-display expressions. Use "undisplay" to cancel display
|
25
|
+
requests previously made.
|
26
|
+
HELP
|
27
|
+
|
28
|
+
CATEGORY = 'data'
|
29
|
+
NEED_STACK = false
|
30
|
+
SHORT_HELP = 'Display expressions when entering debugger'
|
31
|
+
end
|
32
|
+
|
33
|
+
def run(args)
|
34
|
+
|
35
|
+
if args.size == 1
|
36
|
+
# Display anything active
|
37
|
+
@proc.run_eval_display
|
38
|
+
else
|
39
|
+
if %w(/c /x /o /f /s).member?(args[1])
|
40
|
+
if 2 == args.size
|
41
|
+
errmsg("Expecting an expression after the format")
|
42
|
+
return
|
43
|
+
end
|
44
|
+
format = args[1]
|
45
|
+
expr = args[2..-1].join(' ')
|
46
|
+
else
|
47
|
+
format = nil
|
48
|
+
expr = args[1..-1].join(' ')
|
49
|
+
end
|
50
|
+
|
51
|
+
dp = @proc.displays.add(@proc.frame, expr, format)
|
52
|
+
unless dp
|
53
|
+
errmsg('Error evaluating "%s" in the current frame' % expr)
|
54
|
+
return
|
55
|
+
end
|
56
|
+
msg(dp.to_s(@proc.frame))
|
57
|
+
@proc.cmdloop_prehooks.insert_if_new(5, *@proc.display_hook)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
if __FILE__ == $0
|
63
|
+
# Demo it.
|
64
|
+
require_relative '../mock'
|
65
|
+
dbgr, cmd = MockDebugger::setup
|
66
|
+
|
67
|
+
def run_cmd(cmd, args)
|
68
|
+
cmd.run(args)
|
69
|
+
puts '==' * 10
|
70
|
+
end
|
71
|
+
|
72
|
+
# run_cmd(cmd, [cmd.name])
|
73
|
+
# run_cmd(cmd, [cmd.name, '/x', '10'])
|
74
|
+
# run_cmd(cmd, [cmd.name, 'd'])
|
75
|
+
# run_cmd(cmd, [cmd.name])
|
76
|
+
e = 5
|
77
|
+
run_cmd(cmd, [cmd.name, 'e'])
|
78
|
+
end
|