trepanning 0.1.0 → 0.1.1
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 +4 -0
- data/ChangeLog +1279 -235
- data/Makefile +13 -0
- data/NEWS +30 -0
- data/Rakefile +50 -14
- data/app/.gitignore +1 -0
- data/app/breakpoint.rb +7 -2
- data/app/brkptmgr.rb +12 -0
- data/app/cmd_parse.citrus +167 -0
- data/app/cmd_parse.kpeg +221 -0
- data/app/cmd_parse.rb +201 -0
- data/app/cmd_parser.rb +1914 -0
- data/app/complete.rb +79 -0
- data/app/condition.rb +1 -1
- data/app/core.rb +7 -11
- data/app/default.rb +1 -1
- data/app/disassemble.rb +3 -2
- data/app/file.rb +12 -36
- data/app/frame.rb +3 -2
- data/app/irb.rb +9 -5
- data/app/iseq.rb +46 -0
- data/app/options.rb +6 -30
- data/app/run.rb +5 -2
- data/app/util.rb +1 -2
- data/app/yarv.rb +11 -1
- data/bin/.gitignore +1 -0
- data/bin/trepan +6 -6
- data/data/.gitignore +1 -0
- data/interface/.gitignore +1 -0
- data/interface/base_intf.rb +9 -5
- data/interface/comcodes.rb +10 -8
- data/interface/user.rb +76 -17
- data/io/.gitignore +1 -0
- data/io/input.rb +39 -15
- data/io/tcpclient.rb +7 -1
- data/io/tcpfns.rb +5 -3
- data/io/tcpserver.rb +13 -10
- data/lib/.gitignore +1 -0
- data/lib/trepanning.rb +50 -13
- data/processor/.gitignore +1 -0
- data/processor/Makefile +7 -0
- data/processor/breakpoint.rb +7 -2
- data/processor/command/.gitignore +1 -0
- data/processor/command/Makefile +7 -0
- data/processor/command/alias.rb +2 -2
- data/processor/command/backtrace.rb +4 -0
- data/processor/command/base/cmd.rb +45 -2
- data/processor/command/base/subcmd.rb +4 -2
- data/processor/command/base/submgr.rb +23 -19
- data/processor/command/base/subsubcmd.rb +23 -1
- data/processor/command/base/subsubmgr.rb +13 -0
- data/processor/command/break.rb +34 -29
- data/processor/command/complete.rb +37 -0
- data/processor/command/condition.rb +2 -0
- data/processor/command/continue.rb +15 -18
- data/processor/command/disassemble.rb +5 -0
- data/processor/command/down.rb +1 -1
- data/processor/command/eval.rb +70 -0
- data/processor/command/exit.rb +4 -1
- data/processor/command/finish.rb +6 -4
- data/processor/command/frame.rb +6 -3
- data/processor/command/help.rb +97 -54
- data/processor/command/help/.gitignore +1 -0
- data/processor/command/help/README +10 -0
- data/processor/command/help/command.txt +48 -0
- data/processor/command/help/filename.txt +40 -0
- data/processor/command/help/location.txt +37 -0
- data/processor/command/info_subcmd/.gitignore +1 -0
- data/processor/command/info_subcmd/breakpoints.rb +9 -9
- data/processor/command/info_subcmd/{file.rb → files.rb} +92 -27
- data/processor/command/info_subcmd/frame.rb +41 -15
- data/processor/command/info_subcmd/iseq.rb +39 -17
- data/processor/command/info_subcmd/program.rb +2 -8
- data/processor/command/info_subcmd/registers.rb +12 -10
- data/processor/command/info_subcmd/registers_subcmd/.gitignore +1 -0
- data/processor/command/info_subcmd/ruby.rb +60 -0
- data/processor/command/irb.rb +26 -3
- data/processor/command/kill.rb +21 -10
- data/processor/command/list.rb +1 -1
- data/processor/command/macro.rb +37 -23
- data/processor/command/pr.rb +1 -1
- data/processor/command/reload.rb +4 -0
- data/processor/command/reload_subcmd/.gitignore +1 -0
- data/processor/command/restart.rb +9 -9
- data/processor/command/save.rb +29 -36
- data/processor/command/set_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/auto_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/confirm.rb +23 -0
- data/processor/command/set_subcmd/debug_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/different.rb +2 -0
- data/processor/command/set_subcmd/events.rb +2 -0
- data/processor/command/set_subcmd/max.rb +9 -12
- data/processor/command/set_subcmd/max_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/substitute_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/trace.rb +7 -13
- data/processor/command/set_subcmd/trace_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/trace_subcmd/buffer.rb +12 -27
- data/processor/command/set_subcmd/trace_subcmd/print.rb +10 -8
- data/processor/command/set_subcmd/trace_subcmd/var.rb +6 -10
- data/processor/command/show.rb +12 -1
- data/processor/command/show_subcmd/.gitignore +1 -0
- data/processor/command/show_subcmd/alias.rb +11 -15
- data/processor/command/show_subcmd/auto_subcmd/.gitignore +1 -0
- data/processor/command/show_subcmd/basename.rb +1 -9
- data/processor/command/show_subcmd/confirm.rb +25 -0
- data/processor/command/show_subcmd/debug_subcmd/.gitignore +1 -0
- data/processor/command/show_subcmd/macro.rb +32 -14
- data/processor/command/show_subcmd/max_subcmd/.gitignore +1 -0
- data/processor/command/show_subcmd/trace_subcmd/.gitignore +1 -0
- data/processor/command/show_subcmd/trace_subcmd/buffer.rb +11 -31
- data/processor/command/show_subcmd/trace_subcmd/print.rb +4 -20
- data/processor/command/source.rb +7 -1
- data/processor/command/up.rb +7 -4
- data/processor/default.rb +3 -1
- data/processor/eval.rb +13 -0
- data/processor/eventbuf.rb +3 -2
- data/processor/frame.rb +19 -0
- data/processor/help.rb +20 -0
- data/processor/load_cmds.rb +143 -24
- data/processor/location.rb +61 -10
- data/processor/main.rb +30 -11
- data/processor/mock.rb +5 -3
- data/processor/msg.rb +17 -0
- data/processor/running.rb +1 -1
- data/processor/subcmd.rb +3 -2
- data/processor/validate.rb +173 -185
- data/sample/.gitignore +1 -0
- data/sample/list-terminal-colors.rb +139 -0
- data/sample/rocky-dot-trepanrc +14 -0
- data/sample/rocky-trepan-colors.rb +47 -0
- data/test/Makefile +7 -0
- data/test/data/.gitignore +1 -0
- data/test/data/debugger-stop.cmd +3 -0
- data/test/data/debugger-stop.right +5 -0
- data/test/data/fname-with-blank.right +0 -3
- data/test/data/quit.right +0 -1
- data/test/data/quit2.cmd +6 -0
- data/test/data/quit2.right +3 -0
- data/test/data/testing.cmd +1 -0
- data/test/example/.gitignore +1 -0
- data/test/example/debugger-stop.rb +14 -0
- data/test/functional/.gitignore +2 -0
- data/test/functional/fn_helper.rb +7 -9
- data/test/functional/test-break-long.rb +7 -7
- data/test/functional/test-break.rb +7 -7
- data/test/functional/test-condition.rb +4 -4
- data/test/functional/test-delete.rb +6 -5
- data/test/functional/test-eval.rb +115 -0
- data/test/functional/test-raise.rb +1 -1
- data/test/functional/test-return.rb +1 -1
- data/test/integration/.gitignore +2 -0
- data/test/integration/helper.rb +6 -3
- data/test/integration/test-debugger-stop.rb +22 -0
- data/test/integration/test-quit.rb +8 -0
- data/test/unit/.gitignore +1 -0
- data/test/unit/Makefile +7 -0
- data/test/unit/test-app-brkpt.rb +0 -1
- data/test/unit/test-app-cmd_parse.rb +107 -0
- data/test/unit/test-app-cmd_parser.rb +22 -0
- data/test/unit/test-app-complete.rb +38 -0
- data/test/unit/test-app-condition.rb +20 -0
- data/test/unit/test-app-iseq.rb +31 -0
- data/test/unit/test-app-options.rb +9 -1
- data/test/unit/test-app-util.rb +0 -1
- data/test/unit/test-base-cmd.rb +46 -0
- data/test/unit/test-base-subcmd.rb +11 -2
- data/test/unit/test-base-submgr.rb +23 -0
- data/test/unit/test-base-subsubcmd.rb +20 -0
- data/test/unit/test-cmd-break.rb +22 -23
- data/test/unit/test-cmd-help.rb +4 -0
- data/test/unit/test-completion.rb +43 -0
- data/test/unit/test-io-tcpclient.rb +3 -2
- data/test/unit/test-proc-load_cmds.rb +10 -1
- data/test/unit/test-proc-location.rb +39 -0
- data/test/unit/test-proc-main.rb +1 -1
- data/test/unit/test-proc-validate.rb +47 -31
- data/trepanning.gemspec +45 -0
- metadata +247 -179
- data/app/core.rb-consider +0 -198
- data/test/functional/tmp/b3.rb +0 -5
- data/test/functional/tmp/immediate-bug1.rb +0 -9
@@ -0,0 +1 @@
|
|
1
|
+
/*~
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Files in this directory are help for "help syntax".
|
2
|
+
|
3
|
+
A list of sub-names is obtained by Dir.glob('*.txt') in this
|
4
|
+
directory.
|
5
|
+
|
6
|
+
Each file name without the trailing ".txt' is the name of the help
|
7
|
+
subcategory under "help syntax".
|
8
|
+
|
9
|
+
The first line in the file is a summary shown in help summary.
|
10
|
+
Lines 3 on are shown as help text.
|
@@ -0,0 +1,48 @@
|
|
1
|
+
overall debugger command syntax
|
2
|
+
|
3
|
+
Command tokenization syntax is very simple-minded.
|
4
|
+
|
5
|
+
If a line starts with #, the command is ignored.
|
6
|
+
If a line starts with !, the line is eval'd.
|
7
|
+
|
8
|
+
If the command you want eval'd uses the Ruby ! initially, add that
|
9
|
+
after the first ! or start the line with a space.
|
10
|
+
|
11
|
+
Commands are split at whereever ;; appears. This process disregards
|
12
|
+
any quotes or other symbols that have meaning in Ruby. The strings
|
13
|
+
after the leading command string are put back on a command queue.
|
14
|
+
|
15
|
+
Within a single command, tokens are then white-space split. Again,
|
16
|
+
this process disregards quotes or symbols that have meaning in Ruby.
|
17
|
+
Some commands like 'eval', 'macro', and 'break' have access to the
|
18
|
+
untokenized string entered and make use of that rather than the
|
19
|
+
tokenized list.
|
20
|
+
|
21
|
+
The leading token is first looked up in the macro table. If it is in
|
22
|
+
the table, the expansion is replaces the current command and possibly
|
23
|
+
other commands pushed onto a command queue. Next, the leading token is
|
24
|
+
looked up in the debugger alias table and the name may be substituted
|
25
|
+
there. Finally, the leading token is looked up in the debugger alias
|
26
|
+
table. If a match is found, the command name and arguments are
|
27
|
+
dispatched to the command object that process the command.
|
28
|
+
|
29
|
+
If the command is not found and "auto eval" is set on, then the
|
30
|
+
command is eval'd in the context that the program is currently stopped
|
31
|
+
at. If "auto eval" is not set on, then we display an error message
|
32
|
+
that the entered string is "undefined".
|
33
|
+
|
34
|
+
If you want irb-like command-processing, it's possible to go into an
|
35
|
+
irb shell with the "irb" command. It is also possible to arrange going
|
36
|
+
into an irb shell every time you enter the debugger.
|
37
|
+
|
38
|
+
Examples:
|
39
|
+
|
40
|
+
# This line does nothing. It is a comment
|
41
|
+
s # by default, this is an alias for the "step" command
|
42
|
+
!s # shows the value of variable step.
|
43
|
+
!!s # Evaluates !s (or "not s"). The first ! is indicates evaluate.
|
44
|
+
info program;; list # Runs two commands "info program" and "list"
|
45
|
+
pr "hi ;;-)" # Syntax error since ;; splits the line and " is not closed.
|
46
|
+
!puts "hi ;;-)" # One way to do the above.
|
47
|
+
|
48
|
+
See also "alias", "irb", "set auto eval", and "set auto irb".
|
@@ -0,0 +1,40 @@
|
|
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
|
@@ -0,0 +1,37 @@
|
|
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
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
/*~
|
@@ -5,8 +5,8 @@ require_relative '../base/subcmd'
|
|
5
5
|
class Trepan::Subcommand::InfoBreakpoints < Trepan::Subcommand
|
6
6
|
unless defined?(HELP)
|
7
7
|
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
8
|
-
HELP =
|
9
|
-
|
8
|
+
HELP = <<-EOH
|
9
|
+
#{PREFIX.join(' ')} [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
|
@@ -20,11 +20,10 @@ The "enb" column indicates whether the breakpoint is enabled.
|
|
20
20
|
|
21
21
|
The "Where" column indicates where the breakpoint is located.
|
22
22
|
EOH
|
23
|
-
|
24
|
-
|
25
|
-
SHORT_HELP = "Status of user-settable breakpoints"
|
23
|
+
MIN_ABBREV = 'br'.size
|
24
|
+
SHORT_HELP = 'Status of user-settable breakpoints'
|
26
25
|
end
|
27
|
-
|
26
|
+
|
28
27
|
def bpprint(bp, verbose=false)
|
29
28
|
disp = bp.temp? ? 'del ' : 'keep '
|
30
29
|
disp += bp.enabled? ? 'y ' : 'n '
|
@@ -48,7 +47,8 @@ EOH
|
|
48
47
|
msg("\t#{other_loc}") if verbose
|
49
48
|
|
50
49
|
if bp.condition && bp.condition != 'true'
|
51
|
-
msg("\tstop
|
50
|
+
msg("\tstop %s %s" %
|
51
|
+
[bp.negate ? "unless" : "only if", bp.condition])
|
52
52
|
end
|
53
53
|
if bp.ignore > 0
|
54
54
|
msg("\tignore next %d hits" % bp.ignore)
|
@@ -105,7 +105,7 @@ EOH
|
|
105
105
|
msg('No breakpoints.')
|
106
106
|
else
|
107
107
|
# There's at least one
|
108
|
-
|
108
|
+
section("Num Type Disp Enb Where")
|
109
109
|
if show_all
|
110
110
|
bpmgr.list.each do |bp|
|
111
111
|
bpprint(bp, verbose)
|
@@ -133,7 +133,7 @@ if __FILE__ == $0
|
|
133
133
|
require_relative '../../mock'
|
134
134
|
name = File.basename(__FILE__, '.rb')
|
135
135
|
dbgr, cmd = MockDebugger::setup('info')
|
136
|
-
subcommand = Trepan::Subcommand::
|
136
|
+
subcommand = Trepan::Subcommand::InfoBreakpoints.new(cmd)
|
137
137
|
|
138
138
|
puts '-' * 20
|
139
139
|
subcommand.run(%w(info break))
|
@@ -1,24 +1,32 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require 'linecache'
|
4
|
+
require 'columnize'
|
4
5
|
require_relative '../base/subcmd'
|
5
6
|
require_relative '../../../app/file'
|
7
|
+
require_relative '../../../app/complete'
|
6
8
|
|
7
|
-
class Trepan::Subcommand::
|
9
|
+
class Trepan::Subcommand::InfoFiles < Trepan::Subcommand
|
8
10
|
unless defined?(HELP)
|
9
11
|
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
10
|
-
DEFAULT_FILE_ARGS = %w(size sha1)
|
12
|
+
DEFAULT_FILE_ARGS = %w(size mtime sha1)
|
11
13
|
|
12
|
-
HELP =
|
13
|
-
|
14
|
+
HELP = <<-EOH
|
15
|
+
#{CMD} [{FILENAME|.|*} [all|ctime|brkpts|mtime|sha1|size|stat]]
|
14
16
|
|
15
17
|
Show information about the current file. If no filename is given and
|
16
|
-
the program is running then the current file associated with the
|
17
|
-
current stack entry is used.
|
18
|
+
the program is running, then the current file associated with the
|
19
|
+
current stack entry is used. Giving . has the same effect.
|
20
|
+
|
21
|
+
Given * gives a list of all files we know about.
|
22
|
+
|
23
|
+
Sub options which can be shown about a file are:
|
18
24
|
|
19
25
|
brkpts -- Line numbers where there are statement boundaries.
|
20
26
|
These lines can be used in breakpoint commands.
|
27
|
+
ctime -- File creation time
|
21
28
|
iseq -- Instruction sequences from this file.
|
29
|
+
mtime -- File modification time
|
22
30
|
sha1 -- A SHA1 hash of the source text. This may be useful in comparing
|
23
31
|
source code.
|
24
32
|
size -- The number of lines in the file.
|
@@ -26,18 +34,49 @@ stat -- File.stat information
|
|
26
34
|
|
27
35
|
all -- All of the above information.
|
28
36
|
|
29
|
-
If no sub-options are given #{DEFAULT_FILE_ARGS.join(' ')} are assumed.
|
30
|
-
|
37
|
+
If no sub-options are given, "#{DEFAULT_FILE_ARGS.join(' ')}" are assumed.
|
38
|
+
|
39
|
+
Examples:
|
40
|
+
|
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
|
46
|
+
EOH
|
31
47
|
MIN_ABBREV = 'fi'.size # Note we have "info frame"
|
32
48
|
NEED_STACK = false
|
33
49
|
end
|
34
50
|
|
51
|
+
# completion %w(all brkpts iseq sha1 size stat)
|
52
|
+
|
35
53
|
include Trepanning
|
54
|
+
|
55
|
+
def file_list
|
56
|
+
(LineCache.class_variable_get('@@file_cache').keys +
|
57
|
+
LineCache.class_variable_get('@@file2file_remap').keys).uniq
|
58
|
+
end
|
59
|
+
def complete(prefix)
|
60
|
+
completions = ['.'] + file_list
|
61
|
+
Trepan::Complete.complete_token(completions, prefix)
|
62
|
+
end
|
36
63
|
|
37
64
|
# Get file information
|
38
65
|
def run(args)
|
39
66
|
return if args.size < 2
|
40
67
|
args << '.' if 2 == args.size
|
68
|
+
if '*' == args[2]
|
69
|
+
section 'Canonic Files names cached:'
|
70
|
+
primary = LineCache.class_variable_get('@@file_cache')
|
71
|
+
remap = LineCache.class_variable_get('@@file2file_remap')
|
72
|
+
msg columnize_commands(remap.keys.uniq.sort)
|
73
|
+
names = remap.keys - primary.keys
|
74
|
+
unless names.empty?
|
75
|
+
section 'Non-canonic names cached:'
|
76
|
+
msg columnize_commands(names.sort)
|
77
|
+
end
|
78
|
+
return
|
79
|
+
end
|
41
80
|
filename =
|
42
81
|
if '.' == args[2]
|
43
82
|
if not @proc.frame
|
@@ -45,36 +84,49 @@ If no sub-options are given #{DEFAULT_FILE_ARGS.join(' ')} are assumed.
|
|
45
84
|
return false
|
46
85
|
nil
|
47
86
|
else
|
48
|
-
|
87
|
+
frame_file = @proc.frame.source_container[1]
|
88
|
+
LineCache::map_file(frame_file) || File.expand_path(frame_file)
|
49
89
|
end
|
50
90
|
else
|
51
91
|
args[2]
|
52
92
|
end
|
53
93
|
args += DEFAULT_FILE_ARGS if args.size == 3
|
54
94
|
|
55
|
-
m = filename
|
56
|
-
canonic_name =
|
95
|
+
m = filename
|
96
|
+
canonic_name = @proc.canonic_file(filename)
|
97
|
+
canonic_name = LineCache::map_file(canonic_name) || canonic_name
|
57
98
|
if LineCache::cached?(canonic_name)
|
58
|
-
m += " cached in debugger"
|
99
|
+
m += " is cached in debugger"
|
59
100
|
if canonic_name != filename
|
60
|
-
m += (
|
101
|
+
m += (" as:\n " + canonic_name)
|
61
102
|
end
|
62
103
|
m += '.'
|
63
104
|
msg(m)
|
64
105
|
elsif !(matches = find_scripts(filename)).empty?
|
65
106
|
if (matches.size > 1)
|
66
107
|
msg("Multiple files found:")
|
67
|
-
matches.each { |match_file| msg "\t%s" % match_file }
|
108
|
+
matches.sort.each { |match_file| msg "\t%s" % match_file }
|
68
109
|
return
|
69
110
|
else
|
70
111
|
msg('File "%s" just now cached.' % filename)
|
71
112
|
LineCache::cache(matches[0])
|
72
|
-
LineCache::remap_file(matches[0]
|
113
|
+
LineCache::remap_file(filename, matches[0])
|
73
114
|
canonic_name = matches[0]
|
74
115
|
end
|
75
116
|
else
|
76
|
-
|
77
|
-
|
117
|
+
matches = file_list.select{|try| try.end_with?(filename)}
|
118
|
+
if (matches.size > 1)
|
119
|
+
msg("Multiple files found ending filename string:")
|
120
|
+
matches.sort.each { |match_file| msg "\t%s" % match_file }
|
121
|
+
return
|
122
|
+
elsif 1 == matches.size
|
123
|
+
canonic_name = LineCache::map_file(matches[0])
|
124
|
+
m += " matched debugger cache file:\n " + canonic_name
|
125
|
+
msg m
|
126
|
+
else
|
127
|
+
msg(m + ' is not cached in debugger.')
|
128
|
+
return
|
129
|
+
end
|
78
130
|
end
|
79
131
|
seen = {}
|
80
132
|
args[3..-1].each do |arg|
|
@@ -98,13 +150,21 @@ If no sub-options are given #{DEFAULT_FILE_ARGS.join(' ')} are assumed.
|
|
98
150
|
if %w(all brkpts).member?(arg)
|
99
151
|
unless seen[:brkpts]
|
100
152
|
msg("Possible breakpoint line numbers:")
|
101
|
-
lines = LineCache
|
153
|
+
lines = LineCache.trace_line_numbers(canonic_name)
|
102
154
|
fmt_lines = columnize_numbers(lines)
|
103
155
|
msg(fmt_lines)
|
104
156
|
end
|
105
157
|
processed_arg = seen[:brkpts] = true
|
106
158
|
end
|
107
159
|
|
160
|
+
if %w(all ctime).member?(arg)
|
161
|
+
unless seen[:ctime]
|
162
|
+
msg("create time:\t%s." %
|
163
|
+
LineCache::stat(canonic_name).ctime.to_s)
|
164
|
+
end
|
165
|
+
processed_arg = seen[:ctime] = true
|
166
|
+
end
|
167
|
+
|
108
168
|
if %w(all iseq).member?(arg)
|
109
169
|
unless seen[:iseq]
|
110
170
|
if SCRIPT_ISEQS__.member?(canonic_name)
|
@@ -119,6 +179,14 @@ If no sub-options are given #{DEFAULT_FILE_ARGS.join(' ')} are assumed.
|
|
119
179
|
processed_arg = seen[:iseq] = true
|
120
180
|
end
|
121
181
|
|
182
|
+
if %w(all mtime).member?(arg)
|
183
|
+
unless seen[:mtime]
|
184
|
+
msg("modify time:\t%s." %
|
185
|
+
LineCache::stat(canonic_name).mtime.to_s)
|
186
|
+
end
|
187
|
+
processed_arg = seen[:mtime] = true
|
188
|
+
end
|
189
|
+
|
122
190
|
if %w(all stat).member?(arg)
|
123
191
|
unless seen[:stat]
|
124
192
|
msg("Stat info:\n\t%s." % LineCache::stat(canonic_name).inspect)
|
@@ -141,21 +209,18 @@ if __FILE__ == $0
|
|
141
209
|
load(__FILE__)
|
142
210
|
else
|
143
211
|
require_relative '../../mock'
|
144
|
-
|
145
|
-
name = File.basename(__FILE__, '.rb')
|
146
|
-
# FIXME: DRY the below code
|
147
|
-
dbgr, cmd = MockDebugger::setup('info')
|
148
|
-
subcommand = Trepan::Subcommand::InfoFile.new(cmd)
|
149
|
-
testcmdMgr = Trepan::Subcmd.new(subcommand)
|
150
|
-
|
212
|
+
cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoFiles, false)
|
151
213
|
[%w(info file nothere),
|
152
214
|
%w(info file .),
|
215
|
+
%w(info file *),
|
153
216
|
%w(info file),
|
154
217
|
%w(info file file.rb),
|
218
|
+
%w(info file citrus/file.rb),
|
155
219
|
%w(info file . all),
|
156
|
-
%w(info file .
|
157
|
-
|
220
|
+
%w(info file . brkpts bad size sha1 sha1)].each do |args|
|
221
|
+
cmd.run(args)
|
158
222
|
puts '-' * 40
|
159
223
|
end
|
224
|
+
p cmd.complete('')
|
160
225
|
end
|
161
226
|
end
|
@@ -5,18 +5,51 @@ require_relative '../base/subcmd'
|
|
5
5
|
class Trepan::Subcommand::InfoFrame < Trepan::Subcommand
|
6
6
|
unless defined?(HELP)
|
7
7
|
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
8
|
-
HELP
|
8
|
+
HELP = <<-EOH
|
9
|
+
#{CMD}
|
10
|
+
|
11
|
+
Show information about the selected frame. The fields we list are:
|
12
|
+
|
13
|
+
* A source container and name (e.g. "file" or "string" and the value)
|
14
|
+
* The actual number of arguments passed in
|
15
|
+
* The 'arity' or permissible number of arguments passed it. -1 indicates
|
16
|
+
variable number
|
17
|
+
* The frame "type", e.g. TOP, METHOD, BLOCK, EVAL, CFUNC etc.
|
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
|
20
|
+
sequence
|
21
|
+
|
22
|
+
A backtrace shows roughly the same information in a more compact form.
|
23
|
+
|
24
|
+
Example form inside File.basename('foo')
|
25
|
+
|
26
|
+
Frame basename
|
27
|
+
file : /tmp/c-func.rb # actually location of caller
|
28
|
+
line : 2 # inherited from caller
|
29
|
+
argc : 1 # One out argument supplied: 'foo'
|
30
|
+
arity : -1 # Variable number of args, can have up to 2 arguments.
|
31
|
+
type : CFUNC (A C function)
|
32
|
+
|
33
|
+
|
34
|
+
See also: backtrace
|
35
|
+
EOH
|
9
36
|
MIN_ABBREV = 'fr'.size # Note we have "info file"
|
10
37
|
NEED_STACK = true
|
38
|
+
SHORT_HELP = 'Show information about the selected frame'
|
11
39
|
end
|
12
40
|
|
13
41
|
def run(args)
|
14
42
|
frame = @proc.frame
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
43
|
+
section "Frame %2d: #{frame.method}" % @proc.frame_index
|
44
|
+
msg " %-6s: %s" % frame.source_container
|
45
|
+
msg " line : %s" % @proc.frame_line
|
46
|
+
msg " argc : %d" % frame.argc
|
47
|
+
msg " arity : %d" % frame.arity
|
48
|
+
msg " type : %s" % frame.type
|
49
|
+
msg " offset: %d" % frame.pc_offset if frame.iseq
|
50
|
+
if %w(return c-return).member?(@proc.event)
|
51
|
+
ret_val = Trepan::Frame.value_returned(@proc.frame, @proc.event)
|
52
|
+
msg " Return: %s" % ret_val
|
20
53
|
end
|
21
54
|
end
|
22
55
|
|
@@ -25,14 +58,7 @@ end
|
|
25
58
|
if __FILE__ == $0
|
26
59
|
# Demo it.
|
27
60
|
require_relative '../../mock'
|
28
|
-
require_relative '../../subcmd'
|
29
|
-
name = File.basename(__FILE__, '.rb')
|
30
|
-
|
31
|
-
# FIXME: DRY the below code
|
32
61
|
dbgr, cmd = MockDebugger::setup('info')
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
name = File.basename(__FILE__, '.rb')
|
37
|
-
subcommand.summary_help(name)
|
62
|
+
cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoFrame, false)
|
63
|
+
cmd.run(cmd.prefix)
|
38
64
|
end
|