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
data/app/complete.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
|
3
|
+
class Trepan
|
4
|
+
|
5
|
+
# Command completion methods
|
6
|
+
module Complete
|
7
|
+
|
8
|
+
module_function
|
9
|
+
|
10
|
+
# Return an Array of String found from Array of String
|
11
|
+
# +complete_ary+ which start out with String +prefix+.
|
12
|
+
def complete_token(complete_ary, prefix)
|
13
|
+
complete_ary.select { |cmd| cmd.to_s.start_with?(prefix) }.map{|cmd| cmd.to_s}.sort
|
14
|
+
end
|
15
|
+
|
16
|
+
def complete_token_with_next(complete_hash, prefix, cmd_prefix='')
|
17
|
+
result = []
|
18
|
+
complete_hash.each do |cmd_name, cmd_obj|
|
19
|
+
result << [cmd_name.to_s[cmd_prefix.size..-1], cmd_obj] if
|
20
|
+
cmd_name.to_s.start_with?(cmd_prefix + prefix)
|
21
|
+
end
|
22
|
+
result.sort{|a, b| a[0] <=> b[0]}
|
23
|
+
end
|
24
|
+
|
25
|
+
# Find all starting matches in Hash +aliases+ that start with +prefix+,
|
26
|
+
# but filter out any matches already in +expanded+.
|
27
|
+
def complete_token_filtered(aliases, prefix, expanded)
|
28
|
+
complete_ary = aliases.keys
|
29
|
+
complete_ary.select { |cmd|
|
30
|
+
cmd.to_s.start_with?(prefix) && ! expanded.member?(aliases[cmd])}.sort
|
31
|
+
end
|
32
|
+
|
33
|
+
# Find all starting matches in Hash +aliases+ that start with +prefix+,
|
34
|
+
# but filter out any matches already in +expanded+.
|
35
|
+
def complete_token_filtered_with_next(aliases, prefix, expanded,
|
36
|
+
commands)
|
37
|
+
complete_ary = aliases.keys
|
38
|
+
expanded_ary = expanded.keys
|
39
|
+
result = []
|
40
|
+
complete_ary.each do |cmd|
|
41
|
+
if cmd.to_s.start_with?(prefix) &&
|
42
|
+
!expanded_ary.member?(aliases[cmd])
|
43
|
+
result << [cmd, commands[aliases[cmd]]]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
result
|
47
|
+
end
|
48
|
+
|
49
|
+
# Find the next token in str string from start_pos, we return
|
50
|
+
# the token and the next blank position after the token or
|
51
|
+
# str.size if this is the last token. Tokens are delimited by
|
52
|
+
# white space.
|
53
|
+
def next_token(str, start_pos)
|
54
|
+
look_at = str[start_pos..-1]
|
55
|
+
next_nonblank_pos = start_pos + (look_at =~ /\S/ || 0)
|
56
|
+
next_blank_pos =
|
57
|
+
if next_match = str[next_nonblank_pos..-1] =~ /\s/
|
58
|
+
next_nonblank_pos + next_match
|
59
|
+
else
|
60
|
+
str.size
|
61
|
+
end
|
62
|
+
return [next_blank_pos, str[next_nonblank_pos...next_blank_pos]]
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
if __FILE__ == $0
|
69
|
+
include Trepan::Complete
|
70
|
+
hash = {'ab' => 1, 'aac' => 2, 'aa' => 3, 'b' => 4}
|
71
|
+
p complete_token(hash.keys, 'a')
|
72
|
+
p complete_token_with_next(hash, 'a')
|
73
|
+
## 0 1
|
74
|
+
## 0123456789012345678
|
75
|
+
x = ' now is the time'
|
76
|
+
[0, 2, 5, 8, 9, 13, 19].each do |pos|
|
77
|
+
p next_token(x, pos)
|
78
|
+
end
|
79
|
+
end
|
data/app/condition.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
class Trepan
|
3
|
+
module Condition
|
4
|
+
def valid_condition?(str)
|
5
|
+
begin
|
6
|
+
Rubinius::Compiler.compile_string(str)
|
7
|
+
rescue SyntaxError
|
8
|
+
return nil
|
9
|
+
rescue
|
10
|
+
nil
|
11
|
+
end
|
12
|
+
end
|
13
|
+
module_function :valid_condition?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
if __FILE__ == $0
|
17
|
+
include Trepan::Condition
|
18
|
+
p valid_condition?('a+2')
|
19
|
+
puts '-' * 20
|
20
|
+
p valid_condition?('1+')
|
21
|
+
puts '-' * 20
|
22
|
+
end
|
data/app/default.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
# A place for the default settings
|
3
|
+
class Trepan
|
4
|
+
|
5
|
+
# I am not sure if we need to sets of hashes, but we'll start out
|
6
|
+
# that way.
|
7
|
+
|
8
|
+
# Default settings for a Trepan class object
|
9
|
+
DEFAULT_SETTINGS = {
|
10
|
+
:cmdproc_opts => {}, # Default Trepan::CmdProcessor settings
|
11
|
+
:core_opts => {}, # Default Trepan::Core settings
|
12
|
+
:delete_restore => true, # Delete restore profile after reading?
|
13
|
+
:initial_dir => nil, # If --cd option was given, we save it here.
|
14
|
+
:nx => false, # Don't run user startup file (e.g. .trepanxrc)
|
15
|
+
:offset => 0, # skipping back +offset+ frames. This lets you start
|
16
|
+
# the debugger straight into callers method.
|
17
|
+
|
18
|
+
# Default values used only when 'server' or 'client'
|
19
|
+
# (out-of-process debugging)
|
20
|
+
:port => 1955,
|
21
|
+
:host => 'localhost',
|
22
|
+
|
23
|
+
:restart_argv => Rubinius::OS_ARGV,
|
24
|
+
# Command run when "restart" is given.
|
25
|
+
:server => false, # Out-of-process debugging?
|
26
|
+
:skip_loader => false, # If run via -Xdebug or trepanx
|
27
|
+
# command-line we need this to skip
|
28
|
+
# over some initial Rubinius loader
|
29
|
+
# commands.
|
30
|
+
} unless defined?(DEFAULT_SETTINGS)
|
31
|
+
|
32
|
+
# Default settings for Trepan run from the command line.
|
33
|
+
DEFAULT_CMDLINE_SETTINGS = {
|
34
|
+
:cmdfiles => [], # Initialization command files to run
|
35
|
+
:client => false, # Attach to out-of-process program?
|
36
|
+
:nx => false, # Don't run user startup file (e.g. .trepanxrc)
|
37
|
+
:output => nil,
|
38
|
+
:port => DEFAULT_SETTINGS[:port],
|
39
|
+
:host => DEFAULT_SETTINGS[:host],
|
40
|
+
:server => false, # Out-of-process debugging?
|
41
|
+
:readline => true, # Try to use GNU Readline?
|
42
|
+
# Note that at most one of :server or :client can be true.
|
43
|
+
} unless defined?(DEFAULT_CMDLINE_SETTINGS)
|
44
|
+
|
45
|
+
DEFAULT_DEBUG_STR_SETTINGS = {
|
46
|
+
:core_opts => {
|
47
|
+
:cmdproc_opts => {:different => false}},
|
48
|
+
:hide_stack => true,
|
49
|
+
} unless defined?(DEFAULT_DEBUG_STR_SETTINGS)
|
50
|
+
|
51
|
+
CMD_INITFILE_BASE =
|
52
|
+
if RUBY_PLATFORM =~ /mswin/
|
53
|
+
# Of course MS Windows has to be different
|
54
|
+
HOME_DIR = (ENV['HOME'] ||
|
55
|
+
ENV['HOMEDRIVE'].to_s + ENV['HOMEPATH'].to_s).to_s
|
56
|
+
'trepanx.ini'
|
57
|
+
else
|
58
|
+
HOME_DIR = ENV['HOME'].to_s
|
59
|
+
'.trepanxrc'
|
60
|
+
end unless defined?(CMD_INITFILE_BASE)
|
61
|
+
CMD_INITFILE = File.join(HOME_DIR, CMD_INITFILE_BASE) unless
|
62
|
+
defined?(CMD_INITFILE)
|
63
|
+
end
|
64
|
+
|
65
|
+
if __FILE__ == $0
|
66
|
+
# Show it:
|
67
|
+
require 'pp'
|
68
|
+
PP.pp(Trepan::DEFAULT_SETTINGS)
|
69
|
+
puts '=' * 30
|
70
|
+
PP.pp(Trepan::DEFAULT_CMDLINE_SETTINGS)
|
71
|
+
end
|
data/app/display.rb
ADDED
@@ -0,0 +1,186 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011, 2013 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
# Classes to support gdb-like display/undisplay.
|
4
|
+
|
5
|
+
require 'rubygems'; require 'require_relative'
|
6
|
+
require_relative 'frame'
|
7
|
+
|
8
|
+
# return suitable frame signature to key display expressions off of.
|
9
|
+
def display_signature(frame)
|
10
|
+
return nil unless frame
|
11
|
+
frame.vm_location.constant_scope
|
12
|
+
end
|
13
|
+
|
14
|
+
# Manage a list of display expressions.
|
15
|
+
class DisplayMgr
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@next = 0
|
19
|
+
@list = []
|
20
|
+
end
|
21
|
+
|
22
|
+
def [](index)
|
23
|
+
raise TypeError,
|
24
|
+
"index #{index} should be a Fixnum, is #{index.class}" unless
|
25
|
+
index.is_a?(Fixnum)
|
26
|
+
@list.detect {|disp| disp.number == index }
|
27
|
+
end
|
28
|
+
|
29
|
+
def add(frame, arg, fmt=nil)
|
30
|
+
return nil unless frame
|
31
|
+
begin
|
32
|
+
eval(arg, frame.binding)
|
33
|
+
rescue
|
34
|
+
return nil
|
35
|
+
end
|
36
|
+
@next += 1
|
37
|
+
d = Display.new(frame, arg, fmt, @next)
|
38
|
+
@list << d
|
39
|
+
d
|
40
|
+
end
|
41
|
+
|
42
|
+
# List all display items; return 0 if none
|
43
|
+
def all
|
44
|
+
s = []
|
45
|
+
unless @list.empty?
|
46
|
+
s << "Auto-display expressions now in effect:
|
47
|
+
Num Enb Expression"
|
48
|
+
@list.each do |display|
|
49
|
+
s << display.format
|
50
|
+
end
|
51
|
+
end
|
52
|
+
s
|
53
|
+
end
|
54
|
+
|
55
|
+
# Delete all display expressions"""
|
56
|
+
def clear
|
57
|
+
@list = []
|
58
|
+
end
|
59
|
+
|
60
|
+
# Delete display expression i
|
61
|
+
def delete_index(display_number)
|
62
|
+
@list.each_with_index do |display, i|
|
63
|
+
if display_number == display.number
|
64
|
+
@list[i..i] = []
|
65
|
+
return true
|
66
|
+
end
|
67
|
+
end
|
68
|
+
false
|
69
|
+
end
|
70
|
+
|
71
|
+
# display any items that are active'''
|
72
|
+
def display(frame)
|
73
|
+
return unless frame
|
74
|
+
s = []
|
75
|
+
sig = display_signature(frame)
|
76
|
+
@list.each do |display|
|
77
|
+
if display.enabled # && display.signature == sig
|
78
|
+
s << display.to_s(frame)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
return s
|
82
|
+
end
|
83
|
+
|
84
|
+
def enable_disable(display_number, b_enable_disable)
|
85
|
+
@list.each do |display|
|
86
|
+
if display_number == display.number
|
87
|
+
display.enabled = b_enable_disable
|
88
|
+
return true
|
89
|
+
end
|
90
|
+
end
|
91
|
+
false
|
92
|
+
end
|
93
|
+
|
94
|
+
def max
|
95
|
+
@list.map{|disp| disp.number}.max
|
96
|
+
end
|
97
|
+
|
98
|
+
def nums
|
99
|
+
@list.map{|disp| disp.number}
|
100
|
+
end
|
101
|
+
|
102
|
+
def size
|
103
|
+
@list.size
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
class Display
|
108
|
+
attr_reader :number
|
109
|
+
attr_reader :signature
|
110
|
+
attr_accessor :enabled
|
111
|
+
|
112
|
+
def initialize(frame, arg, fmt, number)
|
113
|
+
@signature = display_signature(frame)
|
114
|
+
@fmt = fmt
|
115
|
+
@arg = arg
|
116
|
+
@enabled = true
|
117
|
+
@number = number
|
118
|
+
end
|
119
|
+
|
120
|
+
def disable
|
121
|
+
@enabled = false
|
122
|
+
end
|
123
|
+
|
124
|
+
def disabled?
|
125
|
+
!@enabled
|
126
|
+
end
|
127
|
+
|
128
|
+
def enable
|
129
|
+
@enabled = true
|
130
|
+
end
|
131
|
+
|
132
|
+
def enabled?
|
133
|
+
@enabled
|
134
|
+
end
|
135
|
+
|
136
|
+
def to_s(frame)
|
137
|
+
return 'No symbol "' + @arg + '" in current context.' unless frame
|
138
|
+
|
139
|
+
begin
|
140
|
+
val = eval(@arg, frame.binding)
|
141
|
+
rescue
|
142
|
+
return "No symbol \"#{@arg}\" in current context."
|
143
|
+
end
|
144
|
+
s = "#{self.format(false)} = #{val}"
|
145
|
+
return s
|
146
|
+
end
|
147
|
+
|
148
|
+
# format display item
|
149
|
+
def format(show_enabled=true)
|
150
|
+
what = ''
|
151
|
+
what += @enabled ? ' y ' : ' n ' if
|
152
|
+
show_enabled
|
153
|
+
what += (@fmt + ' ') if @fmt
|
154
|
+
what += @arg if @arg
|
155
|
+
'%3d: %s' % [@number, what]
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
if __FILE__ == $0
|
161
|
+
# Demo it.
|
162
|
+
mgr = DisplayMgr.new
|
163
|
+
|
164
|
+
def print_display(mgr)
|
165
|
+
mgr.all.each {|line| puts line}
|
166
|
+
puts '=' * 40
|
167
|
+
end
|
168
|
+
|
169
|
+
frame = Rubinius::VM.backtrace(0)[0]
|
170
|
+
|
171
|
+
x = 1
|
172
|
+
mgr.add(frame, 'x > 1')
|
173
|
+
puts "Number of displays %s" % mgr.size
|
174
|
+
puts "Max Number %d" % mgr.max
|
175
|
+
print_display(mgr)
|
176
|
+
|
177
|
+
mgr.enable_disable(1, false)
|
178
|
+
print_display(mgr)
|
179
|
+
|
180
|
+
mgr.enable_disable(1, true)
|
181
|
+
print_display(mgr)
|
182
|
+
|
183
|
+
mgr.clear()
|
184
|
+
print_display(mgr)
|
185
|
+
|
186
|
+
end
|
data/app/eventbuffer.rb
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
module Trace
|
3
|
+
|
4
|
+
class EventBuffer
|
5
|
+
EventStruct = Struct.new(:event, :arg, :frame) unless defined?(EventStruct)
|
6
|
+
attr_reader :buf
|
7
|
+
attr_accessor :marks # User position mark into buffer. If buffer is limited,
|
8
|
+
attr_reader :maxsize # Maximum size of buffer or nil if unlimited.
|
9
|
+
attr_reader :size # size of buffer
|
10
|
+
# then marks will drop out as they disappear from the buffer
|
11
|
+
def initialize(maxsize=nil)
|
12
|
+
@maxsize = maxsize
|
13
|
+
reset
|
14
|
+
end
|
15
|
+
|
16
|
+
def reset
|
17
|
+
@buf = []
|
18
|
+
@marks = []
|
19
|
+
@pos = -1
|
20
|
+
@size = 0
|
21
|
+
end
|
22
|
+
|
23
|
+
# Add a new event dropping off old events if that was declared
|
24
|
+
# marks are also dropped if buffer has a limit.
|
25
|
+
def append(event, frame, arg)
|
26
|
+
item = EventStruct.new(event, arg, frame)
|
27
|
+
@pos = self.succ_pos
|
28
|
+
@marks.shift if @marks[0] == @pos
|
29
|
+
@buf[@pos] = item
|
30
|
+
@size += 1 unless @maxsize && @size == @maxsize
|
31
|
+
end
|
32
|
+
|
33
|
+
# Add mark for the current event buffer position.
|
34
|
+
def add_mark
|
35
|
+
@marks << @pos
|
36
|
+
end
|
37
|
+
|
38
|
+
# Like add mark, but do only if the last marked position has
|
39
|
+
# changed
|
40
|
+
def add_mark_nodup
|
41
|
+
@marks << @pos unless @marks[-1] == @pos
|
42
|
+
end
|
43
|
+
|
44
|
+
def each(from=nil, to=nil)
|
45
|
+
from = self.succ_pos unless from
|
46
|
+
to = @pos unless to
|
47
|
+
if from <= to
|
48
|
+
from.upto(to).each do |pos|
|
49
|
+
yield @buf[pos]
|
50
|
+
end
|
51
|
+
else
|
52
|
+
from.upto(@size-1).each do |pos|
|
53
|
+
yield @buf[pos]
|
54
|
+
end
|
55
|
+
0.upto(@pos).each do |pos|
|
56
|
+
yield @buf[pos]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def each_with_index(from=nil, to=nil)
|
62
|
+
from = succ_pos unless from
|
63
|
+
to = @pos unless to
|
64
|
+
if from <= to
|
65
|
+
from.upto(to).each do |pos|
|
66
|
+
yield [@buf[pos], pos]
|
67
|
+
end
|
68
|
+
else
|
69
|
+
from.upto(@size-1).each do |pos|
|
70
|
+
yield [@buf[pos], pos]
|
71
|
+
end
|
72
|
+
0.upto(@pos).each do |pos|
|
73
|
+
yield [@buf[pos], pos]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def format_entry(item, long_format=true)
|
79
|
+
# require 'rbdbgr'; Debugger.debug
|
80
|
+
mess = "#{item.event} #{item.frame}"
|
81
|
+
# if long_format && item.iseq
|
82
|
+
# mess += "\n\t" + "VM offset #{item.pc_offset} of #{item.iseq.name}"
|
83
|
+
# end
|
84
|
+
mess
|
85
|
+
end
|
86
|
+
|
87
|
+
# Return the next event buffer position taking into account
|
88
|
+
# that we may have a fixed-sized buffer ring.
|
89
|
+
def succ_pos(inc=1)
|
90
|
+
pos = @pos + inc
|
91
|
+
@maxsize ? pos % @maxsize : pos
|
92
|
+
end
|
93
|
+
|
94
|
+
# Return the next event buffer position taking into account
|
95
|
+
# that we may have a fixed-sized buffer ring.
|
96
|
+
def pred_pos(dec=1)
|
97
|
+
pos = @pos - dec
|
98
|
+
@maxsize ? pos % @maxsize : pos
|
99
|
+
end
|
100
|
+
|
101
|
+
# Return the adjusted zeroth position in @buf.
|
102
|
+
def zero_pos
|
103
|
+
if !@maxsize || @buf.size < @maxsize
|
104
|
+
0
|
105
|
+
else
|
106
|
+
self.succ_pos
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
end # EventBuffer
|
111
|
+
end # Trace
|
112
|
+
|
113
|
+
if __FILE__ == $0
|
114
|
+
def event_processor(event, frame, arg=nil)
|
115
|
+
begin
|
116
|
+
@eventbuf.append(event, frame, arg)
|
117
|
+
rescue
|
118
|
+
p $!
|
119
|
+
end
|
120
|
+
end
|
121
|
+
def dump_all
|
122
|
+
puts '-' * 40
|
123
|
+
@eventbuf.each do |e|
|
124
|
+
puts @eventbuf.format_entry(e) if e
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
require 'rubygems'; require 'set_trace'
|
129
|
+
@eventbuf = Trace::EventBuffer.new(5)
|
130
|
+
p @eventbuf.zero_pos
|
131
|
+
dump_all
|
132
|
+
|
133
|
+
# trace_filter = Trace::Filter.new
|
134
|
+
# trace_func = method(:event_processor).to_proc
|
135
|
+
# trace_filter << trace_func
|
136
|
+
# trace_filter.set_trace_func(trace_func)
|
137
|
+
# z=5
|
138
|
+
# z.times do |i|
|
139
|
+
# x = i
|
140
|
+
# y = x+2
|
141
|
+
# end
|
142
|
+
# trace_filter.set_trace_func(nil)
|
143
|
+
# p @eventbuf.buf[@eventbuf.zero_pos]
|
144
|
+
# dump_all
|
145
|
+
@eventbuf.reset
|
146
|
+
dump_all
|
147
|
+
end
|
data/app/file.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
# Things related to file/module status
|
4
|
+
|
5
|
+
module Trepanning
|
6
|
+
module FileName
|
7
|
+
def find_load_path(filename)
|
8
|
+
cl = Rubinius::CodeLoader.new(filename)
|
9
|
+
if cl.verify_load_path(filename)
|
10
|
+
path = cl.instance_variable_get('@load_path')
|
11
|
+
path.end_with?(filename) ? filename : nil
|
12
|
+
else
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
if __FILE__ == $0
|
19
|
+
include Trepanning::FileName
|
20
|
+
require 'tmpdir.rb'
|
21
|
+
[__FILE__, 'tmpdir.rb'].each do |name|
|
22
|
+
p find_load_path(name)
|
23
|
+
end
|
24
|
+
end
|
data/app/frame.rb
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
# Copyright (C) 2010-2011, 2013 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
class Trepan
|
3
|
+
|
4
|
+
# Call-Stack frame methods
|
5
|
+
class Frame
|
6
|
+
def initialize(dbgr, number, vm_location)
|
7
|
+
@debugger = dbgr
|
8
|
+
@number = number
|
9
|
+
@vm_location = vm_location
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :number, :vm_location
|
13
|
+
|
14
|
+
def run(code, filename=nil)
|
15
|
+
eval(code, self.binding, filename)
|
16
|
+
end
|
17
|
+
|
18
|
+
def binding
|
19
|
+
@binding ||= Binding.setup(@vm_location.variables,
|
20
|
+
@vm_location.method,
|
21
|
+
@vm_location.constant_scope)
|
22
|
+
end
|
23
|
+
|
24
|
+
def describe(opts = {})
|
25
|
+
if method.required_args > 0
|
26
|
+
locals = []
|
27
|
+
0.upto(method.required_args-1) do |arg|
|
28
|
+
locals << method.local_names[arg].to_s
|
29
|
+
end
|
30
|
+
|
31
|
+
arg_str = locals.join(", ")
|
32
|
+
else
|
33
|
+
arg_str = ""
|
34
|
+
end
|
35
|
+
|
36
|
+
loc = @vm_location
|
37
|
+
|
38
|
+
if loc.is_block
|
39
|
+
if arg_str.empty?
|
40
|
+
recv = "{ } in #{loc.describe_receiver}#{loc.name}"
|
41
|
+
else
|
42
|
+
recv = "{|#{arg_str}| } in #{loc.describe_receiver}#{loc.name}"
|
43
|
+
end
|
44
|
+
else
|
45
|
+
if arg_str.empty?
|
46
|
+
recv = loc.describe
|
47
|
+
else
|
48
|
+
recv = "#{loc.describe}(#{arg_str})"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
filename = loc.method.active_path
|
53
|
+
filename = File.basename(filename) if opts[:basename]
|
54
|
+
str = "#{recv} at #{filename}:#{loc.line}"
|
55
|
+
if opts[:show_ip]
|
56
|
+
str << " (@#{loc.ip})"
|
57
|
+
end
|
58
|
+
|
59
|
+
str
|
60
|
+
end
|
61
|
+
|
62
|
+
def file
|
63
|
+
@vm_location.file
|
64
|
+
end
|
65
|
+
|
66
|
+
def ip
|
67
|
+
@vm_location.ip
|
68
|
+
end
|
69
|
+
|
70
|
+
def next_ip
|
71
|
+
@vm_location.next_ip
|
72
|
+
end
|
73
|
+
|
74
|
+
def line
|
75
|
+
line_no = @vm_location.line
|
76
|
+
line_no == 0 ? ISeq::tail_code_line(method, next_ip) : line_no
|
77
|
+
end
|
78
|
+
|
79
|
+
def local_variables
|
80
|
+
method.local_names
|
81
|
+
end
|
82
|
+
|
83
|
+
# Return true if frame1 and frame2 are at the same place.
|
84
|
+
# We use this for example in detecting tail recursion.
|
85
|
+
def location_equal(other_frame)
|
86
|
+
# if self && other_frame
|
87
|
+
# puts(self.vm_location.line, other_frame.vm_location.line,
|
88
|
+
# self.vm_location.ip, other_frame.vm_location.ip,
|
89
|
+
# self.vm_location.method.active_path, other_frame.vm_locaion.method.actionve_path)
|
90
|
+
# end
|
91
|
+
self && other_frame && self.vm_location.line == other_frame.vm_location.line &&
|
92
|
+
self.vm_location.ip == other_frame.vm_location.ip &&
|
93
|
+
self.vm_location.method.active_path == other_frame.vm_location.method.active_path
|
94
|
+
end
|
95
|
+
|
96
|
+
def method
|
97
|
+
@vm_location.method
|
98
|
+
end
|
99
|
+
|
100
|
+
def scope
|
101
|
+
@vm_location.variables
|
102
|
+
end
|
103
|
+
|
104
|
+
def stack_size
|
105
|
+
@debugger.vm_locations.size
|
106
|
+
end
|
107
|
+
|
108
|
+
def eval?
|
109
|
+
static = @vm_location.constant_scope
|
110
|
+
static && static.script && static.script.eval_source
|
111
|
+
end
|
112
|
+
|
113
|
+
def eval_string
|
114
|
+
return nil unless eval?
|
115
|
+
static = @vm_location.constant_scope
|
116
|
+
static.script.eval_source
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
end
|