rb8-trepanning 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -0
- data/CHANGES +34 -0
- data/ChangeLog +875 -0
- data/README.textile +59 -0
- data/Rakefile +215 -0
- data/app/.gitignore +1 -0
- data/app/cmd_parse.kpeg +241 -0
- data/app/cmd_parse.rb +212 -0
- data/app/cmd_parser.rb +1948 -0
- data/app/complete.rb +79 -0
- data/app/default.rb +90 -0
- data/app/display.rb +148 -0
- data/app/eventbuffer.rb +147 -0
- data/app/frame.rb +166 -0
- data/app/irb.rb +114 -0
- data/app/options.rb +200 -0
- data/app/run.rb +74 -0
- data/app/util.rb +65 -0
- data/bin/.gitignore +1 -0
- data/bin/trepan8 +115 -0
- data/data/.gitignore +1 -0
- data/data/irbrc +41 -0
- data/interface/.gitignore +1 -0
- data/interface/base_intf.rb +109 -0
- data/interface/client.rb +82 -0
- data/interface/comcodes.rb +20 -0
- data/interface/script.rb +110 -0
- data/interface/server.rb +147 -0
- data/interface/user.rb +165 -0
- data/io/base_io.rb +148 -0
- data/io/input.rb +158 -0
- data/io/null_output.rb +46 -0
- data/io/string_array.rb +156 -0
- data/io/tcpclient.rb +129 -0
- data/io/tcpfns.rb +33 -0
- data/io/tcpserver.rb +141 -0
- data/lib/debugger.rb +8 -0
- data/lib/trepanning.rb +283 -0
- data/processor/.gitignore +1 -0
- data/processor/command-ruby-debug/breakpoints.rb +155 -0
- data/processor/command-ruby-debug/catchpoint.rb +55 -0
- data/processor/command-ruby-debug/condition.rb +49 -0
- data/processor/command-ruby-debug/control.rb +31 -0
- data/processor/command-ruby-debug/display.rb +120 -0
- data/processor/command-ruby-debug/enable.rb +202 -0
- data/processor/command-ruby-debug/frame.rb +199 -0
- data/processor/command-ruby-debug/help.rb +63 -0
- data/processor/command-ruby-debug/info.rb +359 -0
- data/processor/command-ruby-debug/method.rb +84 -0
- data/processor/command-ruby-debug/reload.rb +40 -0
- data/processor/command-ruby-debug/save.rb +90 -0
- data/processor/command-ruby-debug/set.rb +237 -0
- data/processor/command-ruby-debug/show.rb +251 -0
- data/processor/command-ruby-debug/source.rb +36 -0
- data/processor/command-ruby-debug/threads.rb +189 -0
- data/processor/command-ruby-debug/trace.rb +57 -0
- data/processor/command-ruby-debug/variables.rb +199 -0
- data/processor/command.rb +270 -0
- data/processor/command/.gitignore +1 -0
- data/processor/command/alias.rb +54 -0
- data/processor/command/backtrace.rb +123 -0
- data/processor/command/base/cmd.rb +177 -0
- data/processor/command/base/subcmd.rb +230 -0
- data/processor/command/base/submgr.rb +188 -0
- data/processor/command/base/subsubcmd.rb +128 -0
- data/processor/command/base/subsubmgr.rb +199 -0
- data/processor/command/break.rb +114 -0
- data/processor/command/catch.rb +71 -0
- data/processor/command/complete.rb +39 -0
- data/processor/command/continue.rb +57 -0
- data/processor/command/directory.rb +50 -0
- data/processor/command/disable.rb +85 -0
- data/processor/command/display.rb +78 -0
- data/processor/command/down.rb +54 -0
- data/processor/command/edit.rb +79 -0
- data/processor/command/enable.rb +48 -0
- data/processor/command/eval.rb +90 -0
- data/processor/command/exit.rb +66 -0
- data/processor/command/finish.rb +59 -0
- data/processor/command/frame.rb +97 -0
- data/processor/command/help.rb +230 -0
- data/processor/command/help/.gitignore +1 -0
- data/processor/command/help/README +10 -0
- data/processor/command/help/command.txt +58 -0
- data/processor/command/help/examples.txt +16 -0
- data/processor/command/help/filename.txt +40 -0
- data/processor/command/help/location.txt +37 -0
- data/processor/command/help/suffixes.txt +17 -0
- data/processor/command/info.rb +28 -0
- data/processor/command/info_subcmd/.gitignore +1 -0
- data/processor/command/info_subcmd/args.rb +39 -0
- data/processor/command/info_subcmd/breakpoints.rb +80 -0
- data/processor/command/info_subcmd/catch.rb +36 -0
- data/processor/command/info_subcmd/files.rb +39 -0
- data/processor/command/info_subcmd/globals.rb +64 -0
- data/processor/command/info_subcmd/line.rb +30 -0
- data/processor/command/info_subcmd/locals.rb +69 -0
- data/processor/command/info_subcmd/macro.rb +62 -0
- data/processor/command/info_subcmd/program.rb +51 -0
- data/processor/command/info_subcmd/ruby.rb +57 -0
- data/processor/command/info_subcmd/source.rb +74 -0
- data/processor/command/info_subcmd/stack.rb +25 -0
- data/processor/command/info_subcmd/threads.rb +75 -0
- data/processor/command/kill.rb +78 -0
- data/processor/command/list.rb +117 -0
- data/processor/command/macro.rb +68 -0
- data/processor/command/next.rb +79 -0
- data/processor/command/parsetree.rb +56 -0
- data/processor/command/pp.rb +40 -0
- data/processor/command/pr.rb +37 -0
- data/processor/command/ps.rb +40 -0
- data/processor/command/restart.rb +86 -0
- data/processor/command/save.rb +58 -0
- data/processor/command/set.rb +47 -0
- data/processor/command/set_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/abbrev.rb +25 -0
- data/processor/command/set_subcmd/auto.rb +27 -0
- data/processor/command/set_subcmd/auto_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/auto_subcmd/eval.rb +53 -0
- data/processor/command/set_subcmd/auto_subcmd/irb.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/list.rb +33 -0
- data/processor/command/set_subcmd/basename.rb +25 -0
- data/processor/command/set_subcmd/callstyle.rb +46 -0
- data/processor/command/set_subcmd/confirm.rb +24 -0
- data/processor/command/set_subcmd/debug.rb +47 -0
- data/processor/command/set_subcmd/different.rb +61 -0
- data/processor/command/set_subcmd/highlight.rb +43 -0
- data/processor/command/set_subcmd/max.rb +26 -0
- data/processor/command/set_subcmd/max_subcmd/list.rb +49 -0
- data/processor/command/set_subcmd/max_subcmd/stack.rb +50 -0
- data/processor/command/set_subcmd/max_subcmd/string.rb +76 -0
- data/processor/command/set_subcmd/max_subcmd/width.rb +49 -0
- data/processor/command/set_subcmd/reload.rb +42 -0
- data/processor/command/set_subcmd/timer.rb +58 -0
- data/processor/command/set_subcmd/trace.rb +37 -0
- data/processor/command/set_subcmd/trace_subcmd/buffer.rb +42 -0
- data/processor/command/set_subcmd/trace_subcmd/print.rb +41 -0
- data/processor/command/shell.rb +139 -0
- data/processor/command/show.rb +39 -0
- data/processor/command/show_subcmd/.gitignore +1 -0
- data/processor/command/show_subcmd/abbrev.rb +20 -0
- data/processor/command/show_subcmd/alias.rb +46 -0
- data/processor/command/show_subcmd/args.rb +34 -0
- data/processor/command/show_subcmd/auto.rb +28 -0
- data/processor/command/show_subcmd/auto_subcmd/eval.rb +27 -0
- data/processor/command/show_subcmd/auto_subcmd/irb.rb +23 -0
- data/processor/command/show_subcmd/auto_subcmd/list.rb +22 -0
- data/processor/command/show_subcmd/basename.rb +20 -0
- data/processor/command/show_subcmd/callstyle.rb +22 -0
- data/processor/command/show_subcmd/confirm.rb +18 -0
- data/processor/command/show_subcmd/debug.rb +26 -0
- data/processor/command/show_subcmd/debug_subcmd/dbgr.rb +21 -0
- data/processor/command/show_subcmd/debug_subcmd/skip.rb +22 -0
- data/processor/command/show_subcmd/debug_subcmd/step.rb +22 -0
- data/processor/command/show_subcmd/different.rb +26 -0
- data/processor/command/show_subcmd/directories.rb +22 -0
- data/processor/command/show_subcmd/highlight.rb +24 -0
- data/processor/command/show_subcmd/max.rb +27 -0
- data/processor/command/show_subcmd/max_subcmd/list.rb +38 -0
- data/processor/command/show_subcmd/max_subcmd/stack.rb +36 -0
- data/processor/command/show_subcmd/max_subcmd/string.rb +42 -0
- data/processor/command/show_subcmd/max_subcmd/width.rb +37 -0
- data/processor/command/show_subcmd/reload.rb +18 -0
- data/processor/command/show_subcmd/timer.rb +18 -0
- data/processor/command/show_subcmd/trace.rb +29 -0
- data/processor/command/show_subcmd/trace_subcmd/buffer.rb +65 -0
- data/processor/command/show_subcmd/trace_subcmd/print.rb +23 -0
- data/processor/command/show_subcmd/version.rb +23 -0
- data/processor/command/source.rb +134 -0
- data/processor/command/step.rb +81 -0
- data/processor/command/tbreak.rb +19 -0
- data/processor/command/unalias.rb +44 -0
- data/processor/command/undisplay.rb +59 -0
- data/processor/command/up.rb +72 -0
- data/processor/default.rb +56 -0
- data/processor/display.rb +17 -0
- data/processor/eval.rb +113 -0
- data/processor/eventbuf.rb +105 -0
- data/processor/frame.rb +172 -0
- data/processor/help.rb +92 -0
- data/processor/helper.rb +76 -0
- data/processor/hook.rb +134 -0
- data/processor/load_cmds.rb +258 -0
- data/processor/location.rb +174 -0
- data/processor/main.rb +455 -0
- data/processor/mock.rb +136 -0
- data/processor/msg.rb +61 -0
- data/processor/processor.rb +674 -0
- data/processor/running.rb +168 -0
- data/processor/stepping.rb +18 -0
- data/processor/subcmd.rb +161 -0
- data/processor/validate.rb +355 -0
- data/processor/virtual.rb +34 -0
- data/test/data/.gitignore +1 -0
- data/test/data/break_bad.cmd +19 -0
- data/test/data/break_bad.right +29 -0
- data/test/data/break_loop_bug.cmd +5 -0
- data/test/data/break_loop_bug.right +15 -0
- data/test/data/dollar-0.right +2 -0
- data/test/data/dollar-0a.right +2 -0
- data/test/data/dollar-0b.right +2 -0
- data/test/data/edit.cmd +14 -0
- data/test/data/edit.right +24 -0
- data/test/data/file-with-space.cmd +6 -0
- data/test/data/file-with-space.right +4 -0
- data/test/data/printvar.cmd +17 -0
- data/test/data/printvar.right +31 -0
- data/test/data/raise.cmd +11 -0
- data/test/data/raise.right +19 -0
- data/test/data/source.cmd +5 -0
- data/test/data/source.right +18 -0
- data/test/data/stepping-1.9.right +50 -0
- data/test/data/stepping.cmd +21 -0
- data/test/data/stepping.right +48 -0
- data/test/data/trepan8-save.1 +6 -0
- data/test/example/bp_loop_issue.rb +3 -0
- data/test/example/break-bug.rb +7 -0
- data/test/example/brkpt-class-bug.rb +8 -0
- data/test/example/classes.rb +11 -0
- data/test/example/dollar-0.rb +5 -0
- data/test/example/except-bug1.rb +4 -0
- data/test/example/except-bug2.rb +7 -0
- data/test/example/file with space.rb +1 -0
- data/test/example/gcd.rb +18 -0
- data/test/example/info-var-bug.rb +47 -0
- data/test/example/info-var-bug2.rb +2 -0
- data/test/example/null.rb +1 -0
- data/test/example/pm-bug.rb +3 -0
- data/test/example/pm.rb +11 -0
- data/test/example/raise.rb +3 -0
- data/test/integration/.gitignore +4 -0
- data/test/integration/config.yaml +8 -0
- data/test/integration/helper.rb +154 -0
- data/test/integration/test-break_bad.rb +26 -0
- data/test/integration/test-dollar-0.rb +31 -0
- data/test/integration/test-edit.rb +17 -0
- data/test/integration/test-file-with-space.rb +26 -0
- data/test/integration/test-printvar.rb +17 -0
- data/test/integration/test-raise.rb +21 -0
- data/test/integration/test-source.rb +16 -0
- data/test/integration/test-stepping.rb +24 -0
- data/test/unit/.gitignore +1 -0
- data/test/unit/cmd-helper.rb +52 -0
- data/test/unit/mock-helper.rb +12 -0
- data/test/unit/test-app-cmd_parse.rb +97 -0
- data/test/unit/test-app-cmd_parser.rb +23 -0
- data/test/unit/test-app-complete.rb +39 -0
- data/test/unit/test-app-frame.rb +32 -0
- data/test/unit/test-app-options.rb +92 -0
- data/test/unit/test-app-run.rb +14 -0
- data/test/unit/test-app-util.rb +44 -0
- data/test/unit/test-base-cmd.rb +45 -0
- data/test/unit/test-base-subcmd.rb +57 -0
- data/test/unit/test-base-submgr.rb +23 -0
- data/test/unit/test-base-subsubcmd.rb +17 -0
- data/test/unit/test-cmd-alias.rb +48 -0
- data/test/unit/test-cmd-exit.rb +27 -0
- data/test/unit/test-cmd-help.rb +104 -0
- data/test/unit/test-cmd-kill.rb +46 -0
- data/test/unit/test-cmd-source.rb +34 -0
- data/test/unit/test-completion.rb +42 -0
- data/test/unit/test-intf-user.rb +46 -0
- data/test/unit/test-io-input.rb +27 -0
- data/test/unit/test-io-tcp.rb +33 -0
- data/test/unit/test-io-tcpclient.rb +54 -0
- data/test/unit/test-io-tcpfns.rb +17 -0
- data/test/unit/test-io-tcpserver.rb +50 -0
- data/test/unit/test-proc-eval.rb +36 -0
- data/test/unit/test-proc-hook.rb +30 -0
- data/test/unit/test-proc-load_cmds.rb +50 -0
- data/test/unit/test-proc-location.rb +79 -0
- data/test/unit/test-subcmd-help.rb +44 -0
- data/trepan8.gemspec +52 -0
- metadata +391 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*~
|
|
@@ -0,0 +1,39 @@
|
|
|
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::InfoArgs < Trepan::Subcommand
|
|
7
|
+
unless defined?(HELP)
|
|
8
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
|
9
|
+
HELP = 'Show argument variables of the current stack frame'
|
|
10
|
+
MIN_ABBREV = 'ar'.size
|
|
11
|
+
MIN_ARGS = 0
|
|
12
|
+
MAX_ARGS = 0
|
|
13
|
+
NEED_STACK = true
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def run(args)
|
|
17
|
+
locals = @proc.frame.local_variables
|
|
18
|
+
args = @proc.frame.args
|
|
19
|
+
if args.empty?
|
|
20
|
+
msg "argument list is empty"
|
|
21
|
+
else
|
|
22
|
+
args.each do |name|
|
|
23
|
+
s = "#{name} = #{locals[name].inspect}"
|
|
24
|
+
if s.size > @proc.settings[:maxwidth]
|
|
25
|
+
s[@proc.settings[:maxwidth]-3 .. -1] = "..."
|
|
26
|
+
end
|
|
27
|
+
msg "#{s}\n"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
if __FILE__ == $0
|
|
34
|
+
# Demo it.
|
|
35
|
+
$0 = __FILE__ + 'notagain' # So we don't run this again
|
|
36
|
+
require_relative '../../mock'
|
|
37
|
+
cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoArgs, false)
|
|
38
|
+
cmd.run(cmd.prefix)
|
|
39
|
+
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_relative '../base/subcmd'
|
|
5
|
+
|
|
6
|
+
class Trepan::Subcommand::InfoBreakpoints < Trepan::Subcommand
|
|
7
|
+
unless defined?(HELP)
|
|
8
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
|
9
|
+
HELP = <<-EOH
|
|
10
|
+
#{PREFIX.join(' ')} [num1 ...]
|
|
11
|
+
|
|
12
|
+
Show status of user-settable breakpoints. If no breakpoint numbers are
|
|
13
|
+
given, the show all breakpoints. Otherwise only those breakpoints
|
|
14
|
+
listed are shown and the order given. If VERBOSE is given, more
|
|
15
|
+
information provided about each breakpoint.
|
|
16
|
+
|
|
17
|
+
The "Disp" column contains one of "keep", "del", the disposition of
|
|
18
|
+
the breakpoint after it gets hit.
|
|
19
|
+
|
|
20
|
+
The "enb" column indicates whether the breakpoint is enabled.
|
|
21
|
+
|
|
22
|
+
The "Where" column indicates where the breakpoint is located.
|
|
23
|
+
EOH
|
|
24
|
+
MIN_ABBREV = 'br'.size
|
|
25
|
+
SHORT_HELP = 'Status of user-settable breakpoints'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def run(args)
|
|
29
|
+
unless @proc.state.context
|
|
30
|
+
errmsg "info breakpoints not available here."
|
|
31
|
+
return
|
|
32
|
+
end
|
|
33
|
+
unless Debugger.breakpoints.empty?
|
|
34
|
+
brkpts = Debugger.breakpoints.sort_by{|b| b.id}
|
|
35
|
+
unless args[2..-1].empty?
|
|
36
|
+
a = args.map{|a| a.to_i}
|
|
37
|
+
brkpts = brkpts.select{|b| a.member?(b.id)}
|
|
38
|
+
if brkpts.empty?
|
|
39
|
+
errmsg "No breakpoints found among list given.\n"
|
|
40
|
+
return
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
section "Num Enb What"
|
|
44
|
+
brkpts.each do |b|
|
|
45
|
+
fname = settings[:basename] ?
|
|
46
|
+
File.basename(b.source) : b.source
|
|
47
|
+
|
|
48
|
+
if b.expr.nil?
|
|
49
|
+
msg "%3d %s at %s:%s" %
|
|
50
|
+
[b.id, (b.enabled? ? 'y' : 'n'), fname, b.pos]
|
|
51
|
+
else
|
|
52
|
+
msg "%3d %s at %s:%s if %s" %
|
|
53
|
+
[b.id, (b.enabled? ? 'y' : 'n'), fname, b.pos, b.expr]
|
|
54
|
+
end
|
|
55
|
+
hits = b.hit_count
|
|
56
|
+
if hits > 0
|
|
57
|
+
s = (hits > 1) ? 's' : ''
|
|
58
|
+
msg "\tbreakpoint already hit #{hits} time#{s}"
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
else
|
|
62
|
+
msg "No breakpoints."
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
if __FILE__ == $0
|
|
68
|
+
# Demo it.
|
|
69
|
+
require_relative '../../mock'
|
|
70
|
+
name = File.basename(__FILE__, '.rb')
|
|
71
|
+
dbgr, cmd = MockDebugger::setup('info')
|
|
72
|
+
subcommand = Trepan::Subcommand::InfoBreakpoints.new(cmd)
|
|
73
|
+
|
|
74
|
+
puts '-' * 20
|
|
75
|
+
subcommand.run(%w(info break))
|
|
76
|
+
puts '-' * 20
|
|
77
|
+
subcommand.summary_help(name)
|
|
78
|
+
puts
|
|
79
|
+
puts '-' * 20
|
|
80
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
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::InfoCatch < Trepan::Subcommand
|
|
7
|
+
unless defined?(HELP)
|
|
8
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
|
9
|
+
HELP = 'Show argument variables of the current stack frame'
|
|
10
|
+
MIN_ABBREV = 'cat'.size
|
|
11
|
+
MIN_ARGS = 0
|
|
12
|
+
MAX_ARGS = 0
|
|
13
|
+
NEED_STACK = true
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def run(args)
|
|
17
|
+
if Debugger.catchpoints and not Debugger.catchpoints.empty?
|
|
18
|
+
# FIXME: show whether Exception is valid or not
|
|
19
|
+
# print "Exception: is_a?(Class)\n"
|
|
20
|
+
Debugger.catchpoints.each do |exception, hits|
|
|
21
|
+
# print "#{exception}: #{exception.is_a?(Class)}\n"
|
|
22
|
+
msg "#{exception}"
|
|
23
|
+
end
|
|
24
|
+
else
|
|
25
|
+
msg "No exceptions set to be caught."
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
if __FILE__ == $0
|
|
31
|
+
# Demo it.
|
|
32
|
+
$0 = __FILE__ + 'notagain' # So we don't run this again
|
|
33
|
+
require_relative '../../mock'
|
|
34
|
+
cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoProgram, false)
|
|
35
|
+
## cmd.run(cmd.prefix)
|
|
36
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
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::InfoFiles < Trepan::Subcommand
|
|
7
|
+
unless defined?(HELP)
|
|
8
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
|
9
|
+
HELP = 'Show files cached by the debugger'
|
|
10
|
+
MIN_ABBREV = 'files'.size
|
|
11
|
+
MIN_ARGS = 0
|
|
12
|
+
MAX_ARGS = 0
|
|
13
|
+
NEED_STACK = false
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def run(args)
|
|
17
|
+
files = LineCache::cached_files
|
|
18
|
+
files += SCRIPT_LINES__.keys unless 'stat' == args[0]
|
|
19
|
+
files.uniq.sort.each do |file|
|
|
20
|
+
stat = LineCache::stat(file)
|
|
21
|
+
path = LineCache::path(file)
|
|
22
|
+
print "File %s" % file
|
|
23
|
+
if path and path != file
|
|
24
|
+
msg(" - %s" % path)
|
|
25
|
+
else
|
|
26
|
+
msg ''
|
|
27
|
+
end
|
|
28
|
+
msg(("\t%s" % stat.mtime)) if stat
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
if __FILE__ == $0
|
|
34
|
+
# Demo it.
|
|
35
|
+
$0 = __FILE__ + 'notagain' # So we don't run this again
|
|
36
|
+
require_relative '../../mock'
|
|
37
|
+
cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoFiles, false)
|
|
38
|
+
cmd.run(cmd.prefix)
|
|
39
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
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/subcmd'
|
|
6
|
+
require_relative '../../../app/frame'
|
|
7
|
+
|
|
8
|
+
class Trepan::Subcommand::InfoGlobals < Trepan::Subcommand
|
|
9
|
+
unless defined?(HELP)
|
|
10
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
|
11
|
+
HELP = <<-EOH
|
|
12
|
+
#{CMD}
|
|
13
|
+
#{CMD} [names]
|
|
14
|
+
|
|
15
|
+
Show global variables.
|
|
16
|
+
Normally for each which show both the name and value. If you just
|
|
17
|
+
want a list of names add parameter 'names'.
|
|
18
|
+
EOH
|
|
19
|
+
SHORT_HELP = 'Show global variables'
|
|
20
|
+
MIN_ARGS = 0
|
|
21
|
+
MAX_ARGS = 1
|
|
22
|
+
MIN_ABBREV = 'gl'.size
|
|
23
|
+
NEED_STACK = true
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def run(args)
|
|
27
|
+
if args.size == 3
|
|
28
|
+
if 0 == 'names'.index(args[-1].downcase)
|
|
29
|
+
if global_variables.empty?
|
|
30
|
+
msg "No global variables defined."
|
|
31
|
+
else
|
|
32
|
+
section "Global variable names:"
|
|
33
|
+
width = settings[:maxwidth]
|
|
34
|
+
mess = Columnize::columnize(global_variables.sort,
|
|
35
|
+
@proc.settings[:maxwidth], ' ',
|
|
36
|
+
false, true, ' ' * 2).chomp
|
|
37
|
+
msg mess
|
|
38
|
+
end
|
|
39
|
+
else
|
|
40
|
+
errmsg("unrecognized argument #{args[2]}")
|
|
41
|
+
end
|
|
42
|
+
elsif args.size == 2
|
|
43
|
+
if global_variables.empty?
|
|
44
|
+
msg "No global variables defined."
|
|
45
|
+
else
|
|
46
|
+
section "Global variables:"
|
|
47
|
+
global_variables.sort.each do |var_name|
|
|
48
|
+
s = @proc.debug_eval(var_name)
|
|
49
|
+
msg("#{var_name} = #{s.inspect}")
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
else
|
|
53
|
+
errmsg("Wrong number of arguments #{args.size}")
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
if __FILE__ == $0
|
|
59
|
+
# Demo it.
|
|
60
|
+
require_relative '../../mock'
|
|
61
|
+
cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoGlobals, false)
|
|
62
|
+
cmd.run(cmd.prefix)
|
|
63
|
+
cmd.run(cmd.prefix + ['name'])
|
|
64
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
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::InfoLine < Trepan::Subcommand
|
|
8
|
+
unless defined?(HELP)
|
|
9
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
|
10
|
+
HELP = 'Line number and file name of current position in source file'
|
|
11
|
+
MIN_ABBREV = 'li'.size
|
|
12
|
+
NEED_STACK = true
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def run(args)
|
|
16
|
+
unless @proc.state.context
|
|
17
|
+
errmsg "info line not available here."
|
|
18
|
+
return
|
|
19
|
+
end
|
|
20
|
+
frame = @proc.frame
|
|
21
|
+
msg "Line %d of \"%s\"" % [frame.line, @proc.canonic_file(frame.file)]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
if __FILE__ == $0
|
|
26
|
+
# Demo it.
|
|
27
|
+
require_relative '../../mock'
|
|
28
|
+
cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoLine, false)
|
|
29
|
+
cmd.run(cmd.prefix)
|
|
30
|
+
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 'columnize'
|
|
5
|
+
require_relative '../base/subcmd'
|
|
6
|
+
require_relative '../../../app/frame'
|
|
7
|
+
|
|
8
|
+
class Trepan::Subcommand::InfoLocals < Trepan::Subcommand
|
|
9
|
+
unless defined?(HELP)
|
|
10
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
|
11
|
+
HELP = <<-EOH
|
|
12
|
+
#{CMD}
|
|
13
|
+
#{CMD} [names]
|
|
14
|
+
|
|
15
|
+
Show local variables including parameters of the current stack frame.
|
|
16
|
+
Normally for each which show both the name and value. If you just
|
|
17
|
+
want a list of names add parameter 'names'.
|
|
18
|
+
EOH
|
|
19
|
+
SHORT_HELP = 'Show local variables of the current stack frame'
|
|
20
|
+
MIN_ARGS = 0
|
|
21
|
+
MAX_ARGS = 1
|
|
22
|
+
MIN_ABBREV = 'lo'.size
|
|
23
|
+
NEED_STACK = true
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def get_local_names
|
|
27
|
+
@proc.frame.local_variables.keys
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def run(args)
|
|
31
|
+
if args.size == 3
|
|
32
|
+
if 0 == 'names'.index(args[-1].downcase)
|
|
33
|
+
local_names = get_local_names()
|
|
34
|
+
if local_names.empty?
|
|
35
|
+
msg "No local variables defined."
|
|
36
|
+
else
|
|
37
|
+
section "Local variable names:"
|
|
38
|
+
width = settings[:maxwidth]
|
|
39
|
+
mess = Columnize::columnize(local_names,
|
|
40
|
+
@proc.settings[:maxwidth], ' ',
|
|
41
|
+
false, true, ' ' * 2).chomp
|
|
42
|
+
msg mess
|
|
43
|
+
end
|
|
44
|
+
else
|
|
45
|
+
errmsg("unrecognized argument #{args[2]}")
|
|
46
|
+
end
|
|
47
|
+
elsif args.size == 2
|
|
48
|
+
local_names = get_local_names
|
|
49
|
+
if local_names.empty?
|
|
50
|
+
msg "No local variables defined."
|
|
51
|
+
else
|
|
52
|
+
section "Local variables:"
|
|
53
|
+
@proc.frame.local_variables.each do |var_name, var_value|
|
|
54
|
+
msg("#{var_name} = #{var_value}")
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
else
|
|
58
|
+
errmsg("Wrong number of arguments #{args.size}")
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
if __FILE__ == $0
|
|
64
|
+
# Demo it.
|
|
65
|
+
require_relative '../../mock'
|
|
66
|
+
cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoLocals, false)
|
|
67
|
+
cmd.run(cmd.prefix)
|
|
68
|
+
cmd.run(cmd.prefix + ['name'])
|
|
69
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
require_relative '../../../app/complete'
|
|
6
|
+
|
|
7
|
+
class Trepan::Subcommand::InfoMacro < Trepan::Subcommand
|
|
8
|
+
unless defined?(HELP)
|
|
9
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
|
10
|
+
HELP = <<-HELP
|
|
11
|
+
#{CMD}
|
|
12
|
+
#{CMD} *
|
|
13
|
+
#{CMD} MACRO1 [MACRO2 ..]
|
|
14
|
+
|
|
15
|
+
In the first form a list of the existing macro names are shown
|
|
16
|
+
in column format.
|
|
17
|
+
|
|
18
|
+
In the second form, all macro names and their definitions are show.
|
|
19
|
+
|
|
20
|
+
In the last form the only definitions of the given macro names is shown.
|
|
21
|
+
HELP
|
|
22
|
+
SHORT_HELP = "Info defined macros"
|
|
23
|
+
MIN_ABBREV = 'ma'.size
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def complete(prefix)
|
|
27
|
+
Trepan::Complete.complete_token(@proc.macros.keys + %w(*), prefix)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def run(args)
|
|
31
|
+
if args.size > 2
|
|
32
|
+
macro_names =
|
|
33
|
+
if args.size == 3 && '*' == args[2]
|
|
34
|
+
@proc.macros.keys
|
|
35
|
+
else
|
|
36
|
+
args[2..-1]
|
|
37
|
+
end
|
|
38
|
+
macro_names.each do |macro_name|
|
|
39
|
+
if @proc.macros.member?(macro_name)
|
|
40
|
+
section "#{macro_name}:"
|
|
41
|
+
string = @proc.macros[macro_name][1]
|
|
42
|
+
msg " #{@proc.ruby_format(string)}", {:unlimited => true}
|
|
43
|
+
else
|
|
44
|
+
errmsg "%s is not a defined macro" % macro_name
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
elsif @proc.macros.empty?
|
|
48
|
+
msg "No macros defined."
|
|
49
|
+
else
|
|
50
|
+
msg columnize_commands(@proc.macros.keys.sort)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
if __FILE__ == $0
|
|
57
|
+
# Demo it.
|
|
58
|
+
$0 = __FILE__ + 'notagain' # So we don't run this agin
|
|
59
|
+
require_relative '../../mock'
|
|
60
|
+
cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoMacro)
|
|
61
|
+
cmd.run(cmd.prefix + %w(u foo))
|
|
62
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
|
3
|
+
require 'rubygems'; require 'require_relative'
|
|
4
|
+
require_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 = 'Show argument variables of the current stack frame'
|
|
10
|
+
MIN_ABBREV = 'pr'.size
|
|
11
|
+
MIN_ARGS = 0
|
|
12
|
+
MAX_ARGS = 0
|
|
13
|
+
NEED_STACK = true
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def run(args)
|
|
17
|
+
if not @proc.context
|
|
18
|
+
errmsg 'The program being debugged is not being run.'
|
|
19
|
+
return
|
|
20
|
+
end
|
|
21
|
+
case @proc.event
|
|
22
|
+
when :raise
|
|
23
|
+
status = 'crashed'
|
|
24
|
+
else
|
|
25
|
+
status = 'stopped'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
msg "Program #{status}."
|
|
29
|
+
event_arg = @proc.state.processor.event_arg
|
|
30
|
+
case @proc.context.stop_reason
|
|
31
|
+
when :step
|
|
32
|
+
msg "It stopped after stepping, next'ing or initial start."
|
|
33
|
+
when :breakpoint
|
|
34
|
+
msg("It stopped at breakpoint %d.\n" %
|
|
35
|
+
(Debugger.breakpoints.index(event_arg)+1))
|
|
36
|
+
when :catchpoint
|
|
37
|
+
msg("Handling an uncaught exception `%s' (%s)." % [event_arg,
|
|
38
|
+
event_arg.class])
|
|
39
|
+
else
|
|
40
|
+
msg "unknown reason: %s" % @proc.context.stop_reason.to_s
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
if __FILE__ == $0
|
|
46
|
+
# Demo it.
|
|
47
|
+
$0 = __FILE__ + 'notagain' # So we don't run this again
|
|
48
|
+
require_relative '../../mock'
|
|
49
|
+
cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoProgram, false)
|
|
50
|
+
## cmd.run(cmd.prefix)
|
|
51
|
+
end
|