trepanning 1.93.35 → 2.15.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +7 -0
  2. data/ChangeLog +491 -55
  3. data/LICENSE +1 -1
  4. data/NEWS +18 -14
  5. data/README.md +5 -22
  6. data/Rakefile +22 -1
  7. data/app/breakpoint.rb +5 -3
  8. data/app/core.rb +147 -179
  9. data/app/default.rb +47 -46
  10. data/app/file.rb +6 -7
  11. data/app/frame.rb +183 -176
  12. data/app/markdown.rb +2 -9
  13. data/app/options.rb +1 -1
  14. data/app/run.rb +71 -37
  15. data/interface/script.rb +8 -8
  16. data/io.rb +19 -20
  17. data/lib/trepanning.rb +292 -297
  18. data/processor.rb +332 -344
  19. data/processor/breakpoint.rb +98 -96
  20. data/processor/command/base/submgr.rb +9 -9
  21. data/processor/command/break.rb +40 -38
  22. data/processor/command/continue.rb +15 -10
  23. data/processor/command/debug.rb +6 -25
  24. data/processor/command/delete.rb +21 -12
  25. data/processor/command/directory.rb +15 -13
  26. data/processor/command/disable.rb +12 -9
  27. data/processor/command/disassemble.rb +80 -74
  28. data/processor/command/display.rb +15 -12
  29. data/processor/command/down.rb +8 -3
  30. data/processor/command/edit.rb +37 -23
  31. data/processor/command/enable.rb +11 -8
  32. data/processor/command/eval.rb +24 -22
  33. data/processor/command/finish.rb +50 -48
  34. data/processor/command/help.rb +1 -1
  35. data/processor/command/info_subcmd/breakpoints.rb +7 -7
  36. data/processor/command/info_subcmd/files.rb +195 -196
  37. data/processor/command/info_subcmd/frame.rb +7 -4
  38. data/processor/command/info_subcmd/locals.rb +29 -12
  39. data/processor/command/info_subcmd/program.rb +48 -39
  40. data/processor/command/info_subcmd/registers_subcmd/ep.rb +46 -0
  41. data/processor/command/info_subcmd/registers_subcmd/helper.rb +32 -35
  42. data/processor/command/info_subcmd/registers_subcmd/sp.rb +29 -23
  43. data/processor/command/info_subcmd/return.rb +28 -10
  44. data/processor/command/info_subcmd/variables_subcmd/class.rb +3 -3
  45. data/processor/command/info_subcmd/variables_subcmd/constants.rb +77 -0
  46. data/processor/command/info_subcmd/variables_subcmd/globals.rb +7 -7
  47. data/processor/command/info_subcmd/variables_subcmd/instance.rb +68 -22
  48. data/processor/command/info_subcmd/variables_subcmd/locals.rb +148 -67
  49. data/processor/command/list.rb +14 -8
  50. data/processor/command/macro.rb +1 -1
  51. data/processor/command/next.rb +1 -0
  52. data/processor/command/set_subcmd/auto.rb +3 -3
  53. data/processor/command/set_subcmd/different.rb +30 -29
  54. data/processor/command/set_subcmd/events.rb +74 -48
  55. data/processor/command/set_subcmd/max_subcmd/list.rb +12 -5
  56. data/processor/command/set_subcmd/max_subcmd/width.rb +28 -19
  57. data/processor/command/set_subcmd/register.rb +37 -0
  58. data/processor/command/set_subcmd/register_subcmd/pc.rb +67 -0
  59. data/processor/command/set_subcmd/register_subcmd/sp.rb +75 -0
  60. data/processor/command/set_subcmd/reload.rb +12 -10
  61. data/processor/command/set_subcmd/return.rb +68 -44
  62. data/processor/command/shell.rb +3 -2
  63. data/processor/command/show_subcmd/different.rb +17 -14
  64. data/processor/command/show_subcmd/events.rb +25 -25
  65. data/processor/default.rb +1 -1
  66. data/processor/eval.rb +14 -15
  67. data/processor/frame.rb +43 -36
  68. data/processor/help.rb +5 -5
  69. data/processor/hook.rb +26 -29
  70. data/processor/location.rb +54 -51
  71. data/processor/mock.rb +4 -3
  72. data/processor/running.rb +113 -103
  73. data/processor/validate.rb +401 -373
  74. data/test/data/debug.cmd +8 -0
  75. data/test/data/debug.right +13 -0
  76. data/test/data/debugger-stop.right +6 -4
  77. data/test/data/fname-with-blank.cmd +1 -1
  78. data/test/data/fname-with-blank.right +5 -0
  79. data/test/data/pc.cmd +8 -0
  80. data/test/data/pc.right +10 -0
  81. data/test/data/quit.right +3 -1
  82. data/test/data/trace.cmd +2 -2
  83. data/test/data/trace.right +41 -20
  84. data/test/example/assign.rb +6 -0
  85. data/test/functional/fn_helper.rb +11 -17
  86. data/test/functional/test-break-long.rb +15 -16
  87. data/test/functional/test-break.rb +6 -8
  88. data/test/functional/test-condition.rb +8 -10
  89. data/test/functional/test-debugger-call-bug.rb +21 -22
  90. data/test/functional/test-delete.rb +57 -59
  91. data/test/functional/test-eval.rb +101 -103
  92. data/test/functional/test-finish.rb +24 -33
  93. data/test/functional/test-immediate-step-bug.rb +6 -10
  94. data/test/functional/test-next.rb +64 -65
  95. data/test/functional/test-raise.rb +63 -64
  96. data/test/functional/test-recursive-bt.rb +81 -76
  97. data/test/functional/test-remap.rb +6 -7
  98. data/test/functional/test-return.rb +44 -38
  99. data/test/functional/test-step.rb +55 -53
  100. data/test/functional/test-stepbug.rb +6 -9
  101. data/test/functional/test-watchg.rb +40 -39
  102. data/test/integration/test-debug.rb +12 -0
  103. data/test/integration/test-debugger-stop.rb +7 -7
  104. data/test/integration/test-pc.rb +24 -0
  105. data/test/integration/test-trace.rb +1 -1
  106. data/test/unit/cmd-helper.rb +0 -1
  107. data/test/unit/test-app-brkpt.rb +21 -21
  108. data/test/unit/test-app-brkptmgr.rb +7 -8
  109. data/test/unit/test-app-display.rb +3 -4
  110. data/test/unit/test-app-frame.rb +4 -5
  111. data/test/unit/test-base-subsubcmd.rb +2 -2
  112. data/test/unit/test-cmd-break.rb +6 -6
  113. data/test/unit/test-cmd-endisable.rb +7 -6
  114. data/test/unit/test-cmd-parse_list_cmd.rb +24 -24
  115. data/test/unit/test-io-tcpserver.rb +39 -35
  116. data/test/unit/test-proc-default.rb +23 -22
  117. data/test/unit/test-proc-eval.rb +1 -2
  118. data/test/unit/test-proc-frame.rb +8 -9
  119. data/test/unit/test-proc-list.rb +1 -1
  120. data/test/unit/test-proc-location.rb +2 -2
  121. data/test/unit/test-proc-main.rb +10 -10
  122. data/test/unit/test-proc-validate.rb +11 -13
  123. data/test/unit/test-subcmd-help.rb +1 -2
  124. data/trepanning.gemspec +8 -13
  125. metadata +44 -95
  126. data/COPYING +0 -57
  127. data/data/custom_require.rb +0 -44
  128. data/data/perldb.bindings +0 -17
  129. data/data/prelude.rb +0 -38
  130. data/processor/command/info_subcmd/variables_subcmd/constant.rb +0 -41
  131. data/processor/command/raise.rb +0 -48
  132. data/processor/command/set_subcmd/pc.rb +0 -62
  133. data/processor/command/set_subcmd/sp.rb +0 -67
  134. data/processor/eventbuf.rb +0 -133
@@ -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}**[**>**] [*module*] [*first* [*num*]]
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 specified location.
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
- `#{NAME} -` shows lines before a previous listing.
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
- end
261
+ end
256
262
  end
@@ -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 'finish' command
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']}
@@ -47,6 +47,7 @@ See also:
47
47
  CATEGORY = 'running'
48
48
  # execution_set = ['Running']
49
49
  MAX_ARGS = 1 # Need at most this many. FIXME: will be eventually 2
50
+ NEED_STACK = true
50
51
  NEED_RUNNING = true
51
52
  SHORT_HELP = 'Step program without entering called functions'
52
53
  end
@@ -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 = ['set', name]
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, 2011 Rocky Bernstein <rockyb@rubyforge.net>
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 'different' to on will cause each 'step' or 'next' command to
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}` you get a stop before ARGV as
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. 'set step nostack' will ignore stack nestings levels on
28
- a given line. Also you can use 'next', but that also stepping into
29
- functions on different lines to also be skipped.
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`' which have suffixes '+' and '-' and which
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
- def run(args)
45
- if args.size == 3 && 'nostack' == args[2]
46
- @proc.settings[:different] = 'nostack'
47
- msg("different is nostack.")
48
- else
49
- super
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
- # Demo it.
58
- require_relative '../../mock'
59
- name = File.basename(__FILE__, '.rb')
58
+ # Demo it.
59
+ require_relative '../../mock'
60
+ name = File.basename(__FILE__, '.rb')
60
61
 
61
- # FIXME: DRY the below code
62
- dbgr, cmd = MockDebugger::setup('set')
63
- subcommand = Trepan::Subcommand::SetDifferent.new(cmd)
64
- testcmdMgr = Trepan::Subcmd.new(subcommand)
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
- subcommand.run_show_bool
67
- subcommand.summary_help(name)
68
- puts
69
- puts '-' * 20
70
- puts subcommand.save_command
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, 2011 Rocky Bernstein <rockyb@rubyforge.net>
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
- Valid event names come from the Trace module and include:
15
- #{Columnize::columnize(Trace.const_get('EVENTS'), 80, ' ' * 4, true, true, ' ' * 2)}
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
- set events call return
22
- set ev call, c_call, return, c_return, c_return, insn
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 Trace.const_get("EVENTS").map{|event| event.to_s}
41
+ completion TRACE_POINT_EVENTS
29
42
 
30
- def save_command
31
- step_events_list = @proc.core.step_events_list
32
- step_events_list = 'brkpt' unless step_events_list
33
- ["#{subcmd_prefix_string} #{step_events_list}"]
34
- end
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
- def run(args)
37
- unless args.size <= 2
38
- events = args[2..-1]
39
- events.each {|event| event.chomp!(',')}
40
- bitmask, bad_events = Trace.events2bitmask(events)
41
- bitmask |= Trace::BRKPT_EVENT_MASK
42
- unless bad_events.empty?
43
- errmsg("Event names unrecognized/ignored: %s" % bad_events.join(', '))
44
- end
45
- @proc.core.step_events = bitmask
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
- # Demo it.
53
- require_relative '../../mock'
54
- name = File.basename(__FILE__, '.rb')
55
-
56
- # FIXME: DRY the below code
57
- dbgr, cmd = MockDebugger::setup('set')
58
- subcommand = Trepan::Subcommand::SetEvents.new(cmd)
59
- testcmdMgr = Trepan::Subcmd.new(subcommand)
60
-
61
- name = File.basename(__FILE__, '.rb')
62
- subcommand.summary_help(name)
63
- puts
64
- subcommand.run([])
65
- [%w(call line foo), %w(insn, c_call, c_return,)].each do |events|
66
- subcommand.run(%w(set events) + events)
67
- puts 'bitmask: %09b, events: %s ' % [dbgr.core.step_events, events.inspect]
68
- end
69
- puts '-' * 20
70
- puts subcommand.save_command()
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
- unless defined?(HELP)
7
- HELP = 'Set max[imum] width NUMBER
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
- 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 run(args)
18
- args.shift
19
- run_set_int(args.join(' '),
20
- "The '#{PREFIX.join(' ')}' command requires a line width",
21
- 0, nil)
22
- end
23
-
24
- alias save_command save_command_from_settings
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