rbx-trepanning 0.0.8-universal-rubinius-1.2 → 0.1.0-universal-rubinius-1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. data/ChangeLog +762 -238
  2. data/NEWS +44 -0
  3. data/Rakefile +61 -32
  4. data/app/breakpoint.rb +2 -0
  5. data/app/brkptmgr.rb +9 -11
  6. data/app/client.rb +0 -1
  7. data/app/cmd_parse.kpeg +21 -4
  8. data/app/cmd_parse.rb +10 -10
  9. data/app/cmd_parser.rb +1029 -840
  10. data/app/complete.rb +1 -1
  11. data/app/display.rb +38 -0
  12. data/app/file.rb +24 -0
  13. data/app/frame.rb +11 -4
  14. data/app/irb.rb +41 -39
  15. data/app/iseq.rb +71 -0
  16. data/app/options.rb +55 -30
  17. data/app/rbx-llvm.rb +0 -2
  18. data/app/run.rb +13 -9
  19. data/app/util.rb +55 -5
  20. data/bin/trepanx +3 -3
  21. data/data/irbrc +13 -13
  22. data/{interface/base_intf.rb → interface.rb} +5 -1
  23. data/interface/client.rb +4 -0
  24. data/interface/script.rb +13 -5
  25. data/interface/server.rb +5 -1
  26. data/interface/user.rb +8 -1
  27. data/{io/base_io.rb → io.rb} +0 -0
  28. data/io/input.rb +1 -1
  29. data/io/null_output.rb +28 -24
  30. data/io/string_array.rb +2 -3
  31. data/io/tcpclient.rb +1 -1
  32. data/io/tcpserver.rb +1 -1
  33. data/lib/trepanning.rb +11 -13
  34. data/{processor/main.rb → processor.rb} +50 -54
  35. data/processor/breakpoint.rb +150 -137
  36. data/processor/{command/base/cmd.rb → command.rb} +1 -1
  37. data/processor/command/alias.rb +14 -3
  38. data/processor/command/backtrace.rb +2 -1
  39. data/processor/command/base/subcmd.rb +1 -5
  40. data/processor/command/base/submgr.rb +5 -2
  41. data/processor/command/base/subsubcmd.rb +1 -1
  42. data/processor/command/base/subsubmgr.rb +4 -4
  43. data/processor/command/break.rb +1 -1
  44. data/processor/command/complete.rb +2 -1
  45. data/processor/command/condition.rb +2 -2
  46. data/processor/command/continue.rb +4 -4
  47. data/processor/command/delete.rb +34 -20
  48. data/processor/command/directory.rb +4 -4
  49. data/processor/command/disable.rb +71 -0
  50. data/processor/command/disassemble.rb +55 -22
  51. data/processor/command/display.rb +3 -1
  52. data/processor/command/down.rb +8 -8
  53. data/processor/command/edit.rb +74 -0
  54. data/processor/command/enable.rb +43 -0
  55. data/processor/command/eval.rb +37 -15
  56. data/processor/command/exit.rb +25 -6
  57. data/processor/command/finish.rb +5 -5
  58. data/processor/command/frame.rb +2 -2
  59. data/processor/command/help.rb +7 -9
  60. data/processor/command/help/README +10 -0
  61. data/processor/command/help/command.txt +37 -27
  62. data/processor/command/help/examples.txt +16 -0
  63. data/processor/command/help/filename.txt +1 -1
  64. data/processor/command/help/suffixes.txt +17 -0
  65. data/processor/command/info.rb +3 -1
  66. data/processor/command/info_subcmd/files.rb +3 -2
  67. data/processor/command/info_subcmd/frame.rb +2 -1
  68. data/processor/command/info_subcmd/line.rb +17 -28
  69. data/processor/command/info_subcmd/locals.rb +22 -0
  70. data/processor/command/{show_subcmd → info_subcmd}/macro.rb +4 -4
  71. data/processor/command/info_subcmd/program.rb +2 -0
  72. data/processor/command/info_subcmd/ruby.rb +2 -0
  73. data/processor/command/info_subcmd/source.rb +75 -0
  74. data/processor/command/info_subcmd/stack.rb +25 -0
  75. data/processor/command/info_subcmd/variables.rb +23 -36
  76. data/processor/command/info_subcmd/variables_subcmd/.gitignore +2 -0
  77. data/processor/command/info_subcmd/variables_subcmd/class.rb +42 -0
  78. data/processor/command/info_subcmd/variables_subcmd/constant.rb +42 -0
  79. data/processor/command/info_subcmd/variables_subcmd/globals.rb +69 -0
  80. data/processor/command/info_subcmd/variables_subcmd/instance.rb +42 -0
  81. data/processor/command/info_subcmd/variables_subcmd/locals.rb +80 -0
  82. data/processor/command/kill.rb +8 -9
  83. data/processor/command/list.rb +101 -167
  84. data/processor/command/macro.rb +28 -10
  85. data/processor/command/next.rb +2 -1
  86. data/processor/command/nexti.rb +1 -1
  87. data/processor/command/parsetree.rb +51 -0
  88. data/processor/command/pr.rb +1 -2
  89. data/processor/command/ps.rb +1 -1
  90. data/processor/command/restart.rb +2 -2
  91. data/processor/command/save.rb +1 -1
  92. data/processor/command/server.rb +1 -1
  93. data/processor/command/set_subcmd/abbrev.rb +25 -0
  94. data/processor/command/set_subcmd/auto.rb +7 -1
  95. data/processor/command/set_subcmd/auto_subcmd/eval.rb +1 -2
  96. data/processor/command/set_subcmd/auto_subcmd/irb.rb +2 -3
  97. data/processor/command/set_subcmd/auto_subcmd/list.rb +2 -3
  98. data/processor/command/set_subcmd/different.rb +1 -1
  99. data/processor/command/set_subcmd/highlight.rb +7 -1
  100. data/processor/command/set_subcmd/reload.rb +42 -0
  101. data/processor/command/set_subcmd/timer.rb +58 -0
  102. data/processor/command/set_subcmd/trace.rb +4 -3
  103. data/processor/command/{irb.rb → shell.rb} +22 -19
  104. data/processor/command/show_subcmd/abbrev.rb +20 -0
  105. data/processor/command/show_subcmd/{alias.rb → aliases.rb} +2 -2
  106. data/processor/command/show_subcmd/auto_subcmd/eval.rb +2 -6
  107. data/processor/command/show_subcmd/directories.rb +22 -0
  108. data/processor/command/show_subcmd/hidelevel.rb +1 -1
  109. data/processor/command/show_subcmd/highlight.rb +2 -1
  110. data/processor/command/show_subcmd/reload.rb +18 -0
  111. data/processor/command/show_subcmd/timer.rb +18 -0
  112. data/processor/command/source.rb +9 -9
  113. data/processor/command/step.rb +1 -1
  114. data/processor/command/tbreak.rb +3 -2
  115. data/processor/command/unalias.rb +11 -6
  116. data/processor/command/undisplay.rb +13 -9
  117. data/processor/command/up.rb +13 -14
  118. data/processor/default.rb +47 -44
  119. data/processor/disassemble.rb +48 -35
  120. data/processor/display.rb +38 -3
  121. data/processor/eval.rb +54 -53
  122. data/processor/eventbuf.rb +69 -69
  123. data/processor/frame.rb +186 -187
  124. data/processor/help.rb +6 -4
  125. data/processor/hook.rb +103 -102
  126. data/processor/list.rb +123 -0
  127. data/processor/load_cmds.rb +9 -1
  128. data/processor/location.rb +193 -188
  129. data/processor/mock.rb +1 -7
  130. data/processor/msg.rb +56 -42
  131. data/processor/running.rb +26 -15
  132. data/processor/stepping.rb +2 -1
  133. data/processor/subcmd.rb +18 -43
  134. data/processor/validate.rb +41 -30
  135. data/processor/virtual.rb +33 -0
  136. data/rbx-trepanning.gemspec +7 -8
  137. data/sample/rocky-trepanx-colors.rb +0 -1
  138. data/test/data/fname-with-blank.right +2 -0
  139. data/test/data/inline-call.right +11 -10
  140. data/test/data/quit.right +1 -0
  141. data/test/example/debugger-stop.rb +1 -1
  142. data/test/example/goto2goto.rb +11 -0
  143. data/test/functional/fn_helper.rb +2 -2
  144. data/test/functional/test-list.rb +7 -6
  145. data/test/integration/helper.rb +5 -5
  146. data/test/unit/cmd-helper.rb +2 -6
  147. data/test/unit/test-app-cmd_parser.rb +3 -2
  148. data/test/unit/test-app-display.rb +22 -0
  149. data/test/unit/test-app-options.rb +14 -10
  150. data/test/unit/test-app-run.rb +0 -2
  151. data/test/unit/test-app-util.rb +21 -4
  152. data/test/unit/test-base-cmd.rb +5 -7
  153. data/test/unit/test-base-subcmd.rb +1 -5
  154. data/test/unit/test-base-submgr.rb +1 -1
  155. data/test/unit/test-base-subsubcmd.rb +0 -4
  156. data/test/unit/test-bin-trepanx.rb +2 -2
  157. data/test/unit/test-cmd-break.rb +2 -0
  158. data/test/unit/test-cmd-edit.rb +34 -0
  159. data/test/unit/test-cmd-kill.rb +11 -4
  160. data/test/unit/test-cmd-parse_list_cmd.rb +36 -0
  161. data/test/unit/test-command.rb +45 -0
  162. data/test/unit/test-completion.rb +1 -1
  163. data/test/unit/test-proc-eval.rb +1 -2
  164. data/test/unit/test-proc-frame.rb +5 -3
  165. data/test/unit/test-proc-list.rb +55 -0
  166. data/test/unit/test-proc-load_cmds.rb +4 -3
  167. data/test/unit/test-proc-location.rb +32 -29
  168. data/test/unit/test-proc-main.rb +1 -5
  169. data/test/unit/test-proc-validate.rb +14 -4
  170. data/test/unit/test-subcmd-help.rb +1 -5
  171. metadata +73 -107
@@ -0,0 +1,16 @@
1
+ Command examples
2
+
3
+ # This line does nothing. It is a comment. Useful in debugger command files.
4
+ # This line also does nothing.
5
+ s # by default, this is an alias for the "step" command
6
+ !s # shows the value of variable "s".
7
+ !!s # Evaluates "!s" (or "not s"). The first ! is indicates evaluate.
8
+ !s # Same as above, since there is a space in column one.
9
+
10
+ info program;; list # Runs two commands "info program" and "list"
11
+ pr "hi ;;-)" # Syntax error since ;; splits the line and " is not closed.
12
+ !puts "hi ;;-)" # One way to do the above.
13
+
14
+ See also "macro" "alias", "irb", "set auto eval", "set auto irb", "set
15
+ abbrev", "info macro", and "show" variants of the above "set"
16
+ commands.
@@ -1,4 +1,4 @@
1
- syntax for indicating a filename
1
+ Syntax for indicating a filename
2
2
 
3
3
  There are two ways you can give a file name:
4
4
  - unadorned (without double-quotes) with possible escapes
@@ -0,0 +1,17 @@
1
+ Command suffixes which have special meaning
2
+
3
+ Some commands like "step", or "list" do different things when an
4
+ alias to the command ends in a particular suffix like ">".
5
+
6
+ Here are a list of commands and the special suffixes:
7
+
8
+ command suffix
9
+ ------- ------
10
+ list >
11
+ step +,-,<,>
12
+ next +,-,<,>
13
+ quit !
14
+ kill !
15
+ eval ?
16
+
17
+ See help on the commands listed above for the specific meaning of the suffix.
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require 'rubygems'; require 'require_relative'
4
4
  require_relative 'base/submgr'
5
5
 
@@ -24,5 +24,7 @@ end
24
24
 
25
25
  if __FILE__ == $0
26
26
  require_relative '../mock'
27
+ require 'ruby-debug'; Debugger.start; debugger
27
28
  dbgr, cmd = MockDebugger::setup
29
+ cmd.run(['info', 'iv'])
28
30
  end
@@ -53,9 +53,10 @@ EOH
53
53
  include Trepanning
54
54
 
55
55
  def file_list
56
- (LineCache.class_variable_get('@@file_cache').keys +
56
+ (LineCache.cached_files +
57
57
  LineCache.class_variable_get('@@file2file_remap').keys).uniq
58
58
  end
59
+
59
60
  def complete(prefix)
60
61
  completions = ['.'] + file_list
61
62
  Trepan::Complete.complete_token(completions, prefix)
@@ -84,7 +85,7 @@ EOH
84
85
  return false
85
86
  nil
86
87
  else
87
- frame_file = @proc.frame_file
88
+ frame_file = @proc.frame.file
88
89
  LineCache::map_file(frame_file) || File.expand_path(frame_file)
89
90
  end
90
91
  else
@@ -35,6 +35,8 @@ Frame basename
35
35
  See also: backtrace
36
36
  EOH
37
37
  MIN_ABBREV = 'fr'.size # Note we have "info file"
38
+ MIN_ARGS = 0
39
+ MAX_ARGS = 0
38
40
  NEED_STACK = true
39
41
  SHORT_HELP = 'Show information about the selected frame'
40
42
  end
@@ -61,7 +63,6 @@ end
61
63
  if __FILE__ == $0
62
64
  # Demo it.
63
65
  require_relative '../../mock'
64
- dbgr, cmd = MockDebugger::setup('info')
65
66
  cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoFrame, false)
66
67
  cmd.run(cmd.prefix)
67
68
  end
@@ -2,6 +2,8 @@
2
2
  # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require 'rubygems'; require 'require_relative'
4
4
  require_relative '../base/subcmd'
5
+ require_relative '../../../app/iseq'
6
+
5
7
 
6
8
  class Trepan::Subcommand::InfoLine < Trepan::Subcommand
7
9
  unless defined?(HELP)
@@ -21,38 +23,21 @@ Examples:
21
23
  SHORT_HELP = 'Byte code offsets for source code line'
22
24
  end
23
25
 
24
- def ip_ranges_for_line(lines, line)
25
- result = []
26
- in_range = false
27
- start_ip = nil
28
- total = lines.size
29
- i = 1
30
- while i < total
31
- cur_line = lines.at(i)
32
- if cur_line == line
33
- start_ip = lines.at(i-1)
34
- in_range = true
35
- elsif cur_line > line && in_range
36
- result << [start_ip, lines.at(i-1)]
37
- start_ip = nil
38
- in_range = false
39
- end
40
- i += 2
41
- end
42
- if in_range && start_ip
43
- result << [start_ip, lines.at(total-1)]
44
- end
45
- result
46
- end
47
-
26
+ include Trepan::ISeq
27
+
48
28
  def run(args)
49
29
  frame = @proc.frame
50
30
  vm_location = frame.vm_location
51
31
  cm = frame.method
52
32
  filename = cm.file
53
33
  lines = cm.lines
34
+ tail_code = false
54
35
  if args.size == 2
55
36
  line_no = vm_location.line
37
+ if line_no == 0
38
+ tail_code = true
39
+ line_no = frame.line
40
+ end
56
41
  else
57
42
  lineno_str = args[2]
58
43
  opts = {
@@ -64,12 +49,16 @@ Examples:
64
49
  line_no = @proc.get_an_int(lineno_str, opts)
65
50
  return false unless line_no
66
51
  end
67
-
68
- ranges = ip_ranges_for_line(lines, line_no)
52
+ ranges, prefix =
53
+ if tail_code
54
+ [ip_ranges_for_ip(lines, frame.next_ip), 'Tail code preceding line']
55
+ else
56
+ [ip_ranges_for_line(lines, line_no), 'Line']
57
+ end
69
58
  if ranges.empty?
70
- msg "Line %s of %s:\n\tno bytecode offsets" % [line_no, filename]
59
+ msg "%s %s of %s:\n\tno bytecode offsets" % [prefix, line_no, filename]
71
60
  else
72
- msg "Line %s of %s:" % [line_no, filename]
61
+ msg "%s %s of %s:" % [prefix, line_no, filename]
73
62
  ranges.each do |tuple|
74
63
  msg "\t starts at offset %d and ends before offset %d" % tuple
75
64
  end
@@ -0,0 +1,22 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../base/subcmd'
5
+
6
+ class Trepan::Subcommand::InfoLocals < Trepan::Subcommand
7
+ unless defined?(HELP)
8
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
+ HELP = 'Same thing as "info locals"'
10
+ NEED_LOCALS = true
11
+ end
12
+
13
+ def run(args)
14
+ @proc.commands['info'].run(%w(info variables locals))
15
+ end
16
+ end
17
+
18
+ if __FILE__ == $0
19
+ # Demo it.
20
+ require_relative '../../mock'
21
+ # ???
22
+ end
@@ -4,7 +4,7 @@ require 'rubygems'; require 'require_relative'
4
4
  require_relative '../base/subcmd'
5
5
  require_relative '../../../app/complete'
6
6
 
7
- class Trepan::Subcommand::ShowMacro < Trepan::Subcommand
7
+ class Trepan::Subcommand::InfoMacro < Trepan::Subcommand
8
8
  unless defined?(HELP)
9
9
  Trepanning::Subcommand.set_name_prefix(__FILE__, self)
10
10
  HELP = <<-HELP
@@ -19,8 +19,8 @@ In the second form, all macro names and their definitions are show.
19
19
 
20
20
  In the last form the only definitions of the given macro names is shown.
21
21
  HELP
22
- SHORT_HELP = "Show defined macros"
23
- MIN_ABBREV = 'ma'.size
22
+ SHORT_HELP = "Info defined macros"
23
+ MIN_ABBREV = 'mac'.size
24
24
  end
25
25
 
26
26
  def complete(prefix)
@@ -57,6 +57,6 @@ if __FILE__ == $0
57
57
  # Demo it.
58
58
  $0 = __FILE__ + 'notagain' # So we don't run this agin
59
59
  require_relative '../../mock'
60
- cmd = MockDebugger::sub_setup(Trepan::Subcommand::ShowMacro)
60
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoMacro)
61
61
  cmd.run(cmd.prefix + %w(u foo))
62
62
  end
@@ -7,6 +7,8 @@ class Trepan::Subcommand::InfoProgram < Trepan::Subcommand
7
7
  unless defined?(HELP)
8
8
  Trepanning::Subcommand.set_name_prefix(__FILE__, self)
9
9
  HELP = 'Information about debugged program and its environment'
10
+ MIN_ARGS = 0
11
+ MAX_ARGS = 0
10
12
  MIN_ABBREV = 'pr'.size
11
13
  NEED_STACK = true
12
14
  end
@@ -17,6 +17,8 @@ See also constants: RUBY_DESCRIPITON, RUBY_VERSION, and RUBY_RELEASE_DATE."
17
17
  EOH
18
18
  MIN_ABBREV = 'ru'.size
19
19
  NEED_STACK = false
20
+ MIN_ARGS = 0
21
+ MAX_ARGS = 0
20
22
  SHORT_HELP = 'Ruby version information'
21
23
  end
22
24
 
@@ -0,0 +1,75 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require 'linecache'
5
+ require 'columnize'
6
+ require_relative '../base/subcmd'
7
+ require_relative '../../../app/file'
8
+ require_relative '../../../app/complete'
9
+
10
+ class Trepan::Subcommand::InfoSource < Trepan::Subcommand
11
+ unless defined?(HELP)
12
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
13
+ DEFAULT_FILE_ARGS = %w(size mtime sha1)
14
+
15
+ HELP = <<-EOH
16
+ #{CMD}
17
+
18
+ Show information about the current source file.
19
+ EOH
20
+ MAX_ARGS = 0
21
+ MIN_ABBREV = 'so'.size # Note we have "info frame"
22
+ NEED_STACK = true
23
+ end
24
+
25
+ # completion %w(all brkpts iseq sha1 size stat)
26
+
27
+ include Trepanning
28
+
29
+ # Get file information
30
+ def run(args)
31
+ if not @proc.frame
32
+ errmsg('No frame - no default file.')
33
+ return false
34
+ end
35
+ frame_file = @proc.frame.file
36
+ filename = LineCache::map_file(frame_file) || File.expand_path(frame_file)
37
+ canonic_name = @proc.canonic_file(filename)
38
+ canonic_name = LineCache::map_file(canonic_name) || canonic_name
39
+ m = filename
40
+ if LineCache::cached?(canonic_name)
41
+ m += ' is cached in debugger'
42
+ if canonic_name != filename
43
+ m += (' as:\n ' + canonic_name)
44
+ end
45
+ m += '.'
46
+ msg(m)
47
+ end
48
+ max_line = LineCache::size(canonic_name)
49
+ msg 'File has %d lines.' % max_line if max_line
50
+ msg('SHA1 is %s.' % LineCache::sha1(canonic_name))
51
+ msg('Possible breakpoint line numbers:')
52
+ lines = LineCache.trace_line_numbers(canonic_name)
53
+ fmt_lines = columnize_numbers(lines)
54
+ msg(fmt_lines)
55
+ if cm = LineCache.compiled_method(canonic_name)
56
+ msg("File has compiled method: #{cm}")
57
+ else
58
+ msg('Compiled method not recorded; there may be some, though.')
59
+ end
60
+ msg("Stat info:\n\t%s" % LineCache::stat(canonic_name).inspect)
61
+ end
62
+ end
63
+
64
+ if __FILE__ == $0
65
+ if !(ARGV.size == 1 && ARGV[0] == 'noload')
66
+ ISEQS__ = {}
67
+ SCRIPT_ISEQS__ = {}
68
+ ARGV[0..-1] = ['noload']
69
+ load(__FILE__)
70
+ else
71
+ require_relative '../../mock'
72
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoSource, false)
73
+ cmd.run(cmd.prefix)
74
+ end
75
+ end
@@ -0,0 +1,25 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../base/subcmd'
5
+
6
+
7
+ class Trepan::Subcommand::InfoStack < Trepan::Subcommand
8
+ unless defined?(HELP)
9
+ Trepanning::Subcommand.set_name_prefix(__FILE__, self)
10
+ HELP = 'Same thing as "backtrace"'
11
+ MIN_ABBREV = 'st'.size
12
+ NEED_STACK = true
13
+ end
14
+
15
+ def run(args)
16
+ @proc.commands['backtrace'].run(['backtrace'] + args[2..-1])
17
+ end
18
+ end
19
+
20
+ if __FILE__ == $0
21
+ # Demo it.
22
+ require_relative '../../mock'
23
+ cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoStack, false)
24
+ cmd.run(cmd.prefix)
25
+ end
@@ -1,48 +1,35 @@
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 '../base/subcmd'
4
+ require_relative '../base/subsubcmd'
5
+ require_relative '../base/subsubmgr'
5
6
 
6
- class Trepan::Command::InfoVariables < Trepan::Subcommand
7
- Trepanning::Subcommand.set_name_prefix(__FILE__, self)
8
- MIN_ABBREV = 'var'.size
9
- NEED_STACK = true
10
- SHORT_HELP = 'Display the value of a variable or variables'
11
- HELP = <<-HELP
12
- Show debugger variables and user created variables. By default,
13
- shows all variables.
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]
14
12
 
15
- The optional argument is which variable specifically to show the value of.
16
- HELP
17
-
18
- def run(args)
19
- if args.size == 2
20
- @proc.dbgr.variables.each do |name, val|
21
- msg "var '#{name}' = #{val.inspect}"
22
- end
23
-
24
- if @proc.dbgr.user_variables > 0
25
- section "User variables"
26
- (0...@proc.dbgr.user_variables).each do |i|
27
- str = "$d#{i}"
28
- val = Rubinius::Globals[str.to_sym]
29
- msg "var #{str} = #{val.inspect}"
30
- end
31
- end
32
- else
33
- var = args[2]
34
- if @proc.dbgr.variables.key?(var)
35
- msg "var '#{var}' = #{variables[var].inspect}"
36
- else
37
- errmsg "No variable set named '#{var}'"
38
- end
39
- end
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'
40
21
  end
41
22
  end
42
23
 
43
24
  if __FILE__ == $0
44
25
  # Demo it.
45
26
  require_relative '../../mock'
46
- cmd = MockDebugger::sub_setup(Trepan::Subcommand::InfoVariables, false)
47
- # cmd.run(cmd.prefix)
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
48
35
  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::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 = '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_variables.sort') || []
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