trepanning 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. data/ChangeLog +465 -0
  2. data/NEWS +26 -1
  3. data/README.textile +1 -1
  4. data/app/cmd_parse.kpeg +2 -1
  5. data/app/cmd_parser.rb +30 -3
  6. data/app/core.rb +1 -1
  7. data/app/display.rb +39 -1
  8. data/app/frame.rb +1 -1
  9. data/app/irb.rb +42 -40
  10. data/app/options.rb +3 -2
  11. data/app/run.rb +21 -7
  12. data/app/util.rb +12 -2
  13. data/app/yarv.rb +0 -2
  14. data/bin/trepan +2 -3
  15. data/data/perldb.bindings +17 -0
  16. data/interface/script.rb +1 -1
  17. data/interface/server.rb +1 -1
  18. data/interface/user.rb +3 -1
  19. data/{interface/base_intf.rb → interface.rb} +1 -1
  20. data/io/input.rb +1 -3
  21. data/io/null_output.rb +1 -1
  22. data/io/string_array.rb +1 -2
  23. data/io/tcpclient.rb +1 -1
  24. data/io/tcpserver.rb +1 -1
  25. data/{io/base_io.rb → io.rb} +0 -0
  26. data/lib/trepanning.rb +2 -1
  27. data/processor/command/alias.rb +15 -4
  28. data/processor/command/backtrace.rb +2 -2
  29. data/processor/command/base/subcmd.rb +1 -5
  30. data/processor/command/base/submgr.rb +1 -1
  31. data/processor/command/base/subsubcmd.rb +1 -1
  32. data/processor/command/base/subsubmgr.rb +4 -4
  33. data/processor/command/break.rb +1 -1
  34. data/processor/command/complete.rb +1 -1
  35. data/processor/command/condition.rb +2 -2
  36. data/processor/command/continue.rb +1 -1
  37. data/processor/command/debug.rb +1 -1
  38. data/processor/command/delete.rb +10 -7
  39. data/processor/command/directory.rb +1 -1
  40. data/processor/command/disable.rb +25 -19
  41. data/processor/command/disassemble.rb +1 -1
  42. data/processor/command/display.rb +35 -28
  43. data/processor/command/down.rb +8 -8
  44. data/processor/command/edit.rb +1 -1
  45. data/processor/command/enable.rb +10 -12
  46. data/processor/command/eval.rb +1 -1
  47. data/processor/command/exit.rb +1 -1
  48. data/processor/command/finish.rb +1 -1
  49. data/processor/command/frame.rb +2 -2
  50. data/processor/command/help.rb +6 -8
  51. data/processor/command/info.rb +2 -0
  52. data/processor/command/info_subcmd/files.rb +17 -11
  53. data/processor/command/info_subcmd/frame.rb +0 -1
  54. data/processor/command/info_subcmd/locals.rb +6 -73
  55. data/processor/command/info_subcmd/source.rb +10 -4
  56. data/processor/command/info_subcmd/variables.rb +34 -0
  57. data/processor/command/info_subcmd/variables_subcmd/.gitignore +1 -0
  58. data/processor/command/info_subcmd/variables_subcmd/class.rb +40 -0
  59. data/processor/command/info_subcmd/variables_subcmd/constant.rb +41 -0
  60. data/processor/command/info_subcmd/{globals.rb → variables_subcmd/globals.rb} +21 -16
  61. data/processor/command/info_subcmd/variables_subcmd/instance.rb +41 -0
  62. data/processor/command/info_subcmd/variables_subcmd/locals.rb +99 -0
  63. data/processor/command/kill.rb +9 -8
  64. data/processor/command/list.rb +9 -107
  65. data/processor/command/macro.rb +27 -9
  66. data/processor/command/next.rb +1 -1
  67. data/processor/command/nocache.rb +2 -2
  68. data/processor/command/parsetree.rb +1 -1
  69. data/processor/command/pp.rb +1 -1
  70. data/processor/command/pr.rb +1 -1
  71. data/processor/command/ps.rb +1 -1
  72. data/processor/command/quit.rb +18 -7
  73. data/processor/command/raise.rb +1 -1
  74. data/processor/command/reload.rb +10 -10
  75. data/processor/command/restart.rb +1 -1
  76. data/processor/command/save.rb +1 -1
  77. data/processor/command/server.rb +1 -1
  78. data/processor/command/set_subcmd/auto.rb +7 -1
  79. data/processor/command/set_subcmd/different.rb +5 -4
  80. data/processor/command/set_subcmd/substitute_subcmd/eval.rb +2 -2
  81. data/processor/command/set_subcmd/trace.rb +5 -4
  82. data/processor/command/set_subcmd/trace_subcmd/print.rb +4 -3
  83. data/processor/command/shell.rb +5 -3
  84. data/processor/command/show_subcmd/{alias.rb → aliases.rb} +2 -2
  85. data/processor/command/show_subcmd/auto_subcmd/eval.rb +2 -7
  86. data/processor/command/show_subcmd/trace_subcmd/print.rb +3 -3
  87. data/processor/command/show_subcmd/version.rb +24 -0
  88. data/processor/command/source.rb +1 -1
  89. data/processor/command/step.rb +1 -1
  90. data/processor/command/tbreak.rb +1 -1
  91. data/processor/command/unalias.rb +11 -6
  92. data/processor/command/undisplay.rb +14 -10
  93. data/processor/command/up.rb +12 -13
  94. data/processor/command/watchg.rb +1 -1
  95. data/processor/{command/base/cmd.rb → command.rb} +3 -2
  96. data/processor/display.rb +34 -0
  97. data/processor/frame.rb +2 -2
  98. data/processor/help.rb +6 -4
  99. data/processor/hook.rb +95 -96
  100. data/processor/list.rb +146 -0
  101. data/processor/location.rb +26 -0
  102. data/processor/mock.rb +4 -7
  103. data/processor/msg.rb +54 -42
  104. data/processor/running.rb +6 -3
  105. data/processor/subcmd.rb +16 -41
  106. data/processor/validate.rb +6 -9
  107. data/{processor/main.rb → processor.rb} +11 -40
  108. data/sample/rocky-trepan-colors.rb +0 -1
  109. data/test/data/enable.cmd +1 -1
  110. data/test/data/trace.cmd +6 -0
  111. data/test/data/trace.right +39 -0
  112. data/test/example/gcd.rb +0 -1
  113. data/test/functional/test-next.rb +1 -1
  114. data/test/integration/helper.rb +4 -0
  115. data/test/integration/test-trace.rb +18 -0
  116. data/test/unit/cmd-helper.rb +4 -4
  117. data/test/unit/test-app-cmd_parse.rb +1 -1
  118. data/test/unit/test-app-display.rb +22 -0
  119. data/test/unit/test-app-options.rb +14 -10
  120. data/test/unit/test-app-run.rb +7 -1
  121. data/test/unit/test-base-subcmd.rb +1 -1
  122. data/test/unit/test-cmd-kill.rb +11 -4
  123. data/test/unit/test-cmd-parse_list_cmd.rb +1 -1
  124. data/test/unit/{test-base-cmd.rb → test-command.rb} +1 -1
  125. data/test/unit/test-proc-eval.rb +1 -2
  126. data/test/unit/test-proc-frame.rb +1 -2
  127. data/test/unit/test-proc-list.rb +52 -0
  128. data/test/unit/test-proc-load_cmds.rb +1 -1
  129. data/test/unit/test-proc-location.rb +11 -4
  130. data/test/unit/test-proc-main.rb +1 -1
  131. data/test/unit/test-proc-validate.rb +1 -2
  132. data/test/unit/test-subcmd-help.rb +1 -1
  133. data/trepanning.gemspec +1 -1
  134. metadata +26 -12
@@ -1,11 +1,10 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
- require 'columnize'
4
- require_relative '../base/subcmd'
5
- require_relative '../../../app/frame'
3
+ require_relative 'locals'
6
4
 
7
- class Trepan::Subcommand::InfoGlobals < Trepan::Subcommand
8
- unless defined?(HELP)
5
+ class Trepan::Subcommand::InfoVariablesGlobals <
6
+ Trepan::Subcommand::InfoVariablesLocals
7
+ Trepan::Util.suppress_warnings {
9
8
  Trepanning::Subcommand.set_name_prefix(__FILE__, self)
10
9
  HELP = <<-EOH
11
10
  #{CMD}
@@ -18,14 +17,18 @@ EOH
18
17
  SHORT_HELP = 'Show global variables'
19
18
  MIN_ARGS = 0
20
19
  MAX_ARGS = 1
21
- MIN_ABBREV = 'gl'.size
22
20
  NEED_STACK = true
21
+ }
22
+
23
+ def get_names
24
+ global_variables
23
25
  end
24
26
 
25
27
  def run(args)
26
- if args.size == 3
28
+ if args.size == 2
27
29
  if 0 == 'names'.index(args[-1].downcase)
28
- if global_variables.empty?
30
+ names = get_names()
31
+ if names.empty?
29
32
  msg "No global variables defined."
30
33
  else
31
34
  section "Global variable names:"
@@ -36,16 +39,17 @@ EOH
36
39
  msg mess
37
40
  end
38
41
  else
39
- errmsg("unrecognized argument #{args[2]}")
42
+ errmsg("unrecognized argument: #{args[-1]}")
40
43
  end
41
- elsif args.size == 2
42
- if global_variables.empty?
44
+ elsif args.size == 1
45
+ names = get_names
46
+ if names.empty?
43
47
  msg "No global variables defined."
44
48
  else
45
49
  section "Global variables:"
46
- global_variables.sort.each do |var_name|
47
- s = @proc.debug_eval(var_name)
48
- msg("#{var_name} = #{s.inspect}")
50
+ names.sort.each do |var_name|
51
+ s = @proc.debug_eval(var_name.to_s)
52
+ msg("#{var_name} = #{s.inspect}", :code=>true)
49
53
  end
50
54
  end
51
55
  else
@@ -56,8 +60,9 @@ end
56
60
 
57
61
  if __FILE__ == $0
58
62
  # Demo it.
59
- require_relative '../../mock'
60
- cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoGlobals, false)
63
+ require_relative '../../../mock'
64
+ cmd = MockDebugger::subsub_setup(Trepan::Subcommand::InfoVariablesGlobals,
65
+ false)
61
66
  cmd.run(cmd.prefix)
62
67
  cmd.run(cmd.prefix + ['name'])
63
68
  end
@@ -0,0 +1,41 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require_relative 'locals'
4
+
5
+ class Trepan::Subcommand::InfoVariablesInstance <
6
+ Trepan::Subcommand::InfoVariablesLocals
7
+ Trepan::Util.suppress_warnings {
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = <<-EOH
10
+ #{CMD}
11
+ #{CMD} [names]
12
+
13
+ Show instance variables of the current stack frame.
14
+ Normally for each which show both the name and value. If you just
15
+ want a list of names add parameter 'names'.
16
+ EOH
17
+ SHORT_HELP = 'Show instance variables of the current stack frame'
18
+ MIN_ARGS = 0
19
+ MAX_ARGS = 1
20
+ MIN_ABBREV = 'iv'.size
21
+ NEED_STACK = true
22
+ }
23
+
24
+ def get_names
25
+ @proc.debug_eval('self.instance_variables')
26
+ end
27
+
28
+ def run(args)
29
+ run_for_type(args, 'instance', @proc.debug_eval('self'))
30
+ end
31
+ end
32
+
33
+ if __FILE__ == $0
34
+ # Demo it.
35
+ require_relative '../../mock'
36
+ cmd =
37
+ MockDebugger::subsub_setup(Trepan::Subcommand::InfoVariables,
38
+ Trepan::Subcommand::InfoVariablesInstance)
39
+ cmd.run(cmd.prefix)
40
+ cmd.run(cmd.prefix + ['name'])
41
+ end
@@ -0,0 +1,99 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'columnize'
4
+ require_relative '../../base/subsubcmd'
5
+ require_relative '../../../../app/frame'
6
+ require_relative '../../../../app/util'
7
+
8
+ class Trepan::Subcommand::InfoVariablesLocals < Trepan::SubSubcommand
9
+ Trepan::Util.suppress_warnings {
10
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
11
+ HELP = <<-EOH
12
+ #{CMD}
13
+ #{CMD} [names]
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
+ }
25
+
26
+ def complete(prefix)
27
+ ['name']
28
+ end
29
+
30
+ def get_names
31
+ iseq = @proc.frame.iseq
32
+ 0.upto(iseq.local_size-2).map do
33
+ |i|
34
+ iseq.local_name(i)
35
+ end
36
+ end
37
+
38
+ def run_for_type(args, type, klass=nil)
39
+ suffix = klass ? " for #{klass.to_s}" : '' rescue ''
40
+ if args.size == 2
41
+ if 0 == 'names'.index(args[-1].downcase)
42
+ if 'CFUNC' == @proc.frame.type
43
+ errmsg("info #{type} names not supported for C frames")
44
+ else
45
+ if names.empty?
46
+ msg "No #{type} variables defined."
47
+ else
48
+ section "#{type.capitalize} variable names#{suffix}:"
49
+ width = settings[:maxwidth]
50
+ mess = Columnize::columnize(names,
51
+ @proc.settings[:maxwidth], ' ',
52
+ false, true, ' ' * 2).chomp
53
+ msg mess
54
+ end
55
+ end
56
+ else
57
+ errmsg("unrecognized argument: #{args[-1]}")
58
+ end
59
+ elsif args.size == 1
60
+ if 'CFUNC' == @proc.frame.type
61
+ argc = @proc.frame.argc
62
+ if argc > 0
63
+ 1.upto(argc).each do |i|
64
+ msg "#{i}: #{@proc.frame.sp(argc-i+3).inspect}"
65
+ end
66
+ else
67
+ msg("No parameters in C call; showing other C locals is not supported.")
68
+ end
69
+ else
70
+ if names.empty?
71
+ msg "No #{type} variables defined#{suffix}."
72
+ else
73
+ section "#{type.capitalize} variables#{suffix}:"
74
+ names.each do |var_name|
75
+ var_value =
76
+ @proc.safe_rep(@proc.debug_eval_no_errmsg(var_name).inspect)
77
+ msg("#{var_name} = #{var_value}", :code => true)
78
+ end
79
+ end
80
+ end
81
+ else
82
+ errmsg("Wrong number of arguments #{args.size}")
83
+ end
84
+ end
85
+ def run(args)
86
+ run_for_type(args, 'local', @proc.debug_eval('self'))
87
+ end
88
+ end
89
+
90
+ if __FILE__ == $0
91
+ # Demo it.
92
+ require_relative '../../../mock'
93
+ require_relative '../variables'
94
+ cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::InfoVariables,
95
+ Trepan::SubSubcommand::InfoVariablesLocals
96
+ )
97
+ cmd.run([])
98
+ cmd.run(['name'])
99
+ end
@@ -1,5 +1,5 @@
1
1
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
- require_relative 'base/cmd'
2
+ require_relative '../command'
3
3
  require_relative '../../app/complete'
4
4
  class Trepan::Command::KillCommand < Trepan::Command
5
5
 
@@ -25,7 +25,7 @@ Examples:
25
25
  #{NAME} kill # same as above
26
26
  #{NAME} -9 # same as above
27
27
  #{NAME} 9 # same as above
28
- #{NAME}! 9 # same as above
28
+ #{NAME}! 9 # above, but unconditional
29
29
  HELP
30
30
 
31
31
  ALIASES = %w(kill!)
@@ -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
@@ -1,8 +1,8 @@
1
1
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
2
  # -*- coding: utf-8 -*-
3
3
  require 'linecache'
4
- require_relative 'base/cmd'
5
- require_relative '../../app/cmd_parse'
4
+ require_relative '../command'
5
+ require_relative '../list'
6
6
 
7
7
  class Trepan::Command::ListCommand < Trepan::Command
8
8
  unless defined?(HELP)
@@ -41,8 +41,9 @@ A LOCATION is a either
41
41
  If the location form is used with a subsequent parameter, the
42
42
  parameter is the starting line number. When there two numbers are
43
43
  given, the last number value is treated as a stopping line unless it
44
- is less than the start line, in which case it is taken to mean the
45
- number of lines to list instead.
44
+ is positive and less than the start line. In this case, it is taken to
45
+ mean the number of lines to list instead. If last is negative, we start
46
+ that many lines back from first and list to first.
46
47
 
47
48
  Wherever a number is expected, it does not need to be a constant --
48
49
  just something that evaluates to a positive integer.
@@ -58,6 +59,7 @@ Some examples:
58
59
  #{NAME} foo.rb 5 6 # list lines 5 and 6 of foo.rb
59
60
  #{NAME} foo.rb 5 2 # Same as above, since 2 < 5.
60
61
  #{NAME} foo.rb:5 2 # Same as above
62
+ #{NAME} foo.rb 15 -5 # List lines 10..15 of foo
61
63
  #{NAME} FileUtils.cp # List lines around the FileUtils.cp function.
62
64
  #{NAME} . # List lines centered from where we currently are stopped
63
65
  #{NAME} . 3 # List 3 lines starting from where we currently are stopped
@@ -81,110 +83,12 @@ enabled, while at line 255 there is an breakpoint 2 which is
81
83
  disabled.
82
84
  HELP
83
85
 
84
- ALIASES = %W(l #{NAME}> l>)
86
+ ALIASES = %W(l #{NAME}> l> cat)
85
87
  CATEGORY = 'files'
86
88
  MAX_ARGS = 3
87
89
  SHORT_HELP = 'List source code'
88
90
  end
89
91
 
90
- include Trepan::CmdParser
91
-
92
- # If last is less than first, assume last is a count rather than an
93
- # end line number.
94
- def adjust_last(first, last)
95
- last < first ? first + last - 1 : last
96
- end
97
-
98
- def frame_filename
99
- frame = @proc.frame
100
-
101
- container = @proc.frame_container(frame, false)
102
-
103
- # FIXME: put into a helper routine
104
- # See also duplicate code in print_location
105
- if container[0] != 'file'
106
- try_container = container
107
- while try_container[0] != 'file' && frame.prev do
108
- frame = frame.prev
109
- try_container = @proc.frame_container(frame, false)
110
- end
111
- container = try_container if try_container[0] == 'file'
112
- end
113
-
114
- return container[1]
115
- end
116
-
117
-
118
- # What a f*cking mess. Necessitated I suppose because we want to
119
- # allow somewhat flexible parsing with either module names, files or none
120
- # and optional line counts or end-line numbers.
121
-
122
- # Parses arguments for the "list" command and returns the tuple:
123
- # filename, start, last
124
- # or sets these to nil if there was some problem.
125
- def parse_list_cmd(arg_str, listsize, center_correction)
126
-
127
- iseq = nil
128
- if arg_str.empty?
129
- filename = frame_filename
130
- first = [1, @proc.frame_line - center_correction].max
131
- else
132
- list_cmd_parse = parse_list(arg_str,
133
- :file_exists_proc => @proc.file_exists_proc)
134
- last = list_cmd_parse.num
135
- position = list_cmd_parse.position
136
-
137
- if position.is_a?(String)
138
- if position == '-'
139
- return no_frame_msg unless @proc.line_no
140
- first = [1, @proc.line_no - 2*listsize - 1].max
141
- elsif position == '.'
142
- return no_frame_msg unless @proc.line_no
143
- if (second = list_cmd_parse.num)
144
- first = @proc.frame_line
145
- last = adjust_last(first, second)
146
- else
147
- first = [1, @proc.frame_line - center_correction].max
148
- last = first + listsize - 1
149
- end
150
- end
151
- filename = frame_filename
152
- else
153
- meth, filename, offset, offset_type = @proc.parse_position(position)
154
- iseq = meth.iseq if meth
155
- return unless filename
156
- if offset_type == :line
157
- first = offset
158
- elsif meth
159
- iseq, first, vm_offset =
160
- @proc.position_to_line_and_offset(meth.iseq, filename,
161
- position, offset_type)
162
- return [nil] * 3 unless first
163
- elsif !offset
164
- # Have just a filename. Go with line 1
165
- first = 1
166
- else
167
- errmsg "Dunno what to do here"
168
- return [nil] * 3
169
- end
170
- end
171
- end
172
-
173
- if last
174
- last = adjust_last(first, last)
175
- else
176
- first = [1, first - center_correction].max
177
- last = first + listsize - 1 unless last
178
- end
179
- LineCache::cache(filename) unless LineCache::cached?(filename)
180
- return iseq, filename, first, last
181
- end
182
-
183
- def no_frame_msg
184
- errmsg("No Ruby program loaded.")
185
- return nil, nil, nil
186
- end
187
-
188
92
  def run(args)
189
93
  if args.empty? and not frame
190
94
  errmsg("No Ruby program loaded.")
@@ -199,7 +103,7 @@ disabled.
199
103
  end
200
104
 
201
105
  iseq, filename, first, last =
202
- parse_list_cmd(@proc.cmd_argstr, listsize, center_correction)
106
+ @proc.parse_list_cmd(@proc.cmd_argstr, listsize, center_correction)
203
107
  return unless filename
204
108
  container = iseq ? iseq.source_container : ['file', filename]
205
109
  breaklist = @proc.brkpts.line_breaks(container)
@@ -258,8 +162,6 @@ end
258
162
 
259
163
  if __FILE__ == $0
260
164
  if !(ARGV.size == 1 && ARGV[0] == 'noload')
261
- ISEQS__ = {}
262
- SCRIPT_ISEQS__ = {}
263
165
  ARGV[0..-1] = ['noload']
264
166
  load(__FILE__)
265
167
  else
@@ -339,6 +241,6 @@ if __FILE__ == $0
339
241
  run_cmd2(cmd, [cmd.name, line.to_s])
340
242
  run_cmd2(cmd, %W(#{cmd.name} run_cmd2))
341
243
  run_cmd2(cmd, %W(#{cmd.name} run_cmd2))
342
- run_cmd2(cmd, %W(#{cmd.name} @713))
244
+ run_cmd2(cmd, %W(#{cmd.name} @0))
343
245
  end
344
246
  end
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
- require_relative 'base/cmd'
3
+ require_relative '../command'
4
4
  require_relative '../eval'
5
5
  class Trepan::Command::MacroCommand < Trepan::Command
6
6
 
@@ -10,25 +10,43 @@ class Trepan::Command::MacroCommand < Trepan::Command
10
10
  #{NAME} MACRO-NAME PROC-OBJECT
11
11
 
12
12
  Define MACRO-NAME as a debugger macro. Debugger macros get a list of
13
- arguments.
13
+ arguments. Debugger macros get a list of arguments which you supply
14
+ without parenthesis or commas. See below for an example.
14
15
 
15
- The macro should return either a String or an Array of Strings which
16
- is substituted for the command. If the return is a String, that gets
17
- tokenized by a simple String#split . Note that macro processing is
18
- done right after splitting on ;; so if the macro returns a string
19
- containing ;; this will not be handled on the string returned.
16
+ The macro (really a Ruby Proc) should return either a String or an
17
+ Array of Strings. The string in both cases are strings of debugger
18
+ commands. If the return is a String, that gets tokenized by a simple
19
+ String#split . Note that macro processing is done right after
20
+ splitting on ;; so if the macro returns a string containing ;; this
21
+ will not be handled on the string returned.
20
22
 
21
23
  If instead, Array of Strings is returned, then the first string is
22
- unshifted from the array and executed. The remaning strings are pushed
24
+ shifted from the array and executed. The remaining strings are pushed
23
25
  onto the command queue. In contrast to the first string, subsequent
24
26
  strings can contain other macros, and ;; in those strings will be
25
27
  split into separate commands.
26
28
 
27
- Here is an example. The below creates a macro called finish+ which
29
+ Here is an example. The below creates a macro called fin+ which
28
30
  issues two commands 'finish' followed by 'step':
29
31
 
30
32
  macro fin+ Proc.new{|*args| %w(finish step)}
31
33
 
34
+ If you wanted to parameterize the argument of the 'finish' command
35
+ you could do that this way:
36
+
37
+ macro fin+ Proc.new{|*args| ['finish \#{args[0]}' 'step']}
38
+
39
+ Invoking with
40
+ fin+ 3
41
+
42
+ would expand to ["finish 3", "step"]
43
+
44
+ If you were to add another parameter for 'step', the note that the
45
+ invocation might be
46
+ fin+ 3 2
47
+
48
+ rather than 'fin+(3,2)' or 'fin+ 3, 2'.
49
+
32
50
  Here is another example using arguments. I use the following to debug
33
51
  a debugger command:
34
52
 
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
- require_relative 'base/cmd'
3
+ require_relative '../command'
4
4
 
5
5
  class Trepan::Command::NextCommand < Trepan::Command
6
6
 
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
- require_relative 'base/cmd'
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require_relative '../command'
4
4
  class Trepan::Command::NoCacheCommand < Trepan::Command
5
5
 
6
6
  unless defined?(HELP)
@@ -3,7 +3,7 @@
3
3
  begin
4
4
  require 'rubygems'
5
5
  require 'parse_tree'
6
- require_relative 'base/cmd'
6
+ require_relative '../command'
7
7
  require_relative '../../app/cmd_parse'
8
8
  class Trepan::Command::ParseTreeCommand < Trepan::Command
9
9
 
@@ -2,7 +2,7 @@
2
2
  # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require 'rubygems'
4
4
  require 'pp'
5
- require_relative 'base/cmd'
5
+ require_relative '../command'
6
6
  class Trepan::Command::PPCommand < Trepan::Command
7
7
 
8
8
  unless defined?(HELP)
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
- require_relative 'base/cmd'
3
+ require_relative '../command'
4
4
  class Trepan::Command::PrCommand < Trepan::Command
5
5
 
6
6
  unless defined?(HELP)
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
3
- require_relative 'base/cmd'
3
+ require_relative '../command'
4
4
  require_relative '../eval'
5
5
  class Trepan::Command::PsCommand < Trepan::Command
6
6
 
@@ -1,5 +1,5 @@
1
- # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
2
- require_relative 'base/cmd'
1
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
+ require_relative '../command'
3
3
  class Trepan::Command::QuitCommand < Trepan::Command
4
4
 
5
5
  unless defined?(HELP)
@@ -16,7 +16,7 @@ to the OS. If no exit code is given, 0 is used.
16
16
 
17
17
  Examples:
18
18
  #{NAME} # quit prompting if we are interactive
19
- #{NAME} conditionally # quit without prompting
19
+ #{NAME} unconditionally # quit without prompting
20
20
  #{NAME}! # same as above
21
21
  #{NAME} 0 # same as "quit"
22
22
  #{NAME}! 1 # unconditional quit setting exit code 1
@@ -36,7 +36,7 @@ See also the commands "exit" and "kill".
36
36
  # This method runs the command
37
37
  def run(args)
38
38
  unconditional =
39
- if args.size > 1 && args[1] == 'unconditionally'
39
+ if args.size > 1 && args[-1] == 'unconditionally'
40
40
  args.shift
41
41
  true
42
42
  elsif args[0][-1] == '!'
@@ -48,8 +48,17 @@ See also the commands "exit" and "kill".
48
48
  msg('Quit not confirmed.')
49
49
  return
50
50
  end
51
-
52
- exitrc = (args.size > 1) ? exitrc = Integer(args[1]) rescue 0 : 0
51
+
52
+ if (args.size > 1)
53
+ if args[1] =~ /\d+/
54
+ exitrc = args[1].to_i;
55
+ else
56
+ errmsg "Bad an Integer return type \"#{args[1]}\"";
57
+ return;
58
+ end
59
+ else
60
+ exitrc = 0
61
+ end
53
62
  # No graceful way to stop threads...
54
63
  @proc.finalize
55
64
  @proc.dbgr.intf[-1].finalize
@@ -60,6 +69,8 @@ end
60
69
  if __FILE__ == $0
61
70
  require_relative '../mock'
62
71
  dbgr, cmd = MockDebugger::setup
63
- fork { cmd.run([cmd.name]) }
72
+ Process.fork { cmd.run([cmd.name]) } if
73
+ Process.respond_to?(:fork)
74
+ cmd.run([cmd.name, 'foo'])
64
75
  cmd.run([cmd.name, '5'])
65
76
  end
@@ -1,5 +1,5 @@
1
1
  # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
2
- require_relative 'base/cmd'
2
+ require_relative '../command'
3
3
  class Trepan::Command::RaiseCommand < Trepan::Command
4
4
 
5
5
  unless defined?(HELP)
@@ -1,18 +1,18 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require_relative 'base/submgr'
4
+ require_relative '../../app/util'
4
5
 
5
6
  class Trepan::Command::ReloadCommand < Trepan::SubcommandMgr
6
- # Silence already initialized constant .. warnings
7
- old_verbose = $VERBOSE
8
- $VERBOSE = nil
9
- NAME = File.basename(__FILE__, '.rb')
10
- ALIASES = %w(rel)
11
- HELP = 'Reload information'
12
- CATEGORY = 'data'
13
- NEED_STACK = false
14
- SHORT_HELP = 'Reload information'
15
- $VERBOSE = old_verbose
7
+ Trepan::Util.suppress_warnings {
8
+ NAME = File.basename(__FILE__, '.rb')
9
+ ALIASES = %w(rel)
10
+ HELP = 'Reload information'
11
+ CATEGORY = 'data'
12
+ NEED_STACK = false
13
+ SHORT_HELP = 'Reload information'
14
+ }
15
+
16
16
  def initialize(proc)
17
17
  super
18
18
  end
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
- require_relative 'base/cmd'
3
+ require_relative '../command'
4
4
  require_relative '../../app/run'
5
5
  class Trepan::Command::RestartCommand < Trepan::Command
6
6
 
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
- require_relative 'base/cmd'
3
+ require_relative '../command'
4
4
  class Trepan::Command::SaveCommand < Trepan::Command
5
5
 
6
6
  unless defined?(HELP)
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require 'optparse'
4
- require_relative 'base/cmd'
4
+ require_relative '../command'
5
5
  require_relative '../../app/default'
6
6
  require_relative '../../interface/server' # server interface (remote debugging)
7
7
  class Trepan::Command::ServerCommand < Trepan::Command