rbx-trepanning 0.0.5-universal-rubinius-1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +2002 -0
- data/LICENSE +25 -0
- data/NEWS +31 -0
- data/README.textile +34 -0
- data/Rakefile +165 -0
- data/THANKS +14 -0
- data/app/breakpoint.rb +219 -0
- data/app/breakpoint.rbc +3551 -0
- data/app/brkptmgr.rb +140 -0
- data/app/brkptmgr.rbc +2903 -0
- data/app/client.rb +61 -0
- data/app/client.rbc +1225 -0
- data/app/complete.rb +52 -0
- data/app/complete.rbc +1288 -0
- data/app/default.rb +71 -0
- data/app/default.rbc +1132 -0
- data/app/display.rb +148 -0
- data/app/display.rbc +2578 -0
- data/app/frame.rb +98 -0
- data/app/frame.rbc +1808 -0
- data/app/irb.rb +111 -0
- data/app/irb.rbc +2094 -0
- data/app/iseq.rb +117 -0
- data/app/iseq.rbc +2192 -0
- data/app/llvm.rbc +2478 -0
- data/app/method.rb +173 -0
- data/app/method.rbc +2492 -0
- data/app/method_name.rbc +2467 -0
- data/app/mock.rb +13 -0
- data/app/mock.rbc +398 -0
- data/app/options.rb +137 -0
- data/app/options.rbc +2898 -0
- data/app/rbx-llvm.rb +165 -0
- data/app/rbx-llvm.rbc +2478 -0
- data/app/run.rb +86 -0
- data/app/run.rbc +1244 -0
- data/app/util.rb +49 -0
- data/app/util.rbc +1146 -0
- data/app/validate.rb +30 -0
- data/app/validate.rbc +676 -0
- data/bin/trepan.compiled.rbc +1043 -0
- data/bin/trepanx +69 -0
- data/bin/trepanx.compiled.rbc +1049 -0
- data/data/irbrc +41 -0
- data/data/irbrc.compiled.rbc +640 -0
- data/interface/base_intf.rb +105 -0
- data/interface/base_intf.rbc +1899 -0
- data/interface/client.rb +80 -0
- data/interface/client.rbc +1072 -0
- data/interface/comcodes.rb +20 -0
- data/interface/comcodes.rbc +385 -0
- data/interface/script.rb +104 -0
- data/interface/script.rbc +1642 -0
- data/interface/server.rb +143 -0
- data/interface/server.rbc +2213 -0
- data/interface/user.rb +150 -0
- data/interface/user.rbc +2867 -0
- data/io/base_io.rb +148 -0
- data/io/base_io.rbc +2111 -0
- data/io/input.rb +135 -0
- data/io/input.rbc +2528 -0
- data/io/null_output.rb +42 -0
- data/io/null_output.rbc +730 -0
- data/io/string_array.rb +156 -0
- data/io/string_array.rbc +2466 -0
- data/io/tcpclient.rb +129 -0
- data/io/tcpclient.rbc +2419 -0
- data/io/tcpfns.rb +33 -0
- data/io/tcpfns.rbc +694 -0
- data/io/tcpserver.rb +141 -0
- data/io/tcpserver.rbc +2638 -0
- data/lib/trepanning.rb +474 -0
- data/lib/trepanning.rbc +7705 -0
- data/lib/trepanning2.rb +441 -0
- data/processor/breakpoint.rb +164 -0
- data/processor/command/alias.rb +55 -0
- data/processor/command/backtrace.rb +76 -0
- data/processor/command/base/cmd.rb +173 -0
- data/processor/command/base/subcmd.rb +229 -0
- data/processor/command/base/submgr.rb +182 -0
- data/processor/command/base/subsubcmd.rb +103 -0
- data/processor/command/base/subsubmgr.rb +195 -0
- data/processor/command/break.rb +100 -0
- data/processor/command/complete.rb +37 -0
- data/processor/command/continue.rb +91 -0
- data/processor/command/delete.rb +30 -0
- data/processor/command/directory.rb +51 -0
- data/processor/command/disassemble.rb +145 -0
- data/processor/command/display.rb +82 -0
- data/processor/command/down.rb +54 -0
- data/processor/command/eval.rb +51 -0
- data/processor/command/exit.rb +62 -0
- data/processor/command/finish.rb +80 -0
- data/processor/command/frame.rb +89 -0
- data/processor/command/help.rb +251 -0
- data/processor/command/info.rb +28 -0
- data/processor/command/info_subcmd/breakpoints.rb +73 -0
- data/processor/command/info_subcmd/files.rb +209 -0
- data/processor/command/info_subcmd/line.rb +86 -0
- data/processor/command/info_subcmd/method.rb +71 -0
- data/processor/command/info_subcmd/program.rb +49 -0
- data/processor/command/info_subcmd/ruby.rb +62 -0
- data/processor/command/info_subcmd/variables.rb +48 -0
- data/processor/command/irb.rb +128 -0
- data/processor/command/kill.rb +70 -0
- data/processor/command/list.rb +300 -0
- data/processor/command/macro.rb +76 -0
- data/processor/command/next.rb +66 -0
- data/processor/command/nexti.rb +59 -0
- data/processor/command/pr.rb +38 -0
- data/processor/command/ps.rb +40 -0
- data/processor/command/restart.rb +60 -0
- data/processor/command/server.rb +72 -0
- data/processor/command/set.rb +47 -0
- data/processor/command/set_subcmd/auto.rb +27 -0
- data/processor/command/set_subcmd/auto_subcmd/dis.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/eval.rb +54 -0
- data/processor/command/set_subcmd/auto_subcmd/irb.rb +34 -0
- data/processor/command/set_subcmd/auto_subcmd/list.rb +34 -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/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 +59 -0
- data/processor/command/set_subcmd/hidelevel.rb +62 -0
- data/processor/command/set_subcmd/highlight.rb +33 -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/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/substitute.rb +24 -0
- data/processor/command/set_subcmd/substitute_subcmd/path.rb +56 -0
- data/processor/command/set_subcmd/trace.rb +36 -0
- data/processor/command/set_subcmd/trace_subcmd/print.rb +57 -0
- data/processor/command/show.rb +38 -0
- data/processor/command/show_subcmd/alias.rb +42 -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/dis.rb +37 -0
- data/processor/command/show_subcmd/auto_subcmd/eval.rb +28 -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/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/hidelevel.rb +41 -0
- data/processor/command/show_subcmd/highlight.rb +24 -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/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/trace.rb +27 -0
- data/processor/command/show_subcmd/trace_subcmd/print.rb +38 -0
- data/processor/command/show_subcmd/version.rb +23 -0
- data/processor/command/source.rb +126 -0
- data/processor/command/step.rb +84 -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 +86 -0
- data/processor/default.rb +58 -0
- data/processor/disassemble.rb +46 -0
- data/processor/display.rb +18 -0
- data/processor/eval.rb +96 -0
- data/processor/frame.rb +211 -0
- data/processor/help.rb +72 -0
- data/processor/hook.rb +133 -0
- data/processor/load_cmds.rb +185 -0
- data/processor/location.rb +137 -0
- data/processor/main.rb +412 -0
- data/processor/mock.rb +144 -0
- data/processor/msg.rb +43 -0
- data/processor/running.rb +234 -0
- data/processor/stepping.rb +114 -0
- data/processor/subcmd.rb +161 -0
- data/processor/validate.rb +355 -0
- data/sample/list-terminal-colors.rb +139 -0
- data/sample/list-terminal-colors.rbc +2318 -0
- data/sample/rocky-dot-trepanxrc +14 -0
- data/sample/rocky-trepanx-colors.rb +47 -0
- data/sample/rocky-trepanx-colors.rbc +530 -0
- data/test/data/enable.right +36 -0
- data/test/data/fname-with-blank.cmd +6 -0
- data/test/data/fname-with-blank.right +4 -0
- data/test/data/inline-call.cmd +6 -0
- data/test/data/inline-call.right +13 -0
- data/test/data/quit-Xdebug.right +3 -0
- data/test/data/quit.cmd +5 -0
- data/test/data/quit.right +2 -0
- data/test/data/quit2.cmd +6 -0
- data/test/data/quit2.right +3 -0
- data/test/data/step-bug.cmd +11 -0
- data/test/data/step-bug.right +3 -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/inline-call.rb +23 -0
- data/test/example/null.rb +1 -0
- data/test/example/step-bug.rb +14 -0
- data/test/example/thread1.rb +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 +51 -0
- data/test/functional/test-finish.rb +70 -0
- data/test/functional/test-fn_helper.rb +43 -0
- data/test/functional/test-list.rb +55 -0
- data/test/functional/test-next-bug.rb +49 -0
- data/test/functional/test-next.rb +101 -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/file-diff.rb +89 -0
- data/test/integration/helper.rb +78 -0
- data/test/integration/skip-test-step-bug.rb +17 -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/cmd-helper.rb +50 -0
- data/test/unit/mock-helper.rb +10 -0
- data/test/unit/test-app-brkpt.rb +29 -0
- data/test/unit/test-app-brkptmgr.rb +51 -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 +82 -0
- data/test/unit/test-app-run.rb +16 -0
- data/test/unit/test-app-util.rb +27 -0
- data/test/unit/test-app-validate.rb +18 -0
- data/test/unit/test-base-cmd.rb +47 -0
- data/test/unit/test-base-subcmd.rb +61 -0
- data/test/unit/test-base-submgr.rb +24 -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 +22 -0
- data/test/unit/test-cmd-exit.rb +27 -0
- data/test/unit/test-cmd-finish.rb +27 -0
- data/test/unit/test-cmd-help.rb +104 -0
- data/test/unit/test-cmd-kill.rb +47 -0
- data/test/unit/test-cmd-source.rb +34 -0
- data/test/unit/test-cmd-step.rb +29 -0
- data/test/unit/test-completion.rb +38 -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-frame.rb +79 -0
- data/test/unit/test-proc-help.rb +16 -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 +53 -0
- data/test/unit/test-proc-main.rb +99 -0
- data/test/unit/test-proc-validate.rb +91 -0
- data/test/unit/test-subcmd-help.rb +47 -0
- metadata +398 -0
@@ -0,0 +1,100 @@
|
|
1
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative './base/cmd'
|
4
|
+
|
5
|
+
class Trepan::Command::SetBreakpointCommand < Trepan::Command
|
6
|
+
|
7
|
+
ALIASES = %w(b brk)
|
8
|
+
CATEGORY = 'breakpoints'
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
HELP = <<-HELP
|
11
|
+
#{NAME}
|
12
|
+
#{NAME} [line number|offset]
|
13
|
+
#{NAME} Class[.#]method[:line-or-offset]
|
14
|
+
|
15
|
+
Sets a breakpoint. In the first form, a breakpoint is set at the
|
16
|
+
current line you are stopped at. In the second form, you give a line
|
17
|
+
number or an offset. An offset is a number that is prefaced with 'O'
|
18
|
+
or 'o' and represents a Rubinius VM PC offset.
|
19
|
+
|
20
|
+
The current method name is used for the start of the search. If a line
|
21
|
+
number is given and the line number is not found in that method,
|
22
|
+
enclosing scopes are searched for the line.
|
23
|
+
|
24
|
+
The last form is the most explicit. Use '#' to specify an instance
|
25
|
+
method and '.' to specify a class method. If a line number or offset
|
26
|
+
is omitted, we use the first line of the method.
|
27
|
+
|
28
|
+
Examples:
|
29
|
+
|
30
|
+
#{NAME} # set breakpoint at the current line
|
31
|
+
#{NAME} 5 # set breakpoint on line 5
|
32
|
+
#{NAME} O5 # set breakpoint at offset 5
|
33
|
+
#{NAME} o5 # same as above
|
34
|
+
#{NAME} Array#pop::3 # Set break at instance method 'pop' in Array, line 3
|
35
|
+
#{NAME} Trepan.start:3 # Set break in class method 'start' of Trepan, line 3
|
36
|
+
#{NAME} Trepan.start:o3 # Same as above but at offset 3, not line 3.
|
37
|
+
#{NAME} Trepan.start # Set break in class method 'start' of Trepan
|
38
|
+
|
39
|
+
See also 'tbreak', 'info breakpoint', and 'delete'.
|
40
|
+
HELP
|
41
|
+
SHORT_HELP = 'Set a breakpoint at a point in a method'
|
42
|
+
|
43
|
+
def run(args, temp=false)
|
44
|
+
arg_str = args[1..-1].join(' ')
|
45
|
+
|
46
|
+
describe, klass_name, which, name, line, ip =
|
47
|
+
@proc.breakpoint_position(args[1..-1])
|
48
|
+
event = temp ? 'tbrkpt' : 'brkpt'
|
49
|
+
opts={:event => event, :temp => temp}
|
50
|
+
if name.kind_of?(Rubinius::CompiledMethod)
|
51
|
+
bp = @proc.set_breakpoint_method(describe, name, line, ip, opts)
|
52
|
+
else
|
53
|
+
return unless klass_name
|
54
|
+
|
55
|
+
begin
|
56
|
+
klass = @proc.debug_eval(klass_name, settings[:maxstring])
|
57
|
+
rescue NameError
|
58
|
+
errmsg "Unable to find class/module: #{klass_name}"
|
59
|
+
ask_deferred klass_name, which, name, line
|
60
|
+
return
|
61
|
+
end
|
62
|
+
|
63
|
+
begin
|
64
|
+
if which == "#"
|
65
|
+
method = klass.instance_method(name)
|
66
|
+
else
|
67
|
+
method = klass.method(name)
|
68
|
+
end
|
69
|
+
rescue NameError
|
70
|
+
errmsg "Unable to find method '#{name}' in #{klass}"
|
71
|
+
ask_deferred klass_name, which, name, line
|
72
|
+
return
|
73
|
+
end
|
74
|
+
|
75
|
+
bp = @proc.set_breakpoint_method(arg_str.strip, method, line, ip, opts)
|
76
|
+
end
|
77
|
+
|
78
|
+
bp.set_temp! if temp
|
79
|
+
return bp
|
80
|
+
end
|
81
|
+
|
82
|
+
def ask_deferred(klass_name, which, name, line)
|
83
|
+
if confirm('Would you like to defer this breakpoint to later?', false)
|
84
|
+
@proc.dbgr.add_deferred_breakpoint(klass_name, which, name, line)
|
85
|
+
msg 'Deferred breakpoint created.'
|
86
|
+
else
|
87
|
+
msg 'Not confirmed.'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
if __FILE__ == $0
|
93
|
+
require_relative '../mock'
|
94
|
+
dbgr, cmd = MockDebugger::setup
|
95
|
+
cmd.run([cmd.name])
|
96
|
+
# require 'trepanning'
|
97
|
+
# Trepan.start(:set_restart => true)
|
98
|
+
cmd.run([cmd.name, __LINE__.to_s])
|
99
|
+
cmd.run([cmd.name, 'foo'])
|
100
|
+
end
|
@@ -0,0 +1,37 @@
|
|
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
|
+
@proc.complete(args[1..-1]).each do |match|
|
22
|
+
msg match
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
if __FILE__ == $0
|
28
|
+
# Demo it.
|
29
|
+
require_relative '../mock'
|
30
|
+
dbgr, cmd = MockDebugger::setup
|
31
|
+
%w(d b bt).each do |prefix|
|
32
|
+
cmd.run [cmd.name, prefix]
|
33
|
+
puts '=' * 40
|
34
|
+
end
|
35
|
+
cmd.run %w(#{cmd.name} fdafsasfda)
|
36
|
+
puts '=' * 40
|
37
|
+
end
|
@@ -0,0 +1,91 @@
|
|
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::ContinueCommand < Trepan::Command
|
7
|
+
unless defined?(HELP)
|
8
|
+
NAME = File.basename(__FILE__, '.rb')
|
9
|
+
HELP = <<-HELP
|
10
|
+
#{NAME} [breakpoint-position]
|
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. Offset are numbers prefixed with an "O" otherwise
|
18
|
+
the parameter is taken as a line number.
|
19
|
+
|
20
|
+
Examples:
|
21
|
+
#{NAME}
|
22
|
+
#{NAME} 10 # continue to line 10
|
23
|
+
#{NAME} o20 # continue to VM Instruction Sequence offset 20
|
24
|
+
#{NAME} gcd # continue to first instruction of method gcd
|
25
|
+
#{NAME} IRB.start o7 # continue to IRB.start offset 7
|
26
|
+
|
27
|
+
See also 'step', 'next', 'finish', and 'nexti' commands.
|
28
|
+
HELP
|
29
|
+
|
30
|
+
ALIASES = %w(c cont)
|
31
|
+
CATEGORY = 'running'
|
32
|
+
MAX_ARGS = 2 # Need at most this many
|
33
|
+
NEED_RUNNING = true
|
34
|
+
SHORT_HELP = 'Continue execution of the debugged program'
|
35
|
+
end
|
36
|
+
|
37
|
+
# This is the method that runs the command
|
38
|
+
def run(args)
|
39
|
+
|
40
|
+
## FIXME: DRY this code, tbreak and break.
|
41
|
+
unless args.size == 1
|
42
|
+
describe, klass_name, which, name, line, ip =
|
43
|
+
@proc.breakpoint_position(args[1..-1])
|
44
|
+
unless describe
|
45
|
+
errmsg "Can't parse temporary breakpoint location"
|
46
|
+
return
|
47
|
+
end
|
48
|
+
if name.kind_of?(Rubinius::CompiledMethod)
|
49
|
+
bp = @proc.set_breakpoint_method(describe, name, line, ip,
|
50
|
+
{:temp=>true, :event =>'tbrkpt'})
|
51
|
+
unless bp
|
52
|
+
errmsg "Trouble setting temporary breakpoint"
|
53
|
+
return
|
54
|
+
end
|
55
|
+
else
|
56
|
+
return unless klass_name
|
57
|
+
begin
|
58
|
+
klass = @proc.debug_eval(klass_name, settings[:maxstring])
|
59
|
+
rescue NameError
|
60
|
+
errmsg "Unable to find class/module: #{klass_name}"
|
61
|
+
return
|
62
|
+
end
|
63
|
+
|
64
|
+
begin
|
65
|
+
if which == "#"
|
66
|
+
method = klass.instance_method(name)
|
67
|
+
else
|
68
|
+
method = klass.method(name)
|
69
|
+
end
|
70
|
+
rescue NameError
|
71
|
+
errmsg "Unable to find method '#{name}' in #{klass}"
|
72
|
+
return
|
73
|
+
end
|
74
|
+
arg_str = args[1..-1].join(' ')
|
75
|
+
bp = @proc.set_breakpoint_method(arg_str.strip, method, line, nil,
|
76
|
+
{:temp=>true, :event =>'tbrkpt'})
|
77
|
+
unless bp
|
78
|
+
errmsg "Trouble setting temporary breakpoint"
|
79
|
+
return
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
@proc.continue('continue')
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
if __FILE__ == $0
|
88
|
+
require_relative '../mock'
|
89
|
+
dbgr, cmd = MockDebugger::setup
|
90
|
+
p cmd.run([cmd.name])
|
91
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rubygems'; require 'require_relative'
|
2
|
+
require_relative './base/cmd'
|
3
|
+
|
4
|
+
class Trepan::Command::DeleteBreakpontCommand < Trepan::Command
|
5
|
+
CATEGORY = 'breakpoints'
|
6
|
+
NAME = File.basename(__FILE__, '.rb')
|
7
|
+
SHORT_HELP = 'Delete a breakpoint'
|
8
|
+
HELP = <<-HELP
|
9
|
+
Specify the breakpoint by number, use 'info break' to see the numbers
|
10
|
+
HELP
|
11
|
+
|
12
|
+
def run(args)
|
13
|
+
if args.size != 2
|
14
|
+
errmsg 'Please specify which breakpoint by number'
|
15
|
+
return
|
16
|
+
end
|
17
|
+
|
18
|
+
begin
|
19
|
+
i = Integer(args[1])
|
20
|
+
rescue ArgumentError
|
21
|
+
errmsg "'#{args}' is not a number"
|
22
|
+
return
|
23
|
+
end
|
24
|
+
|
25
|
+
if @proc.delete_breakpoint_by_number(i)
|
26
|
+
msg('Deleted breakpoint %d.' % i)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,51 @@
|
|
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} ~/.rvm/src/rbx-head # Adds an rvm-like directory to path
|
24
|
+
#{NAME} # reset to $cdir:$cwd
|
25
|
+
HELP
|
26
|
+
|
27
|
+
SHORT_HELP =
|
28
|
+
'Add directory DIR to beginning of search path for source files'
|
29
|
+
end
|
30
|
+
|
31
|
+
# This method runs the command
|
32
|
+
def run(args) # :nodoc
|
33
|
+
if args.size > 1
|
34
|
+
path = File.expand_path(args[1])
|
35
|
+
settings[:directory] = "#{path}:#{settings[:directory]}"
|
36
|
+
msg "Source directories searched: #{settings[:directory]}"
|
37
|
+
else
|
38
|
+
if confirm('Reintialize source path to empty?', false)
|
39
|
+
settings[:directory] = '$cdir:$cwd'
|
40
|
+
msg 'Source directories searched: $cdir:$cwd'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
if __FILE__ == $0
|
47
|
+
require_relative '../mock'
|
48
|
+
dbgr, cmd = MockDebugger::setup
|
49
|
+
cmd.run([cmd.name])
|
50
|
+
cmd.run([cmd.name, '/tmp'])
|
51
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative './base/cmd'
|
5
|
+
require_relative '../../app/method'
|
6
|
+
require_relative '../../app/iseq'
|
7
|
+
|
8
|
+
class Trepan::Command::DisassembleCommand < Trepan::Command
|
9
|
+
|
10
|
+
include Trepanning::Method
|
11
|
+
|
12
|
+
NAME = File.basename(__FILE__, '.rb')
|
13
|
+
ALIASES = %w(disas disassem) # Note we (will) have disable
|
14
|
+
CATEGORY = 'data'
|
15
|
+
HELP = <<-HELP
|
16
|
+
#{NAME} [all]
|
17
|
+
#{NAME} [method|LINE-NUM]...
|
18
|
+
|
19
|
+
Disassembles Rubinius VM instructions. By default, the bytecode for the
|
20
|
+
current line is disassembled only.
|
21
|
+
|
22
|
+
If a method name is given, disassemble just that method.
|
23
|
+
|
24
|
+
If a line number given, then disassemble just that line number if it
|
25
|
+
has bytecode assocated with that line. Note that if a line has
|
26
|
+
discontinuous regions we will show just the first region associated
|
27
|
+
with that line.
|
28
|
+
|
29
|
+
If the argument is 'all', the entire method is shown as bytecode.
|
30
|
+
|
31
|
+
Examples:
|
32
|
+
#{NAME} # dissasemble VM for current line
|
33
|
+
#{NAME} all # disassemble entire current method
|
34
|
+
#{NAME} [1,2].max # disassemble max method of Array
|
35
|
+
#{NAME} Object.is_a? # disassemble Object.is_a?
|
36
|
+
#{NAME} is_a? # same as above (probably)
|
37
|
+
#{NAME} 6 # Disassemble line 6 if there is bytecode for it
|
38
|
+
#{NAME} 6 is_a? # The above two commands combined into one
|
39
|
+
HELP
|
40
|
+
|
41
|
+
NEED_STACK = true
|
42
|
+
SHORT_HELP = 'Show the bytecode for the current method'
|
43
|
+
|
44
|
+
def disassemble_method(cm)
|
45
|
+
frame_ip = (@proc.frame.method == cm) ? @proc.frame.next_ip : nil
|
46
|
+
lines = cm.lines
|
47
|
+
next_line_ip = 0
|
48
|
+
next_i = 1
|
49
|
+
prefixes = []
|
50
|
+
disasm = ''
|
51
|
+
cm.decode.each do |insn|
|
52
|
+
show_line =
|
53
|
+
if insn.ip >= next_line_ip
|
54
|
+
next_line_ip = lines.at(next_i+1)
|
55
|
+
line_no = lines.at(next_i)
|
56
|
+
next_i += 2
|
57
|
+
true
|
58
|
+
else
|
59
|
+
false
|
60
|
+
end
|
61
|
+
|
62
|
+
prefixes << Trepan::ISeq::disasm_prefix(insn.ip, frame_ip, cm)
|
63
|
+
str = insn.to_s
|
64
|
+
if show_line
|
65
|
+
str +=
|
66
|
+
if insn.instance_variable_get('@comment')
|
67
|
+
' '
|
68
|
+
elsif str[-1..-1] !~/\s/
|
69
|
+
' '
|
70
|
+
else
|
71
|
+
''
|
72
|
+
end
|
73
|
+
str += "# line: #{line_no}"
|
74
|
+
end
|
75
|
+
disasm += "#{str}\n"
|
76
|
+
end
|
77
|
+
|
78
|
+
# FIXME DRY with ../disassemble.rb
|
79
|
+
if settings[:highlight]
|
80
|
+
require_relative '../../app/rbx-llvm'
|
81
|
+
@llvm_highlighter ||= CodeRay::Duo[:llvm, :term]
|
82
|
+
# llvm_scanner = CodeRay.scanner :llvm
|
83
|
+
# p llvm_scanner.tokenize(disasm)
|
84
|
+
disasm = @llvm_highlighter.encode(disasm)
|
85
|
+
end
|
86
|
+
|
87
|
+
disasm.split("\n").each_with_index do |inst, i|
|
88
|
+
msg ("#{prefixes[i]} #{inst}", :unlimited => true)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# Run command.
|
93
|
+
def run(args)
|
94
|
+
if 1 == args.size
|
95
|
+
@proc.show_bytecode
|
96
|
+
elsif 'all' == args[1]
|
97
|
+
section "Bytecode for #{@proc.frame.vm_location.describe}"
|
98
|
+
disassemble_method(current_method)
|
99
|
+
else
|
100
|
+
args[1..-1].each do |arg|
|
101
|
+
cm = @proc.parse_method(arg)
|
102
|
+
if cm
|
103
|
+
section "Bytecode for method #{arg}"
|
104
|
+
disassemble_method(cm.executable)
|
105
|
+
else
|
106
|
+
opts = {:msg_on_error => false }
|
107
|
+
line_num = @proc.get_an_int(arg, opts)
|
108
|
+
if line_num
|
109
|
+
cm = find_method_with_line(current_method, line_num)
|
110
|
+
if cm
|
111
|
+
@proc.show_bytecode(line_num)
|
112
|
+
else
|
113
|
+
errmsg "Can't find that bytecode for line #{line_num}"
|
114
|
+
end
|
115
|
+
else
|
116
|
+
errmsg "Method #{arg} not found"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
if __FILE__ == $0
|
125
|
+
# Demo it.
|
126
|
+
require_relative '../mock'
|
127
|
+
dbgr, cmd = MockDebugger::setup
|
128
|
+
def foo(cmd)
|
129
|
+
puts "#{cmd.name}"
|
130
|
+
cmd.run([cmd.name])
|
131
|
+
puts '=' * 40
|
132
|
+
puts "#{cmd.name} all"
|
133
|
+
cmd.run([cmd.name, 'all'])
|
134
|
+
puts '=' * 40
|
135
|
+
p cmd.proc.frame.vm_location.describe
|
136
|
+
cmd.run([cmd.name, 'foo'])
|
137
|
+
puts '=' * 40
|
138
|
+
# require_relative '../../lib/trepanning'
|
139
|
+
# debugger
|
140
|
+
cmd.run([cmd.name, 'self.setup'])
|
141
|
+
puts '=' * 40
|
142
|
+
cmd.run([cmd.name, __LINE__.to_s])
|
143
|
+
end
|
144
|
+
foo(cmd)
|
145
|
+
end
|