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/list.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Copyright (C) 2010-2011, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
2
2
|
# -*- coding: utf-8 -*-
|
3
3
|
require 'linecache'
|
4
|
+
require 'rbconfig'
|
4
5
|
require_relative '../command'
|
5
6
|
require_relative '../list'
|
6
7
|
|
@@ -8,9 +9,8 @@ class Trepan::Command::ListCommand < Trepan::Command
|
|
8
9
|
unless defined?(HELP)
|
9
10
|
NAME = File.basename(__FILE__, '.rb')
|
10
11
|
HELP = <<-HELP
|
11
|
-
**#{NAME}
|
12
|
-
|
13
|
-
**#{NAME}**[**>**] *location* [*num*]
|
12
|
+
**#{NAME}[>]** [*module*] [*first* [*num*]]
|
13
|
+
**#{NAME}[>]** *location [*num*]
|
14
14
|
|
15
15
|
List source code.
|
16
16
|
|
@@ -22,13 +22,13 @@ changing, then that is start the line after we last one previously
|
|
22
22
|
shown.
|
23
23
|
|
24
24
|
If the command has a ">" suffix, then line centering is disabled and
|
25
|
-
listing begins at the
|
25
|
+
listing begins at the specificed location.
|
26
26
|
|
27
27
|
The number of lines to show is controlled by the debugger "listsize"
|
28
28
|
setting. Use 'set max list' or 'show max list' to see or set the
|
29
29
|
value.
|
30
30
|
|
31
|
-
|
31
|
+
\"#{NAME} -\" shows lines before a previous listing.
|
32
32
|
|
33
33
|
A *location* is a either:
|
34
34
|
|
@@ -113,6 +113,14 @@ See also:
|
|
113
113
|
iseq, filename, first, last =
|
114
114
|
@proc.parse_list_cmd(@proc.cmd_argstr, listsize, center_correction)
|
115
115
|
return unless filename
|
116
|
+
unless @proc.text_file?(filename)
|
117
|
+
errmsg("File \"%s\" doesn't seem to contain source text." % filename)
|
118
|
+
if [RbConfig::CONFIG['DLEXT'],
|
119
|
+
RbConfig::CONFIG['DLEXT2']].member?(File.basename(filename))
|
120
|
+
msg("File has dynamic loader extension")
|
121
|
+
end
|
122
|
+
return
|
123
|
+
end
|
116
124
|
container = iseq ? iseq.source_container : ['file', filename]
|
117
125
|
breaklist = @proc.brkpts.line_breaks(container)
|
118
126
|
|
@@ -162,8 +170,6 @@ See also:
|
|
162
170
|
msg(s + "\t" + line, {:unlimited => true})
|
163
171
|
@proc.line_no = lineno
|
164
172
|
end
|
165
|
-
@proc.list_lineno += listsize + center_correction + 1
|
166
|
-
@proc.list_lineno = max_line if @proc.list_lineno > max_line
|
167
173
|
rescue => e
|
168
174
|
errmsg e.to_s if settings[:debugexcept]
|
169
175
|
end
|
@@ -252,5 +258,5 @@ if __FILE__ == $0
|
|
252
258
|
run_cmd2(cmd, %W(#{cmd.name} run_cmd2))
|
253
259
|
run_cmd2(cmd, %W(#{cmd.name} run_cmd2))
|
254
260
|
run_cmd2(cmd, %W(#{cmd.name} @0))
|
255
|
-
|
261
|
+
end
|
256
262
|
end
|
data/processor/command/macro.rb
CHANGED
@@ -42,7 +42,7 @@ macro called fin+ which issues two commands 'finish' followed by
|
|
42
42
|
|
43
43
|
macro fin+ Proc.new{|*args| %w(finish step)}
|
44
44
|
|
45
|
-
If you wanted to parameterize the argument of the
|
45
|
+
If you wanted to parameterize the argument of the *finish* command
|
46
46
|
you could do that this way:
|
47
47
|
|
48
48
|
macro fin+ Proc.new{|*args| ["finish \#{args[0]}" 'step']}
|
data/processor/command/next.rb
CHANGED
@@ -9,7 +9,7 @@ class Trepan::SubSubcommand::SetAuto < Trepan::SubSubcommandMgr
|
|
9
9
|
HELP = <<-EOH
|
10
10
|
Set controls for things with some sort of "automatic" default behavior.
|
11
11
|
|
12
|
-
See "#{PREFIX.join(' ')} *" for a list of subcommands or "#{PREFIX.join(' ')} <name>"
|
12
|
+
See "#{PREFIX.join(' ')} *" for a list of subcommands or "#{PREFIX.join(' ')} <name>"
|
13
13
|
for help on a particular trace subcommand.
|
14
14
|
EOH
|
15
15
|
SHORT_HELP = 'Set controls for some "automatic" default behaviors'
|
@@ -21,9 +21,9 @@ if __FILE__ == $0
|
|
21
21
|
dbgr, cmd = MockDebugger::setup('set')
|
22
22
|
cmds = dbgr.core.processor.commands
|
23
23
|
set_cmd = cmds['set']
|
24
|
-
command = Trepan::SubSubcommand::SetAuto.new(dbgr.core.processor,
|
24
|
+
command = Trepan::SubSubcommand::SetAuto.new(dbgr.core.processor,
|
25
25
|
set_cmd)
|
26
|
-
cmd_args =
|
26
|
+
cmd_args = Trepan::SubSubcommand::SetAuto::PREFIX
|
27
27
|
set_cmd.instance_variable_set('@last_args', cmd_args)
|
28
28
|
# require_relative '../../../lib/trepanning'
|
29
29
|
# Trepan.debug
|
@@ -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 '../base/subcmd'
|
4
4
|
|
5
5
|
class Trepan::Subcommand::SetDifferent < Trepan::SetBoolSubcommand
|
@@ -16,21 +16,22 @@ stopping points with possibly different event type. In a debugger it
|
|
16
16
|
is sometimes desirable to continue but stop only when the position
|
17
17
|
next changes.
|
18
18
|
|
19
|
-
Setting
|
19
|
+
Setting to "different" to on will cause each `step` or `next` command to
|
20
20
|
stop at a different position.
|
21
21
|
|
22
22
|
Note though that the notion of different does take into account stack
|
23
|
-
nesting. So in `ARGV.map {|arg| arg.to_i}
|
24
|
-
well as one in the block
|
23
|
+
nesting. So in `ARGV.map {|arg| arg.to_i}`, you get a stop before
|
24
|
+
*ARGV* as well as one in the block as well as before to call to
|
25
|
+
*to_i*.
|
25
26
|
|
26
|
-
If you to ignore stopping at added nesting levels, there are two
|
27
|
-
possibilities.
|
28
|
-
a given line. Also you can use 'next', but that also stepping
|
29
|
-
functions
|
27
|
+
If you wan to ignore stopping at added nesting levels, there are two
|
28
|
+
possibilities. `set step nostack` will ignore stack nestings levels on
|
29
|
+
a given line. Also you can use 'next', but that also skips stepping
|
30
|
+
into functions.
|
30
31
|
|
31
32
|
See also:
|
32
33
|
---------
|
33
|
-
`step`, `next`
|
34
|
+
The debugger command `step`, `next` have suffixes '+' and '-' which
|
34
35
|
override this setting.
|
35
36
|
EOH
|
36
37
|
|
@@ -41,31 +42,31 @@ override this setting.
|
|
41
42
|
|
42
43
|
completion %w(on off nostack)
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
def run(args)
|
46
|
+
if args.size == 3 && 'nostack' == args[2]
|
47
|
+
@proc.settings[:different] = 'nostack'
|
48
|
+
msg("different is nostack.")
|
49
|
+
else
|
50
|
+
super
|
51
|
+
end
|
52
|
+
@proc.different_pos = @proc.settings[:different]
|
50
53
|
end
|
51
|
-
@proc.different_pos = @proc.settings[:different]
|
52
|
-
end
|
53
54
|
|
54
55
|
end
|
55
56
|
|
56
57
|
if __FILE__ == $0
|
57
|
-
|
58
|
-
|
59
|
-
|
58
|
+
# Demo it.
|
59
|
+
require_relative '../../mock'
|
60
|
+
name = File.basename(__FILE__, '.rb')
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
# FIXME: DRY the below code
|
63
|
+
dbgr, cmd = MockDebugger::setup('set')
|
64
|
+
subcommand = Trepan::Subcommand::SetDifferent.new(cmd)
|
65
|
+
testcmdMgr = Trepan::Subcmd.new(subcommand)
|
65
66
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
subcommand.run_show_bool
|
68
|
+
# subcommand.summary_help(name)
|
69
|
+
puts
|
70
|
+
puts '-' * 20
|
71
|
+
puts subcommand.save_command
|
71
72
|
end
|
@@ -1,72 +1,98 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010,
|
3
|
-
require 'trace'
|
2
|
+
# Copyright (C) 2010-2011, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
4
3
|
require 'columnize'
|
5
4
|
require_relative '../base/subcmd'
|
6
5
|
|
6
|
+
|
7
7
|
class Trepan::Subcommand::SetEvents < Trepan::Subcommand
|
8
|
-
unless defined?(HELP)
|
9
|
-
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
10
|
-
HELP = "set events {event-name[,] ...}
|
11
8
|
|
12
|
-
Set trace events that the debugger will stop on
|
13
9
|
|
14
|
-
|
15
|
-
|
10
|
+
unless defined?(HELP)
|
11
|
+
TRACE_POINT_EVENTS = TracePoint.new{}.event_mask.map{|e| e.to_s}
|
12
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
13
|
+
HELP = <<-EOH
|
14
|
+
**#{PREFIX.join(' ')}** {*event-name*[,] ...}
|
15
|
+
|
16
|
+
Set trace events that the debugger will stop on.
|
17
|
+
|
18
|
+
Event names are:
|
19
|
+
|
20
|
+
#{Columnize::columnize(TRACE_POINT_EVENTS, 80, ' ' * 4,
|
21
|
+
true, true, ' ' * 4)}
|
16
22
|
|
17
23
|
Separate event names with space and an optional comma is also
|
18
24
|
allowable after an event name.
|
19
25
|
|
20
26
|
Examples:
|
21
|
-
|
22
|
-
|
23
|
-
|
27
|
+
---------
|
28
|
+
set events call return
|
29
|
+
set ev call, c_call, return, c_return, c_return
|
30
|
+
|
31
|
+
See also:
|
32
|
+
---------
|
33
|
+
|
34
|
+
`show events`
|
35
|
+
|
36
|
+
EOH
|
24
37
|
MIN_ABBREV = 'ev'.size
|
25
38
|
SHORT_HELP = 'Set trace events we may stop on.'
|
26
39
|
end
|
27
40
|
|
28
|
-
completion
|
41
|
+
completion TRACE_POINT_EVENTS
|
29
42
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
43
|
+
def save_command
|
44
|
+
step_events_list = @proc.core.step_events_list
|
45
|
+
step_events_list = 'brkpt' unless step_events_list
|
46
|
+
["#{subcmd_prefix_string} #{step_events_list}"]
|
47
|
+
end
|
48
|
+
|
49
|
+
def run(args)
|
50
|
+
unless args.size <= 2
|
51
|
+
events = args[2..-1]
|
52
|
+
invalid_names = []
|
53
|
+
valid_events = events.map do |event|
|
54
|
+
event.chomp!(',')
|
55
|
+
if TRACE_POINT_EVENTS.member?(event)
|
56
|
+
event
|
57
|
+
else
|
58
|
+
invalid_names << event
|
59
|
+
nil
|
60
|
+
end
|
61
|
+
end.compact
|
35
62
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
63
|
+
# FIXME: check validity of events
|
64
|
+
if @proc.core.trace_point
|
65
|
+
@proc.core.trace_point.event_mask_set *valid_events
|
66
|
+
else
|
67
|
+
errmsg("No tracepoint currently set")
|
68
|
+
end
|
69
|
+
unless invalid_names.empty?
|
70
|
+
errmsg("Event names unrecognized/ignored: %s" % invalid_names.join(', '))
|
71
|
+
end
|
72
|
+
end
|
73
|
+
@proc.commands['show'].subcmds.subcmds[:events].run('events')
|
46
74
|
end
|
47
|
-
@proc.commands['show'].subcmds.subcmds[:events].run('events')
|
48
|
-
end
|
49
75
|
end
|
50
76
|
|
51
77
|
if __FILE__ == $0
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
78
|
+
# Demo it.
|
79
|
+
require_relative '../../mock'
|
80
|
+
name = File.basename(__FILE__, '.rb')
|
81
|
+
|
82
|
+
# FIXME: DRY the below code
|
83
|
+
dbgr, cmd = MockDebugger::setup('set')
|
84
|
+
subcommand = Trepan::Subcommand::SetEvents.new(cmd)
|
85
|
+
testcmdMgr = Trepan::Subcmd.new(subcommand)
|
86
|
+
|
87
|
+
name = File.basename(__FILE__, '.rb')
|
88
|
+
# subcommand.summary_help(name)
|
89
|
+
puts
|
90
|
+
subcommand.run([])
|
91
|
+
[%w(call line foo), %w(c_call, c_return,)].each do |events|
|
92
|
+
subcommand.run(%w(set events) + events)
|
93
|
+
puts dbgr.core.step_events
|
94
|
+
end
|
95
|
+
puts '-' * 20
|
96
|
+
puts subcommand.save_command()
|
71
97
|
|
72
98
|
end
|
@@ -1,23 +1,30 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
# Copyright (C) 2010, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require_relative '../../base/subsubcmd'
|
4
4
|
|
5
5
|
class Trepan::SubSubcommand::SetMaxList < Trepan::SubSubcommand
|
6
6
|
unless defined?(HELP)
|
7
7
|
NAME = File.basename(__FILE__, '.rb')
|
8
|
-
HELP = "Set max[imum] #{NAME} NUMBER
|
9
|
-
|
10
|
-
Set number of source-code lines to list by default."
|
11
8
|
IN_LIST = true
|
12
9
|
MIN_ABBREV = 'lis'.size
|
13
10
|
PREFIX = %W(set max #{NAME})
|
14
11
|
SHORT_HELP = 'Set number of lines to list'
|
12
|
+
HELP = <<-EOH
|
13
|
+
**#{PREFIX.join(' ')}** *integer-expression*
|
14
|
+
|
15
|
+
Set number of source-code lines to list by default in a debugger `list` command.
|
16
|
+
|
17
|
+
See also:
|
18
|
+
---------
|
19
|
+
`list`, `show maximum list`
|
20
|
+
EOH
|
21
|
+
|
15
22
|
end
|
16
23
|
|
17
24
|
def run(args)
|
18
25
|
args.shift
|
19
26
|
run_set_int(args.join(' '),
|
20
|
-
"The '#{PREFIX.join(' ')}' command requires a list size",
|
27
|
+
"The '#{PREFIX.join(' ')}' command requires a list size",
|
21
28
|
0, nil)
|
22
29
|
end
|
23
30
|
|
@@ -1,27 +1,36 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
# Copyright (C) 2010, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require_relative '../../base/subsubcmd'
|
4
4
|
|
5
5
|
class Trepan::SubSubcommand::SetMaxWidth < Trepan::SubSubcommand
|
6
|
-
|
7
|
-
|
6
|
+
unless defined?(HELP)
|
7
|
+
HELP = 'Set max[imum] width NUMBER
|
8
8
|
|
9
9
|
Set number of characters the debugger thinks are in a line.'
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
10
|
+
IN_LIST = true
|
11
|
+
MIN_ABBREV = 'wid'.size
|
12
|
+
NAME = File.basename(__FILE__, '.rb')
|
13
|
+
PREFIX = %w(set max width)
|
14
|
+
SHORT_HELP = 'Set number of characters the debugger thinks are in a line'
|
15
|
+
end
|
16
|
+
|
17
|
+
def display_width
|
18
|
+
(ENV['COLUMNS'] || `tput cols &2>/dev/null`).to_i rescue 80
|
19
|
+
end
|
20
|
+
|
21
|
+
def run(args)
|
22
|
+
args.shift
|
23
|
+
if args.size == 0
|
24
|
+
@proc.settings[:maxwidth] = display_width
|
25
|
+
run_show_int
|
26
|
+
else
|
27
|
+
run_set_int(args.join(' '),
|
28
|
+
"The '#{PREFIX.join(' ')}' command requires a line width",
|
29
|
+
0, nil)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
alias save_command save_command_from_settings
|
25
34
|
|
26
35
|
end
|
27
36
|
|
@@ -31,7 +40,7 @@ if __FILE__ == $0
|
|
31
40
|
name = File.basename(__FILE__, '.rb')
|
32
41
|
|
33
42
|
dbgr, set_cmd = MockDebugger::setup('set')
|
34
|
-
max_cmd = Trepan::SubSubcommand::SetMax.new(dbgr.core.processor,
|
43
|
+
max_cmd = Trepan::SubSubcommand::SetMax.new(dbgr.core.processor,
|
35
44
|
set_cmd)
|
36
45
|
cmd_ary = Trepan::SubSubcommand::SetMaxWidth::PREFIX
|
37
46
|
cmd_name = cmd_ary.join(' ')
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require_relative '../base/subsubcmd'
|
4
|
+
require_relative '../base/subsubmgr'
|
5
|
+
|
6
|
+
class Trepan::SubSubcommand::SetRegister < Trepan::SubSubcommandMgr
|
7
|
+
unless defined?(HELP)
|
8
|
+
Trepanning::Subcommand.set_name_prefix(__FILE__, self)
|
9
|
+
HELP = <<-EOH
|
10
|
+
**#{PREFIX.join(' ')}** {*register-name*[,] ...}
|
11
|
+
|
12
|
+
Allows setting certain VM registers. *Warning*: these are potentially
|
13
|
+
dangerous.
|
14
|
+
|
15
|
+
See also:
|
16
|
+
---------
|
17
|
+
`#{PREFIX.join(' ')} *` for a list of subcommands or `#{PREFIX.join(' ')} *name*`
|
18
|
+
for help on a particular register subcommand.
|
19
|
+
EOH
|
20
|
+
SHORT_HELP = 'Set VM registers'
|
21
|
+
MIN_ABBREV = 'reg'.size
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
if __FILE__ == $0
|
26
|
+
require_relative '../../mock'
|
27
|
+
dbgr, cmd = MockDebugger::setup('set')
|
28
|
+
cmds = dbgr.core.processor.commands
|
29
|
+
set_cmd = cmds['set']
|
30
|
+
command = Trepan::SubSubcommand::SetRegister.new(dbgr.core.processor,
|
31
|
+
set_cmd)
|
32
|
+
cmd_args = Trepan::SubSubcommand::SetRegister::PREFIX
|
33
|
+
set_cmd.instance_variable_set('@last_args', cmd_args)
|
34
|
+
# require_relative '../../../lib/trepanning'
|
35
|
+
# Trepan.debug
|
36
|
+
command.run(cmd_args)
|
37
|
+
end
|