trepanning 0.1.6 → 1.93.32
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/COPYING +57 -0
- data/ChangeLog +585 -736
- data/NEWS +26 -12
- data/README.md +62 -0
- data/Rakefile +15 -9
- data/app/breakpoint.rb +11 -12
- data/app/complete.rb +14 -14
- data/app/core.rb +34 -30
- data/app/default.rb +8 -7
- data/app/markdown.rb +191 -0
- data/app/options.rb +104 -99
- data/app/run.rb +9 -1
- data/app/util.rb +7 -7
- data/bin/trepan +7 -7
- data/interface.rb +0 -4
- data/interface/user.rb +11 -11
- data/io/input.rb +13 -13
- data/lib/trepanning.rb +30 -29
- data/processor.rb +40 -40
- data/processor/command.rb +13 -9
- data/processor/command/alias.rb +21 -15
- data/processor/command/backtrace.rb +27 -19
- data/processor/command/break.rb +24 -21
- data/processor/command/complete.rb +5 -2
- data/processor/command/condition.rb +14 -9
- data/processor/command/debug.rb +8 -8
- data/processor/command/down.rb +6 -6
- data/processor/command/edit.rb +4 -0
- data/processor/command/eval.rb +2 -2
- data/processor/command/exit.rb +12 -9
- data/processor/command/finish.rb +25 -23
- data/processor/command/frame.rb +30 -26
- data/processor/command/help.rb +203 -185
- data/processor/command/help/{command.txt → command.md} +21 -18
- data/processor/command/help/examples.md +20 -0
- data/processor/command/help/filename.md +46 -0
- data/processor/command/help/location.md +34 -0
- data/processor/command/help/suffixes.md +19 -0
- data/processor/command/info.rb +6 -4
- data/processor/command/info_subcmd/breakpoints.rb +13 -13
- data/processor/command/info_subcmd/files.rb +35 -31
- data/processor/command/info_subcmd/frame.rb +82 -33
- data/processor/command/info_subcmd/macro.rb +1 -1
- data/processor/command/info_subcmd/program.rb +8 -5
- data/processor/command/info_subcmd/registers.rb +15 -13
- data/processor/command/kill.rb +23 -17
- data/processor/command/list.rb +63 -56
- data/processor/command/macro.rb +45 -28
- data/processor/command/next.rb +29 -23
- data/processor/command/pp.rb +11 -9
- data/processor/command/pr.rb +10 -8
- data/processor/command/ps.rb +5 -5
- data/processor/command/quit.rb +24 -17
- data/processor/command/raise.rb +6 -6
- data/processor/command/reload.rb +9 -2
- data/processor/command/reload_subcmd/command.rb +4 -4
- data/processor/command/restart.rb +9 -4
- data/processor/command/save.rb +9 -9
- data/processor/command/server.rb +18 -17
- data/processor/command/set.rb +8 -6
- data/processor/command/set_subcmd/confirm.rb +15 -2
- data/processor/command/set_subcmd/different.rb +7 -5
- data/processor/command/set_subcmd/highlight.rb +14 -3
- data/processor/command/set_subcmd/pc.rb +62 -0
- data/processor/command/set_subcmd/sp.rb +8 -2
- data/processor/command/shell.rb +25 -23
- data/processor/command/show.rb +9 -7
- data/processor/command/show_subcmd/confirm.rb +12 -1
- data/processor/command/show_subcmd/highlight.rb +13 -3
- data/processor/command/source.rb +27 -26
- data/processor/command/step.rb +52 -43
- data/processor/command/tbreak.rb +9 -4
- data/processor/command/unalias.rb +9 -7
- data/processor/command/undisplay.rb +11 -7
- data/processor/command/up.rb +18 -13
- data/processor/command/watchg.rb +20 -17
- data/processor/complete.rb +120 -0
- data/processor/default.rb +47 -43
- data/processor/list.rb +23 -6
- data/processor/load_cmds.rb +25 -105
- data/processor/location.rb +104 -96
- data/processor/mock.rb +12 -12
- data/processor/msg.rb +61 -52
- data/processor/validate.rb +36 -27
- data/test/data/fname-with-blank.right +0 -1
- data/test/data/trace-mingw.right +28 -0
- data/test/data/trace.right +0 -2
- data/test/functional/test-raise.rb +3 -0
- data/test/integration/helper.rb +16 -16
- data/test/integration/test-debugger-stop.rb +8 -2
- data/test/integration/test-quit.rb +16 -15
- data/test/integration/test-trace.rb +19 -10
- data/test/unit/cmd-helper.rb +4 -1
- data/test/unit/test-app-complete.rb +3 -1
- data/test/unit/test-app-options.rb +7 -1
- data/test/unit/test-app-run.rb +9 -1
- data/test/unit/test-cmd-alias.rb +1 -1
- data/test/unit/test-cmd-edit.rb +2 -0
- data/test/unit/test-cmd-help.rb +10 -5
- data/test/unit/test-cmd-parse_list_cmd.rb +3 -3
- data/test/unit/test-completion.rb +2 -2
- data/test/unit/test-proc-default.rb +34 -0
- data/trepanning.gemspec +15 -14
- metadata +70 -44
- data/README.textile +0 -50
- data/processor/command/help/examples.txt +0 -16
- data/processor/command/help/filename.txt +0 -40
- data/processor/command/help/location.txt +0 -37
- data/processor/command/help/suffixes.txt +0 -17
- data/processor/command/info_subcmd/registers_subcmd/dfp.rb +0 -28
- data/processor/command/info_subcmd/registers_subcmd/lfp.rb +0 -47
- data/processor/command/nocache.rb +0 -32
- data/processor/command/parsetree.rb +0 -56
data/README.textile
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
A modular, testable debugger for MRI Ruby 1.9.2 or 1.9.3. A total rewrite of _ruby-debug_.
|
2
|
-
|
3
|
-
__In order to use this debugger, you'll need a patched MRI Ruby 1.9.2 or 1.9.3 and some additional packages. See the "installation instructions.":https://github.com/rocky/rb-trepanning/wiki/How-to-Install-rb-trepanning__
|
4
|
-
|
5
|
-
Right now this debugger is beta code.
|
6
|
-
|
7
|
-
There is a "google group mailing list":http://groups.google.com/group/ruby-debugger for Ruby debuggers.
|
8
|
-
|
9
|
-
If rb-trepanning is installed, here is how to run:
|
10
|
-
|
11
|
-
bc. trepan ruby-program [program]
|
12
|
-
|
13
|
-
If your program needs options of its own:
|
14
|
-
|
15
|
-
bc. trepan -- ruby-program [program args...]
|
16
|
-
|
17
|
-
If you want to run from the source tree you can do that too:
|
18
|
-
|
19
|
-
bc. cd place-where-trepan-is-installed:
|
20
|
-
./bin/trepan -- ruby-program [program args...]
|
21
|
-
|
22
|
-
Running from inside _irb_:
|
23
|
-
|
24
|
-
bc. require 'trepanning'
|
25
|
-
Trepan.debug { your code }
|
26
|
-
|
27
|
-
The return value from Trepan is the return value of the block, i.e. the final value in the block.
|
28
|
-
|
29
|
-
You can run the same thing inside your Ruby program, but probably you don't want to give a block. Instead, you may want to have debugging start on the next statement in the code:
|
30
|
-
|
31
|
-
bc. require 'trepan'
|
32
|
-
Trepan.debug # Don't stop here...
|
33
|
-
work # but stop here.
|
34
|
-
|
35
|
-
The above is really shorthand for something like:
|
36
|
-
|
37
|
-
bc. $trepan = Trepan.new
|
38
|
-
$trepan.debugger
|
39
|
-
|
40
|
-
The global variable $trepan set holds debugger settings, such as "autolist" or "autoeval" settings and breakpoint information.
|
41
|
-
|
42
|
-
Due to the line-event orientation in ruby-debug, it occasionally was convenient to add a synchronous stop in your program. I don't think that will be necessary here, but if you do call to the debugger at the point of the call rather than the subsequent stopping point, set opts[:immediate] to true. Example:
|
43
|
-
|
44
|
-
bc. # ... work, work, work
|
45
|
-
mydbg.debugger(:immediate=>true) # enter debugger here
|
46
|
-
# ... work, work, work
|
47
|
-
|
48
|
-
There is extensive on-line help. Run "help" inside the debugger.
|
49
|
-
|
50
|
-
|
@@ -1,16 +0,0 @@
|
|
1
|
-
Command examples
|
2
|
-
|
3
|
-
# This line does nothing. It is a comment. Useful in debugger command files.
|
4
|
-
# This line also does nothing.
|
5
|
-
s # by default, this is an alias for the "step" command
|
6
|
-
!s # shows the value of variable "s".
|
7
|
-
!!s # Evaluates "!s" (or "not s"). The first ! is indicates evaluate.
|
8
|
-
!s # Same as above, since there is a space in column one.
|
9
|
-
|
10
|
-
info program;; list # Runs two commands "info program" and "list"
|
11
|
-
pr "hi ;;-)" # Syntax error since ;; splits the line and " is not closed.
|
12
|
-
!puts "hi ;;-)" # One way to do the above.
|
13
|
-
|
14
|
-
See also "macro" "alias", "irb", "set auto eval", "set auto irb", "set
|
15
|
-
abbrev", "info macro", and "show" variants of the above "set"
|
16
|
-
commands.
|
@@ -1,40 +0,0 @@
|
|
1
|
-
syntax for indicating a filename
|
2
|
-
|
3
|
-
There are two ways you can give a file name:
|
4
|
-
- unadorned (without double-quotes) with possible escapes
|
5
|
-
- as a double-quoted string with possible escapes in the string
|
6
|
-
|
7
|
-
Probably most of the time a file name will be specified in the first
|
8
|
-
form, without using quotes. If the file name however has a space or a
|
9
|
-
colon in it, escape that character with a backslash. Also, if you need
|
10
|
-
to enter a backslash and the character followinng that is unlucky
|
11
|
-
enough to be a colon, space, or backslash use two backslashes. Some
|
12
|
-
examples:
|
13
|
-
|
14
|
-
irb.rb => irb.rb
|
15
|
-
/tmp/irb.rb => /tmp/irb.rb
|
16
|
-
C\:irb.rb => C:irb.rb
|
17
|
-
C\:\irb.rb => C:\irb.rb
|
18
|
-
C\:\\irb.rb => C:\irb.rb # Note: double slash not needed
|
19
|
-
\\new.rb => \new.rb # Note: double slash, or filename has newline
|
20
|
-
my\ file.rb => my file.rb
|
21
|
-
|
22
|
-
|
23
|
-
The quoted string is useful if you have a file name that contains
|
24
|
-
several characters that normally confuse the debugger parser, notably
|
25
|
-
a space, newline, or a colon. The quoted string starts with a double
|
26
|
-
quote ("). Escape sequences are allowed inside the string to be able
|
27
|
-
to enter tabs or newlines, or a double quote inside the string. The
|
28
|
-
list of translations is as follows:
|
29
|
-
|
30
|
-
\t => <tab>
|
31
|
-
\n => <newline>
|
32
|
-
\" => "
|
33
|
-
\\ => \
|
34
|
-
|
35
|
-
Here are some examples of quoted filenames:
|
36
|
-
|
37
|
-
"This is a file with blanks.rb" => This is a file with blanks.rb
|
38
|
-
"/tmp/RubyProgram \"foo\".rb => /tmp/RubyProgram "foo".rb
|
39
|
-
"/Ruby\nProgram.rb" => /tmp/Ruby
|
40
|
-
Program.rb
|
@@ -1,37 +0,0 @@
|
|
1
|
-
syntax for source code locations; e.g. used "list" and "break"
|
2
|
-
|
3
|
-
Locations are used to indicates places in the source code or the
|
4
|
-
places in bytecode compiled from source code. Locations are used in
|
5
|
-
the listing commands like "list" or "disassemble"; they are also used
|
6
|
-
in "breakpoint" commands like "break", "tbreak" and "continue"
|
7
|
-
|
8
|
-
A location is either some sort of "container" and a position inside
|
9
|
-
that container. A container is either a file name or a method
|
10
|
-
name. And a position is either a line number or a bytecode offset.
|
11
|
-
Bytecode offsets are prefaced with an '@'. So 4 is a line number 4, but
|
12
|
-
@4 is bytecode offset 4.
|
13
|
-
|
14
|
-
File names are distinguished from method names purely by semantic
|
15
|
-
means. That its "foo" (without the quotes) could conceivably be
|
16
|
-
either a method or a file name. The debugger does a file check to see
|
17
|
-
if "foo" is a file.
|
18
|
-
|
19
|
-
In gdb, locations are often given using a filename a colon and a line
|
20
|
-
number. That is supported here are well. So myfile.rb:5 indicates line 5
|
21
|
-
of file "myfile.rb". But since we also allow method names you can also use
|
22
|
-
"gcd:5" to indicate line 5 of method "gcd".
|
23
|
-
|
24
|
-
Line numbers in methods are not relative to the beginning of the
|
25
|
-
method but relative the beginning of source text that contains the
|
26
|
-
method. This is also how Ruby stores line numbers for methods which
|
27
|
-
are shown for example in a backtrace. So all of this hopefully will
|
28
|
-
feel familiar and consistent.
|
29
|
-
|
30
|
-
Instead of using a colon to separate the container and the position,
|
31
|
-
you can also use spacs. So "gcd 5" is the same as gcd:5.
|
32
|
-
|
33
|
-
If the filename has an embedded blank in it, you can indicate that by
|
34
|
-
using a backslash escape. For example: "file\ with\ blanks.rb"
|
35
|
-
|
36
|
-
|
37
|
-
|
@@ -1,17 +0,0 @@
|
|
1
|
-
Command suffixes which have special meaning
|
2
|
-
|
3
|
-
Some commands like "step", or "list" do different things when an
|
4
|
-
alias to the command ends in a particular suffix like ">".
|
5
|
-
|
6
|
-
Here are a list of commands and the special suffixes:
|
7
|
-
|
8
|
-
command suffix
|
9
|
-
------- ------
|
10
|
-
list >
|
11
|
-
step +,-,<,>
|
12
|
-
next +,-,<,>
|
13
|
-
quit !
|
14
|
-
kill !
|
15
|
-
eval ?
|
16
|
-
|
17
|
-
See help on the commands listed above for the specific meaning of the suffix.
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
-
require_relative '../../base/subsubcmd'
|
4
|
-
require_relative 'helper'
|
5
|
-
|
6
|
-
class Trepan::Subcommand::InfoRegistersDfp < Trepan::SubSubcommand
|
7
|
-
unless defined?(HELP)
|
8
|
-
Trepanning::SubSubcommand.set_name_prefix(__FILE__, self)
|
9
|
-
HELP = 'Show the value of the VM dynamic frame pointer (DFP)'
|
10
|
-
MIN_ABBREV = 'df'.size
|
11
|
-
NEED_STACK = true
|
12
|
-
end
|
13
|
-
|
14
|
-
include Registers
|
15
|
-
def run(args)
|
16
|
-
register_array_index(PREFIX[-1], args[0])
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
if __FILE__ == $0
|
21
|
-
# Demo it.
|
22
|
-
require_relative '../../../mock'
|
23
|
-
require_relative '../registers'
|
24
|
-
cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::InfoRegisters,
|
25
|
-
Trepan::SubSubcommand::InfoRegistersDfp,
|
26
|
-
false)
|
27
|
-
cmd.run(['0'])
|
28
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
-
require_relative '../../base/subsubcmd'
|
4
|
-
require_relative 'helper'
|
5
|
-
|
6
|
-
class Trepan::Subcommand::InfoRegistersLfp < Trepan::SubSubcommand
|
7
|
-
unless defined?(HELP)
|
8
|
-
Trepanning::SubSubcommand.set_name_prefix(__FILE__, self)
|
9
|
-
HELP = <<EOH
|
10
|
-
#{CMD} NUMBER
|
11
|
-
|
12
|
-
Show the value of the VM local frame pointer (LFP).
|
13
|
-
When a local variable is defined for the first time, this stack
|
14
|
-
is pushed and the value for local variable is assigned to this stack entry.
|
15
|
-
|
16
|
-
See also "info register sp".'
|
17
|
-
EOH
|
18
|
-
|
19
|
-
MIN_ABBREV = 'lf'.size
|
20
|
-
MIN_ARGS = 1
|
21
|
-
MAX_ARGS = 1
|
22
|
-
NEED_STACK = true
|
23
|
-
SHORT_HELP = "Show the value of the VM local frame pointer (LFP)."
|
24
|
-
end
|
25
|
-
|
26
|
-
include Registers
|
27
|
-
def run(args)
|
28
|
-
frame = @proc.frame
|
29
|
-
if 'CFUNC' == frame.type
|
30
|
-
msg "local_name not available for C function"
|
31
|
-
else
|
32
|
-
iseq = frame.iseq
|
33
|
-
index = register_array_index(PREFIX[-1], args[0], iseq.local_size-1)
|
34
|
-
msg("local_name(%d)=%s" % [index, iseq.local_name(index)]) if index
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
if __FILE__ == $0
|
40
|
-
# Demo it.
|
41
|
-
require_relative '../../../mock'
|
42
|
-
require_relative '../registers'
|
43
|
-
cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::InfoRegisters,
|
44
|
-
Trepan::SubSubcommand::InfoRegistersLfp,
|
45
|
-
false)
|
46
|
-
cmd.run([])
|
47
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
-
require_relative '../command'
|
4
|
-
class Trepan::Command::NoCacheCommand < Trepan::Command
|
5
|
-
|
6
|
-
unless defined?(HELP)
|
7
|
-
HELP = "Remove getinlinecache instructions from instruction sequence."
|
8
|
-
|
9
|
-
CATEGORY = 'running'
|
10
|
-
MAX_ARGS = 0 # Need at most this many
|
11
|
-
NAME = File.basename(__FILE__, '.rb')
|
12
|
-
NEED_STACK = true
|
13
|
-
SHORT_HELP = 'Remove getinlinecache instructions from instruction sequence.'
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
# This method runs the command
|
18
|
-
def run(args)
|
19
|
-
if @proc.frame.iseq
|
20
|
-
puts @proc.frame.iseq.disassemble
|
21
|
-
count = @proc.frame.iseq.killcache
|
22
|
-
msg "%d locations removed" % count
|
23
|
-
# puts @proc.frame.iseq.disassemble
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
if __FILE__ == $0
|
29
|
-
require_relative '../mock'
|
30
|
-
dbgr, cmd = MockDebugger::setup
|
31
|
-
cmd.run([cmd.name])
|
32
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
-
begin
|
4
|
-
require 'rubygems'
|
5
|
-
require 'parse_tree'
|
6
|
-
require_relative '../command'
|
7
|
-
require_relative '../../app/cmd_parse'
|
8
|
-
class Trepan::Command::ParseTreeCommand < Trepan::Command
|
9
|
-
|
10
|
-
unless defined?(HELP)
|
11
|
-
NAME = File.basename(__FILE__, '.rb')
|
12
|
-
HELP = <<-HELP
|
13
|
-
#{NAME}
|
14
|
-
#{NAME} method
|
15
|
-
|
16
|
-
In the first form, print a ParseTree S-expression of the current
|
17
|
-
class.
|
18
|
-
In the second form, preint a ParseTree S-expression of the current method.
|
19
|
-
In the third form print a ParseTree S-expression of CLASS.
|
20
|
-
In the fourth form, print a ParseTree S-expression of the given method.
|
21
|
-
HELP
|
22
|
-
|
23
|
-
# ALIASES = %w(p)
|
24
|
-
CATEGORY = 'data'
|
25
|
-
SHORT_HELP = 'PrettyPrint a ParseTree S-expression'
|
26
|
-
end
|
27
|
-
|
28
|
-
def run(args)
|
29
|
-
@processor ||= ParseTree19.new(false)
|
30
|
-
meth = nil
|
31
|
-
case args.size
|
32
|
-
when 1
|
33
|
-
method_name = @proc.frame.method
|
34
|
-
when 2
|
35
|
-
method_name = args[1]
|
36
|
-
else
|
37
|
-
errmsg 'Expecting a method name'
|
38
|
-
return
|
39
|
-
end
|
40
|
-
meth = Trepan::CmdParser.meth_for_string(method_name, @proc.frame.binding)
|
41
|
-
if meth and meth.kind_of?(Method)
|
42
|
-
msg @processor.parse_tree_for_method(meth, true).pretty_inspect
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
if __FILE__ == $0
|
47
|
-
require 'pp'
|
48
|
-
require_relative '../mock'
|
49
|
-
dbgr, cmd = MockDebugger::setup
|
50
|
-
cmd.proc.frame.instance_variable_set('@binding', TOPLEVEL_BINDING)
|
51
|
-
cmd.run([cmd.name, 'FileUtils.rm'])
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
rescue LoadError
|
56
|
-
end
|