rb8-trepanning 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +10 -0
- data/ChangeLog +276 -0
- data/Makefile +13 -0
- data/Rakefile +1 -2
- data/app/display.rb +41 -1
- data/app/irb.rb +55 -49
- data/app/options.rb +3 -2
- data/app/run.rb +25 -7
- data/app/util.rb +19 -1
- data/bin/trepan8 +0 -2
- data/data/perldb.bindings +17 -0
- data/interface/script.rb +1 -1
- data/interface/server.rb +1 -1
- data/interface/user.rb +3 -1
- data/{interface/base_intf.rb → interface.rb} +1 -1
- data/io/input.rb +1 -1
- data/io/null_output.rb +1 -1
- data/io/string_array.rb +2 -2
- data/io/tcpclient.rb +1 -1
- data/io/tcpserver.rb +1 -1
- data/{io/base_io.rb → io.rb} +0 -0
- data/lib/debugger.rb +0 -1
- data/lib/trepanning.rb +3 -1
- data/processor/command/alias.rb +13 -2
- data/processor/command/backtrace.rb +2 -1
- data/processor/command/base/subcmd.rb +1 -5
- data/processor/command/base/submgr.rb +1 -1
- data/processor/command/base/subsubcmd.rb +1 -1
- data/processor/command/base/subsubmgr.rb +4 -4
- data/processor/command/break.rb +19 -11
- data/processor/command/catch.rb +1 -1
- data/processor/command/complete.rb +1 -1
- data/processor/command/continue.rb +7 -1
- data/processor/command/directory.rb +2 -2
- data/processor/command/disable.rb +13 -14
- data/processor/command/display.rb +3 -1
- data/processor/command/down.rb +8 -8
- data/processor/command/edit.rb +1 -1
- data/processor/command/enable.rb +21 -22
- data/processor/command/eval.rb +1 -2
- data/processor/command/exit.rb +25 -8
- data/processor/command/finish.rb +7 -2
- data/processor/command/frame.rb +1 -1
- data/processor/command/help.rb +3 -4
- data/processor/command/info.rb +2 -0
- data/processor/command/info_subcmd/files.rb +2 -2
- data/processor/command/info_subcmd/locals.rb +6 -53
- data/processor/command/info_subcmd/source.rb +10 -4
- data/processor/command/info_subcmd/variables.rb +35 -0
- data/processor/command/info_subcmd/variables_subcmd/.gitignore +1 -0
- data/processor/command/info_subcmd/variables_subcmd/class.rb +42 -0
- data/processor/command/info_subcmd/variables_subcmd/constant.rb +42 -0
- data/processor/command/info_subcmd/{globals.rb → variables_subcmd/globals.rb} +22 -17
- data/processor/command/info_subcmd/variables_subcmd/instance.rb +42 -0
- data/processor/command/info_subcmd/variables_subcmd/locals.rb +80 -0
- data/processor/command/kill.rb +8 -7
- data/processor/command/list.rb +2 -2
- data/processor/command/macro.rb +27 -9
- data/processor/command/next.rb +1 -1
- data/processor/command/parsetree.rb +1 -1
- data/processor/command/pp.rb +1 -1
- data/processor/command/pr.rb +1 -1
- data/processor/command/ps.rb +1 -1
- data/processor/command/restart.rb +1 -1
- data/processor/command/save.rb +1 -1
- data/processor/command/set_subcmd/auto.rb +7 -1
- data/processor/command/set_subcmd/different.rb +1 -1
- data/processor/command/set_subcmd/trace.rb +5 -4
- data/processor/command/set_subcmd/trace_subcmd/print.rb +4 -3
- data/processor/command/shell.rb +5 -4
- data/processor/command/show_subcmd/{alias.rb → aliases.rb} +2 -2
- data/processor/command/source.rb +1 -1
- data/processor/command/step.rb +2 -5
- data/processor/command/tbreak.rb +1 -1
- data/processor/command/unalias.rb +13 -8
- data/processor/command/undisplay.rb +13 -9
- data/processor/command/up.rb +12 -14
- data/processor/command.rb +138 -230
- data/processor/display.rb +46 -10
- data/processor/help.rb +5 -3
- data/processor/hook.rb +2 -2
- data/processor/location.rb +25 -0
- data/processor/mock.rb +3 -2
- data/processor/msg.rb +55 -42
- data/processor/old-command.rb +270 -0
- data/processor/{processor.rb → old-processor.rb} +7 -8
- data/processor/running.rb +7 -12
- data/processor/subcmd.rb +15 -41
- data/processor/validate.rb +240 -238
- data/{processor/main.rb → processor.rb} +20 -42
- data/test/data/trace.cmd +6 -0
- data/test/data/trace.right +46 -0
- data/test/integration/helper.rb +2 -0
- data/test/integration/test-trace.rb +29 -0
- data/test/unit/cmd-helper.rb +2 -3
- data/test/unit/test-app-options.rb +13 -11
- data/test/unit/test-app-run.rb +7 -1
- data/test/unit/test-base-cmd.rb +1 -1
- data/test/unit/test-cmd-kill.rb +11 -4
- data/test/unit/test-io-tcpserver.rb +9 -4
- data/test/unit/test-proc-eval.rb +1 -2
- data/test/unit/test-proc-location.rb +26 -32
- data/test/unit/test-subcmd-help.rb +1 -1
- data/trepan8.gemspec +9 -1
- metadata +60 -17
- data/processor/command/base/cmd.rb +0 -177
@@ -4,14 +4,14 @@ require 'rubygems'; require 'require_relative'
|
|
4
4
|
require_relative '../base/subcmd'
|
5
5
|
|
6
6
|
class Trepan::Subcommand::InfoFiles < Trepan::Subcommand
|
7
|
-
|
7
|
+
Trepan::Util::suppress_warnings {
|
8
8
|
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
9
9
|
HELP = 'Show files cached by the debugger'
|
10
10
|
MIN_ABBREV = 'files'.size
|
11
11
|
MIN_ARGS = 0
|
12
12
|
MAX_ARGS = 0
|
13
13
|
NEED_STACK = false
|
14
|
-
|
14
|
+
}
|
15
15
|
|
16
16
|
def run(args)
|
17
17
|
files = LineCache::cached_files
|
@@ -1,69 +1,22 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C)
|
2
|
+
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require 'rubygems'; require 'require_relative'
|
4
|
-
require 'columnize'
|
5
4
|
require_relative '../base/subcmd'
|
6
|
-
require_relative '../../../app/frame'
|
7
5
|
|
8
6
|
class Trepan::Subcommand::InfoLocals < Trepan::Subcommand
|
9
7
|
unless defined?(HELP)
|
10
8
|
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
11
|
-
HELP
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
Show local variables including parameters of the current stack frame.
|
16
|
-
Normally for each which show both the name and value. If you just
|
17
|
-
want a list of names add parameter 'names'.
|
18
|
-
EOH
|
19
|
-
SHORT_HELP = 'Show local variables of the current stack frame'
|
20
|
-
MIN_ARGS = 0
|
21
|
-
MAX_ARGS = 1
|
22
|
-
MIN_ABBREV = 'lo'.size
|
23
|
-
NEED_STACK = true
|
24
|
-
end
|
25
|
-
|
26
|
-
def get_local_names
|
27
|
-
@proc.frame.local_variables.keys
|
28
|
-
end
|
9
|
+
HELP = 'Same thing as "info locals"'
|
10
|
+
NEED_LOCALS = true
|
11
|
+
end
|
29
12
|
|
30
13
|
def run(args)
|
31
|
-
|
32
|
-
if 0 == 'names'.index(args[-1].downcase)
|
33
|
-
local_names = get_local_names()
|
34
|
-
if local_names.empty?
|
35
|
-
msg "No local variables defined."
|
36
|
-
else
|
37
|
-
section "Local variable names:"
|
38
|
-
width = settings[:maxwidth]
|
39
|
-
mess = Columnize::columnize(local_names,
|
40
|
-
@proc.settings[:maxwidth], ' ',
|
41
|
-
false, true, ' ' * 2).chomp
|
42
|
-
msg mess
|
43
|
-
end
|
44
|
-
else
|
45
|
-
errmsg("unrecognized argument #{args[2]}")
|
46
|
-
end
|
47
|
-
elsif args.size == 2
|
48
|
-
local_names = get_local_names
|
49
|
-
if local_names.empty?
|
50
|
-
msg "No local variables defined."
|
51
|
-
else
|
52
|
-
section "Local variables:"
|
53
|
-
@proc.frame.local_variables.each do |var_name, var_value|
|
54
|
-
msg("#{var_name} = #{var_value}")
|
55
|
-
end
|
56
|
-
end
|
57
|
-
else
|
58
|
-
errmsg("Wrong number of arguments #{args.size}")
|
59
|
-
end
|
14
|
+
@proc.commands['info'].run(%w(info variables locals))
|
60
15
|
end
|
61
16
|
end
|
62
17
|
|
63
18
|
if __FILE__ == $0
|
64
19
|
# Demo it.
|
65
20
|
require_relative '../../mock'
|
66
|
-
|
67
|
-
cmd.run(cmd.prefix)
|
68
|
-
cmd.run(cmd.prefix + ['name'])
|
21
|
+
# ???
|
69
22
|
end
|
@@ -10,6 +10,7 @@ end
|
|
10
10
|
require 'columnize'
|
11
11
|
require_relative '../base/subcmd'
|
12
12
|
require_relative '../../../app/complete'
|
13
|
+
require_relative '../../../app/run'
|
13
14
|
|
14
15
|
class Trepan::Subcommand::InfoSource < Trepan::Subcommand
|
15
16
|
unless defined?(HELP)
|
@@ -52,10 +53,15 @@ EOH
|
|
52
53
|
max_line = LineCache::size(canonic_name)
|
53
54
|
msg 'File has %d lines.' % max_line if max_line
|
54
55
|
msg('SHA1 is %s.' % LineCache::sha1(canonic_name))
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
syntax_errors = Trepan::ruby_syntax_errors(canonic_name)
|
57
|
+
if syntax_errors
|
58
|
+
msg('Not a syntactically-correct Ruby program.')
|
59
|
+
else
|
60
|
+
msg('Possible breakpoint line numbers:')
|
61
|
+
lines = LineCache.trace_line_numbers(canonic_name)
|
62
|
+
fmt_lines = columnize_numbers(lines)
|
63
|
+
msg(fmt_lines)
|
64
|
+
end
|
59
65
|
msg("Stat info:\n\t%s" % LineCache::stat(canonic_name).pretty_inspect)
|
60
66
|
end
|
61
67
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../base/subsubcmd'
|
5
|
+
require_relative '../base/subsubmgr'
|
6
|
+
|
7
|
+
class Trepan::Subcommand::InfoVariables < Trepan::SubSubcommandMgr
|
8
|
+
unless defined?(HELP)
|
9
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
10
|
+
HELP = <<-EOH
|
11
|
+
#{CMD} [locals|globals|instance]
|
12
|
+
|
13
|
+
List various classes of variables for the current stack frame.
|
14
|
+
|
15
|
+
Examples:
|
16
|
+
#{CMD} locals # show local variables
|
17
|
+
#{CMD} globals # show global variables
|
18
|
+
EOH
|
19
|
+
NEED_STACK = true
|
20
|
+
SHORT_HELP = 'List names and/or values from the current stack frame'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
if __FILE__ == $0
|
25
|
+
# Demo it.
|
26
|
+
require_relative '../../mock'
|
27
|
+
dbgr, parent_cmd = MockDebugger::setup('info', false)
|
28
|
+
cmd = Trepan::Subcommand::InfoVariables.new(dbgr.processor,
|
29
|
+
parent_cmd)
|
30
|
+
cmd.run(cmd.prefix + %w(locals))
|
31
|
+
cmd.run(cmd.prefix + %w(globals name))
|
32
|
+
%w(loc glo globals i).each do |prefix|
|
33
|
+
p [prefix, cmd.complete(prefix)]
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
/*~
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'locals'
|
5
|
+
|
6
|
+
class Trepan::Subcommand::InfoVariablesClass <
|
7
|
+
Trepan::Subcommand::InfoVariablesLocals
|
8
|
+
Trepan::Util.suppress_warnings {
|
9
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
10
|
+
HELP = <<-EOH
|
11
|
+
#{CMD}
|
12
|
+
#{CMD} [names]
|
13
|
+
|
14
|
+
Show class variables of the current stack frame.
|
15
|
+
Normally for each which show both the name and value. If you just
|
16
|
+
want a list of names add parameter 'names'.
|
17
|
+
EOH
|
18
|
+
SHORT_HELP = 'Show instance variables of the current stack frame'
|
19
|
+
MIN_ABBREV = 'cl'.size
|
20
|
+
MIN_ARGS = 0
|
21
|
+
MAX_ARGS = 1
|
22
|
+
NEED_STACK = true
|
23
|
+
}
|
24
|
+
|
25
|
+
def get_names
|
26
|
+
@proc.debug_eval_no_errmsg('self.class_variables') || []
|
27
|
+
end
|
28
|
+
|
29
|
+
def run(args)
|
30
|
+
run_for_type(args, 'class', @proc.debug_eval('self'))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
if __FILE__ == $0
|
35
|
+
# Demo it.
|
36
|
+
require_relative '../../mock'
|
37
|
+
cmd =
|
38
|
+
MockDebugger::subsub_setup(Trepan::Subcommand::InfoVariables,
|
39
|
+
Trepan::Subcommand::InfoVariablesClass)
|
40
|
+
cmd.run(cmd.prefix)
|
41
|
+
cmd.run(cmd.prefix + ['name'])
|
42
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'locals'
|
5
|
+
|
6
|
+
class Trepan::Subcommand::InfoVariablesConstant <
|
7
|
+
Trepan::Subcommand::InfoVariablesLocals
|
8
|
+
Trepan::Util.suppress_warnings {
|
9
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
10
|
+
HELP = <<-EOH
|
11
|
+
#{CMD}
|
12
|
+
#{CMD} [names]
|
13
|
+
|
14
|
+
Show class constants of the current stack frame.
|
15
|
+
Normally for each which show both the name and value. If you just
|
16
|
+
want a list of names add parameter 'names'.
|
17
|
+
EOH
|
18
|
+
SHORT_HELP = 'Show class constants via the current stack frame'
|
19
|
+
MIN_ABBREV = 'co'.size
|
20
|
+
MIN_ARGS = 0
|
21
|
+
MAX_ARGS = 1
|
22
|
+
NEED_STACK = true
|
23
|
+
}
|
24
|
+
|
25
|
+
def get_names
|
26
|
+
@proc.debug_eval_no_errmsg('self.class.constants.sort') || []
|
27
|
+
end
|
28
|
+
|
29
|
+
def run(args)
|
30
|
+
run_for_type(args, 'constant', @proc.debug_eval('self'))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
if __FILE__ == $0
|
35
|
+
# Demo it.
|
36
|
+
require_relative '../../mock'
|
37
|
+
cmd =
|
38
|
+
MockDebugger::subsub_setup(Trepan::Subcommand::InfoVariables,
|
39
|
+
Trepan::Subcommand::InfoVariablesConstant)
|
40
|
+
cmd.run(cmd.prefix)
|
41
|
+
cmd.run(cmd.prefix + ['name'])
|
42
|
+
end
|
@@ -1,12 +1,10 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require 'rubygems'; require 'require_relative'
|
4
|
-
|
5
|
-
require_relative '../base/subcmd'
|
6
|
-
require_relative '../../../app/frame'
|
4
|
+
require_relative 'locals'
|
7
5
|
|
8
|
-
class Trepan::
|
9
|
-
|
6
|
+
class Trepan::SubSubcommand::InfoVariablesGlobals < Trepan::SubSubcommand
|
7
|
+
Trepan::Util.suppress_warnings {
|
10
8
|
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
11
9
|
HELP = <<-EOH
|
12
10
|
#{CMD}
|
@@ -19,34 +17,39 @@ EOH
|
|
19
17
|
SHORT_HELP = 'Show global variables'
|
20
18
|
MIN_ARGS = 0
|
21
19
|
MAX_ARGS = 1
|
22
|
-
MIN_ABBREV = 'gl'.size
|
23
20
|
NEED_STACK = true
|
21
|
+
}
|
22
|
+
|
23
|
+
def get_names
|
24
|
+
global_variables.sort
|
24
25
|
end
|
25
26
|
|
26
27
|
def run(args)
|
27
|
-
if args.size ==
|
28
|
+
if args.size == 2
|
28
29
|
if 0 == 'names'.index(args[-1].downcase)
|
29
|
-
|
30
|
+
names = get_names()
|
31
|
+
if names.empty?
|
30
32
|
msg "No global variables defined."
|
31
33
|
else
|
32
34
|
section "Global variable names:"
|
33
35
|
width = settings[:maxwidth]
|
34
|
-
mess = Columnize::columnize(
|
36
|
+
mess = Columnize::columnize(names,
|
35
37
|
@proc.settings[:maxwidth], ' ',
|
36
38
|
false, true, ' ' * 2).chomp
|
37
39
|
msg mess
|
38
40
|
end
|
39
41
|
else
|
40
|
-
errmsg("unrecognized argument #{args[
|
42
|
+
errmsg("unrecognized argument: #{args[-1]}")
|
41
43
|
end
|
42
|
-
elsif args.size ==
|
43
|
-
|
44
|
+
elsif args.size == 1
|
45
|
+
names = get_names
|
46
|
+
if names.empty?
|
44
47
|
msg "No global variables defined."
|
45
48
|
else
|
46
49
|
section "Global variables:"
|
47
|
-
|
48
|
-
s = @proc.debug_eval(var_name)
|
49
|
-
msg("#{var_name} = #{s.inspect}")
|
50
|
+
names.each do |var_name|
|
51
|
+
s = @proc.debug_eval(var_name.to_s)
|
52
|
+
msg("#{var_name} = #{s.inspect}", :code=>true)
|
50
53
|
end
|
51
54
|
end
|
52
55
|
else
|
@@ -57,8 +60,10 @@ end
|
|
57
60
|
|
58
61
|
if __FILE__ == $0
|
59
62
|
# Demo it.
|
60
|
-
require_relative '
|
61
|
-
|
63
|
+
require_relative '../../../mock'
|
64
|
+
require_relative '../variables'
|
65
|
+
cmd = MockDebugger::subsub_setup(Trepan::Subcommand::InfoVariables,
|
66
|
+
Trepan::SubSubcommand::InfoVariablesGlobals)
|
62
67
|
cmd.run(cmd.prefix)
|
63
68
|
cmd.run(cmd.prefix + ['name'])
|
64
69
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'locals'
|
5
|
+
|
6
|
+
class Trepan::Subcommand::InfoVariablesInstance <
|
7
|
+
Trepan::Subcommand::InfoVariablesLocals
|
8
|
+
Trepan::Util.suppress_warnings {
|
9
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
10
|
+
HELP = <<-EOH
|
11
|
+
#{CMD}
|
12
|
+
#{CMD} [names]
|
13
|
+
|
14
|
+
Show instance variables of the current stack frame.
|
15
|
+
Normally for each which show both the name and value. If you just
|
16
|
+
want a list of names add parameter 'names'.
|
17
|
+
EOH
|
18
|
+
SHORT_HELP = 'Show instance variables of the current stack frame'
|
19
|
+
MIN_ARGS = 0
|
20
|
+
MAX_ARGS = 1
|
21
|
+
MIN_ABBREV = 'iv'.size
|
22
|
+
NEED_STACK = true
|
23
|
+
}
|
24
|
+
|
25
|
+
def get_names
|
26
|
+
@proc.debug_eval('self.instance_variables')
|
27
|
+
end
|
28
|
+
|
29
|
+
def run(args)
|
30
|
+
run_for_type(args, 'instance', @proc.debug_eval('self'))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
if __FILE__ == $0
|
35
|
+
# Demo it.
|
36
|
+
require_relative '../../mock'
|
37
|
+
cmd =
|
38
|
+
MockDebugger::subsub_setup(Trepan::Subcommand::InfoVariables,
|
39
|
+
Trepan::Subcommand::InfoVariablesInstance)
|
40
|
+
cmd.run(cmd.prefix)
|
41
|
+
cmd.run(cmd.prefix + ['name'])
|
42
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require 'columnize'
|
5
|
+
require_relative '../../base/subsubcmd'
|
6
|
+
require_relative '../../../../app/frame'
|
7
|
+
require_relative '../../../../app/util'
|
8
|
+
|
9
|
+
class Trepan::Subcommand::InfoVariablesLocals < Trepan::SubSubcommand
|
10
|
+
Trepan::Util.suppress_warnings {
|
11
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
12
|
+
HELP = <<-EOH
|
13
|
+
#{CMD}
|
14
|
+
#{CMD} [names]
|
15
|
+
|
16
|
+
Show local variables including parameters of the current stack frame.
|
17
|
+
Normally for each which show both the name and value. If you just
|
18
|
+
want a list of names add parameter 'names'.
|
19
|
+
EOH
|
20
|
+
SHORT_HELP = 'Show local variables of the current stack frame'
|
21
|
+
MIN_ARGS = 0
|
22
|
+
MAX_ARGS = 1
|
23
|
+
MIN_ABBREV = 'lo'.size
|
24
|
+
NEED_STACK = true
|
25
|
+
}
|
26
|
+
|
27
|
+
def get_names
|
28
|
+
@proc.state.context.frame_args(@proc.state.frame_pos)
|
29
|
+
end
|
30
|
+
|
31
|
+
def run_for_type(args, type, klass=nil)
|
32
|
+
suffix = klass ? " for #{klass.to_s}" : ''
|
33
|
+
names = get_names()
|
34
|
+
if args.size == 2
|
35
|
+
if 0 == 'names'.index(args[-1].downcase)
|
36
|
+
names = get_names()
|
37
|
+
if names.empty?
|
38
|
+
msg "No #{type} variables defined."
|
39
|
+
else
|
40
|
+
section "#{type.capitalize} variable names#{suffix}:"
|
41
|
+
|
42
|
+
width = settings[:maxwidth]
|
43
|
+
mess = Columnize::columnize(names,
|
44
|
+
@proc.settings[:maxwidth], ' ',
|
45
|
+
false, true, ' ' * 2).chomp
|
46
|
+
msg mess
|
47
|
+
end
|
48
|
+
else
|
49
|
+
errmsg("unrecognized argument: #{args[-1]}")
|
50
|
+
end
|
51
|
+
elsif args.size == 1
|
52
|
+
if names.empty?
|
53
|
+
msg "No #{type} variables defined#{suffix}."
|
54
|
+
else
|
55
|
+
section "#{type.capitalize} variables#{suffix}:"
|
56
|
+
names.each do |var_name|
|
57
|
+
var_value =
|
58
|
+
@proc.safe_rep(@proc.debug_eval_no_errmsg(var_name).inspect)
|
59
|
+
msg("#{var_name} = #{var_value}", :code =>true)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
else
|
63
|
+
errmsg("Wrong number of arguments #{args.size}")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
def run(args)
|
67
|
+
run_for_type(args, 'local', @proc.debug_eval('self'))
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
if __FILE__ == $0
|
72
|
+
# Demo it.
|
73
|
+
require_relative '../../../mock'
|
74
|
+
require_relative '../variables'
|
75
|
+
cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::InfoVariables,
|
76
|
+
Trepan::SubSubcommand::InfoVariablesLocals
|
77
|
+
)
|
78
|
+
cmd.run([])
|
79
|
+
cmd.run(['name'])
|
80
|
+
end
|
data/processor/command/kill.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
2
|
require 'rubygems'; require 'require_relative'
|
3
|
-
require_relative '
|
3
|
+
require_relative '../command'
|
4
4
|
class Trepan::Command::KillCommand < Trepan::Command
|
5
5
|
|
6
6
|
unless defined?(HELP)
|
@@ -35,9 +35,10 @@ Examples:
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def complete(prefix)
|
38
|
-
completions = Signal.list.keys +
|
38
|
+
completions = Signal.list.keys + Signal.list.keys.map{|k| k.downcase} +
|
39
39
|
Signal.list.values.map{|i| i.to_s} +
|
40
|
-
Signal.list.values.map{|i| (-i).to_s}
|
40
|
+
Signal.list.values.map{|i| (-i).to_s} +
|
41
|
+
['unconditionally']
|
41
42
|
Trepan::Complete.complete_token(completions, prefix)
|
42
43
|
end
|
43
44
|
|
@@ -59,10 +60,10 @@ Examples:
|
|
59
60
|
end
|
60
61
|
end
|
61
62
|
begin
|
62
|
-
## @proc.intf.finalize if 'KILL' == sig || Signal['KILL'] == sig
|
63
|
+
## @proc.intf.finalize if 'KILL' == sig || Signal.list['KILL'] == sig
|
63
64
|
Process.kill(sig, Process.pid)
|
64
|
-
rescue Errno::ESRCH
|
65
|
-
errmsg "Unable to send kill #{sig} to process #{Process.pid}"
|
65
|
+
rescue Errno::ESRCH, Errno::EINVAL, Errno::EPERM, RangeError
|
66
|
+
errmsg "Unable to send kill #{sig} to process #{Process.pid}: #{$!}"
|
66
67
|
end
|
67
68
|
end
|
68
69
|
end
|
@@ -70,7 +71,7 @@ end
|
|
70
71
|
if __FILE__ == $0
|
71
72
|
require_relative '../mock'
|
72
73
|
dbgr, cmd = MockDebugger::setup
|
73
|
-
%w(fooo 1 -1 HUP -9).each do |arg|
|
74
|
+
%w(fooo 100 1 -1 HUP -9).each do |arg|
|
74
75
|
puts "#{cmd.name} #{arg}"
|
75
76
|
cmd.run([cmd.name, arg])
|
76
77
|
puts '=' * 40
|
data/processor/command/list.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require 'rubygems'; require 'require_relative'
|
4
|
-
require_relative '
|
4
|
+
require_relative '../command'
|
5
5
|
|
6
6
|
class Trepan::Command::ListCommand < Trepan::Command
|
7
7
|
unless defined?(HELP)
|
@@ -29,7 +29,7 @@ In the third form, list lines centered around the current line.
|
|
29
29
|
Use 'set max list' or 'show max list' to see or set the value.
|
30
30
|
HELP
|
31
31
|
|
32
|
-
ALIASES = %W(l)
|
32
|
+
ALIASES = %W(l cat)
|
33
33
|
CATEGORY = 'files'
|
34
34
|
MAX_ARGS = 2
|
35
35
|
SHORT_HELP = 'List source code'
|
data/processor/command/macro.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require 'rubygems'; require 'require_relative'
|
4
|
-
require_relative '
|
4
|
+
require_relative '../command'
|
5
5
|
require_relative '../eval'
|
6
6
|
class Trepan::Command::MacroCommand < Trepan::Command
|
7
7
|
|
@@ -11,25 +11,43 @@ class Trepan::Command::MacroCommand < Trepan::Command
|
|
11
11
|
#{NAME} MACRO-NAME PROC-OBJECT
|
12
12
|
|
13
13
|
Define MACRO-NAME as a debugger macro. Debugger macros get a list of
|
14
|
-
arguments.
|
14
|
+
arguments. Debugger macros get a list of arguments which you supply
|
15
|
+
without parenthesis or commas. See below for an example.
|
15
16
|
|
16
|
-
The macro should return either a String or an
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
The macro (really a Ruby Proc) should return either a String or an
|
18
|
+
Array of Strings. The string in both cases are strings of debugger
|
19
|
+
commands. If the return is a String, that gets tokenized by a simple
|
20
|
+
String#split . Note that macro processing is done right after
|
21
|
+
splitting on ;; so if the macro returns a string containing ;; this
|
22
|
+
will not be handled on the string returned.
|
21
23
|
|
22
24
|
If instead, Array of Strings is returned, then the first string is
|
23
|
-
|
25
|
+
shifted from the array and executed. The remaning strings are pushed
|
24
26
|
onto the command queue. In contrast to the first string, subsequent
|
25
27
|
strings can contain other macros, and ;; in those strings will be
|
26
28
|
split into separate commands.
|
27
29
|
|
28
|
-
Here is an example. The below creates a macro called
|
30
|
+
Here is an example. The below creates a macro called fin+ which
|
29
31
|
issues two commands 'finish' followed by 'step':
|
30
32
|
|
31
33
|
macro fin+ Proc.new{|*args| %w(finish step)}
|
32
34
|
|
35
|
+
If you wanted to parameterize the argument of the 'finish' command you
|
36
|
+
could do that this way:
|
37
|
+
|
38
|
+
macro fin+ Proc.new{|*args| ['finish \#{args[0]}' 'step']}
|
39
|
+
|
40
|
+
Invoking with
|
41
|
+
fin+ 3
|
42
|
+
|
43
|
+
would expand to ["finish 3", "step"]
|
44
|
+
|
45
|
+
If you were to add another parameter for 'step', the note that the
|
46
|
+
invocation might be:
|
47
|
+
fin+ 3 2
|
48
|
+
|
49
|
+
rather than 'fin+(3,2)' or 'fin+ 3, 2'.
|
50
|
+
|
33
51
|
See also 'show macro'.
|
34
52
|
HELP
|
35
53
|
|
data/processor/command/next.rb
CHANGED
data/processor/command/pp.rb
CHANGED
data/processor/command/pr.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require 'rubygems'; require 'require_relative'
|
4
|
-
require_relative '
|
4
|
+
require_relative '../command'
|
5
5
|
class Trepan::Command::PrCommand < Trepan::Command
|
6
6
|
|
7
7
|
unless defined?(HELP)
|
data/processor/command/ps.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require 'rubygems'; require 'require_relative'
|
4
|
-
require_relative '
|
4
|
+
require_relative '../command'
|
5
5
|
require_relative '../eval'
|
6
6
|
class Trepan::Command::PsCommand < Trepan::Command
|
7
7
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require 'rubygems'; require 'require_relative'
|
4
|
-
require_relative '
|
4
|
+
require_relative '../command'
|
5
5
|
## require_relative '../../app/run'
|
6
6
|
class Trepan::Command::RestartCommand < Trepan::Command
|
7
7
|
|
data/processor/command/save.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require 'rubygems'; require 'require_relative'
|
4
|
-
require_relative '
|
4
|
+
require_relative '../command'
|
5
5
|
class Trepan::Command::SaveCommand < Trepan::Command
|
6
6
|
|
7
7
|
unless defined?(HELP)
|
@@ -6,8 +6,14 @@ require_relative '../base/subsubmgr'
|
|
6
6
|
|
7
7
|
class Trepan::SubSubcommand::SetAuto < Trepan::SubSubcommandMgr
|
8
8
|
unless defined?(HELP)
|
9
|
-
HELP = 'Set controls for things with some sort of "automatic" default behavior'
|
10
9
|
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
10
|
+
HELP = <<-EOH
|
11
|
+
Set controls for things with some sort of "automatic" default behavior.
|
12
|
+
|
13
|
+
See "#{PREFIX.join(' ')} *" for a list of subcommands or "#{PREFIX.join(' ')} <name>"
|
14
|
+
for help on a particular trace subcommand.
|
15
|
+
EOH
|
16
|
+
SHORT_HELP = 'Set controls for some "automatic" default behaviors'
|
11
17
|
end
|
12
18
|
end
|
13
19
|
|
@@ -10,7 +10,7 @@ class Trepan::Subcommand::SetDifferent < Trepan::SetBoolSubcommand
|
|
10
10
|
HELP = <<-EOH
|
11
11
|
#{PREFIX.join(' ')} [on|off|nostack]
|
12
12
|
|
13
|
-
|
13
|
+
Set to make sure 'next' or 'step' moves to a new position.
|
14
14
|
|
15
15
|
Due to the interpretive, expression-oriented nature of the Ruby
|
16
16
|
Language and implementation, each line often may contain many possible
|