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,75 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require 'linecache'
|
5
|
+
require 'columnize'
|
6
|
+
require_relative '../base/subcmd'
|
7
|
+
require_relative '../../../app/file'
|
8
|
+
require_relative '../../../app/complete'
|
9
|
+
|
10
|
+
class Trepan::Subcommand::InfoSource < Trepan::Subcommand
|
11
|
+
unless defined?(HELP)
|
12
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
13
|
+
DEFAULT_FILE_ARGS = %w(size mtime sha1)
|
14
|
+
|
15
|
+
HELP = <<-EOH
|
16
|
+
#{CMD}
|
17
|
+
|
18
|
+
Show information about the current source file.
|
19
|
+
EOH
|
20
|
+
MAX_ARGS = 0
|
21
|
+
MIN_ABBREV = 'so'.size # Note we have "info frame"
|
22
|
+
NEED_STACK = true
|
23
|
+
end
|
24
|
+
|
25
|
+
# completion %w(all brkpts iseq sha1 size stat)
|
26
|
+
|
27
|
+
include Trepanning
|
28
|
+
|
29
|
+
# Get file information
|
30
|
+
def run(args)
|
31
|
+
if not @proc.frame
|
32
|
+
errmsg('No frame - no default file.')
|
33
|
+
return false
|
34
|
+
end
|
35
|
+
frame_file = @proc.frame.file
|
36
|
+
filename = LineCache::map_file(frame_file) || File.expand_path(frame_file)
|
37
|
+
canonic_name = @proc.canonic_file(filename)
|
38
|
+
canonic_name = LineCache::map_file(canonic_name) || canonic_name
|
39
|
+
m = filename
|
40
|
+
if LineCache::cached?(canonic_name)
|
41
|
+
m += ' is cached in debugger'
|
42
|
+
if canonic_name != filename
|
43
|
+
m += (' as:\n ' + canonic_name)
|
44
|
+
end
|
45
|
+
m += '.'
|
46
|
+
msg(m)
|
47
|
+
end
|
48
|
+
max_line = LineCache::size(canonic_name)
|
49
|
+
msg 'File has %d lines.' % max_line if max_line
|
50
|
+
msg('SHA1 is %s.' % LineCache::sha1(canonic_name))
|
51
|
+
msg('Possible breakpoint line numbers:')
|
52
|
+
lines = LineCache.trace_line_numbers(canonic_name)
|
53
|
+
fmt_lines = columnize_numbers(lines)
|
54
|
+
msg(fmt_lines)
|
55
|
+
if cm = LineCache.compiled_method(canonic_name)
|
56
|
+
msg("File has compiled method: #{cm}")
|
57
|
+
else
|
58
|
+
msg('Compiled method not recorded; there may be some, though.')
|
59
|
+
end
|
60
|
+
msg("Stat info:\n\t%s" % LineCache::stat(canonic_name).inspect)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
if __FILE__ == $0
|
65
|
+
if !(ARGV.size == 1 && ARGV[0] == 'noload')
|
66
|
+
ISEQS__ = {}
|
67
|
+
SCRIPT_ISEQS__ = {}
|
68
|
+
ARGV[0..-1] = ['noload']
|
69
|
+
load(__FILE__)
|
70
|
+
else
|
71
|
+
require_relative '../../mock'
|
72
|
+
cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoSource, false)
|
73
|
+
cmd.run(cmd.prefix)
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,25 @@
|
|
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
|
+
|
7
|
+
class Trepan::Subcommand::InfoStack < Trepan::Subcommand
|
8
|
+
unless defined?(HELP)
|
9
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
10
|
+
HELP = 'Same thing as "backtrace"'
|
11
|
+
MIN_ABBREV = 'st'.size
|
12
|
+
NEED_STACK = true
|
13
|
+
end
|
14
|
+
|
15
|
+
def run(args)
|
16
|
+
@proc.commands['backtrace'].run(['backtrace'] + args[2..-1])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
if __FILE__ == $0
|
21
|
+
# Demo it.
|
22
|
+
require_relative '../../mock'
|
23
|
+
cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoStack, false)
|
24
|
+
cmd.run(cmd.prefix)
|
25
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../base/subsubcmd'
|
5
|
+
require_relative '../base/subsubmgr'
|
6
|
+
|
7
|
+
class Trepan::Subcommand::InfoVariables < Trepan::SubSubcommandMgr
|
8
|
+
unless defined?(HELP)
|
9
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
10
|
+
HELP = <<-EOH
|
11
|
+
#{CMD} [locals|globals|instance]
|
12
|
+
|
13
|
+
List various classes of variables for the current stack frame.
|
14
|
+
|
15
|
+
Examples:
|
16
|
+
#{CMD} locals # show local variables
|
17
|
+
#{CMD} globals # show global variables
|
18
|
+
EOH
|
19
|
+
NEED_STACK = true
|
20
|
+
SHORT_HELP = 'List names and/or values from the current stack frame'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
if __FILE__ == $0
|
25
|
+
# Demo it.
|
26
|
+
require_relative '../../mock'
|
27
|
+
dbgr, parent_cmd = MockDebugger::setup('info', false)
|
28
|
+
cmd = Trepan::Subcommand::InfoVariables.new(dbgr.processor,
|
29
|
+
parent_cmd)
|
30
|
+
cmd.run(cmd.prefix + %w(locals))
|
31
|
+
cmd.run(cmd.prefix + %w(globals name))
|
32
|
+
%w(loc glo globals i).each do |prefix|
|
33
|
+
p [prefix, cmd.complete(prefix)]
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'locals'
|
5
|
+
|
6
|
+
class Trepan::Subcommand::InfoVariablesClass <
|
7
|
+
Trepan::Subcommand::InfoVariablesLocals
|
8
|
+
Trepan::Util.suppress_warnings {
|
9
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
10
|
+
HELP = <<-EOH
|
11
|
+
#{CMD}
|
12
|
+
#{CMD} [names]
|
13
|
+
|
14
|
+
Show class variables of the current stack frame.
|
15
|
+
Normally for each which show both the name and value. If you just
|
16
|
+
want a list of names add parameter 'names'.
|
17
|
+
EOH
|
18
|
+
SHORT_HELP = 'Show instance variables of the current stack frame'
|
19
|
+
MIN_ABBREV = 'co'.size
|
20
|
+
MIN_ARGS = 0
|
21
|
+
MAX_ARGS = 1
|
22
|
+
NEED_STACK = true
|
23
|
+
}
|
24
|
+
|
25
|
+
def get_names
|
26
|
+
@proc.debug_eval_no_errmsg('self.class_variables.sort') || []
|
27
|
+
end
|
28
|
+
|
29
|
+
def run(args)
|
30
|
+
run_for_type(args, 'class', @proc.debug_eval('self'))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
if __FILE__ == $0
|
35
|
+
# Demo it.
|
36
|
+
require_relative '../../mock'
|
37
|
+
cmd =
|
38
|
+
MockDebugger::subsub_setup(Trepan::Subcommand::InfoVariables,
|
39
|
+
Trepan::Subcommand::InfoVariablesClass)
|
40
|
+
cmd.run(cmd.prefix)
|
41
|
+
cmd.run(cmd.prefix + ['name'])
|
42
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'locals'
|
5
|
+
|
6
|
+
class Trepan::Subcommand::InfoVariablesConstant <
|
7
|
+
Trepan::Subcommand::InfoVariablesLocals
|
8
|
+
Trepan::Util.suppress_warnings {
|
9
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
10
|
+
HELP = <<-EOH
|
11
|
+
#{CMD}
|
12
|
+
#{CMD} [names]
|
13
|
+
|
14
|
+
Show class constants of the current stack frame.
|
15
|
+
Normally for each which show both the name and value. If you just
|
16
|
+
want a list of names add parameter 'names'.
|
17
|
+
EOH
|
18
|
+
SHORT_HELP = 'Show class constants via the current stack frame'
|
19
|
+
MIN_ABBREV = 'co'.size
|
20
|
+
MIN_ARGS = 0
|
21
|
+
MAX_ARGS = 1
|
22
|
+
NEED_STACK = true
|
23
|
+
}
|
24
|
+
|
25
|
+
def get_names
|
26
|
+
@proc.debug_eval_no_errmsg('self.class.constants.sort') || []
|
27
|
+
end
|
28
|
+
|
29
|
+
def run(args)
|
30
|
+
run_for_type(args, 'constant', @proc.debug_eval('self'))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
if __FILE__ == $0
|
35
|
+
# Demo it.
|
36
|
+
require_relative '../../mock'
|
37
|
+
cmd =
|
38
|
+
MockDebugger::subsub_setup(Trepan::Subcommand::InfoVariables,
|
39
|
+
Trepan::Subcommand::InfoVariablesConstant)
|
40
|
+
cmd.run(cmd.prefix)
|
41
|
+
cmd.run(cmd.prefix + ['name'])
|
42
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'locals'
|
5
|
+
|
6
|
+
class Trepan::SubSubcommand::InfoVariablesGlobals < Trepan::SubSubcommand
|
7
|
+
Trepan::Util.suppress_warnings {
|
8
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
9
|
+
HELP = <<-EOH
|
10
|
+
#{CMD}
|
11
|
+
#{CMD} [names]
|
12
|
+
|
13
|
+
Show global variables.
|
14
|
+
Normally for each which show both the name and value. If you just
|
15
|
+
want a list of names add parameter 'names'.
|
16
|
+
EOH
|
17
|
+
SHORT_HELP = 'Show global variables'
|
18
|
+
MIN_ARGS = 0
|
19
|
+
MAX_ARGS = 1
|
20
|
+
NEED_STACK = true
|
21
|
+
}
|
22
|
+
|
23
|
+
def get_names
|
24
|
+
global_variables.sort
|
25
|
+
end
|
26
|
+
|
27
|
+
def run(args)
|
28
|
+
if args.size == 2
|
29
|
+
if 0 == 'names'.index(args[-1].downcase)
|
30
|
+
names = get_names()
|
31
|
+
if names.empty?
|
32
|
+
msg "No global variables defined."
|
33
|
+
else
|
34
|
+
section "Global variable names:"
|
35
|
+
width = settings[:maxwidth]
|
36
|
+
mess = Columnize::columnize(names,
|
37
|
+
@proc.settings[:maxwidth], ' ',
|
38
|
+
false, true, ' ' * 2).chomp
|
39
|
+
msg mess
|
40
|
+
end
|
41
|
+
else
|
42
|
+
errmsg("unrecognized argument: #{args[-1]}")
|
43
|
+
end
|
44
|
+
elsif args.size == 1
|
45
|
+
names = get_names
|
46
|
+
if names.empty?
|
47
|
+
msg "No global variables defined."
|
48
|
+
else
|
49
|
+
section "Global variables:"
|
50
|
+
names.each do |var_name|
|
51
|
+
s = @proc.debug_eval(var_name.to_s)
|
52
|
+
msg("#{var_name} = #{s.inspect}", :code=>true)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
else
|
56
|
+
errmsg("Wrong number of arguments #{args.size}")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
if __FILE__ == $0
|
62
|
+
# Demo it.
|
63
|
+
require_relative '../../../mock'
|
64
|
+
require_relative '../variables'
|
65
|
+
cmd = MockDebugger::subsub_setup(Trepan::Subcommand::InfoVariables,
|
66
|
+
Trepan::SubSubcommand::InfoVariablesGlobals)
|
67
|
+
cmd.run(cmd.prefix)
|
68
|
+
cmd.run(cmd.prefix + ['name'])
|
69
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'locals'
|
5
|
+
|
6
|
+
class Trepan::Subcommand::InfoVariablesInstance <
|
7
|
+
Trepan::Subcommand::InfoVariablesLocals
|
8
|
+
Trepan::Util.suppress_warnings {
|
9
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
10
|
+
HELP = <<-EOH
|
11
|
+
#{CMD}
|
12
|
+
#{CMD} [names]
|
13
|
+
|
14
|
+
Show instance variables of the current stack frame.
|
15
|
+
Normally for each which show both the name and value. If you just
|
16
|
+
want a list of names add parameter 'names'.
|
17
|
+
EOH
|
18
|
+
SHORT_HELP = 'Show instance variables of the current stack frame'
|
19
|
+
MIN_ARGS = 0
|
20
|
+
MAX_ARGS = 1
|
21
|
+
MIN_ABBREV = 'iv'.size
|
22
|
+
NEED_STACK = true
|
23
|
+
}
|
24
|
+
|
25
|
+
def get_names
|
26
|
+
@proc.debug_eval('self.instance_variables')
|
27
|
+
end
|
28
|
+
|
29
|
+
def run(args)
|
30
|
+
run_for_type(args, 'instance', @proc.debug_eval('self'))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
if __FILE__ == $0
|
35
|
+
# Demo it.
|
36
|
+
require_relative '../../mock'
|
37
|
+
cmd =
|
38
|
+
MockDebugger::subsub_setup(Trepan::Subcommand::InfoVariables,
|
39
|
+
Trepan::Subcommand::InfoVariablesInstance)
|
40
|
+
cmd.run(cmd.prefix)
|
41
|
+
cmd.run(cmd.prefix + ['name'])
|
42
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require 'columnize'
|
5
|
+
require_relative '../../base/subsubcmd'
|
6
|
+
require_relative '../../../../app/frame'
|
7
|
+
require_relative '../../../../app/util'
|
8
|
+
|
9
|
+
class Trepan::Subcommand::InfoVariablesLocals < Trepan::SubSubcommand
|
10
|
+
Trepan::Util.suppress_warnings {
|
11
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
12
|
+
HELP = <<-EOH
|
13
|
+
#{CMD}
|
14
|
+
#{CMD} [names]
|
15
|
+
|
16
|
+
Show local variables including parameters of the current stack frame.
|
17
|
+
Normally for each which show both the name and value. If you just
|
18
|
+
want a list of names add parameter 'names'.
|
19
|
+
EOH
|
20
|
+
SHORT_HELP = 'Show local variables of the current stack frame'
|
21
|
+
MIN_ARGS = 0
|
22
|
+
MAX_ARGS = 1
|
23
|
+
MIN_ABBREV = 'lo'.size
|
24
|
+
NEED_STACK = true
|
25
|
+
}
|
26
|
+
|
27
|
+
def get_names
|
28
|
+
@proc.frame.local_variables
|
29
|
+
end
|
30
|
+
|
31
|
+
def run_for_type(args, type, klass=nil)
|
32
|
+
suffix = klass ? " for #{klass.to_s}" : '' rescue ''
|
33
|
+
names = get_names()
|
34
|
+
if args.size == 2
|
35
|
+
if 0 == 'names'.index(args[-1].downcase)
|
36
|
+
names = get_names()
|
37
|
+
if names.empty?
|
38
|
+
msg "No #{type} variables defined."
|
39
|
+
else
|
40
|
+
section "#{type.capitalize} variable names#{suffix}:"
|
41
|
+
|
42
|
+
width = settings[:maxwidth]
|
43
|
+
mess = Columnize::columnize(names,
|
44
|
+
@proc.settings[:maxwidth], ' ',
|
45
|
+
false, true, ' ' * 2).chomp
|
46
|
+
msg mess
|
47
|
+
end
|
48
|
+
else
|
49
|
+
errmsg("unrecognized argument: #{args[-1]}")
|
50
|
+
end
|
51
|
+
elsif args.size == 1
|
52
|
+
if names.empty?
|
53
|
+
msg "No #{type} variables defined#{suffix}."
|
54
|
+
else
|
55
|
+
section "#{type.capitalize} variables#{suffix}:"
|
56
|
+
names.each do |var_name|
|
57
|
+
var_value =
|
58
|
+
@proc.safe_rep(@proc.debug_eval_no_errmsg(var_name).inspect)
|
59
|
+
msg("#{var_name} = #{var_value}", :code =>true)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
else
|
63
|
+
errmsg("Wrong number of arguments #{args.size}")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
def run(args)
|
67
|
+
run_for_type(args, 'local', @proc.debug_eval('self'))
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
if __FILE__ == $0
|
72
|
+
# Demo it.
|
73
|
+
require_relative '../../../mock'
|
74
|
+
require_relative '../variables'
|
75
|
+
cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::InfoVariables,
|
76
|
+
Trepan::SubSubcommand::InfoVariablesLocals
|
77
|
+
)
|
78
|
+
cmd.run([])
|
79
|
+
cmd.run(['name'])
|
80
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative '../command'
|
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]
|
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 you are in interactive mode, you are prompted to confirm killing.
|
17
|
+
However when this command is aliased from a command ending in !, no
|
18
|
+
questions are asked.
|
19
|
+
|
20
|
+
Examples:
|
21
|
+
|
22
|
+
#{NAME}
|
23
|
+
#{NAME} unconditionally
|
24
|
+
#{NAME} KILL # same as above
|
25
|
+
#{NAME} kill # same as above
|
26
|
+
#{NAME} -9 # same as above
|
27
|
+
#{NAME} 9 # same as above
|
28
|
+
#{NAME}! 9 # same as above, but no questions asked.
|
29
|
+
HELP
|
30
|
+
|
31
|
+
ALIASES = %w(kill!)
|
32
|
+
CATEGORY = 'running'
|
33
|
+
MAX_ARGS = 1 # Need at most this many
|
34
|
+
SHORT_HELP = 'Send this process a POSIX signal (default "9" is "kill -9")'
|
35
|
+
end
|
36
|
+
|
37
|
+
def complete(prefix)
|
38
|
+
completions = Signal.list.keys + Signal.list.keys.map{|k| k.downcase} +
|
39
|
+
Signal.list.values.map{|i| i.to_s} +
|
40
|
+
Signal.list.values.map{|i| (-i).to_s} +
|
41
|
+
['unconditionally']
|
42
|
+
Trepan::Complete.complete_token(completions, prefix)
|
43
|
+
end
|
44
|
+
|
45
|
+
# This method runs the command
|
46
|
+
def run(args) # :nodoc
|
47
|
+
unconditional = ('!' == args[0][-1..-1])
|
48
|
+
if args.size > 1
|
49
|
+
sig = Integer(args[1]) rescue args[1]
|
50
|
+
unless sig.is_a?(Integer) || Signal.list.member?(sig.upcase)
|
51
|
+
errmsg("Signal name '#{sig}' is not a signal I know about.\n")
|
52
|
+
return false
|
53
|
+
end
|
54
|
+
else
|
55
|
+
if not (unconditional || confirm('Really quit?', false))
|
56
|
+
msg('Kill not confirmed.')
|
57
|
+
return
|
58
|
+
else
|
59
|
+
sig = 'KILL'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
begin
|
63
|
+
@proc.intf.finalize if 'KILL' == sig || Signal.list['KILL'] == sig
|
64
|
+
Process.kill(sig, Process.pid)
|
65
|
+
rescue Errno::ESRCH, Errno::EINVAL, Errno::EPERM, RangeError
|
66
|
+
errmsg "Unable to send kill #{sig} to process #{Process.pid}: #{$!}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
if __FILE__ == $0
|
72
|
+
require_relative '../mock'
|
73
|
+
dbgr, cmd = MockDebugger::setup
|
74
|
+
%w(fooo 100 1 -1 HUP -9).each do |arg|
|
75
|
+
puts "#{cmd.name} #{arg}"
|
76
|
+
cmd.run([cmd.name, arg])
|
77
|
+
puts '=' * 40
|
78
|
+
end
|
79
|
+
end
|