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,49 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../base/subcmd'
|
5
|
+
|
6
|
+
class Trepan::Subcommand::InfoProgram < Trepan::Subcommand
|
7
|
+
unless defined?(HELP)
|
8
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
9
|
+
HELP = 'Information about debugged program and its environment'
|
10
|
+
MIN_ABBREV = 'pr'.size
|
11
|
+
NEED_STACK = true
|
12
|
+
end
|
13
|
+
|
14
|
+
def run(args)
|
15
|
+
frame = @proc.frame
|
16
|
+
## m = 'Program stop event: %s' % @proc.core.event
|
17
|
+
m = ''
|
18
|
+
m += "Frame index #{@proc.frame_index}, " if @proc.frame_index != 0
|
19
|
+
m +=
|
20
|
+
if frame.method
|
21
|
+
"PC offset %d of method: %s" %
|
22
|
+
[frame.next_ip, frame.method.name]
|
23
|
+
else
|
24
|
+
## '.'
|
25
|
+
end
|
26
|
+
msg m
|
27
|
+
# if 'return' == @proc.core.event
|
28
|
+
# msg 'R=> %s' % @proc.frame.sp(1).inspect
|
29
|
+
# elsif 'raise' == @proc.core.event
|
30
|
+
# msg @proc.core.hook_arg.inspect if @proc.core.hook_arg
|
31
|
+
# end
|
32
|
+
|
33
|
+
if @proc.brkpt && @proc.brkpt.event == :Breakpoint
|
34
|
+
msg('It stopped at %sbreakpoint %d.' %
|
35
|
+
[@proc.brkpt.temp? ? 'temporary ' : '',
|
36
|
+
@proc.brkpt.id])
|
37
|
+
else
|
38
|
+
msg("Program stopped at a #{@proc.event} event.")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
if __FILE__ == $0
|
45
|
+
# Demo it.
|
46
|
+
require_relative '../../mock'
|
47
|
+
cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoProgram, false)
|
48
|
+
cmd.run(cmd.prefix)
|
49
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../base/subcmd'
|
5
|
+
|
6
|
+
class Trepan::Subcommand::InfoRuby < Trepan::Subcommand
|
7
|
+
unless defined?(HELP)
|
8
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
9
|
+
HELP = <<-EOH
|
10
|
+
#{CMD=PREFIX.join(' ')} [-v|--verbose|-no-verbose]
|
11
|
+
|
12
|
+
Show Ruby version information such as you'd get from
|
13
|
+
"rbx -v" (which is really just the value of RUBY_RELEASE_DATE),
|
14
|
+
or from "rbx -vv".
|
15
|
+
|
16
|
+
See also constants: RUBY_DESCRIPITON, RUBY_VERSION, and RUBY_RELEASE_DATE."
|
17
|
+
EOH
|
18
|
+
MIN_ABBREV = 'ru'.size
|
19
|
+
NEED_STACK = false
|
20
|
+
SHORT_HELP = 'Ruby version information'
|
21
|
+
end
|
22
|
+
|
23
|
+
def parse_options(args) # :nodoc
|
24
|
+
options = {}
|
25
|
+
parser = OptionParser.new do |opts|
|
26
|
+
opts.on("-v",
|
27
|
+
"--[no-]verbose", "show additional version information") do
|
28
|
+
|v|
|
29
|
+
options[:verbose] = v
|
30
|
+
end
|
31
|
+
end
|
32
|
+
parser.parse(args)
|
33
|
+
return options
|
34
|
+
end
|
35
|
+
|
36
|
+
def run(args)
|
37
|
+
options = parse_options(args[2..-1])
|
38
|
+
msg RUBY_DESCRIPTION
|
39
|
+
if options[:verbose]
|
40
|
+
msg "Options:"
|
41
|
+
msg " Interpreter type: #{Rubinius::INTERPRETER}"
|
42
|
+
if jit = Rubinius::JIT
|
43
|
+
msg " JIT enabled: #{jit.join(', ')}"
|
44
|
+
else
|
45
|
+
msg " JIT disabled"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
if __FILE__ == $0
|
53
|
+
# Demo it.
|
54
|
+
$0 = __FILE__ + 'notagain' # So we don't run this again
|
55
|
+
require_relative '../../mock'
|
56
|
+
cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoRuby, false)
|
57
|
+
cmd.run(cmd.prefix)
|
58
|
+
%w(-v --verbose --no-verbose).each do |opt|
|
59
|
+
puts '-' * 10 + " #{opt}"
|
60
|
+
cmd.run(cmd.prefix + [opt])
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../base/subcmd'
|
5
|
+
|
6
|
+
class Trepan::Command::InfoVariables < Trepan::Subcommand
|
7
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
8
|
+
MIN_ABBREV = 'var'.size
|
9
|
+
NEED_STACK = true
|
10
|
+
SHORT_HELP = 'Display the value of a variable or variables'
|
11
|
+
HELP = <<-HELP
|
12
|
+
Show debugger variables and user created variables. By default,
|
13
|
+
shows all variables.
|
14
|
+
|
15
|
+
The optional argument is which variable specifically to show the value of.
|
16
|
+
HELP
|
17
|
+
|
18
|
+
def run(args)
|
19
|
+
if args.size == 2
|
20
|
+
@proc.dbgr.variables.each do |name, val|
|
21
|
+
msg "var '#{name}' = #{val.inspect}"
|
22
|
+
end
|
23
|
+
|
24
|
+
if @proc.dbgr.user_variables > 0
|
25
|
+
section "User variables"
|
26
|
+
(0...@proc.dbgr.user_variables).each do |i|
|
27
|
+
str = "$d#{i}"
|
28
|
+
val = Rubinius::Globals[str.to_sym]
|
29
|
+
msg "var #{str} = #{val.inspect}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
else
|
33
|
+
var = args[2]
|
34
|
+
if @proc.dbgr.variables.key?(var)
|
35
|
+
msg "var '#{var}' = #{variables[var].inspect}"
|
36
|
+
else
|
37
|
+
errmsg "No variable set named '#{var}'"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
if __FILE__ == $0
|
44
|
+
# Demo it.
|
45
|
+
require_relative '../../mock'
|
46
|
+
cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoVariables, false)
|
47
|
+
# cmd.run(cmd.prefix)
|
48
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'irb'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'base/cmd'
|
5
|
+
require_relative '../../app/irb'
|
6
|
+
class Trepan::Command::IRBCommand < Trepan::Command
|
7
|
+
|
8
|
+
unless defined?(HELP)
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
HELP = <<-HELP
|
11
|
+
#{NAME} [-d]\tstarts an Interactive Ruby (IRB) session.
|
12
|
+
|
13
|
+
If -d is added you can get access to debugger frame the global variables
|
14
|
+
$trepanx_frame and $trepanx_cmdproc.
|
15
|
+
|
16
|
+
#{NAME} is extended with methods 'cont', 'ne', and, 'q', 'step' which
|
17
|
+
run the corresponding debugger commands 'continue', 'next', 'exit' and 'step'.
|
18
|
+
|
19
|
+
To issue a debugger command, inside #{NAME} nested inside a debugger use
|
20
|
+
'dbgr'. For example:
|
21
|
+
|
22
|
+
dbgr %w(info program)
|
23
|
+
dbgr('info', 'program') # Same as above
|
24
|
+
dbgr 'info program' # Single quoted string also works
|
25
|
+
|
26
|
+
But arguments have to be quoted because #{NAME} will evaluate them:
|
27
|
+
|
28
|
+
dbgr info program # wrong!
|
29
|
+
dbgr info, program # wrong!
|
30
|
+
dbgr(info, program) # What I say 3 times is wrong!
|
31
|
+
|
32
|
+
Here then is a loop to query VM stack values:
|
33
|
+
(-1..1).each {|i| dbgr(\"info reg sp \#{i}\")}
|
34
|
+
HELP
|
35
|
+
|
36
|
+
CATEGORY = 'support'
|
37
|
+
MAX_ARGS = 1 # Need at most this many
|
38
|
+
SHORT_HELP = "Run #{NAME} as a command subshell"
|
39
|
+
end
|
40
|
+
|
41
|
+
# This method runs the command
|
42
|
+
def run(args)
|
43
|
+
add_debugging =
|
44
|
+
if args.size > 1
|
45
|
+
'-d' == args[1]
|
46
|
+
else
|
47
|
+
false
|
48
|
+
end
|
49
|
+
|
50
|
+
# unless @state.interface.kind_of?(LocalInterface)
|
51
|
+
# print "Command is available only in local mode.\n"
|
52
|
+
# throw :debug_error
|
53
|
+
# end
|
54
|
+
|
55
|
+
save_trap = trap('SIGINT') do
|
56
|
+
throw :IRB_EXIT, :cont if $trepanx_in_irb
|
57
|
+
end
|
58
|
+
|
59
|
+
$trepanx = @proc.dbgr
|
60
|
+
if add_debugging
|
61
|
+
$trepanx_cmdproc = @proc
|
62
|
+
$trepanx_frame = @proc.frame
|
63
|
+
end
|
64
|
+
$trepanx_in_irb = true
|
65
|
+
$trepanx_irb_statements = nil
|
66
|
+
$trepanx_command = nil
|
67
|
+
|
68
|
+
conf = {:BACK_TRACE_LIMIT => settings[:maxstack],
|
69
|
+
:RC => true}
|
70
|
+
|
71
|
+
# ?? Should we set GNU readline to what we have,
|
72
|
+
# or let IRB make its own determination?
|
73
|
+
|
74
|
+
# Save the Readline history and set the Readline completion function
|
75
|
+
# to be IRB's function
|
76
|
+
if Trepan::GNU_readline?
|
77
|
+
@proc.intf.save_history if @proc.intf.respond_to?(:save_history)
|
78
|
+
require 'irb/completion'
|
79
|
+
Readline.completion_proc = IRB::InputCompletor::CompletionProc
|
80
|
+
end
|
81
|
+
|
82
|
+
# And just when you thought, we'd never get around to
|
83
|
+
# actually running irb...
|
84
|
+
cont = IRB.start_session(@proc.frame.binding, @proc, conf)
|
85
|
+
trap('SIGINT', save_trap) # Restore our old interrupt function.
|
86
|
+
|
87
|
+
# Restore the debuggers' Readline history and the Readline completion
|
88
|
+
# function
|
89
|
+
if Trepan::GNU_readline? && @proc.dbgr.completion_proc
|
90
|
+
@proc.intf.read_history if @proc.intf.respond_to?(:read_history)
|
91
|
+
Readline.completion_proc = @proc.dbgr.completion_proc
|
92
|
+
end
|
93
|
+
|
94
|
+
# Respect any backtrace limit set in irb.
|
95
|
+
back_trace_limit = IRB.CurrentContext.back_trace_limit
|
96
|
+
if settings[:maxstack] != back_trace_limit
|
97
|
+
msg("\nSetting debugger's BACK_TRACE_LIMIT (%d) to match irb's last setting (%d)" %
|
98
|
+
[settings[:maxstack], back_trace_limit])
|
99
|
+
settings[:maxstack]= IRB.CurrentContext.back_trace_limit
|
100
|
+
end
|
101
|
+
|
102
|
+
case cont
|
103
|
+
when :continue
|
104
|
+
@proc.continue
|
105
|
+
when :finish
|
106
|
+
@proc.finish
|
107
|
+
when :next
|
108
|
+
@proc.next # (1, {})
|
109
|
+
when :quit
|
110
|
+
@proc.quit
|
111
|
+
when :step
|
112
|
+
@proc.step # (1, {})
|
113
|
+
else
|
114
|
+
@proc.print_location
|
115
|
+
end
|
116
|
+
ensure
|
117
|
+
$trepanx_in_irb = false
|
118
|
+
# restore old trap if any
|
119
|
+
trap('SIGINT', save_trap) if save_trap
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
if __FILE__ == $0
|
124
|
+
require_relative '../mock'
|
125
|
+
dbgr, cmd = MockDebugger::setup
|
126
|
+
# Get an IRB session -- the hard way :-)
|
127
|
+
cmd.run([cmd.name]) if ARGV.size > 0
|
128
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative 'base/cmd'
|
4
|
+
class Trepan::Command::KillCommand < Trepan::Command
|
5
|
+
|
6
|
+
unless defined?(HELP)
|
7
|
+
NAME = File.basename(__FILE__, '.rb')
|
8
|
+
HELP = <<-HELP
|
9
|
+
#{NAME} [signal-number|signal-name|unconditionally]
|
10
|
+
|
11
|
+
Kill execution of program being debugged.
|
12
|
+
|
13
|
+
Equivalent of Process.kill('KILL', Process.pid). This is an unmaskable
|
14
|
+
signal. When all else fails, e.g. in thread code, use this.
|
15
|
+
|
16
|
+
If 'unconditionally' is given, no questions are asked. Otherwise, if
|
17
|
+
we are in interactive mode, we'll prompt to make sure.
|
18
|
+
|
19
|
+
Examples:
|
20
|
+
|
21
|
+
#{NAME}
|
22
|
+
#{NAME} unconditionally
|
23
|
+
#{NAME} KILL # same as above
|
24
|
+
#{NAME} kill # same as above
|
25
|
+
#{NAME} -9 # same as above
|
26
|
+
#{NAME} 9 # same as above
|
27
|
+
HELP
|
28
|
+
|
29
|
+
CATEGORY = 'running'
|
30
|
+
MAX_ARGS = 1 # Need at most this many
|
31
|
+
SHORT_HELP = 'Send this process a POSIX signal (default "9" is "kill -9")'
|
32
|
+
end
|
33
|
+
|
34
|
+
# This method runs the command
|
35
|
+
def run(args) # :nodoc
|
36
|
+
if args.size > 1
|
37
|
+
sig = Integer(args[1]) rescue args[1]
|
38
|
+
unless sig.is_a?(Integer) || Signal.list.member?(sig.upcase)
|
39
|
+
errmsg("Signal name '#{sig}' is not a signal I know about.\n")
|
40
|
+
return false
|
41
|
+
end
|
42
|
+
# FIXME: reinstate
|
43
|
+
# if 'KILL' == sig || Signal['KILL'] == sig
|
44
|
+
# @proc.intf.finalize
|
45
|
+
# end
|
46
|
+
else
|
47
|
+
if not confirm('Really kill?', false)
|
48
|
+
msg('Kill not confirmed.')
|
49
|
+
return
|
50
|
+
else
|
51
|
+
sig = 'KILL'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
begin
|
55
|
+
Process.kill(sig, Process.pid)
|
56
|
+
rescue Errno::ESRCH
|
57
|
+
errmsg "Unable to send kill #{sig} to process #{Process.pid}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
if __FILE__ == $0
|
63
|
+
require_relative '../mock'
|
64
|
+
dbgr, cmd = MockDebugger::setup
|
65
|
+
%w(fooo 1 -1 HUP -9).each do |arg|
|
66
|
+
puts "#{cmd.name} #{arg}"
|
67
|
+
cmd.run([cmd.name, arg])
|
68
|
+
puts '=' * 40
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,300 @@
|
|
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 'base/cmd'
|
7
|
+
|
8
|
+
class Trepan::Command::ListCommand < Trepan::Command
|
9
|
+
unless defined?(HELP)
|
10
|
+
NAME = File.basename(__FILE__, '.rb')
|
11
|
+
HELP = <<-HELP
|
12
|
+
#{NAME}[>] [FIRST [NUM]]
|
13
|
+
#{NAME}[>] LOCATION [NUM]
|
14
|
+
|
15
|
+
#{NAME} source code.
|
16
|
+
|
17
|
+
Without arguments, prints lines centered around the current
|
18
|
+
line. If this is the first #{NAME} command issued since the debugger
|
19
|
+
command loop was entered, then the current line is the current
|
20
|
+
frame. If a subsequent #{NAME} command was issued with no intervening
|
21
|
+
frame changing, then that is start the line after we last one
|
22
|
+
previously shown.
|
23
|
+
|
24
|
+
If the command has a '>' suffix, then line centering is disabled and
|
25
|
+
listing begins at the specificed location.
|
26
|
+
|
27
|
+
The number of lines to show is controlled by the debugger "list size"
|
28
|
+
setting. Use 'set max list' or 'show max list' to see or set the
|
29
|
+
value.
|
30
|
+
|
31
|
+
\"#{NAME} -\" shows lines before a previous listing.
|
32
|
+
|
33
|
+
A LOCATION is a either
|
34
|
+
- number, e.g. 5,
|
35
|
+
- a function, e.g. join or os.path.join
|
36
|
+
- a module, e.g. os or os.path
|
37
|
+
- a filename, colon, and a number, e.g. foo.rb:5,
|
38
|
+
- or a module name and a number, e.g,. os.path:5.
|
39
|
+
- a '.' for the current line number
|
40
|
+
- a '-' for the lines before the current line number
|
41
|
+
|
42
|
+
If the location form is used with a subsequent parameter, the
|
43
|
+
parameter is the starting line number. When there two numbers are
|
44
|
+
given, the last number value is treated as a stopping line unless it
|
45
|
+
is less than the start line, in which case it is taken to mean the
|
46
|
+
number of lines to list instead.
|
47
|
+
|
48
|
+
Wherever a number is expected, it does not need to be a constant --
|
49
|
+
just something that evaluates to a positive integer.
|
50
|
+
|
51
|
+
Some examples:
|
52
|
+
|
53
|
+
#{NAME} 5 # List centered around line 5
|
54
|
+
#{NAME} 4+1 # Same as above.
|
55
|
+
#{NAME} 5> # List starting at line 5
|
56
|
+
#{NAME} foo.rb:5 # List centered around line 5 of foo.rb
|
57
|
+
#{NAME} foo.rb 5 # Same as above.
|
58
|
+
#{NAME} foo.rb:5> # List starting around line 5 of foo.rb
|
59
|
+
#{NAME} foo.rb 5 6 # list lines 5 and 6 of foo.rb
|
60
|
+
#{NAME} foo.rb 5 2 # Same as above, since 2 < 5.
|
61
|
+
#{NAME} foo.rb:5 2 # Same as above
|
62
|
+
#{NAME} FileUtils.cp # List lines around the FileUtils.cp function.
|
63
|
+
#{NAME} . # List lines centered from where we currently are stopped
|
64
|
+
#{NAME} . 3 # List 3 lines starting from where we currently are stopped
|
65
|
+
# if . > 3. Otherwise we list from . to 3.
|
66
|
+
#{NAME} - # List lines previous to those just shown
|
67
|
+
|
68
|
+
HELP
|
69
|
+
|
70
|
+
ALIASES = %W(l #{NAME}> l>)
|
71
|
+
CATEGORY = 'files'
|
72
|
+
MAX_ARGS = 3
|
73
|
+
SHORT_HELP = 'List source code'
|
74
|
+
end
|
75
|
+
|
76
|
+
# If last is less than first, assume last is a count rather than an
|
77
|
+
# end line number.
|
78
|
+
def adjust_last(first, last)
|
79
|
+
last < first ? first + last - 1 : last
|
80
|
+
end
|
81
|
+
|
82
|
+
# What a f*cking mess. Necessitated I suppose because we want to
|
83
|
+
# allow somewhat flexible parsing with either module names, files or none
|
84
|
+
# and optional line counts or end-line numbers.
|
85
|
+
|
86
|
+
# Parses arguments for the "list" command and returns the tuple:
|
87
|
+
# filename, start, last
|
88
|
+
# or sets these to nil if there was some problem.
|
89
|
+
def parse_list_cmd(args, listsize, center_correction)
|
90
|
+
|
91
|
+
last = nil
|
92
|
+
|
93
|
+
if args.size > 0
|
94
|
+
if args[0] == '-'
|
95
|
+
return no_frame_msg unless @proc.line_no
|
96
|
+
first = [1, @proc.line_no - 2*listsize - 1].max
|
97
|
+
file = @proc.frame.file
|
98
|
+
elsif args[0] == '.'
|
99
|
+
return no_frame_msg unless @proc.line_no
|
100
|
+
if args.size == 2
|
101
|
+
opts = {
|
102
|
+
:msg_on_error =>
|
103
|
+
"#{NAME} command last or count parameter expected, " +
|
104
|
+
'got: %s.' % args[2]
|
105
|
+
}
|
106
|
+
second = @proc.get_an_int(args[1], opts)
|
107
|
+
return nil, nil, nil unless second
|
108
|
+
first = @proc.frame.line
|
109
|
+
last = adjust_last(first, second)
|
110
|
+
else
|
111
|
+
first = [1, @proc.frame.line - center_correction].max
|
112
|
+
end
|
113
|
+
|
114
|
+
file = @proc.frame.file
|
115
|
+
else
|
116
|
+
modfunc, file, first = @proc.parse_position(args[0])
|
117
|
+
if first == nil and modfunc == nil
|
118
|
+
# error should have been shown previously
|
119
|
+
return nil, nil, nil
|
120
|
+
end
|
121
|
+
if args.size == 1
|
122
|
+
first = 1 if !first and modfunc
|
123
|
+
first = [1, first - center_correction].max
|
124
|
+
elsif args.size == 2 or (args.size == 3 and modfunc)
|
125
|
+
opts = {
|
126
|
+
:msg_on_error =>
|
127
|
+
"#{NAME} command starting line expected, got %s." % args[-1]
|
128
|
+
}
|
129
|
+
last = @proc.get_an_int(args[1], opts)
|
130
|
+
return nil, nil, nil unless last
|
131
|
+
if modfunc
|
132
|
+
if first
|
133
|
+
first = last
|
134
|
+
if args.size == 3 and modfunc
|
135
|
+
opts[:msg_on_error] =
|
136
|
+
("#{NAME} command last or count parameter expected, " +
|
137
|
+
'got: %s.' % args[2])
|
138
|
+
last = @proc.get_an_int(args[2], opts)
|
139
|
+
return nil, nil, nil unless last
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
last = adjust_last(first, last)
|
144
|
+
elsif not modfunc
|
145
|
+
errmsg('At most 2 parameters allowed when no module' +
|
146
|
+
' name is found/given. Saw: %d parameters' % args.size)
|
147
|
+
return nil, nil, nil
|
148
|
+
else
|
149
|
+
errmsg(('At most 3 parameters allowed when a module' +
|
150
|
+
' name is given. Saw: %d parameters') % args.size)
|
151
|
+
return nil, nil, nil
|
152
|
+
end
|
153
|
+
end
|
154
|
+
elsif !@proc.line_no and @proc.frame
|
155
|
+
first = [1, @proc.frame.line - center_correction].max
|
156
|
+
file = @proc.frame.file
|
157
|
+
else
|
158
|
+
first = [1, @proc.line_no - center_correction].max
|
159
|
+
file = @proc.frame.file
|
160
|
+
end
|
161
|
+
last = first + listsize - 1 unless last
|
162
|
+
|
163
|
+
if @proc.frame.eval?
|
164
|
+
script = @proc.frame.vm_location.static_scope.script
|
165
|
+
LineCache::cache(script)
|
166
|
+
else
|
167
|
+
LineCache::cache(file)
|
168
|
+
script = nil
|
169
|
+
end
|
170
|
+
return file, script, first, last
|
171
|
+
end
|
172
|
+
|
173
|
+
def no_frame_msg
|
174
|
+
errmsg("No Ruby program loaded.")
|
175
|
+
return nil, nil, nil
|
176
|
+
end
|
177
|
+
|
178
|
+
def run(args)
|
179
|
+
listsize = settings[:maxlist]
|
180
|
+
center_correction =
|
181
|
+
if args[0][-1..-1] == '>'
|
182
|
+
0
|
183
|
+
else
|
184
|
+
(listsize-1) / 2
|
185
|
+
end
|
186
|
+
|
187
|
+
file, script, first, last =
|
188
|
+
parse_list_cmd(args[1..-1], listsize, center_correction)
|
189
|
+
frame = @proc.frame
|
190
|
+
return unless file
|
191
|
+
|
192
|
+
cached_item = script || file
|
193
|
+
|
194
|
+
# We now have range information. Do the listing.
|
195
|
+
max_line = LineCache::size(cached_item)
|
196
|
+
|
197
|
+
# FIXME: join with line_at of location.rb
|
198
|
+
unless max_line && file
|
199
|
+
# Try using search directories (set with command "directory")
|
200
|
+
if file[0..0] != File::SEPARATOR
|
201
|
+
try_filename = @proc.resolve_file_with_dir(file)
|
202
|
+
if try_filename &&
|
203
|
+
max_line = LineCache::size(try_filename)
|
204
|
+
LineCache::remap_file(file, try_filename)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
unless max_line
|
210
|
+
errmsg('File "%s" not found.' % file)
|
211
|
+
return
|
212
|
+
end
|
213
|
+
|
214
|
+
if first > max_line
|
215
|
+
errmsg('Bad line range [%d...%d]; file "%s" has only %d lines' %
|
216
|
+
[first, last, file, max_line])
|
217
|
+
return
|
218
|
+
end
|
219
|
+
|
220
|
+
if last > max_line
|
221
|
+
# msg('End position changed to last line %d ' % max_line)
|
222
|
+
last = max_line
|
223
|
+
end
|
224
|
+
|
225
|
+
begin
|
226
|
+
opts = {
|
227
|
+
:reload_on_change => @proc.reload_on_change,
|
228
|
+
:output => settings[:highlight]
|
229
|
+
}
|
230
|
+
first.upto(last).each do |lineno|
|
231
|
+
line = LineCache::getline(cached_item, lineno, opts)
|
232
|
+
unless line
|
233
|
+
msg('[EOF]')
|
234
|
+
break
|
235
|
+
end
|
236
|
+
line.chomp!
|
237
|
+
s = '%3d' % lineno
|
238
|
+
s = s + ' ' if s.size < 4
|
239
|
+
s += (@proc.frame && lineno == @proc.frame.vm_location.line) ? '->' : ' '
|
240
|
+
# && container == frame.source_container)
|
241
|
+
msg(s + "\t" + line, {:unlimited => true})
|
242
|
+
@proc.line_no = lineno
|
243
|
+
end
|
244
|
+
rescue => e
|
245
|
+
errmsg e.to_s if settings[:debugexcept]
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
if __FILE__ == $0
|
251
|
+
require_relative '../location'
|
252
|
+
require_relative '../mock'
|
253
|
+
require_relative '../frame'
|
254
|
+
dbgr, cmd = MockDebugger::setup
|
255
|
+
cmd.proc.send('frame_initialize')
|
256
|
+
LineCache::cache(__FILE__)
|
257
|
+
require 'trepanning'
|
258
|
+
cmd.run([cmd.name])
|
259
|
+
cmd.run([cmd.name, __FILE__ + ':10'])
|
260
|
+
|
261
|
+
def run_cmd(cmd, args)
|
262
|
+
seps = '--' * 10
|
263
|
+
puts "%s %s %s" % [seps, args.join(' '), seps]
|
264
|
+
cmd.run(args)
|
265
|
+
end
|
266
|
+
|
267
|
+
|
268
|
+
load 'tmpdir.rb'
|
269
|
+
run_cmd(cmd, %W(#{cmd.name} tmpdir.rb 10))
|
270
|
+
run_cmd(cmd, %W(#{cmd.name} tmpdir.rb))
|
271
|
+
|
272
|
+
run_cmd(cmd, %W(cmd.name .))
|
273
|
+
run_cmd(cmd, %W(cmd.name 30))
|
274
|
+
|
275
|
+
# cmd.run(['list', '9+1'])
|
276
|
+
|
277
|
+
run_cmd(cmd, %W(cmd.name> 10))
|
278
|
+
run_cmd(cmd, %W(cmd.name 3000))
|
279
|
+
run_cmd(cmd, %W(cmd.name run_cmd))
|
280
|
+
|
281
|
+
p = Proc.new do
|
282
|
+
|x,y| x + y
|
283
|
+
end
|
284
|
+
run_cmd(cmd, %W(#{cmd.name} p))
|
285
|
+
|
286
|
+
# Function from a file found via an instruction sequence
|
287
|
+
run_cmd(cmd, %W(#{cmd.name} Columnize.columnize))
|
288
|
+
|
289
|
+
# Use Class/method name. 15 isn't in the function - should this be okay?
|
290
|
+
run_cmd(cmd, %W(#{cmd.name} Columnize.columnize 15))
|
291
|
+
|
292
|
+
# Start line and count, since 3 < 30
|
293
|
+
run_cmd(cmd, %W(#{cmd.name} Columnize.columnize 30 3))
|
294
|
+
|
295
|
+
# Start line finish line
|
296
|
+
run_cmd(cmd, %W(#{cmd.name} Columnize.columnize 40 50))
|
297
|
+
|
298
|
+
# Method name
|
299
|
+
run_cmd(cmd, %W(#{cmd.name} cmd.run))
|
300
|
+
end
|