trepanning 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. data/ChangeLog +188 -0
  2. data/Makefile +7 -0
  3. data/NEWS +9 -0
  4. data/README.textile +3 -3
  5. data/Rakefile +3 -3
  6. data/app/breakpoint.rb +1 -1
  7. data/app/brkptmgr.rb +1 -1
  8. data/app/client.rb +15 -4
  9. data/app/core.rb +4 -4
  10. data/app/default.rb +1 -0
  11. data/app/display.rb +1 -1
  12. data/app/frame.rb +38 -19
  13. data/app/options.rb +4 -1
  14. data/app/run.rb +12 -2
  15. data/bin/trepan +2 -1
  16. data/check-filter.rb +18 -0
  17. data/interface/client.rb +1 -1
  18. data/interface/comcodes.rb +9 -8
  19. data/interface/server.rb +38 -2
  20. data/interface/user.rb +2 -2
  21. data/io/input.rb +11 -3
  22. data/io/tcpclient.rb +0 -2
  23. data/io/tcpserver.rb +3 -2
  24. data/lib/trepanning.rb +8 -8
  25. data/processor.rb +4 -4
  26. data/processor/command/backtrace.rb +1 -1
  27. data/processor/command/base/subcmd.rb +4 -1
  28. data/processor/command/break.rb +1 -1
  29. data/processor/command/condition.rb +1 -1
  30. data/processor/command/debug.rb +19 -15
  31. data/processor/command/delete.rb +2 -1
  32. data/processor/command/disassemble.rb +2 -2
  33. data/processor/command/display.rb +1 -1
  34. data/processor/command/down.rb +1 -2
  35. data/processor/command/finish.rb +8 -4
  36. data/processor/command/frame.rb +1 -1
  37. data/processor/command/help.rb +1 -1
  38. data/processor/command/info_subcmd/breakpoints.rb +1 -1
  39. data/processor/command/info_subcmd/registers.rb +1 -1
  40. data/processor/command/info_subcmd/source.rb +1 -1
  41. data/processor/command/info_subcmd/thread.rb +2 -2
  42. data/processor/command/list.rb +1 -1
  43. data/processor/command/set_subcmd/auto_subcmd/eval.rb +10 -6
  44. data/processor/command/set_subcmd/auto_subcmd/irb.rb +2 -2
  45. data/processor/command/set_subcmd/auto_subcmd/list.rb +2 -2
  46. data/processor/command/set_subcmd/substitute_subcmd/eval.rb +1 -1
  47. data/processor/command/show_subcmd/abbrev.rb +2 -2
  48. data/processor/command/undisplay.rb +1 -1
  49. data/processor/command/up.rb +1 -2
  50. data/processor/eval.rb +9 -5
  51. data/processor/frame.rb +1 -1
  52. data/processor/list.rb +1 -1
  53. data/processor/location.rb +3 -2
  54. data/processor/mock.rb +3 -3
  55. data/processor/running.rb +1 -1
  56. data/processor/validate.rb +1 -1
  57. data/test/example/factorial.rb +10 -0
  58. data/test/example/gcd1.rb +1 -1
  59. data/test/functional/fn_helper.rb +1 -1
  60. data/test/functional/test-recursive-bt.rb +103 -0
  61. data/test/functional/test-remap.rb +50 -0
  62. data/test/integration/test-remote.rb +23 -0
  63. data/test/unit/test-app-brkpt.rb +1 -1
  64. data/test/unit/test-app-brkptmgr.rb +2 -2
  65. data/test/unit/test-app-display.rb +1 -1
  66. data/test/unit/test-app-frame.rb +3 -3
  67. data/test/unit/test-app-options.rb +1 -1
  68. data/test/unit/test-cmd-break.rb +2 -2
  69. data/test/unit/test-cmd-endisable.rb +1 -1
  70. data/test/unit/test-cmd-parse_list_cmd.rb +1 -1
  71. data/test/unit/test-cmd-quit.rb +1 -0
  72. data/test/unit/test-cmd-set-auto-eval.rb.try +19 -0
  73. data/test/unit/test-proc-eval.rb +1 -1
  74. data/test/unit/test-proc-frame.rb +2 -2
  75. data/test/unit/test-proc-list.rb +1 -1
  76. data/test/unit/test-proc-location.rb +1 -1
  77. data/test/unit/test-proc-validate.rb +3 -3
  78. data/trepanning.gemspec +5 -5
  79. metadata +101 -104
data/ChangeLog CHANGED
@@ -1,3 +1,191 @@
1
+ 2012-11-25 rocky <rockyb@rubyforge.org>
2
+
3
+ * NEWS, app/options.rb: Get ready for release. 0.1.6
4
+
5
+ 2012-11-25 rocky <rockyb@rubyforge.org>
6
+
7
+ * Rakefile: Gem packaging de jour. Gem packaging stuff keeps moving
8
+ around.
9
+
10
+ 2012-11-25 rocky <rockyb@rubyforge.org>
11
+
12
+ * processor/command/debug.rb, processor/eval.rb: Hacks to make
13
+ recursive debugging on 1.9.3 work. This is really horrible.
14
+
15
+ 2012-11-24 rocky <rockyb@rubyforge.org>
16
+
17
+ * README.textile: Note that this now works on 1.9.3.
18
+
19
+ 2012-11-24 rocky <rockyb@rubyforge.org>
20
+
21
+ * README.textile: Note that this now works on 1.9.3.
22
+
23
+ 2012-11-24 rocky <rockyb@rubyforge.org>
24
+
25
+ Merge branch 'master' of github.com:rocky/rb-trepanning
26
+
27
+ 2012-11-24 rocky <rockyb@rubyforge.org>
28
+
29
+ * lib/trepanning.rb, processor/command/debug.rb,
30
+ processor/command/finish.rb, test/functional/test-recursive-bt.rb,
31
+ trepanning.gemspec: Make this work on 1.9.3! (Really the heavy
32
+ lifting was done in rb-threadframe). Adjust dependent versions
33
+ acceptance.
34
+
35
+ 2012-08-25 rocky <rockyb@rubyforge.org>
36
+
37
+ * NEWS, processor/command/delete.rb, processor/command/down.rb,
38
+ processor/command/up.rb: Remove aliases 'd' and 'u'.
39
+
40
+ 2012-08-25 rocky <rockyb@rubyforge.org>
41
+
42
+ * processor/command/finish.rb: Correct "finish" doc string.
43
+
44
+ 2012-08-05 rocky <rockyb@rubyforge.org>
45
+
46
+ Merge branch 'master' of github.com:rocky/rb-trepanning
47
+
48
+ 2012-08-05 rocky <rockyb@rubyforge.org>
49
+
50
+ * test/functional/test-remap.rb: Skipp remap test until I figure
51
+ what's up.
52
+
53
+ 2012-08-05 rocky <rockyb@rubyforge.org>
54
+
55
+ * processor/command/show_subcmd/abbrev.rb: Doc string typo.
56
+
57
+ 2012-07-02 rocky <rockyb@rubyforge.org>
58
+
59
+ * trepanning.gemspec: Need 0.40 now with ThreadFrame -> Frame
60
+ change.
61
+
62
+ 2012-07-02 rocky <rockyb@rubyforge.org>
63
+
64
+ * ChangeLog, NEWS, app/breakpoint.rb, app/brkptmgr.rb, app/core.rb,
65
+ app/display.rb, app/frame.rb, app/run.rb, lib/trepanning.rb,
66
+ processor/command/backtrace.rb, processor/command/break.rb,
67
+ processor/command/condition.rb, processor/command/debug.rb,
68
+ processor/command/disassemble.rb, processor/command/display.rb,
69
+ processor/command/down.rb, processor/command/frame.rb,
70
+ processor/command/help.rb,
71
+ processor/command/info_subcmd/breakpoints.rb,
72
+ processor/command/info_subcmd/registers.rb,
73
+ processor/command/info_subcmd/thread.rb, processor/command/list.rb,
74
+ processor/command/set_subcmd/substitute_subcmd/eval.rb,
75
+ processor/command/undisplay.rb, processor/command/up.rb,
76
+ processor/eval.rb, processor/frame.rb, processor/list.rb,
77
+ processor/location.rb, processor/mock.rb, processor/validate.rb,
78
+ test/example/gcd1.rb, test/functional/fn_helper.rb,
79
+ test/unit/test-app-brkpt.rb, test/unit/test-app-brkptmgr.rb,
80
+ test/unit/test-app-display.rb, test/unit/test-app-frame.rb,
81
+ test/unit/test-cmd-break.rb, test/unit/test-cmd-endisable.rb,
82
+ test/unit/test-cmd-parse_list_cmd.rb, test/unit/test-proc-eval.rb,
83
+ test/unit/test-proc-frame.rb, test/unit/test-proc-list.rb,
84
+ test/unit/test-proc-location.rb, test/unit/test-proc-validate.rb,
85
+ trepanning.gemspec: RubyVM::ThreadFrame -> RubyVM::Frame
86
+
87
+ 2012-06-29 rocky <rockyb@rubyforge.org>
88
+
89
+ * app/core.rb, app/default.rb, app/options.rb, app/run.rb,
90
+ bin/trepan, processor.rb, processor/location.rb,
91
+ processor/running.rb: Lame attempt at post-mortem
92
+
93
+ 2012-06-29 rocky <rockyb@rubyforge.org>
94
+
95
+ * app/client.rb, interface/comcodes.rb, interface/server.rb: Add a
96
+ sync op. Not sure if it will be useful though
97
+
98
+ 2012-06-27 rocky <rockyb@rubyforge.org>
99
+
100
+ * app/client.rb, io/input.rb: Remove debug output, small indention
101
+ correction; sync with rbx-trepanning
102
+
103
+ 2012-06-25 rocky <rockyb@rubyforge.org>
104
+
105
+ * io/input.rb: Remove stray debugger call. Doesn't anyone check
106
+ these commits?
107
+
108
+ 2012-06-25 rocky <rockyb@rubyforge.org>
109
+
110
+ * app/client.rb: This commented-out code *is* useful. Should turn
111
+ into a debug option. Until then...
112
+
113
+ 2012-06-25 rocky <rockyb@rubyforge.org>
114
+
115
+ * Rakefile, app/client.rb, interface/client.rb, interface/user.rb,
116
+ io/input.rb, io/tcpserver.rb, lib/trepanning.rb,
117
+ test/integration/test-remote.rb, test/unit/test-app-options.rb,
118
+ test/unit/test-cmd-quit.rb: Fix missing prompt/confirm output in
119
+ client mode. Noticed during Bandung 2012 tak.
120
+
121
+ 2012-06-20 rocky <rockyb@rubyforge.org>
122
+
123
+ * Makefile, check-filter.rb, processor/command/base/subcmd.rb,
124
+ processor/command/set_subcmd/auto_subcmd/eval.rb,
125
+ processor/command/set_subcmd/auto_subcmd/irb.rb,
126
+ processor/command/set_subcmd/auto_subcmd/list.rb,
127
+ test/unit/test-cmd-set-auto-eval.rb.try: Makefile, check-filter.rb:
128
+ reduce verbosity of testing output. Makefile: comment targets
129
+ subcmd: document how save_command is supposed to work.
130
+
131
+ 2012-06-19 rocky <rockyb@rubyforge.org>
132
+
133
+ * processor/command/set_subcmd/auto_subcmd/eval.rb,
134
+ processor/command/set_subcmd/auto_subcmd/irb.rb,
135
+ processor/command/set_subcmd/auto_subcmd/list.rb: "set auto *"
136
+ routines were not setting their prefix properly causing "restart" to
137
+ fail.
138
+
139
+ 2012-05-10 rocky <rockyb@rubyforge.org>
140
+
141
+ * io/tcpclient.rb, processor.rb, test/functional/test-remap.rb: * processor.rb: Since location of processor has moved, relative path
142
+ to data has changed too. * test/functional/test-remap.rb: test above
143
+ change * io/tcpclient.rb: remove unused DEFAULT_OPTIONS
144
+
145
+ 2012-03-09 R. Bernstein <rocky.bernstein@gmail.com>
146
+
147
+ Merge pull request #2 from Erkan-Yilmaz/master two small
148
+ language changes
149
+
150
+ 2012-03-09 Erkan Yilmaz <erkan77@gmail.com>
151
+
152
+ * README.textile: small language changes
153
+
154
+ 2011-10-29 rocky <rockyb@rubyforge.org>
155
+
156
+ * app/frame.rb, test/functional/test-recursive-bt.rb: Add "more
157
+ frames follow" on truncated backtraces. Matches what we do in
158
+ rbx-trepanning.
159
+
160
+ 2011-10-28 rocky <rockyb@rubyforge.org>
161
+
162
+ * app/frame.rb, app/options.rb, app/run.rb,
163
+ processor/command/info_subcmd/source.rb, test/example/factorial.rb,
164
+ test/functional/test-recursive-bt.rb: app/frame.rb: Add direct
165
+ recursion in stack frame and give a count of repeated frames. Was
166
+ floor rounding halfway frame point when should have been ceiling
167
+ rounding. source.rb: called ruby_syntax incorrectly. app/options.rb:
168
+ bump version number
169
+
170
+ 2011-10-27 rocky <rockyb@rubyforge.org>
171
+
172
+ * app/options.rb: Get ready 0.1.4 release
173
+
174
+ 2011-10-23 rocky <rockyb@rubyforge.org>
175
+
176
+ Merge branch 'master' of github.com:rocky/rb-trepanning
177
+
178
+ 2011-10-23 rocky <rockyb@rubyforge.org>
179
+
180
+ * processor/command/set_subcmd/substitute_subcmd/eval.rb: Doc
181
+ spelling typo
182
+
183
+ 2011-10-16 rocky <rockyb@rubyforge.org>
184
+
185
+ * ChangeLog, NEWS, processor/command/shell.rb: Update NEWS and
186
+ ChangeLog in preparation for release. shell.rb: adjust help to refer
187
+ to "irb", since #{NAME} is no longer "irb" but "shell".
188
+
1
189
  2011-10-15 rocky <rockyb@rubyforge.org>
2
190
 
3
191
  * processor/command/enable.rb: Another small doc change to enable
data/Makefile CHANGED
@@ -4,8 +4,15 @@
4
4
 
5
5
  all: test
6
6
 
7
+ #: Run all tests without bloated output
8
+ check-short:
9
+ $(MAKE) check 2>&1 | ruby check-filter.rb
10
+
11
+ #: Run all tests (same as "test")
7
12
  check:
8
13
  rake test
14
+
15
+ #: Run all tests (same as "check")
9
16
  test:
10
17
  rake test
11
18
 
data/NEWS CHANGED
@@ -1,3 +1,12 @@
1
+ (0.1.6) Nov 25, 2012
2
+ - Make it work on Ruby 1.9.3 p327
3
+ - Incompatible change: Remove aliases 'd' and 'u' for down and up
4
+ respectively. gdb uses 'u' and 'd' to mean something different.
5
+
6
+ (0.1.5)
7
+ - Fix bug in remote debugging not showing prompt.
8
+ - Internal RubyVM::ThreadFrame -> RubyVM::Frame
9
+
1
10
  Oct 27, 2011 (0.1.4)
2
11
  - Add debugger commands:
3
12
  * info iv (is in ruby-debug)
@@ -1,6 +1,6 @@
1
- A modular, testable debugger for Ruby 1.9.2. A total rewrite of _ruby-debug_.
1
+ A modular, testable debugger for MRI Ruby 1.9.2 or 1.9.3. A total rewrite of _ruby-debug_.
2
2
 
3
- __In order to use this debugger, you'll need a patched Ruby 1.9.2 and some additional packages. See the "installation instructions.":https://github.com/rocky/rb-trepanning/wiki/How-to-Install-rb-trepanning__
3
+ __In order to use this debugger, you'll need a patched MRI Ruby 1.9.2 or 1.9.3 and some additional packages. See the "installation instructions.":https://github.com/rocky/rb-trepanning/wiki/How-to-Install-rb-trepanning__
4
4
 
5
5
  Right now this debugger is beta code.
6
6
 
@@ -39,7 +39,7 @@ bc. $trepan = Trepan.new
39
39
 
40
40
  The global variable $trepan set holds debugger settings, such as "autolist" or "autoeval" settings and breakpoint information.
41
41
 
42
- Due to the line-event orientation in ruby-debug, it occasionally it was convenient to add a synchronous stop in your program. I don't think that will as necessary here, but if you do call to the debugger at the point of the call rather than the subsequent stopping point, set opts[:immediate] to true. Example:
42
+ Due to the line-event orientation in ruby-debug, it occasionally was convenient to add a synchronous stop in your program. I don't think that will be necessary here, but if you do call to the debugger at the point of the call rather than the subsequent stopping point, set opts[:immediate] to true. Example:
43
43
 
44
44
  bc. # ... work, work, work
45
45
  mydbg.debugger(:immediate=>true) # enter debugger here
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ def gemspec
10
10
  @gemspec ||= eval(File.read(Gemspec_filename), binding, Gemspec_filename)
11
11
  end
12
12
 
13
- require 'rake/gempackagetask'
13
+ require 'rubygems/package_task'
14
14
  desc "Build the gem"
15
15
  task :package=>:gem
16
16
  task :gem=>:gemspec do
@@ -86,7 +86,7 @@ Rake::TestTask.new(:'test:integration') do |t|
86
86
  t.options = '--verbose' if $VERBOSE
87
87
  end
88
88
 
89
- desc 'Test everything - unit tests for now.'
89
+ desc 'Test everything - unit, functional, and integration tests.'
90
90
  task :test do
91
91
  exceptions = %w(test:unit test:functional test:integration).collect do |task|
92
92
  begin
@@ -182,7 +182,7 @@ task :gemspec do
182
182
  end
183
183
 
184
184
  # --------- RDoc Documentation ------
185
- require 'rake/rdoctask'
185
+ require 'rdoc/task'
186
186
  desc "Generate rdoc documentation"
187
187
  Rake::RDocTask.new("rdoc") do |rdoc|
188
188
  rdoc.rdoc_dir = 'doc'
@@ -134,7 +134,7 @@ class Trepan
134
134
  end
135
135
 
136
136
  if __FILE__ == $0
137
- tf = RubyVM::ThreadFrame.current
137
+ tf = RubyVM::Frame.current
138
138
  iseq = tf.iseq
139
139
  b1 = Trepan::Breakpoint.new(iseq, 0)
140
140
  p b1
@@ -129,7 +129,7 @@ if __FILE__ == $0
129
129
  puts "--- #{i} ---"
130
130
  end
131
131
 
132
- frame = RubyVM::ThreadFrame.current
132
+ frame = RubyVM::Frame.current
133
133
  iseq = frame.iseq
134
134
  brkpts = Trepan::BreakpointMgr.new
135
135
  brkpts.add(iseq, 0)
@@ -1,20 +1,27 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
+ # Copyright (C) 2011, 2012 Rocky Bernstein <rockyb@rubyforge.net>
3
3
  require_relative 'default' # default debugger settings
4
+ require_relative '../lib/trepanning' # main Trepan object & initialization
4
5
  require_relative '../interface/comcodes' # communication codes
5
6
 
6
7
  module Trepanning
7
8
  include Trepanning::RemoteCommunication
8
9
  def start_client(options)
9
10
  puts "Client option given"
11
+ user_opts = {}
12
+ %w(readline).each do |opt|
13
+ user_opts[opt.to_sym] = options[opt.to_sym]
14
+ end
10
15
  dbgr = Trepan.new(:client => true,
11
16
  :cmdfiles => [],
12
17
  :initial_dir => options[:chdir],
13
18
  :nx => true,
14
19
  :host => options[:host],
15
- :port => options[:port]
20
+ :port => options[:port],
21
+ :user_opts => user_opts
16
22
  )
17
23
  intf = dbgr.intf[-1]
24
+ intf.write_remote(SYNC, 'FIXME: add useful info')
18
25
  while true
19
26
  begin
20
27
  control_code, line = intf.read_remote
@@ -25,6 +32,11 @@ module Trepanning
25
32
  # p [control_code, line]
26
33
  case control_code
27
34
  when PRINT
35
+
36
+ # FIXME: don't know why server sometimes adds a gratuituous space.
37
+ # the space is added somewhere inside TCPSocket.print
38
+ line = line[0..-2] if line.end_with?("\n ")
39
+
28
40
  print line
29
41
  when CONFIRM_TRUE
30
42
  response = intf.confirm(line, true)
@@ -33,8 +45,7 @@ module Trepanning
33
45
  response = intf.confirm(line, true)
34
46
  intf.write_remote(CONFIRM_REPLY, response ? 'Y' : 'N')
35
47
  when PROMPT
36
- # require 'trepanning'
37
- # debugger
48
+ # Printing of prompt has been handled already by PRINT.
38
49
  begin
39
50
  command = intf.read_command(line)
40
51
  rescue EOFError
@@ -146,14 +146,14 @@ class Trepan
146
146
 
147
147
  return_exception = @exception
148
148
  @frame = @event = @arg = @exception = nil
149
-
149
+
150
150
  end
151
151
  return return_exception
152
152
  end
153
153
 
154
154
  # A Ruby 1.8-style event processor. We don't use file, line, id, bind.
155
155
  def old_event_processor(event, file, line, id, bind, klass)
156
- event_processor(event, RubyVM::ThreadFrame.current.prev)
156
+ event_processor(event, RubyVM::Frame.current.prev)
157
157
  end
158
158
 
159
159
  # Call this from inside the program you want to get a synchronous
@@ -163,14 +163,14 @@ class Trepan
163
163
  while @frame && @frame.type == 'IFUNC'
164
164
  @frame = @frame.prev
165
165
  end
166
- frame = RubyVM::ThreadFrame.current.prev(prev_count+1)
166
+ frame = RubyVM::Frame.current.prev(prev_count+1)
167
167
  @step_count = 0 # Make event processor stop
168
168
  event_processor('debugger-call', frame)
169
169
  end
170
170
 
171
171
  # A trace-hook processor for 'trace var'
172
172
  def trace_var_processor(var_name, value)
173
- frame = RubyVM::ThreadFrame.current.prev(2)
173
+ frame = RubyVM::Frame.current.prev(2)
174
174
  if 'CFUNC' == frame.type
175
175
  # Don't need the C call that got us here.
176
176
  prev = frame.prev
@@ -16,6 +16,7 @@ class Trepan
16
16
  # Default values used only when 'server' or 'client'
17
17
  # (out-of-process debugging)
18
18
  :port => 1955,
19
+ :post_mortem => false,
19
20
  :host => 'localhost',
20
21
 
21
22
  :restart_argv => RubyVM::OS_ARGV,
@@ -166,7 +166,7 @@ if __FILE__ == $0
166
166
  end
167
167
 
168
168
  require 'thread_frame'
169
- frame = RubyVM::ThreadFrame::current
169
+ frame = RubyVM::Frame::current
170
170
 
171
171
  x = 1
172
172
  mgr.add(frame, 'x > 1')
@@ -156,13 +156,20 @@ class Trepan
156
156
  return s
157
157
  end
158
158
 
159
+ # Return true if frame1 and frame2 are at the same place.
160
+ # We use this for example in detecting tail recursion.
161
+ def location_equal(frame1, frame2)
162
+ frame1 && frame2 && frame1.source_location == frame2.source_location &&
163
+ frame1.pc_offset == frame2.pc_offset &&
164
+ frame1.source_container == frame2.source_container
165
+ end
166
+
159
167
  def offset_for_return(event)
160
168
  raise RuntimeError unless %w(return c-return).member?(event)
161
169
  # FIXME: C calls have a RubyVM::Env added to the stack.
162
170
  # Where? Why?
163
171
  'return' == event ? 1 : 4
164
172
  end
165
- module_function :offset_for_return
166
173
 
167
174
  def param_names(iseq, start, stop, prefix='')
168
175
  start.upto(stop).map do |i|
@@ -180,10 +187,22 @@ class Trepan
180
187
  end
181
188
 
182
189
  def print_stack_trace_from_to(from, to, frame, opts)
190
+ last_frame = nil
191
+ # TODO: handle indirect recursion.
192
+ direct_recursion_count = 0
183
193
  from.upto(to) do |i|
184
- prefix = (i == opts[:current_pos]) ? '-->' : ' '
185
- prefix += ' #%d ' % [i]
186
- print_stack_entry(frame, i, prefix, opts)
194
+ if location_equal(last_frame, frame)
195
+ direct_recursion_count += 1
196
+ else
197
+ if direct_recursion_count > 0
198
+ msg("... above line repeated #{direct_recursion_count} times")
199
+ direct_recursion_count = 0
200
+ end
201
+ prefix = (i == opts[:current_pos]) ? '-->' : ' '
202
+ prefix += ' #%d ' % [i]
203
+ print_stack_entry(frame, i, prefix, opts)
204
+ end
205
+ last_frame = frame
187
206
  frame = frame.prev
188
207
  end
189
208
  end
@@ -191,7 +210,7 @@ class Trepan
191
210
  # Print `count' frame entries
192
211
  def print_stack_trace(frame, opts={})
193
212
  opts = DEFAULT_STACK_TRACE_SETTINGS.merge(opts)
194
- halfstack = opts[:maxstack] / 2
213
+ halfstack = (opts[:maxstack]+1) / 2
195
214
  n = frame.stack_size
196
215
  n = [n, opts[:count]].min if opts[:count]
197
216
  if n > (halfstack * 2)
@@ -201,6 +220,7 @@ class Trepan
201
220
  else
202
221
  print_stack_trace_from_to(0, n-1, frame, opts)
203
222
  end
223
+ msg "(More stack frames follow...)" if n < frame.stack_size
204
224
  end
205
225
 
206
226
  def set_return_value(frame, event, value)
@@ -212,7 +232,6 @@ class Trepan
212
232
  def value_returned(frame, event)
213
233
  frame.sp(offset_for_return(event))
214
234
  end
215
- module_function :value_returned
216
235
  end
217
236
  end
218
237
 
@@ -223,61 +242,61 @@ if __FILE__ == $0
223
242
  def msg(msg)
224
243
  puts msg
225
244
  end
226
- print_stack_trace(RubyVM::ThreadFrame.current, :basename => true)
245
+ print_stack_trace(RubyVM::Frame.current, :basename => true)
227
246
  def foo
228
247
  puts '=' * 10
229
- print_stack_trace(RubyVM::ThreadFrame.current, :show_pc => true)
248
+ print_stack_trace(RubyVM::Frame.current, :show_pc => true)
230
249
  end
231
250
  foo
232
251
 
233
252
  def bar(a, b, c)
234
253
  puts '=' * 10
235
- print_stack_trace(RubyVM::ThreadFrame.current,
254
+ print_stack_trace(RubyVM::Frame.current,
236
255
  )
237
256
  end
238
257
  bar(1, 2, 3)
239
258
 
240
259
  def baz(a, b, c=5)
241
260
  puts '=' * 10
242
- print_stack_trace(RubyVM::ThreadFrame.current)
261
+ print_stack_trace(RubyVM::Frame.current)
243
262
  end
244
263
  baz(1, 2)
245
264
 
246
265
  def bat(a, b, &block)
247
266
  puts '=' * 10
248
- print_stack_trace(RubyVM::ThreadFrame.current)
267
+ print_stack_trace(RubyVM::Frame.current)
249
268
  end
250
269
  bat(1, 2)
251
270
 
252
271
  def babe(a, b, *rest)
253
272
  puts '=' * 10
254
- print_stack_trace(RubyVM::ThreadFrame.current)
273
+ print_stack_trace(RubyVM::Frame.current)
255
274
  end
256
275
  babe(1, 2)
257
276
 
258
277
  puts '=' * 10
259
- x = lambda { |a,b| print_stack_trace(RubyVM::ThreadFrame::current) }
278
+ x = lambda { |a,b| print_stack_trace(RubyVM::Frame::current) }
260
279
  x.call(1,2)
261
280
  puts '=' * 10
262
281
  x = Proc.new do |a|
263
- print_stack_trace(RubyVM::ThreadFrame::current)
282
+ print_stack_trace(RubyVM::Frame::current)
264
283
  end
265
284
  x.call(1,2)
266
285
  class C # :nodoc
267
286
  def initialize(a)
268
- print_stack_trace(RubyVM::ThreadFrame::current)
287
+ print_stack_trace(RubyVM::Frame::current)
269
288
  end
270
289
  end
271
290
  puts '=' * 30
272
291
  C.new('Hi')
273
292
  puts '=' * 30
274
- eval("print_stack_trace(RubyVM::ThreadFrame.current)")
293
+ eval("print_stack_trace(RubyVM::Frame.current)")
275
294
  puts '=' * 30
276
- eval("eval('print_stack_trace(RubyVM::ThreadFrame.current)')")
295
+ eval("eval('print_stack_trace(RubyVM::Frame.current)')")
277
296
  puts '=' * 30
278
- eval("eval('print_stack_trace(RubyVM::ThreadFrame.current, :maxstack => 2)')")
297
+ eval("eval('print_stack_trace(RubyVM::Frame.current, :maxstack => 2)')")
279
298
  puts '=' * 30
280
299
  1.times do |a; b|
281
- print_stack_trace(RubyVM::ThreadFrame::current)
300
+ print_stack_trace(RubyVM::Frame::current)
282
301
  end
283
302
  end