trepanning 1.93.35 → 2.15.33
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.
- checksums.yaml +7 -0
- data/ChangeLog +491 -55
- data/LICENSE +1 -1
- data/NEWS +18 -14
- data/README.md +5 -22
- data/Rakefile +22 -1
- data/app/breakpoint.rb +5 -3
- data/app/core.rb +147 -179
- data/app/default.rb +47 -46
- data/app/file.rb +6 -7
- data/app/frame.rb +183 -176
- data/app/markdown.rb +2 -9
- data/app/options.rb +1 -1
- data/app/run.rb +71 -37
- data/interface/script.rb +8 -8
- data/io.rb +19 -20
- data/lib/trepanning.rb +292 -297
- data/processor.rb +332 -344
- data/processor/breakpoint.rb +98 -96
- data/processor/command/base/submgr.rb +9 -9
- data/processor/command/break.rb +40 -38
- data/processor/command/continue.rb +15 -10
- data/processor/command/debug.rb +6 -25
- data/processor/command/delete.rb +21 -12
- data/processor/command/directory.rb +15 -13
- data/processor/command/disable.rb +12 -9
- data/processor/command/disassemble.rb +80 -74
- data/processor/command/display.rb +15 -12
- data/processor/command/down.rb +8 -3
- data/processor/command/edit.rb +37 -23
- data/processor/command/enable.rb +11 -8
- data/processor/command/eval.rb +24 -22
- data/processor/command/finish.rb +50 -48
- data/processor/command/help.rb +1 -1
- data/processor/command/info_subcmd/breakpoints.rb +7 -7
- data/processor/command/info_subcmd/files.rb +195 -196
- data/processor/command/info_subcmd/frame.rb +7 -4
- data/processor/command/info_subcmd/locals.rb +29 -12
- data/processor/command/info_subcmd/program.rb +48 -39
- data/processor/command/info_subcmd/registers_subcmd/ep.rb +46 -0
- data/processor/command/info_subcmd/registers_subcmd/helper.rb +32 -35
- data/processor/command/info_subcmd/registers_subcmd/sp.rb +29 -23
- data/processor/command/info_subcmd/return.rb +28 -10
- data/processor/command/info_subcmd/variables_subcmd/class.rb +3 -3
- data/processor/command/info_subcmd/variables_subcmd/constants.rb +77 -0
- data/processor/command/info_subcmd/variables_subcmd/globals.rb +7 -7
- data/processor/command/info_subcmd/variables_subcmd/instance.rb +68 -22
- data/processor/command/info_subcmd/variables_subcmd/locals.rb +148 -67
- data/processor/command/list.rb +14 -8
- data/processor/command/macro.rb +1 -1
- data/processor/command/next.rb +1 -0
- data/processor/command/set_subcmd/auto.rb +3 -3
- data/processor/command/set_subcmd/different.rb +30 -29
- data/processor/command/set_subcmd/events.rb +74 -48
- data/processor/command/set_subcmd/max_subcmd/list.rb +12 -5
- data/processor/command/set_subcmd/max_subcmd/width.rb +28 -19
- data/processor/command/set_subcmd/register.rb +37 -0
- data/processor/command/set_subcmd/register_subcmd/pc.rb +67 -0
- data/processor/command/set_subcmd/register_subcmd/sp.rb +75 -0
- data/processor/command/set_subcmd/reload.rb +12 -10
- data/processor/command/set_subcmd/return.rb +68 -44
- data/processor/command/shell.rb +3 -2
- data/processor/command/show_subcmd/different.rb +17 -14
- data/processor/command/show_subcmd/events.rb +25 -25
- data/processor/default.rb +1 -1
- data/processor/eval.rb +14 -15
- data/processor/frame.rb +43 -36
- data/processor/help.rb +5 -5
- data/processor/hook.rb +26 -29
- data/processor/location.rb +54 -51
- data/processor/mock.rb +4 -3
- data/processor/running.rb +113 -103
- data/processor/validate.rb +401 -373
- data/test/data/debug.cmd +8 -0
- data/test/data/debug.right +13 -0
- data/test/data/debugger-stop.right +6 -4
- data/test/data/fname-with-blank.cmd +1 -1
- data/test/data/fname-with-blank.right +5 -0
- data/test/data/pc.cmd +8 -0
- data/test/data/pc.right +10 -0
- data/test/data/quit.right +3 -1
- data/test/data/trace.cmd +2 -2
- data/test/data/trace.right +41 -20
- data/test/example/assign.rb +6 -0
- data/test/functional/fn_helper.rb +11 -17
- data/test/functional/test-break-long.rb +15 -16
- data/test/functional/test-break.rb +6 -8
- data/test/functional/test-condition.rb +8 -10
- data/test/functional/test-debugger-call-bug.rb +21 -22
- data/test/functional/test-delete.rb +57 -59
- data/test/functional/test-eval.rb +101 -103
- data/test/functional/test-finish.rb +24 -33
- data/test/functional/test-immediate-step-bug.rb +6 -10
- data/test/functional/test-next.rb +64 -65
- data/test/functional/test-raise.rb +63 -64
- data/test/functional/test-recursive-bt.rb +81 -76
- data/test/functional/test-remap.rb +6 -7
- data/test/functional/test-return.rb +44 -38
- data/test/functional/test-step.rb +55 -53
- data/test/functional/test-stepbug.rb +6 -9
- data/test/functional/test-watchg.rb +40 -39
- data/test/integration/test-debug.rb +12 -0
- data/test/integration/test-debugger-stop.rb +7 -7
- data/test/integration/test-pc.rb +24 -0
- data/test/integration/test-trace.rb +1 -1
- data/test/unit/cmd-helper.rb +0 -1
- data/test/unit/test-app-brkpt.rb +21 -21
- data/test/unit/test-app-brkptmgr.rb +7 -8
- data/test/unit/test-app-display.rb +3 -4
- data/test/unit/test-app-frame.rb +4 -5
- data/test/unit/test-base-subsubcmd.rb +2 -2
- data/test/unit/test-cmd-break.rb +6 -6
- data/test/unit/test-cmd-endisable.rb +7 -6
- data/test/unit/test-cmd-parse_list_cmd.rb +24 -24
- data/test/unit/test-io-tcpserver.rb +39 -35
- data/test/unit/test-proc-default.rb +23 -22
- data/test/unit/test-proc-eval.rb +1 -2
- data/test/unit/test-proc-frame.rb +8 -9
- data/test/unit/test-proc-list.rb +1 -1
- data/test/unit/test-proc-location.rb +2 -2
- data/test/unit/test-proc-main.rb +10 -10
- data/test/unit/test-proc-validate.rb +11 -13
- data/test/unit/test-subcmd-help.rb +1 -2
- data/trepanning.gemspec +8 -13
- metadata +44 -95
- data/COPYING +0 -57
- data/data/custom_require.rb +0 -44
- data/data/perldb.bindings +0 -17
- data/data/prelude.rb +0 -38
- data/processor/command/info_subcmd/variables_subcmd/constant.rb +0 -41
- data/processor/command/raise.rb +0 -48
- data/processor/command/set_subcmd/pc.rb +0 -62
- data/processor/command/set_subcmd/sp.rb +0 -67
- data/processor/eventbuf.rb +0 -133
data/processor/command/enable.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010,
|
2
|
+
# Copyright (C) 2010-2011, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require_relative 'disable'
|
4
4
|
|
5
5
|
# enable breakpoint command. Is like disable but the parameter
|
@@ -10,12 +10,15 @@ class Trepan::Command::EnableCommand < Trepan::Command::DisableCommand
|
|
10
10
|
Trepan::Util.suppress_warnings {
|
11
11
|
NAME = File.basename(__FILE__, '.rb')
|
12
12
|
HELP = <<-HELP
|
13
|
-
|
14
|
-
|
15
|
-
Enables breakpoints or display NUM1... Breakpoints numbers are given as a space-
|
16
|
-
separated list numbers.
|
13
|
+
**#{NAME}** [**display**] *num1* [*num2* ...]
|
17
14
|
|
18
|
-
|
15
|
+
Enables breakpoints or display *num1*... Breakpoints numbers are given
|
16
|
+
as a space-separated list numbers.
|
17
|
+
|
18
|
+
See also:
|
19
|
+
---------
|
20
|
+
|
21
|
+
`disable` and `info break`.
|
19
22
|
HELP
|
20
23
|
|
21
24
|
ALIASES = %w(en)
|
@@ -24,11 +27,11 @@ See also "disable" and "info break".
|
|
24
27
|
|
25
28
|
def initialize(proc)
|
26
29
|
super
|
27
|
-
@enable_parm = true # true if enable
|
30
|
+
@enable_parm = true # true if enable
|
28
31
|
end
|
29
32
|
|
30
33
|
end
|
31
|
-
|
34
|
+
|
32
35
|
if __FILE__ == $0
|
33
36
|
require_relative '../mock'
|
34
37
|
dbgr, cmd = MockDebugger::setup
|
data/processor/command/eval.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2011,
|
2
|
+
# Copyright (C) 2011-2012, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require_relative './../command'
|
4
4
|
require_relative '../../app/util'
|
5
5
|
|
6
6
|
class Trepan::Command::EvalCommand < Trepan::Command
|
7
7
|
|
8
|
-
old_verbose = $VERBOSE
|
8
|
+
old_verbose = $VERBOSE
|
9
9
|
$VERBOSE = nil
|
10
10
|
NAME = File.basename(__FILE__, '.rb')
|
11
11
|
HELP = <<-HELP
|
12
|
-
|
12
|
+
**#{NAME}** [*string*]
|
13
13
|
|
14
14
|
Run code in the context of the current frame.
|
15
15
|
|
@@ -18,44 +18,46 @@ may be used again easily. The name of the global variable is printed
|
|
18
18
|
next to the inspect output of the value.
|
19
19
|
|
20
20
|
If no string is given, we run the string from the current source code
|
21
|
-
about to be run. If the command ends ? (via an alias) and no
|
22
|
-
given, the following translations occur:
|
21
|
+
about to be run. If the command ends with a "?" (via an alias) and no
|
22
|
+
string is given, the following translations occur:
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
{if|elsif|unless} expr [then] => expr
|
25
|
+
{until|while} expr [do] => expr
|
26
|
+
return expr => expr
|
27
|
+
case expr => expr
|
28
|
+
def fn(params) => [params]
|
29
|
+
var = expr => expr
|
30
30
|
|
31
31
|
The above is done via regular expression. No fancy parsing is done, say,
|
32
32
|
to look to see if expr is split across a line or whether var an assigment
|
33
33
|
might have multiple variables on the left-hand side.
|
34
34
|
|
35
35
|
Examples:
|
36
|
+
---------
|
36
37
|
|
37
|
-
#{NAME} 1+2 # 3
|
38
|
-
#{NAME} @v
|
39
|
-
#{NAME} # Run current source-code line
|
40
|
-
#{NAME}? # but strips off leading 'if', 'while', ..
|
41
|
-
|
38
|
+
#{NAME} 1+2 # 3
|
39
|
+
#{NAME} @v
|
40
|
+
#{NAME} # Run current source-code line
|
41
|
+
#{NAME}? # but strips off leading 'if', 'while', ..a
|
42
|
+
# from command
|
42
43
|
|
43
|
-
See also
|
44
|
-
|
44
|
+
See also:
|
45
|
+
---------
|
46
|
+
`set autoeval`.
|
45
47
|
HELP
|
46
48
|
|
47
49
|
ALIASES = %w(eval? ev? ev)
|
48
50
|
CATEGORY = 'data'
|
49
51
|
NEED_STACK = true
|
50
52
|
SHORT_HELP = 'Run code in the current context'
|
51
|
-
$VERBOSE = old_verbose
|
53
|
+
$VERBOSE = old_verbose
|
52
54
|
|
53
55
|
def complete(prefix)
|
54
|
-
if prefix.empty?
|
56
|
+
if prefix.empty?
|
55
57
|
if @proc.leading_str.start_with?('eval?')
|
56
58
|
Trepan::Util.extract_expression @proc.current_source_text
|
57
59
|
else
|
58
|
-
@proc.current_source_text
|
60
|
+
@proc.current_source_text
|
59
61
|
end
|
60
62
|
else
|
61
63
|
prefix
|
@@ -65,7 +67,7 @@ See 'set buffer trace' for showing what may have already been run.
|
|
65
67
|
def run(args)
|
66
68
|
if args.size == 1
|
67
69
|
text = @proc.current_source_text
|
68
|
-
if '?' == args[0][-1..-1]
|
70
|
+
if '?' == args[0][-1..-1]
|
69
71
|
text = Trepan::Util::extract_expression(text)
|
70
72
|
msg "eval: #{text}"
|
71
73
|
end
|
data/processor/command/finish.rb
CHANGED
@@ -33,58 +33,60 @@ program. In general, `#{NAME}`, `step` and `next` may slow a program
|
|
33
33
|
down while `break` will have less overhead.
|
34
34
|
|
35
35
|
HELP
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
ALIASES = %w(fin)
|
37
|
+
CATEGORY = 'running'
|
38
|
+
# execution_set = ['Running']
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
# This method runs the command
|
47
|
-
def run(args)
|
48
|
-
opts = {}
|
49
|
-
if args.size == 1
|
50
|
-
# Form is: "finish" which means "finish 1"
|
51
|
-
level_count = 0
|
52
|
-
else
|
53
|
-
count_str = args[1]
|
54
|
-
opts = {
|
55
|
-
:msg_on_error =>
|
56
|
-
"The '#{NAME}' command argument must eval to an integer. Got: %s" %
|
57
|
-
count_str,
|
58
|
-
:min_value => 1
|
59
|
-
}
|
60
|
-
count = @proc.get_an_int(count_str, opts)
|
61
|
-
return unless count
|
62
|
-
# step 1 is core.level_count = 0 or "stop next event"
|
63
|
-
level_count = count - 1
|
40
|
+
# Need at most this many.
|
41
|
+
MAX_ARGS = 1
|
42
|
+
NEED_STACK = true
|
43
|
+
NEED_RUNNING = true
|
44
|
+
SHORT_HELP = 'Step to end of current method (step out)'
|
64
45
|
end
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
46
|
+
|
47
|
+
# This method runs the command
|
48
|
+
def run(args)
|
49
|
+
opts = {}
|
50
|
+
if args.size == 1
|
51
|
+
# Form is: "finish" which means "finish 1"
|
52
|
+
level_count = 0
|
53
|
+
else
|
54
|
+
count_str = args[1]
|
55
|
+
opts = {
|
56
|
+
:msg_on_error =>
|
57
|
+
"The '#{NAME}' command argument must eval to an integer. Got: %s" %
|
58
|
+
count_str,
|
59
|
+
:min_value => 1
|
60
|
+
}
|
61
|
+
count = @proc.get_an_int(count_str, opts)
|
62
|
+
return unless count
|
63
|
+
# step 1 is core.level_count = 0 or "stop next event"
|
64
|
+
level_count = count - 1
|
65
|
+
end
|
66
|
+
if (0 == level_count and
|
67
|
+
%w(return c_return b_return end raise).member?(@proc.event.to_s))
|
68
|
+
errmsg "You are already at the requested return event."
|
69
|
+
else
|
70
|
+
@proc.finish(level_count, opts)
|
71
|
+
end
|
69
72
|
end
|
70
|
-
end
|
71
73
|
end
|
72
74
|
|
73
75
|
if __FILE__ == $0
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
76
|
+
require_relative '../mock'
|
77
|
+
dbgr, cmd = MockDebugger::setup
|
78
|
+
[%W(#{cmd.name} 1), %w(fin 2-1), %w(n foo)].each do |c|
|
79
|
+
cmd.proc.next_level = 0
|
80
|
+
cmd.proc.leave_cmd_loop = false
|
81
|
+
result = cmd.run(c)
|
82
|
+
puts 'Run result: %s' % result
|
83
|
+
puts 'level_count %d, leave_cmd_loop: %s' % [cmd.proc.next_level,
|
84
|
+
cmd.proc.leave_cmd_loop]
|
85
|
+
end
|
86
|
+
[%w(fin), [cmd.name]].each do |c|
|
87
|
+
cmd.proc.next_level = 0
|
88
|
+
cmd.proc.leave_cmd_loop = false
|
89
|
+
result = cmd.run(c)
|
90
|
+
puts cmd.proc.different_pos
|
91
|
+
end
|
90
92
|
end
|
data/processor/command/help.rb
CHANGED
@@ -34,7 +34,7 @@ info line command.
|
|
34
34
|
NEED_STACK = false
|
35
35
|
SHORT_HELP = 'Print commands or give help for command(s)'
|
36
36
|
|
37
|
-
ROOT_DIR = File.dirname(RubyVM::Frame.
|
37
|
+
ROOT_DIR = File.dirname(RubyVM::Frame.get.source_container[1])
|
38
38
|
HELP_DIR = File.join(ROOT_DIR, 'help')
|
39
39
|
MARKDOWN_EXTENSION='.md'
|
40
40
|
end
|
@@ -6,19 +6,19 @@ 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
|
-
**#{CMD}** [*num1* ...] [
|
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
|
+
In the *Disp* column values are "keep", or "del", the disposition of
|
17
17
|
the breakpoint after it gets hit.
|
18
18
|
|
19
|
-
The
|
19
|
+
The *enb* column indicates whether the breakpoint is enabled.
|
20
20
|
|
21
|
-
The
|
21
|
+
The *Where* column indicates where the breakpoint is located.
|
22
22
|
EOH
|
23
23
|
MIN_ABBREV = 'br'.size
|
24
24
|
SHORT_HELP = 'Status of user-settable breakpoints'
|
@@ -35,7 +35,7 @@ EOH
|
|
35
35
|
[iseq.source_container.join(' '),
|
36
36
|
iseq.offset2lines(bp.offset).join(', ')]
|
37
37
|
vm_loc = "VM offset %d of instruction sequence \"%s\"" %
|
38
|
-
[bp.offset, iseq.
|
38
|
+
[bp.offset, iseq.label]
|
39
39
|
|
40
40
|
loc, other_loc =
|
41
41
|
if 'line' == bp.type
|
@@ -79,7 +79,7 @@ EOH
|
|
79
79
|
def run(args)
|
80
80
|
verbose = false
|
81
81
|
unless args.empty?
|
82
|
-
if 'verbose' == args[-1]
|
82
|
+
if '--verbose' == args[-1]
|
83
83
|
verbose = true
|
84
84
|
args.pop
|
85
85
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010,
|
2
|
+
# Copyright (C) 2010-2011, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require 'linecache'
|
4
4
|
require 'columnize'
|
5
5
|
require_relative '../base/subcmd'
|
@@ -7,230 +7,229 @@ require_relative '../../../app/run'
|
|
7
7
|
require_relative '../../../app/util'
|
8
8
|
|
9
9
|
class Trepan::Subcommand::InfoFiles < Trepan::Subcommand
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
Trepan::Util::suppress_warnings {
|
11
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
12
|
+
DEFAULT_FILE_ARGS = %w(size mtime sha1)
|
13
13
|
|
14
|
-
|
15
|
-
**#{CMD}** [{*filename
|
16
|
-
|
17
|
-
*attributes* can be any set of of:
|
18
|
-
**all**, **ctime**, **brkpts**, **mtime**, **sha1**, **size** or **stat**
|
14
|
+
HELP = <<-EOH
|
15
|
+
**#{CMD}** [{*filename*|**.**|`*`} [**all**|**ctime**|**brkpts**|**mtime**|**sha1**|**size**|**stat**]]
|
19
16
|
|
20
17
|
Show information about the current file. If no filename is given and
|
21
18
|
the program is running, then the current file associated with the
|
22
19
|
current stack entry is used. Giving . has the same effect.
|
23
20
|
|
24
|
-
|
21
|
+
If given a filename of `*`, we give a list of all files we know about.
|
25
22
|
|
26
23
|
Sub options which can be shown about a file are:
|
27
24
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
stat -- File.stat information
|
37
|
-
|
38
|
-
all -- All of the above information.
|
25
|
+
* `brkpts` Line numbers where there are statement boundaries. These lines can be used in breakpoint commands.
|
26
|
+
* `ctime` File creation time
|
27
|
+
* `iseq` Instruction sequences from this file.
|
28
|
+
* `mtime` File modification time
|
29
|
+
* `sha1` SHA1 hash of the source text. This may be useful in comparing source code.
|
30
|
+
* `size` number of lines in the file.
|
31
|
+
* `stat` File.stat information
|
32
|
+
* `all` All of the above information.
|
39
33
|
|
40
|
-
If no sub-options are given,
|
34
|
+
If no sub-options are given, "#{DEFAULT_FILE_ARGS.join(' ')}" are assumed.
|
41
35
|
|
42
36
|
Examples:
|
43
|
-
|
44
|
-
|
37
|
+
--------
|
45
38
|
#{CMD} # Show #{DEFAULT_FILE_ARGS.join(' ')} information about current file
|
46
39
|
#{CMD} . # same as above
|
47
40
|
#{CMD} brkpts # show the number of lines in the current file
|
48
41
|
#{CMD} brkpts size # same as above but also list breakpoint line numbers
|
49
42
|
#{CMD} * # Give a list of files we know about
|
43
|
+
|
44
|
+
See also:
|
45
|
+
---------
|
46
|
+
`info frame`, `info program`
|
50
47
|
EOH
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
def complete(prefix)
|
65
|
-
completions = ['.'] + file_list
|
66
|
-
Trepan::Complete.complete_token(completions, prefix)
|
67
|
-
end
|
68
|
-
|
69
|
-
# Get file information
|
70
|
-
def run(args)
|
71
|
-
return if args.size < 2
|
72
|
-
args << '.' if 2 == args.size
|
73
|
-
if '*' == args[2]
|
74
|
-
section 'Canonic Files names cached:'
|
75
|
-
primary = LineCache.class_variable_get('@@file_cache')
|
76
|
-
remap = LineCache.class_variable_get('@@file2file_remap')
|
77
|
-
msg columnize_commands(remap.keys.uniq.sort)
|
78
|
-
names = remap.keys - primary.keys
|
79
|
-
unless names.empty?
|
80
|
-
section 'Non-canonic names cached:'
|
81
|
-
msg columnize_commands(names.sort)
|
82
|
-
end
|
83
|
-
return
|
48
|
+
MIN_ABBREV = 'fi'.size # Note we have "info frame"
|
49
|
+
NEED_STACK = false
|
50
|
+
}
|
51
|
+
|
52
|
+
# completion %w(all brkpts iseq sha1 size stat)
|
53
|
+
|
54
|
+
include Trepanning
|
55
|
+
|
56
|
+
def file_list
|
57
|
+
(LineCache.cached_files +
|
58
|
+
LineCache.class_variable_get('@@file2file_remap').keys).uniq
|
84
59
|
end
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
return false
|
90
|
-
nil
|
91
|
-
else
|
92
|
-
frame_file = @proc.frame.source_container[1]
|
93
|
-
LineCache::unmap_file(frame_file) || File.expand_path(frame_file)
|
94
|
-
end
|
95
|
-
else
|
96
|
-
args[2]
|
97
|
-
end
|
98
|
-
args += DEFAULT_FILE_ARGS if args.size == 3
|
99
|
-
|
100
|
-
m = filename
|
101
|
-
canonic_name = @proc.canonic_file(filename)
|
102
|
-
canonic_name = LineCache::map_file(canonic_name) || canonic_name
|
103
|
-
if LineCache::cached?(canonic_name)
|
104
|
-
m += " is cached in debugger"
|
105
|
-
if canonic_name != filename
|
106
|
-
m += (" as:\n " + canonic_name)
|
107
|
-
end
|
108
|
-
m += '.'
|
109
|
-
msg(m)
|
110
|
-
elsif !(matches = find_scripts(filename)).empty?
|
111
|
-
if (matches.size > 1)
|
112
|
-
msg("Multiple files found:")
|
113
|
-
matches.sort.each { |match_file| msg "\t%s" % match_file }
|
114
|
-
return
|
115
|
-
else
|
116
|
-
msg('File "%s" just now cached.' % filename)
|
117
|
-
LineCache::cache(matches[0])
|
118
|
-
LineCache::remap_file(filename, matches[0])
|
119
|
-
canonic_name = matches[0]
|
120
|
-
end
|
121
|
-
else
|
122
|
-
matches = file_list.select{|try| try.end_with?(filename)}
|
123
|
-
if (matches.size > 1)
|
124
|
-
msg("Multiple files found ending filename string:")
|
125
|
-
matches.sort.each { |match_file| msg "\t%s" % match_file }
|
126
|
-
return
|
127
|
-
elsif 1 == matches.size
|
128
|
-
canonic_name = LineCache::map_file(matches[0])
|
129
|
-
m += " matched debugger cache file:\n " + canonic_name
|
130
|
-
msg m
|
131
|
-
else
|
132
|
-
msg(m + ' is not cached in debugger.')
|
133
|
-
return
|
134
|
-
end
|
60
|
+
|
61
|
+
def complete(prefix)
|
62
|
+
completions = ['.'] + file_list
|
63
|
+
Trepan::Complete.complete_token(completions, prefix)
|
135
64
|
end
|
136
|
-
seen = {}
|
137
|
-
args[3..-1].each do |arg|
|
138
|
-
processed_arg = false
|
139
|
-
|
140
|
-
if %w(all size).member?(arg)
|
141
|
-
unless seen[:size]
|
142
|
-
max_line = LineCache::size(canonic_name)
|
143
|
-
msg "File has %d lines." % max_line if max_line
|
144
|
-
end
|
145
|
-
processed_arg = seen[:size] = true
|
146
|
-
end
|
147
65
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
fmt_lines = columnize_numbers(lines)
|
164
|
-
msg(fmt_lines)
|
165
|
-
end
|
66
|
+
# Get file information
|
67
|
+
def run(args)
|
68
|
+
return if args.size < 2
|
69
|
+
args << '.' if 2 == args.size
|
70
|
+
if '*' == args[2]
|
71
|
+
section 'Canonic filenames cached:'
|
72
|
+
primary = LineCache.class_variable_get('@@file_cache')
|
73
|
+
remap = LineCache.class_variable_get('@@file2file_remap')
|
74
|
+
msg columnize_commands(remap.keys.uniq.sort)
|
75
|
+
names = remap.keys - primary.keys
|
76
|
+
unless names.empty?
|
77
|
+
section 'Non-canonic names cached:'
|
78
|
+
msg columnize_commands(names.sort)
|
79
|
+
end
|
80
|
+
return
|
166
81
|
end
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
82
|
+
if '.' == args[2]
|
83
|
+
if not @proc.frame
|
84
|
+
errmsg("No frame - no default file.")
|
85
|
+
return false
|
86
|
+
nil
|
87
|
+
elsif @proc.frame.source_container[0] == 'binary'
|
88
|
+
errmsg("frame refers to binary - no file here.")
|
89
|
+
return false
|
90
|
+
else
|
91
|
+
frame_file = @proc.frame.source_container[1]
|
92
|
+
filename = LineCache::map_file(frame_file) || File.expand_path(frame_file)
|
93
|
+
end
|
94
|
+
else
|
95
|
+
filename = args[2]
|
174
96
|
end
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
97
|
+
args += DEFAULT_FILE_ARGS if args.size == 3
|
98
|
+
|
99
|
+
m = filename
|
100
|
+
canonic_name = @proc.canonic_file(filename)
|
101
|
+
canonic_name = LineCache::map_file(canonic_name) || canonic_name
|
102
|
+
if LineCache::cached?(canonic_name)
|
103
|
+
m += " is cached in debugger"
|
104
|
+
if canonic_name != filename
|
105
|
+
m += (" as:\n " + canonic_name)
|
106
|
+
end
|
107
|
+
m += '.'
|
108
|
+
msg(m)
|
109
|
+
elsif !(matches = find_scripts(filename)).empty?
|
110
|
+
if (matches.size > 1)
|
111
|
+
msg("Multiple files found:")
|
112
|
+
matches.sort.each { |match_file| msg "\t%s" % match_file }
|
113
|
+
return
|
114
|
+
else
|
115
|
+
msg('File "%s" just now cached.' % filename)
|
116
|
+
LineCache::cache(matches[0])
|
117
|
+
LineCache::remap_file(filename, matches[0])
|
118
|
+
canonic_name = matches[0]
|
119
|
+
end
|
120
|
+
else
|
121
|
+
matches = file_list.select{|try| try.end_with?(filename)}
|
122
|
+
if (matches.size > 1)
|
123
|
+
msg("Multiple files found ending filename string:")
|
124
|
+
matches.sort.each { |match_file| msg "\t%s" % match_file }
|
125
|
+
return
|
126
|
+
elsif 1 == matches.size
|
127
|
+
canonic_name = LineCache::map_file(matches[0])
|
128
|
+
m += " matched debugger cache file:\n " + canonic_name
|
129
|
+
msg m
|
130
|
+
else
|
131
|
+
msg(m + ' is not cached in debugger.')
|
132
|
+
return
|
184
133
|
end
|
185
|
-
else
|
186
|
-
msg("Instruction sequences not recorded; there may be some, though.")
|
187
|
-
end
|
188
134
|
end
|
189
|
-
|
190
|
-
|
135
|
+
seen = {}
|
136
|
+
args[3..-1].each do |arg|
|
137
|
+
processed_arg = false
|
138
|
+
|
139
|
+
if %w(all size).member?(arg)
|
140
|
+
unless seen[:size]
|
141
|
+
max_line = LineCache::size(canonic_name)
|
142
|
+
msg "File has %d lines." % max_line if max_line
|
143
|
+
end
|
144
|
+
processed_arg = seen[:size] = true
|
145
|
+
end
|
191
146
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
end
|
147
|
+
if %w(all sha1).member?(arg)
|
148
|
+
unless seen[:sha1]
|
149
|
+
msg("SHA1 is %s." % LineCache::sha1(canonic_name))
|
150
|
+
end
|
151
|
+
processed_arg = seen[:sha1] = true
|
152
|
+
end
|
199
153
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
154
|
+
if %w(all brkpts).member?(arg)
|
155
|
+
unless seen[:brkpts]
|
156
|
+
syntax_errors = Trepanning::ruby_syntax_errors(canonic_name)
|
157
|
+
if syntax_errors
|
158
|
+
msg('Not a syntactically-correct Ruby program.')
|
159
|
+
else
|
160
|
+
msg("Possible breakpoint line numbers:")
|
161
|
+
lines = LineCache.trace_line_numbers(canonic_name)
|
162
|
+
fmt_lines = columnize_numbers(lines)
|
163
|
+
msg(fmt_lines)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
processed_arg = seen[:brkpts] = true
|
167
|
+
end
|
168
|
+
|
169
|
+
if %w(all ctime).member?(arg)
|
170
|
+
unless seen[:ctime]
|
171
|
+
msg("create time:\t%s." %
|
172
|
+
LineCache::stat(canonic_name).ctime.to_s)
|
173
|
+
end
|
174
|
+
processed_arg = seen[:ctime] = true
|
175
|
+
end
|
176
|
+
|
177
|
+
if %w(all iseq).member?(arg)
|
178
|
+
unless seen[:iseq]
|
179
|
+
if SCRIPT_ISEQS__.member?(canonic_name)
|
180
|
+
msg("File contains instruction sequences:")
|
181
|
+
SCRIPT_ISEQS__[canonic_name].each do |iseq|
|
182
|
+
msg("\t %s %s" % [iseq, iseq.label.inspect])
|
183
|
+
end
|
184
|
+
else
|
185
|
+
msg("Instruction sequences not recorded; there may be some, though.")
|
186
|
+
end
|
187
|
+
end
|
188
|
+
processed_arg = seen[:iseq] = true
|
189
|
+
end
|
190
|
+
|
191
|
+
if %w(all mtime).member?(arg)
|
192
|
+
unless seen[:mtime]
|
193
|
+
msg("modify time:\t%s." %
|
194
|
+
LineCache::stat(canonic_name).mtime.to_s)
|
195
|
+
end
|
196
|
+
processed_arg = seen[:mtime] = true
|
197
|
+
end
|
198
|
+
|
199
|
+
if %w(all stat).member?(arg)
|
200
|
+
unless seen[:stat]
|
201
|
+
msg("Stat info:\n\t%s." % LineCache::stat(canonic_name).inspect)
|
202
|
+
end
|
203
|
+
processed_arg = seen[:stat] = true
|
204
|
+
end
|
205
|
+
|
206
|
+
if not processed_arg
|
207
|
+
errmsg("I don't understand sub-option \"%s\"." % arg)
|
208
|
+
end
|
209
|
+
end unless args.empty?
|
210
|
+
end
|
212
211
|
end
|
213
212
|
|
214
213
|
if __FILE__ == $0
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
214
|
+
if !(ARGV.size == 1 && ARGV[0] == 'noload')
|
215
|
+
ISEQS__ = {}
|
216
|
+
SCRIPT_ISEQS__ = {}
|
217
|
+
ARGV[0..-1] = ['noload']
|
218
|
+
load(__FILE__)
|
219
|
+
else
|
220
|
+
require_relative '../../mock'
|
221
|
+
cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoFiles, false)
|
222
|
+
[%w(info file nothere),
|
223
|
+
%w(info file .),
|
224
|
+
%w(info file *),
|
225
|
+
%w(info file),
|
226
|
+
%w(info file file.rb),
|
227
|
+
%w(info file citrus/file.rb),
|
228
|
+
%w(info file . all),
|
229
|
+
%w(info file . brkpts bad size sha1 sha1)].each do |args|
|
230
|
+
cmd.run(args)
|
231
|
+
puts '-' * 40
|
232
|
+
end
|
233
|
+
p cmd.complete('')
|
233
234
|
end
|
234
|
-
p cmd.complete('')
|
235
|
-
end
|
236
235
|
end
|