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
@@ -0,0 +1,20 @@
|
|
1
|
+
Command examples
|
2
|
+
================
|
3
|
+
|
4
|
+
# This line does nothing. It is a comment. Useful in debugger command files.
|
5
|
+
# This line also does nothing.
|
6
|
+
s # by default, this is an alias for the "step" command
|
7
|
+
!s # shows the value of variable "s".
|
8
|
+
!!s # Evaluates "!s" (or "not s"). The first ! is indicates evaluate.
|
9
|
+
!s # Same as above, since there is a space in column one.
|
10
|
+
|
11
|
+
info program;; list # Runs two commands "info program" and "list"
|
12
|
+
pr "hi ;;-)" # Syntax error since ;; splits the line and " is not closed.
|
13
|
+
!puts "hi ;;-)" # One way to do the above.
|
14
|
+
|
15
|
+
See also:
|
16
|
+
---------
|
17
|
+
|
18
|
+
`macro`, `alias`, `irb`, `set auto eval`, `set auto irb`, `set
|
19
|
+
abbrev`, `info macro`, and the *show* variants of the above *set*
|
20
|
+
commands.
|
@@ -0,0 +1,46 @@
|
|
1
|
+
Syntax for Indicating a Filename
|
2
|
+
================================
|
3
|
+
|
4
|
+
There are two ways you can give a file name:
|
5
|
+
|
6
|
+
* unadorned (without double-quotes) with possible escapes
|
7
|
+
* as a double-quoted string with possible escapes in the string
|
8
|
+
|
9
|
+
Probably most of the time a file name will be specified in the first
|
10
|
+
form, without using quotes. If the file name however has a space or a
|
11
|
+
colon in it, escape that character with a backslash. Also, if you need
|
12
|
+
to enter a backslash and the character followinng that is unlucky
|
13
|
+
enough to be a colon, space, or backslash use two backslashes.
|
14
|
+
|
15
|
+
Filename Examples:
|
16
|
+
------------------
|
17
|
+
|
18
|
+
irb.rb => irb.rb
|
19
|
+
/tmp/irb.rb => /tmp/irb.rb
|
20
|
+
C\:irb.rb => C:irb.rb
|
21
|
+
C\:\irb.rb => C:\irb.rb
|
22
|
+
C\:\\irb.rb => C:\irb.rb # Note: double slash not needed
|
23
|
+
\\new.rb => \new.rb # Note: double slash, or filename has newline
|
24
|
+
my\ file.rb => my file.rb
|
25
|
+
|
26
|
+
|
27
|
+
The quoted string is useful if you have a file name that contains
|
28
|
+
several characters that normally confuse the debugger parser, notably
|
29
|
+
a space, newline, or a colon. The quoted string starts with a double
|
30
|
+
quote ("). Escape sequences are allowed inside the string to be able
|
31
|
+
to enter tabs or newlines, or a double quote inside the string. The
|
32
|
+
list of translations is as follows:
|
33
|
+
|
34
|
+
|
35
|
+
\t => <tab>
|
36
|
+
\n => <newline>
|
37
|
+
\" => "
|
38
|
+
\\ => \
|
39
|
+
|
40
|
+
Quoted Filename Examples:
|
41
|
+
-------------------------
|
42
|
+
|
43
|
+
"This is a file with blanks.rb" => This is a file with blanks.rb
|
44
|
+
"/tmp/RubyProgram \"foo\".rb => /tmp/RubyProgram "foo".rb
|
45
|
+
"/Ruby\nProgram.rb" => /tmp/Ruby
|
46
|
+
Program.rb
|
@@ -0,0 +1,34 @@
|
|
1
|
+
Syntax for Source-Code Locations
|
2
|
+
================================
|
3
|
+
|
4
|
+
Locations are used to indicates places in the source code or the
|
5
|
+
places in bytecode compiled from source code. Locations are used in
|
6
|
+
the listing commands like `list` or `disassemble`; they are also used
|
7
|
+
in *breakpoint* commands like `break`, `tbreak` and `continue`.
|
8
|
+
|
9
|
+
A location is either some sort of *container* and a position inside
|
10
|
+
that container. A container is either a file name or a method
|
11
|
+
name. And a position is either a line number or a bytecode offset.
|
12
|
+
Bytecode offsets are prefaced with an "@". So 4 is a line number 4, but
|
13
|
+
`@4` is bytecode offset 4.
|
14
|
+
|
15
|
+
File names are distinguished from method names purely by semantic
|
16
|
+
means. That its *foo* could conceivably be either a method or a file
|
17
|
+
name. The debugger does a file check to see 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"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Command suffixes which have special meaning
|
2
|
+
===========================================
|
3
|
+
|
4
|
+
Some commands like `step`, or `list` do different things when an
|
5
|
+
alias to the command ends in a particular suffix like `>`.
|
6
|
+
|
7
|
+
Here are a list of commands and the special suffixes:
|
8
|
+
|
9
|
+
command suffix
|
10
|
+
------- ------
|
11
|
+
list >
|
12
|
+
step +,-,<,>
|
13
|
+
next +,-,<,>
|
14
|
+
quit !
|
15
|
+
kill !
|
16
|
+
eval ?
|
17
|
+
|
18
|
+
See the help on the specific commands listed above for the specific
|
19
|
+
meaning of the suffix.
|
data/processor/command/info.rb
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010,
|
2
|
+
# Copyright (C) 2010-2011, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require_relative 'base/submgr'
|
4
4
|
|
5
5
|
class Trepan::Command::InfoCommand < Trepan::SubcommandMgr
|
6
6
|
unless defined?(HELP)
|
7
7
|
NAME = File.basename(__FILE__, '.rb')
|
8
8
|
HELP = <<-HELP
|
9
|
-
|
9
|
+
**#{NAME}** [*info-subcommand*]
|
10
|
+
|
11
|
+
Generic command for showing things about the program being debugged.
|
10
12
|
|
11
13
|
You can give unique prefix of the name of a subcommand to get
|
12
14
|
information about just that subcommand.
|
13
15
|
|
14
|
-
Type
|
15
|
-
Type
|
16
|
+
Type `#{NAME}` for a list of *#{NAME}* subcommands and what they do.
|
17
|
+
Type `help #{NAME} `" for just a list of `*#{NAME}*` subcommands.
|
16
18
|
HELP
|
17
19
|
|
18
20
|
ALIASES = %w(i)
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010,
|
2
|
+
# Copyright (C) 2010-2011, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require_relative '../base/subcmd'
|
4
4
|
|
5
5
|
class Trepan::Subcommand::InfoBreakpoints < Trepan::Subcommand
|
6
6
|
unless defined?(HELP)
|
7
7
|
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
8
8
|
HELP = <<-EOH
|
9
|
-
|
9
|
+
**#{CMD}** [*num1* ...] [**verbose**]
|
10
10
|
|
11
11
|
Show status of user-settable breakpoints. If no breakpoint numbers are
|
12
12
|
given, the show all breakpoints. Otherwise only those breakpoints
|
13
|
-
listed are shown and the order given. If
|
13
|
+
listed are shown and the order given. If *verbose* is given, more
|
14
14
|
information provided about each breakpoint.
|
15
15
|
|
16
16
|
The "Disp" column contains one of "keep", "del", the disposition of
|
@@ -23,7 +23,7 @@ EOH
|
|
23
23
|
MIN_ABBREV = 'br'.size
|
24
24
|
SHORT_HELP = 'Status of user-settable breakpoints'
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def bpprint(bp, verbose=false)
|
28
28
|
disp = bp.temp? ? 'del ' : 'keep '
|
29
29
|
disp += bp.enabled? ? 'y ' : 'n '
|
@@ -31,7 +31,7 @@ EOH
|
|
31
31
|
iseq = bp.iseq
|
32
32
|
mess = '%-4dbreakpoint %s at ' % [bp.id, disp]
|
33
33
|
|
34
|
-
line_loc = '%s:%d' %
|
34
|
+
line_loc = '%s:%d' %
|
35
35
|
[iseq.source_container.join(' '),
|
36
36
|
iseq.offset2lines(bp.offset).join(', ')]
|
37
37
|
vm_loc = "VM offset %d of instruction sequence \"%s\"" %
|
@@ -66,7 +66,7 @@ EOH
|
|
66
66
|
iseq = bp.iseq
|
67
67
|
next unless 'file' == iseq.source_container[0]
|
68
68
|
loc = iseq.source_container[1] + ':'
|
69
|
-
loc +=
|
69
|
+
loc +=
|
70
70
|
# if 'line' == bp.type
|
71
71
|
iseq.offset2lines(bp.offset)[0].to_s
|
72
72
|
# else
|
@@ -86,10 +86,10 @@ EOH
|
|
86
86
|
end
|
87
87
|
|
88
88
|
|
89
|
-
show_all =
|
89
|
+
show_all =
|
90
90
|
if args.size > 2
|
91
91
|
opts = {
|
92
|
-
:msg_on_error =>
|
92
|
+
:msg_on_error =>
|
93
93
|
"An '#{CMD}' argument must eval to a breakpoint between 1..#{@proc.brkpts.max}.",
|
94
94
|
:min_value => 1,
|
95
95
|
:max_value => @proc.brkpts.max
|
@@ -99,9 +99,9 @@ EOH
|
|
99
99
|
else
|
100
100
|
true
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
bpmgr = @proc.brkpts
|
104
|
-
if bpmgr.empty?
|
104
|
+
if bpmgr.empty?
|
105
105
|
msg('No breakpoints.')
|
106
106
|
else
|
107
107
|
# There's at least one
|
@@ -121,7 +121,7 @@ EOH
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
errmsg "No breakpoint number(s) #{not_found.join(' ')}." unless
|
124
|
-
notfound.empty?
|
124
|
+
notfound.empty?
|
125
125
|
end
|
126
126
|
end
|
127
127
|
if @proc.traced_vars.empty?
|
@@ -152,9 +152,9 @@ if __FILE__ == $0
|
|
152
152
|
tf = RubyVM::Frame.current
|
153
153
|
pc_offset = tf.pc_offset
|
154
154
|
def foo
|
155
|
-
5
|
155
|
+
5
|
156
156
|
end
|
157
|
-
|
157
|
+
|
158
158
|
brk_cmd = dbgr.core.processor.commands['break']
|
159
159
|
brk_cmd.run(['break', "O#{pc_offset}"])
|
160
160
|
cmd.run(%w(info break))
|
@@ -12,37 +12,41 @@ class Trepan::Subcommand::InfoFiles < Trepan::Subcommand
|
|
12
12
|
DEFAULT_FILE_ARGS = %w(size mtime sha1)
|
13
13
|
|
14
14
|
HELP = <<-EOH
|
15
|
-
|
15
|
+
**#{CMD}** [{*filename*|.|\\*} *attributes*
|
16
|
+
|
17
|
+
*attributes* can be any set of of:
|
18
|
+
**all**, **ctime**, **brkpts**, **mtime**, **sha1**, **size** or **stat**
|
16
19
|
|
17
20
|
Show information about the current file. If no filename is given and
|
18
21
|
the program is running, then the current file associated with the
|
19
|
-
current stack entry is used. Giving . has the same effect.
|
22
|
+
current stack entry is used. Giving . has the same effect.
|
20
23
|
|
21
|
-
|
24
|
+
A `*` gives a list of all files we know about.
|
22
25
|
|
23
26
|
Sub options which can be shown about a file are:
|
24
27
|
|
25
|
-
brkpts -- Line numbers where there are statement boundaries.
|
26
|
-
|
27
|
-
ctime -- File creation time
|
28
|
-
iseq -- Instruction sequences from this file.
|
29
|
-
mtime -- File modification time
|
30
|
-
sha1 -- A SHA1 hash of the source text. This may be useful in comparing
|
31
|
-
|
32
|
-
size -- The number of lines in the file.
|
33
|
-
stat -- File.stat information
|
28
|
+
brkpts -- Line numbers where there are statement boundaries.
|
29
|
+
These lines can be used in breakpoint commands.
|
30
|
+
ctime -- File creation time
|
31
|
+
iseq -- Instruction sequences from this file.
|
32
|
+
mtime -- File modification time
|
33
|
+
sha1 -- A SHA1 hash of the source text. This may be useful in comparing
|
34
|
+
source code.
|
35
|
+
size -- The number of lines in the file.
|
36
|
+
stat -- File.stat information
|
34
37
|
|
35
|
-
all -- All of the above information.
|
38
|
+
all -- All of the above information.
|
36
39
|
|
37
|
-
If no sub-options are given,
|
40
|
+
If no sub-options are given, `#{DEFAULT_FILE_ARGS.join(' ')}` are assumed.
|
38
41
|
|
39
42
|
Examples:
|
43
|
+
---------
|
40
44
|
|
41
|
-
#{CMD} # Show #{DEFAULT_FILE_ARGS.join(' ')} information about current file
|
42
|
-
#{CMD} . # same as above
|
43
|
-
#{CMD} brkpts # show the number of lines in the current file
|
44
|
-
#{CMD} brkpts size # same as above but also list breakpoint line numbers
|
45
|
-
#{CMD} * # Give a list of files we know about
|
45
|
+
#{CMD} # Show #{DEFAULT_FILE_ARGS.join(' ')} information about current file
|
46
|
+
#{CMD} . # same as above
|
47
|
+
#{CMD} brkpts # show the number of lines in the current file
|
48
|
+
#{CMD} brkpts size # same as above but also list breakpoint line numbers
|
49
|
+
#{CMD} * # Give a list of files we know about
|
46
50
|
EOH
|
47
51
|
MIN_ABBREV = 'fi'.size # Note we have "info frame"
|
48
52
|
NEED_STACK = false
|
@@ -53,7 +57,7 @@ EOH
|
|
53
57
|
include Trepanning
|
54
58
|
|
55
59
|
def file_list
|
56
|
-
(LineCache.cached_files +
|
60
|
+
(LineCache.cached_files +
|
57
61
|
LineCache.class_variable_get('@@file2file_remap').keys).uniq
|
58
62
|
end
|
59
63
|
|
@@ -61,11 +65,11 @@ EOH
|
|
61
65
|
completions = ['.'] + file_list
|
62
66
|
Trepan::Complete.complete_token(completions, prefix)
|
63
67
|
end
|
64
|
-
|
68
|
+
|
65
69
|
# Get file information
|
66
70
|
def run(args)
|
67
71
|
return if args.size < 2
|
68
|
-
args << '.' if 2 == args.size
|
72
|
+
args << '.' if 2 == args.size
|
69
73
|
if '*' == args[2]
|
70
74
|
section 'Canonic Files names cached:'
|
71
75
|
primary = LineCache.class_variable_get('@@file_cache')
|
@@ -78,7 +82,7 @@ EOH
|
|
78
82
|
end
|
79
83
|
return
|
80
84
|
end
|
81
|
-
filename =
|
85
|
+
filename =
|
82
86
|
if '.' == args[2]
|
83
87
|
if not @proc.frame
|
84
88
|
errmsg("No frame - no default file.")
|
@@ -133,7 +137,7 @@ EOH
|
|
133
137
|
args[3..-1].each do |arg|
|
134
138
|
processed_arg = false
|
135
139
|
|
136
|
-
if %w(all size).member?(arg)
|
140
|
+
if %w(all size).member?(arg)
|
137
141
|
unless seen[:size]
|
138
142
|
max_line = LineCache::size(canonic_name)
|
139
143
|
msg "File has %d lines." % max_line if max_line
|
@@ -165,19 +169,19 @@ EOH
|
|
165
169
|
|
166
170
|
if %w(all ctime).member?(arg)
|
167
171
|
unless seen[:ctime]
|
168
|
-
msg("create time:\t%s." %
|
172
|
+
msg("create time:\t%s." %
|
169
173
|
LineCache::stat(canonic_name).ctime.to_s)
|
170
174
|
end
|
171
175
|
processed_arg = seen[:ctime] = true
|
172
176
|
end
|
173
|
-
|
174
|
-
if %w(all iseq).member?(arg)
|
177
|
+
|
178
|
+
if %w(all iseq).member?(arg)
|
175
179
|
unless seen[:iseq]
|
176
180
|
if SCRIPT_ISEQS__.member?(canonic_name)
|
177
181
|
msg("File contains instruction sequences:")
|
178
182
|
SCRIPT_ISEQS__[canonic_name].each do |iseq|
|
179
183
|
msg("\t %s %s" % [iseq, iseq.name.inspect])
|
180
|
-
end
|
184
|
+
end
|
181
185
|
else
|
182
186
|
msg("Instruction sequences not recorded; there may be some, though.")
|
183
187
|
end
|
@@ -187,12 +191,12 @@ EOH
|
|
187
191
|
|
188
192
|
if %w(all mtime).member?(arg)
|
189
193
|
unless seen[:mtime]
|
190
|
-
msg("modify time:\t%s." %
|
194
|
+
msg("modify time:\t%s." %
|
191
195
|
LineCache::stat(canonic_name).mtime.to_s)
|
192
196
|
end
|
193
197
|
processed_arg = seen[:mtime] = true
|
194
198
|
end
|
195
|
-
|
199
|
+
|
196
200
|
if %w(all stat).member?(arg)
|
197
201
|
unless seen[:stat]
|
198
202
|
msg("Stat info:\n\t%s." % LineCache::stat(canonic_name).inspect)
|
@@ -213,7 +217,7 @@ if __FILE__ == $0
|
|
213
217
|
SCRIPT_ISEQS__ = {}
|
214
218
|
ARGV[0..-1] = ['noload']
|
215
219
|
load(__FILE__)
|
216
|
-
else
|
220
|
+
else
|
217
221
|
require_relative '../../mock'
|
218
222
|
cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoFiles, false)
|
219
223
|
[%w(info file nothere),
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010,
|
2
|
+
# Copyright (C) 2010-2011, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require_relative '../base/subcmd'
|
4
4
|
|
5
5
|
class Trepan::Subcommand::InfoFrame < Trepan::Subcommand
|
6
6
|
unless defined?(HELP)
|
7
7
|
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
8
8
|
HELP = <<-EOH
|
9
|
-
|
9
|
+
**#{CMD}**
|
10
10
|
|
11
11
|
Show information about the selected frame. The fields we list are:
|
12
12
|
|
@@ -14,47 +14,96 @@ Show information about the selected frame. The fields we list are:
|
|
14
14
|
* The actual number of arguments passed in
|
15
15
|
* The 'arity' or permissible number of arguments passed it. -1 indicates
|
16
16
|
variable number
|
17
|
-
* The frame "type", e.g. TOP
|
17
|
+
* The frame "type", e.g. `TOP`, `METHOD`, `BLOCK`, `EVAL`, `CFUNC`, etc.
|
18
18
|
* The return value if the frame is at a return point
|
19
|
-
* The PC offset we are currently at; May be omitted of no instruction
|
19
|
+
* The PC offset we are currently at; May be omitted of no instruction
|
20
20
|
sequence
|
21
21
|
|
22
22
|
A backtrace shows roughly the same information in a more compact form.
|
23
23
|
|
24
|
-
Example
|
24
|
+
Example from inside File.basename('foo'):
|
25
|
+
-----------------------------------------
|
25
26
|
|
26
|
-
Frame basename
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
Frame basename
|
28
|
+
file : /tmp/c-func.rb # actually location of caller
|
29
|
+
line : 2 # inherited from caller
|
30
|
+
argc : 1 # One out argument supplied: 'foo'
|
31
|
+
arity : -1 # Variable number of args, can have up to 2 arguments.
|
32
|
+
type : CFUNC (A C function)
|
32
33
|
|
34
|
+
See also:
|
35
|
+
---------
|
36
|
+
`backtrace`
|
37
|
+
EOH
|
38
|
+
MIN_ABBREV = 'fr'.size # Note we have "info file"
|
39
|
+
MIN_ARGS = 0
|
40
|
+
MAX_ARGS = 0
|
41
|
+
NEED_STACK = true
|
42
|
+
SHORT_HELP = 'Show information about the selected frame'
|
43
|
+
end
|
33
44
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
msg " offset: %d" % frame.pc_offset if frame.iseq
|
52
|
-
if %w(return c-return).member?(@proc.event)
|
53
|
-
ret_val = Trepan::Frame.value_returned(@proc.frame, @proc.event)
|
54
|
-
msg " Return: %s" % ret_val
|
45
|
+
def print_frame_c_params(frame)
|
46
|
+
argc = frame.argc
|
47
|
+
# FIXME should figure out why exception is raised.
|
48
|
+
begin
|
49
|
+
if 0 == argc
|
50
|
+
return
|
51
|
+
elsif frame
|
52
|
+
1.upto(argc).map do
|
53
|
+
|i|
|
54
|
+
msg " \t#{frame.sp(argc-i+3).inspect}"
|
55
|
+
end
|
56
|
+
else
|
57
|
+
msg " \t??"
|
58
|
+
end
|
59
|
+
rescue NotImplementedError
|
60
|
+
msg " \t??"
|
61
|
+
end
|
55
62
|
end
|
56
|
-
end
|
57
63
|
|
64
|
+
def run(args)
|
65
|
+
if args.size == 2
|
66
|
+
frame = @proc.frame
|
67
|
+
frame_num = @proc.frame_index
|
68
|
+
else
|
69
|
+
frame_arg = args[2]
|
70
|
+
low, high = @proc.frame_low_high(nil)
|
71
|
+
opts={
|
72
|
+
:msg_on_error =>
|
73
|
+
"The '#{NAME}' command requires a frame number. Got: #{frame_arg}",
|
74
|
+
:min_value => low, :max_value => high
|
75
|
+
}
|
76
|
+
frame_num = @proc.get_an_int(frame_arg, opts)
|
77
|
+
frame, frame_num = @proc.get_frame(frame_num, true)
|
78
|
+
end
|
79
|
+
meth = frame.method rescue nil
|
80
|
+
|
81
|
+
section "Frame %2d: #{frame.method}" % @proc.frame_index
|
82
|
+
msg " %-6s: %s" % frame.source_container if frame.source_container
|
83
|
+
msg " line : %s" % @proc.frame_line
|
84
|
+
msg " argc : %d" % frame.argc if frame.argc
|
85
|
+
msg " arity : %d" % frame.arity if frame.arity
|
86
|
+
msg " type : %s" % frame.type
|
87
|
+
msg " offset: %d" % frame.pc_offset if frame.iseq
|
88
|
+
msg " label: %s" % frame.label if frame.label unless meth
|
89
|
+
if frame.argc and frame.argc > 0
|
90
|
+
msg " parameters:"
|
91
|
+
if meth and frame.type != 'IFUNC'
|
92
|
+
iseq = frame.iseq
|
93
|
+
if 'CFUNC' == frame.type
|
94
|
+
print_frame_c_params(frame)
|
95
|
+
elsif iseq
|
96
|
+
all_param_names(iseq).each do |param|
|
97
|
+
msg " \t#{param}"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
if %w(return c_return b_return).member?(@proc.event.to_s)
|
104
|
+
@proc.commands['info'].run(%W(info return))
|
105
|
+
end
|
106
|
+
end
|
58
107
|
end
|
59
108
|
|
60
109
|
if __FILE__ == $0
|