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
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require 'rubygems'; require 'require_relative'
4
- require_relative 'base/cmd'
4
+ require_relative '../command'
5
5
 
6
6
  class Trepan::Command::DisplayCommand < Trepan::Command
7
7
 
@@ -23,6 +23,8 @@ case or not.
23
23
  With no argument, evaluate and display all currently requested
24
24
  auto-display expressions. Use "undisplay" to cancel display
25
25
  requests previously made.
26
+
27
+ See also "undisplay", "enable", and "disable".
26
28
  HELP
27
29
 
28
30
  CATEGORY = 'data'
@@ -7,10 +7,10 @@ require_relative 'up'
7
7
  # direction (set by DIRECTION) reversed.
8
8
  class Trepan::Command::DownCommand < Trepan::Command::UpCommand
9
9
 
10
- # Silence already initialized constant .. warnings
11
- old_verbose = $VERBOSE
12
- $VERBOSE = nil
13
- HELP = <<-HELP
10
+ Trepan::Util.suppress_warnings {
11
+ old_verbose = $VERBOSE
12
+ $VERBOSE = nil
13
+ HELP = <<-HELP
14
14
  #{NAME} [count]
15
15
 
16
16
  Move the current frame down in the stack trace (to a newer frame). 0
@@ -19,10 +19,10 @@ is the most recent frame. If no count is given, move down 1.
19
19
  See also 'up' and 'frame'.
20
20
  HELP
21
21
 
22
- ALIASES = %w(d)
23
- NAME = File.basename(__FILE__, '.rb')
24
- SHORT_HELP = 'Move frame in the direction of the caller of the last-selected frame'
25
- $VERBOSE = old_verbose
22
+ ALIASES = %w(d)
23
+ NAME = File.basename(__FILE__, '.rb')
24
+ SHORT_HELP = 'Move frame in the direction of the caller of the last-selected frame'
25
+ }
26
26
 
27
27
  def initialize(proc)
28
28
  super
@@ -0,0 +1,74 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative '../command'
5
+
6
+ class Trepan::Command::EditCommand < Trepan::Command
7
+
8
+ old_verbose = $VERBOSE
9
+ $VERBOSE = nil
10
+ NAME = File.basename(__FILE__, '.rb')
11
+ HELP = <<-HELP
12
+ #{NAME} [[FILE] [LINE]]
13
+
14
+ With no argument, edits file containing most recent line listed.
15
+ The value of the environment variable EDITOR is used for the
16
+ editor to run. If no EDITOR environment variable is set /bin/ex
17
+ is used. The editor should support line and file positioning via
18
+ editor-name +line file-name
19
+ (Most editors do.)
20
+
21
+ Examples:
22
+ #{NAME} # Edit current location
23
+ #{NAME} 7 # Edit current file at line 7
24
+ #{NAME} test.rb # Edit test.rb, line 1
25
+ #{NAME} test.rb 10 # Edit test.rb line 10
26
+ HELP
27
+
28
+ ALIASES = %w(e)
29
+ CATEGORY = 'files'
30
+ NEED_STACK = false
31
+ SHORT_HELP = 'Invoke an editor on some source code'
32
+ MAX_ARGS = 2
33
+ $VERBOSE = old_verbose
34
+
35
+ # FIXME: redo with locations and kparse.
36
+ def run(args)
37
+ case args.size
38
+ when 1
39
+ file = @proc.frame.file
40
+ line = @proc.frame.line
41
+ when 2
42
+ line = Integer(args[1]) rescue nil
43
+ if line
44
+ file = @proc.frame.file
45
+ else
46
+ file = args[1]
47
+ line = 1
48
+ end
49
+ when 3
50
+ line, file = args[2], args[1]
51
+ else
52
+ errmsg "edit needs at most 2 args."
53
+ end
54
+ editor = ENV['EDITOR'] || '/bin/ex'
55
+ if File.readable?(file)
56
+ file = File.basename(file) if settings[:basename]
57
+ edit_cmd = "#{editor} +#{line} \"#{file}\""
58
+ msg "Running #{edit_cmd}..."
59
+ system(edit_cmd)
60
+ msg "Warning: return code was #{$?.exitstatus}" if $?.exitstatus != 0
61
+ else
62
+ errmsg "File \"#{file}\" is not readable."
63
+ end
64
+ end
65
+ end
66
+
67
+ if __FILE__ == $0
68
+ require_relative '../mock'
69
+ dbgr, cmd = MockDebugger::setup
70
+ ENV['EDITOR'] = 'echo FAKE-EDITOR'
71
+ cmd.run [cmd.name]
72
+ cmd.run [cmd.name, '7']
73
+ cmd.run [cmd.name, __FILE__, '10']
74
+ end
@@ -0,0 +1,43 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+ require 'rubygems'; require 'require_relative'
4
+ require_relative 'disable'
5
+
6
+ # enable breakpoint command. Is like disable but the parameter
7
+ # to @proc.en_disable_breakpoint_by_number is different (set as
8
+ # ENABLE_PARM below).
9
+ class Trepan::Command::EnableCommand < Trepan::Command::DisableCommand
10
+
11
+ Trepan::Util.suppress_warnings {
12
+ NAME = File.basename(__FILE__, '.rb')
13
+ HELP = <<-HELP
14
+ #{NAME} [display] NUM1 [NUM2 ...]
15
+
16
+ Enables breakpoints or display NUM1. Breakpoints numbers are given as
17
+ a space-separated list numbers.
18
+
19
+ See also "disable" and "info break".
20
+ HELP
21
+
22
+ ALIASES = %w(en)
23
+ SHORT_HELP = 'Enable some breakpoints'
24
+ }
25
+
26
+ def initialize(proc)
27
+ super
28
+ @enable_parm = true # true if enable
29
+ end
30
+
31
+ end
32
+
33
+ if __FILE__ == $0
34
+ require_relative '../mock'
35
+ dbgr, cmd = MockDebugger::setup
36
+ cmd.run([cmd.name])
37
+ cmd.run([cmd.name, '1'])
38
+ cmdproc = cmd.proc
39
+ cmds = cmdproc.commands
40
+ break_cmd = cmds['break']
41
+ break_cmd.run(['break', cmdproc.frame.source_location[0].to_s])
42
+ cmd.run([cmd.name, '1'])
43
+ end
@@ -1,7 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require 'rubygems'; require 'require_relative'
4
- require_relative './base/cmd'
4
+ require_relative '../command'
5
+ require_relative '../../app/util'
5
6
 
6
7
  class Trepan::Command::EvalCommand < Trepan::Command
7
8
 
@@ -17,10 +18,22 @@ The value of the expression is stored into a global variable so it
17
18
  may be used again easily. The name of the global variable is printed
18
19
  next to the inspect output of the value.
19
20
 
20
- If no string is given we run the string from the current source code
21
+ If no string is given, we run the string from the current source code
21
22
  about to be run. If the command ends ? (via an alias) and no string is
22
- given we will also strip off any leading 'if', 'while', 'elseif',
23
- 'return', 'case', 'unless', or 'until' in the string.
23
+ given we will the following translations occur:
24
+
25
+ {if|elsif|unless} expr [then] => expr
26
+ {until|while} expr [do] => expr
27
+ return expr => expr
28
+ case expr => expr
29
+ def fn(params) => [params]
30
+ var = expr => expr
31
+
32
+ The above is done via regular expression. No fancy parsing is done, say,
33
+ to look to see if expr is split across a line or whether var an assigment
34
+ might have multiple variables on the left-hand side.
35
+
36
+ Examples:
24
37
 
25
38
  #{NAME} 1+2 # 3
26
39
  #{NAME} @v
@@ -38,21 +51,24 @@ See 'set buffer trace' for showing what may have already been run.
38
51
  SHORT_HELP = 'Run code in the current context'
39
52
  $VERBOSE = old_verbose
40
53
 
54
+ def complete(prefix)
55
+ if prefix.empty?
56
+ if @proc.leading_str.start_with?('eval?')
57
+ Trepan::Util.extract_expression @proc.current_source_text
58
+ else
59
+ @proc.current_source_text
60
+ end
61
+ else
62
+ prefix
63
+ end
64
+ end
65
+
41
66
  def run(args)
42
67
  if args.size == 1
43
68
  text = @proc.current_source_text
69
+ ## FIXME turn into a subroutine and use in complete.
44
70
  if '?' == args[0][-1..-1]
45
- if text =~ /^\s*(?:if|elsif|unless)\s+/
46
- text.gsub!(/^\s*(?:if|elsif|unless)\s+/,'')
47
- text.gsub!(/\s+then\s*$/, '')
48
- elsif text =~ /^\s*(?:until|while)\s+/
49
- text.gsub!(/^\s*(?:until|while)\s+/,'')
50
- text.gsub!(/\s+do\s*$/, '')
51
- elsif text =~ /^\s*return\s+/
52
- text.gsub!(/^\s*return\s+/,'')
53
- elsif text =~ /^\s*case\s+/
54
- text.gsub!(/^\s*case\s*/,'')
55
- end
71
+ text = Trepan::Util::extract_expression(text)
56
72
  msg "eval: #{text}"
57
73
  end
58
74
  else
@@ -68,4 +84,10 @@ if __FILE__ == $0
68
84
  arg_str = '1 + 2'
69
85
  cmd.proc.instance_variable_set('@cmd_argstr', arg_str)
70
86
  puts "eval #{arg_str} is: #{cmd.run([cmd.name, arg_str])}"
87
+ arg_str = 'return "foo"'
88
+ # def cmd.proc.current_source_text
89
+ # 'return "foo"'
90
+ # end
91
+ # cmd.proc.instance_variable_set('@cmd_argstr', arg_str)
92
+ # puts "eval? #{arg_str} is: #{cmd.run([cmd.name + '?'])}"
71
93
  end
@@ -1,13 +1,13 @@
1
- # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
1
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
2
  require 'rubygems'; require 'require_relative'
3
- require_relative 'base/cmd'
3
+ require_relative '../command'
4
4
  class Trepan::Command::ExitCommand < Trepan::Command
5
5
 
6
6
  unless defined?(HELP)
7
7
  NAME = File.basename(__FILE__, '.rb')
8
8
  ALIASES = %w(quit q q! quit! exit!)
9
9
  HELP = <<-HELP
10
- #{NAME} [exitcode] - hard exit of the debugged program.
10
+ #{NAME} [exitcode] [unconditionally] - hard exit of the debugged program.
11
11
 
12
12
  The program being debugged is exited via exit!() which does not run
13
13
  the Kernel at_exit finalizers. If a return code is given, that is the
@@ -18,6 +18,13 @@ If you are in interactive mode, and confirm is not set off, you are
18
18
  prompted to confirm quitting. However if you do not want to be
19
19
  prompted, add ! the end. (vim/vi/ed users can use alias q!).
20
20
 
21
+ Examples:
22
+ #{NAME} # quit prompting if we are interactive
23
+ #{NAME} unconditionally # quit without prompting
24
+ #{NAME}! # same as above
25
+ #{NAME} 0 # same as "quit"
26
+ #{NAME}! 1 # unconditional quit setting exit code 1
27
+
21
28
  See also "kill" and "set confirm".'
22
29
  HELP
23
30
 
@@ -32,7 +39,7 @@ See also "kill" and "set confirm".'
32
39
  # This method runs the command
33
40
  def run(args) # :nodoc
34
41
  unconditional =
35
- if args.size > 1 && args[1] == 'unconditionally'
42
+ if args.size > 1 && args[-1] == 'unconditionally'
36
43
  args.shift
37
44
  true
38
45
  elsif args[0][-1..-1] == '!'
@@ -44,7 +51,17 @@ See also "kill" and "set confirm".'
44
51
  msg('Quit not confirmed.')
45
52
  return
46
53
  end
47
- exitrc = (args.size > 1) ? exitrc = Integer(args[1]) rescue 0 : 0
54
+
55
+ if (args.size > 1)
56
+ if args[1] =~ /\d+/
57
+ exitrc = args[1].to_i;
58
+ else
59
+ errmsg "Bad an Integer return type \"#{args[1]}\"";
60
+ return;
61
+ end
62
+ else
63
+ exitrc = 0
64
+ end
48
65
 
49
66
  # FIXME: Is this the best/most general way?
50
67
  @proc.finalize
@@ -59,6 +76,8 @@ end
59
76
  if __FILE__ == $0
60
77
  require_relative '../mock'
61
78
  dbgr, cmd = MockDebugger::setup
62
- fork { cmd.run([cmd.name]) }
79
+ Process.fork { cmd.run([cmd.name]) } if
80
+ Process.respond_to?(:fork)
81
+ cmd.run([cmd.name, 'foo'])
63
82
  cmd.run([cmd.name, '10'])
64
83
  end
@@ -1,11 +1,13 @@
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
- require_relative 'base/cmd'
4
+ require_relative '../command'
5
5
 
6
6
  class Trepan::Command::FinishCommand < Trepan::Command
7
7
 
8
8
  unless defined?(HELP)
9
+ ALIASES = %w(fin finish+ fin+)
10
+ CATEGORY = 'running'
9
11
  NAME = File.basename(__FILE__, '.rb')
10
12
  HELP = <<-HELP
11
13
  #{NAME}
@@ -28,9 +30,7 @@ Examples:
28
30
  See also commands:
29
31
  'continue', 'break', 'next', 'nexti', 'step' for other ways to continue.
30
32
  HELP
31
- ALIASES = %w(fin finish+ fin+)
32
- CATEGORY = 'running'
33
- # execution_set = ['Running']
33
+ NEED_RUNNING = true
34
34
  MAX_ARGS = 1 # Need at most this many.
35
35
  NEED_STACK = true
36
36
  SHORT_HELP = 'Step to end of current method (step out)'
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'; require 'require_relative'
2
- require_relative './base/cmd'
2
+ require_relative '../command'
3
3
 
4
4
  class Trepan::Command::FrameCommand < Trepan::Command
5
5
  CATEGORY = 'stack'
@@ -59,7 +59,7 @@ See also 'up', 'down', and 'backtrace'.
59
59
  # ## @proc.find_and_set_debugged_frame(frame, thread_id)
60
60
  end
61
61
 
62
- stack_size = @proc.dbgr.vm_locations.size
62
+ stack_size = @proc.frame.stack_size
63
63
  if stack_size == 0
64
64
  errmsg('No frames recorded.')
65
65
  return false
@@ -1,6 +1,6 @@
1
1
  # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
2
  require 'rubygems'; require 'require_relative'
3
- require_relative 'base/cmd'
3
+ require_relative '../command'
4
4
  require_relative '../../app/complete'
5
5
  class Trepan::Command::HelpCommand < Trepan::Command
6
6
  unless defined?(HELP)
@@ -21,8 +21,6 @@ Some commands like 'info', 'set', and 'show' can accept an
21
21
  additional subcommand to give help just about that particular
22
22
  subcommand. For example 'help info line' give help about the
23
23
  info line command.
24
-
25
- See also 'examine' and 'whatis'.
26
24
  HELP
27
25
 
28
26
  ALIASES = %w(?)
@@ -76,10 +74,10 @@ Type "help" followed by a class name for a list of help items in that class.
76
74
  Type "help aliases" for a list of current aliases.
77
75
  Type "help macros" for a list of current macros.
78
76
  Type "help *" for the list of all commands, macros and aliases.
79
- Type "help all" for the list of all commands.
77
+ Type "help all" for a brief description of all commands.
80
78
  Type "help REGEXP" for the list of commands matching /^#{REGEXP}/.
81
79
  Type "help CLASS *" for the list of all commands in class CLASS.
82
- Type "help" followed by command name for full documentation.
80
+ Type "help" followed by a command name for full documentation.
83
81
  '
84
82
  msg(final_msg)
85
83
  end
@@ -102,6 +100,7 @@ Type "help" followed by command name for full documentation.
102
100
  elsif cmd_name =~ /^all$/i
103
101
  CATEGORIES.sort.each do |category|
104
102
  show_category(category[0], [])
103
+ msg('')
105
104
  end
106
105
  elsif CATEGORIES.member?(cmd_name)
107
106
  show_category(args[1], args[2..-1])
@@ -155,12 +154,11 @@ Type "help" followed by command name for full documentation.
155
154
  category == @proc.commands[cmd_name].category
156
155
  end.sort
157
156
  width = settings[:maxwidth]
158
- return columnize_commands(cmds)
157
+ msg columnize_commands(cmds)
158
+ return
159
159
  end
160
160
 
161
- msg('')
162
161
  section "Command class: %s" % category
163
- msg('')
164
162
  @proc.commands.keys.sort.each do |name|
165
163
  next if category != @proc.commands[name].category
166
164
  msg("%-13s -- %s" % [name, @proc.commands[name].short_help])
@@ -188,7 +186,7 @@ Type "help" followed by command name for full documentation.
188
186
  @syntax_help ||= {}
189
187
  @syntax_help[name] =
190
188
  File.open(File.join(HELP_DIR, "#{name}.txt")).readlines[2..-1].join
191
- section "Debugger syntax for a #{name}:"
189
+ section "Help for #{name}:"
192
190
  msg @syntax_help[name]
193
191
  else
194
192
  errmsg "No syntax help for #{name}"
@@ -0,0 +1,10 @@
1
+ Files in this directory are help for "help syntax".
2
+
3
+ A list of sub-names is obtained by Dir.glob('*.txt') in this
4
+ directory.
5
+
6
+ Each file name without the trailing ".txt' is the name of the help
7
+ subcategory under "help syntax".
8
+
9
+ The first line in the file is a summary shown in help summary.
10
+ Lines 3 on are shown as help text.
@@ -1,11 +1,11 @@
1
- overall debugger command syntax
1
+ Overall Debugger Command Syntax
2
2
 
3
- Command tokenization syntax is very simple-minded.
3
+ If the first non-blank character of a line starts with #,
4
+ the command is ignored.
4
5
 
5
- If a line starts with #, the command is ignored.
6
- If a line starts with !, the line is eval'd.
6
+ If a line starts with ! in column one, the line is eval'd.
7
7
 
8
- If the command you want eval'd uses the Ruby ! initially, add that
8
+ If the command you want Ruby to eval uses ! initially, add that
9
9
  after the first ! or start the line with a space.
10
10
 
11
11
  Commands are split at whereever ;; appears. This process disregards
@@ -18,31 +18,41 @@ Some commands like 'eval', 'macro', and 'break' have access to the
18
18
  untokenized string entered and make use of that rather than the
19
19
  tokenized list.
20
20
 
21
- The leading token is first looked up in the macro table. If it is in
22
- the table, the expansion is replaces the current command and possibly
23
- other commands pushed onto a command queue. Next, the leading token is
24
- looked up in the debugger alias table and the name may be substituted
25
- there. Finally, the leading token is looked up in the debugger alias
26
- table. If a match is found, the command name and arguments are
27
- dispatched to the command object that process the command.
21
+ Resolving a command name involves possibly 4 steps. Some steps may be
22
+ omitted depending on early success or some debugger settings:
28
23
 
29
- If the command is not found and "auto eval" is set on, then the
30
- command is eval'd in the context that the program is currently stopped
31
- at. If "auto eval" is not set on, then we display an error message
32
- that the entered string is "undefined".
24
+ 1. The leading token is first looked up in the macro table. If it is in
25
+ the table, the expansion is replaces the current command and possibly
26
+ other commands pushed onto a command queue. See the "help macros" for
27
+ help on how to define macros, and "info macro" for current macro
28
+ definitions.
29
+
30
+ 2. The leading token is next looked up in the debugger alias table and
31
+ the name may be substituted there. See "help alias" for how to define
32
+ aliases, and "show alias" for the current list of aliases.
33
+
34
+ 3. After the above, The leading token is looked up a table of debugger
35
+ commands. If an exact match is found, the command name and arguments
36
+ are dispatched to that command. Otherwise, we may check to see the the
37
+ token is a unique prefix of a valid command. For example, "dis" is not
38
+ a unique prefix because there are both "display" and "disable"
39
+ commands, but "disp" is a unique prefix. You can allow or disallow
40
+ abbreviations for commands using "set abbrev". The default is
41
+ abbreviations are on.
42
+
43
+ 4. If after all of the above, we still don't find a command, the line
44
+ may be evaluated as a Ruby statement in the current context of the
45
+ program at the point it is stoppped. However this is done only if
46
+ "autoeval" is on. (It is on by default.)
47
+
48
+ If "auto eval" is not set on, or if running the Ruby statement
49
+ produces an error, we display an error message that the entered string
50
+ is "undefined".
33
51
 
34
52
  If you want irb-like command-processing, it's possible to go into an
35
53
  irb shell with the "irb" command. It is also possible to arrange going
36
54
  into an irb shell every time you enter the debugger.
37
55
 
38
- Examples:
39
-
40
- # This line does nothing. It is a comment
41
- s # by default, this is an alias for the "step" command
42
- !s # shows the value of variable step.
43
- !!s # Evaluates !s (or "not s"). The first ! is indicates evaluate.
44
- info program;; list # Runs two commands "info program" and "list"
45
- pr "hi ;;-)" # Syntax error since ;; splits the line and " is not closed.
46
- !puts "hi ;;-)" # One way to do the above.
47
-
48
- See also "alias", "irb", "set auto eval", and "set auto irb".
56
+ See also:
57
+ "help syntax examples"
58
+ "help syntax suffix"