rbx-trepanning 0.0.6-universal-rubinius-1.2 → 0.0.7-universal-rubinius-1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. data/.gitignore +5 -0
  2. data/ChangeLog +161 -0
  3. data/Makefile +13 -0
  4. data/NEWS +11 -0
  5. data/Rakefile +6 -5
  6. data/app/.gitignore +2 -0
  7. data/app/breakpoint.rb +53 -36
  8. data/app/brkptmgr.rb +10 -0
  9. data/app/complete.rb +29 -2
  10. data/app/condition.rb +22 -0
  11. data/app/default.rb +1 -0
  12. data/app/eventbuffer.rb +147 -0
  13. data/app/frame.rb +3 -1
  14. data/app/options.rb +2 -2
  15. data/app/run.rb +5 -3
  16. data/bin/.gitignore +2 -0
  17. data/data/.gitignore +2 -0
  18. data/doc/.gitignore +1 -0
  19. data/doc/debugger.html +108 -0
  20. data/interface/.gitignore +2 -0
  21. data/interface/user.rb +8 -7
  22. data/io/.gitignore +3 -0
  23. data/io/input.rb +14 -8
  24. data/lib/.gitignore +2 -0
  25. data/lib/trepanning.rb +25 -33
  26. data/processor/.gitignore +3 -0
  27. data/processor/Makefile +7 -0
  28. data/processor/breakpoint.rb +4 -0
  29. data/processor/command/.gitignore +2 -0
  30. data/processor/command/backtrace.rb +5 -0
  31. data/processor/command/base/.gitignore +2 -0
  32. data/processor/command/base/subcmd.rb +2 -1
  33. data/processor/command/base/subsubcmd.rb +23 -1
  34. data/processor/command/base/subsubmgr.rb +2 -1
  35. data/processor/command/complete.rb +2 -1
  36. data/processor/command/condition.rb +62 -0
  37. data/processor/command/down.rb +4 -4
  38. data/processor/command/eval.rb +14 -6
  39. data/processor/command/exit.rb +8 -7
  40. data/processor/command/frame.rb +6 -2
  41. data/processor/command/info_subcmd/.gitignore +3 -0
  42. data/processor/command/info_subcmd/breakpoints.rb +8 -0
  43. data/processor/command/info_subcmd/files.rb +1 -1
  44. data/processor/command/info_subcmd/line.rb +1 -1
  45. data/processor/command/info_subcmd/ruby.rb +1 -1
  46. data/processor/command/kill.rb +21 -10
  47. data/processor/command/macro.rb +15 -23
  48. data/processor/command/set_subcmd/.gitignore +2 -0
  49. data/processor/command/set_subcmd/auto_subcmd/.gitignore +2 -0
  50. data/processor/command/set_subcmd/debug_subcmd/.gitignore +2 -0
  51. data/processor/command/set_subcmd/different.rb +2 -0
  52. data/processor/command/set_subcmd/max_subcmd/.gitignore +2 -0
  53. data/processor/command/set_subcmd/substitute_subcmd/.gitignore +3 -0
  54. data/processor/command/set_subcmd/trace_subcmd/.gitignore +2 -0
  55. data/processor/command/set_subcmd/trace_subcmd/buffer.rb +42 -0
  56. data/processor/command/set_subcmd/trace_subcmd/print.rb +13 -29
  57. data/processor/command/show_subcmd/.gitignore +3 -0
  58. data/processor/command/show_subcmd/alias.rb +7 -3
  59. data/processor/command/show_subcmd/auto_subcmd/.gitignore +3 -0
  60. data/processor/command/show_subcmd/auto_subcmd/irb.rb +1 -1
  61. data/processor/command/show_subcmd/debug_subcmd/.gitignore +3 -0
  62. data/processor/command/show_subcmd/macro.rb +62 -0
  63. data/processor/command/show_subcmd/max_subcmd/.gitignore +2 -0
  64. data/processor/command/show_subcmd/trace_subcmd/.gitignore +2 -0
  65. data/processor/command/show_subcmd/trace_subcmd/buffer.rb +64 -0
  66. data/processor/command/show_subcmd/trace_subcmd/print.rb +5 -20
  67. data/processor/command/source.rb +7 -0
  68. data/processor/command/up.rb +12 -8
  69. data/processor/eventbuf.rb +101 -0
  70. data/processor/frame.rb +19 -1
  71. data/processor/hook.rb +2 -2
  72. data/processor/load_cmds.rb +57 -49
  73. data/processor/location.rb +40 -0
  74. data/processor/main.rb +27 -26
  75. data/processor/msg.rb +17 -0
  76. data/processor/stepping.rb +21 -1
  77. data/processor/validate.rb +1 -0
  78. data/rbx-trepanning.gemspec +40 -0
  79. data/sample/.gitignore +2 -0
  80. data/test/data/.gitignore +1 -0
  81. data/test/example/.gitignore +2 -0
  82. data/test/functional/.gitignore +3 -0
  83. data/test/functional/test-finish.rb +2 -2
  84. data/test/integration/.gitignore +3 -0
  85. data/test/unit/.gitignore +3 -0
  86. data/test/unit/cmd-helper.rb +6 -2
  87. data/test/unit/test-app-brkpt.rb +14 -12
  88. data/test/unit/test-app-complete.rb +39 -0
  89. data/test/unit/test-app-condition.rb +18 -0
  90. data/test/unit/test-app-options.rb +8 -1
  91. data/test/unit/test-base-subsubcmd.rb +21 -0
  92. data/test/unit/test-cmd-finish.rb +4 -0
  93. data/test/unit/test-completion.rb +11 -6
  94. data/test/unit/test-proc-load_cmds.rb +2 -2
  95. metadata +295 -218
  96. data/app/breakpoint.rbc +0 -3551
  97. data/app/brkptmgr.rbc +0 -2903
  98. data/app/client.rbc +0 -1225
  99. data/app/complete.rbc +0 -1288
  100. data/app/default.rbc +0 -1132
  101. data/app/display.rbc +0 -2578
  102. data/app/frame.rbc +0 -1808
  103. data/app/irb.rbc +0 -2094
  104. data/app/iseq.rbc +0 -2192
  105. data/app/llvm.rbc +0 -2478
  106. data/app/method.rbc +0 -2492
  107. data/app/method_name.rbc +0 -2467
  108. data/app/mock.rbc +0 -398
  109. data/app/options.rbc +0 -2898
  110. data/app/rbx-llvm.rbc +0 -2478
  111. data/app/run.rbc +0 -1244
  112. data/app/util.rbc +0 -1146
  113. data/app/validate.rbc +0 -676
  114. data/bin/trepan.compiled.rbc +0 -1043
  115. data/bin/trepanx.compiled.rbc +0 -1049
  116. data/data/irbrc.compiled.rbc +0 -640
  117. data/interface/base_intf.rbc +0 -1899
  118. data/interface/client.rbc +0 -1072
  119. data/interface/comcodes.rbc +0 -385
  120. data/interface/script.rbc +0 -1642
  121. data/interface/server.rbc +0 -2213
  122. data/interface/user.rbc +0 -2867
  123. data/io/base_io.rbc +0 -2111
  124. data/io/input.rbc +0 -2528
  125. data/io/null_output.rbc +0 -730
  126. data/io/string_array.rbc +0 -2466
  127. data/io/tcpclient.rbc +0 -2419
  128. data/io/tcpfns.rbc +0 -694
  129. data/io/tcpserver.rbc +0 -2638
  130. data/lib/trepanning.rbc +0 -7705
  131. data/lib/trepanning2.rb +0 -441
  132. data/sample/list-terminal-colors.rbc +0 -2318
  133. data/sample/rocky-trepanx-colors.rbc +0 -530
  134. data/test/data/step-bug.cmd +0 -11
  135. data/test/data/step-bug.right +0 -3
  136. data/test/example/step-bug.rb +0 -14
  137. data/test/integration/skip-test-step-bug.rb +0 -17
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ /*.rbc
2
+ /*~
3
+ /irc-discuss
4
+ /pkg
5
+ /tmp
data/ChangeLog CHANGED
@@ -1,3 +1,164 @@
1
+ 2011-02-22 rocky <rockyb@rubyforge.org>
2
+
3
+ * app/breakpoint.rb, app/brkptmgr.rb, lib/trepanning.rb,
4
+ processor/breakpoint.rb, processor/main.rb, processor/stepping.rb,
5
+ test/unit/cmd-helper.rb, test/unit/test-app-brkpt.rb,
6
+ test/unit/test-cmd-finish.rb: Add finalization routine to remove
7
+ stepping and other breakpoints. Fixes the "no debugger" messages on
8
+ rake test.
9
+
10
+ 2011-02-22 rocky <rockyb@rubyforge.org>
11
+
12
+ * test/functional/test-finish.rb: Adjust test check line number. In latest rubinius release line
13
+ numbers for assignment statement are better, use LHS.
14
+
15
+ 2011-02-22 rocky <rockyb@rubyforge.org>
16
+
17
+ * app/breakpoint.rb, app/condition.rb, lib/trepanning.rb,
18
+ processor/command/condition.rb,
19
+ processor/command/info_subcmd/breakpoints.rb,
20
+ processor/location.rb, processor/validate.rb,
21
+ test/unit/test-app-condition.rb: Add breakpoint conditions. Not
22
+ showing # of hits right now though.
23
+
24
+ 2011-02-21 rocky <rockyb@rubyforge.org>
25
+
26
+ * processor/command/source.rb: Add first use of filename completion
27
+ on "source" command
28
+
29
+ 2011-02-20 rocky <rockyb@rubyforge.org>
30
+
31
+ * processor/command/backtrace.rb, processor/command/down.rb,
32
+ processor/command/up.rb: Sync with rb-trepanning
33
+
34
+ 2011-02-20 rocky <rockyb@rubyforge.org>
35
+
36
+ * processor/command/frame.rb, processor/command/up.rb,
37
+ processor/frame.rb: Improve range checking on frame, up and down
38
+ commands.
39
+
40
+ 2011-02-20 rocky <rockyb@rubyforge.org>
41
+
42
+ * io/input.rb: Try two kinds of Readline includes. Possibly I got it
43
+ right this time
44
+
45
+ 2011-02-19 rocky <rockyb@rubyforge.org>
46
+
47
+ Merge branch 'master' of github.com:rocky/rbx-trepanning
48
+
49
+ 2011-02-19 rocky <rockyb@rubyforge.org>
50
+
51
+ * processor/command/exit.rb, processor/command/kill.rb,
52
+ processor/command/show_subcmd/alias.rb: Add kill! alias and update
53
+ help
54
+
55
+ 2011-02-19 rocky <rockyb@rubyforge.org>
56
+
57
+ Merge branch 'master' of github.com:rocky/rbx-trepanning
58
+
59
+ 2011-02-19 rocky <rockyb@rubyforge.org>
60
+
61
+ * app/eventbuffer.rb, processor/command/base/subcmd.rb,
62
+ processor/command/info_subcmd/files.rb,
63
+ processor/command/info_subcmd/line.rb,
64
+ processor/command/info_subcmd/ruby.rb,
65
+ processor/command/set_subcmd/trace_subcmd/print.rb,
66
+ processor/command/show_subcmd/alias.rb,
67
+ processor/command/show_subcmd/auto_subcmd/irb.rb,
68
+ processor/command/show_subcmd/macro.rb,
69
+ processor/command/show_subcmd/trace_subcmd/print.rb,
70
+ processor/eventbuf.rb, processor/hook.rb, processor/main.rb:
71
+ Basically same as what in HEAD
72
+
73
+ 2011-02-19 rocky <rockyb@rubyforge.org>
74
+
75
+ * app/eventbuffer.rb, processor/command/base/subcmd.rb,
76
+ processor/command/info_subcmd/files.rb,
77
+ processor/command/info_subcmd/line.rb,
78
+ processor/command/info_subcmd/ruby.rb,
79
+ processor/command/set_subcmd/trace_subcmd/buffer.rb,
80
+ processor/command/set_subcmd/trace_subcmd/print.rb,
81
+ processor/command/show_subcmd/alias.rb,
82
+ processor/command/show_subcmd/auto_subcmd/irb.rb,
83
+ processor/command/show_subcmd/macro.rb,
84
+ processor/command/show_subcmd/trace_subcmd/buffer.rb,
85
+ processor/command/show_subcmd/trace_subcmd/print.rb,
86
+ processor/eventbuf.rb, processor/hook.rb, processor/main.rb: Add
87
+ rudimentary event buffer save/print. Not fully functional. CMD
88
+ constant now saved automatically in subcommands. DRY some code.
89
+
90
+ 2011-02-19 rocky <rockyb@rubyforge.org>
91
+
92
+ * Rakefile, processor/command/backtrace.rb,
93
+ processor/command/frame.rb, processor/command/up.rb,
94
+ processor/frame.rb: Add frame number completion. Why not?
95
+
96
+ 2011-02-19 rocky <rockyb@rubyforge.org>
97
+
98
+ * processor/command/show_subcmd/alias.rb: Add completion for "show
99
+ aliases"
100
+
101
+ 2011-02-18 rocky <rockyb@rubyforge.org>
102
+
103
+ * processor/command/show_subcmd/macro.rb, processor/msg.rb: show
104
+ macro improvements: add "show macro *" and long help. Sync with
105
+ rb-trepanning.
106
+
107
+ 2011-02-18 rocky <rockyb@rubyforge.org>
108
+
109
+ * processor/command/eval.rb, processor/command/macro.rb,
110
+ processor/command/show_subcmd/macro.rb, processor/location.rb,
111
+ processor/main.rb, processor/msg.rb: Add eval? alias ev? to evaluate
112
+ current source line without leading "if", "while" "elsif" Add show
113
+ macro to see macros. Syntax highight that if desired.
114
+
115
+ 2011-02-18 rocky <rockyb@rubyforge.org>
116
+
117
+ * app/complete.rb, app/frame.rb, lib/trepanning.rb,
118
+ processor/command/base/subsubcmd.rb,
119
+ processor/command/base/subsubmgr.rb, processor/command/complete.rb,
120
+ processor/command/macro.rb,
121
+ processor/command/set_subcmd/different.rb, processor/load_cmds.rb,
122
+ processor/main.rb, test/unit/test-completion.rb,
123
+ test/unit/test-proc-load_cmds.rb: Sync with rb-trepanning. Had
124
+ broken completion in code refactor.
125
+
126
+ 2011-02-18 rocky <rockyb@rubyforge.org>
127
+
128
+ * test/unit/test-app-complete.rb: Redo completion somewhat to be
129
+ more general and much input line when there are abreviations less.
130
+
131
+ 2011-02-16 rocky <rockyb@rubyforge.org>
132
+
133
+ * app/run.rb, interface/user.rb: Sync with rb-trepanning
134
+
135
+ 2011-02-16 rocky <rockyb@rubyforge.org>
136
+
137
+ * app/default.rb, app/run.rb, interface/user.rb, io/input.rb,
138
+ processor/load_cmds.rb, test/unit/test-app-options.rb,
139
+ test/unit/test-completion.rb: Completion was totally borked and so
140
+ was handling of Readline. Fix. Fix completion of aliases and test
141
+ for that now.
142
+
143
+ 2011-02-16 rocky <rockyb@rubyforge.org>
144
+
145
+ * .gemspec, Rakefile, app/options.rb, rbx-trepanning.gemspec: Work
146
+ on packaging yet again. Steal from kpat's for good ideas.
147
+ options.rb: Correct usage one more time. In 0.0.7.dev now
148
+
149
+ 2011-02-15 rocky <rockyb@rubyforge.org>
150
+
151
+ * .gemspec: Repackage using rubinius 1.2 rather than 1.2.1
152
+
153
+ 2011-02-15 rocky <rockyb@rubyforge.org>
154
+
155
+ * .gemspec, NEWS, app/options.rb: Repackage using rubinius 1.2
156
+ rather than 1.2.1
157
+
158
+ 2011-02-15 rocky <rockyb@rubyforge.org>
159
+
160
+ * ChangeLog: Update ChangeLog for release
161
+
1
162
  2011-02-15 rocky <rockyb@rubyforge.org>
2
163
 
3
164
  * .gemspec, Rakefile, app/options.rb: Get ready for 0.0.5 release
data/Makefile ADDED
@@ -0,0 +1,13 @@
1
+ # I'll admit it -- I'm an absent-minded old-timer who has trouble
2
+ # learning new tricks.
3
+ .PHONY: all test
4
+
5
+ all: test
6
+
7
+ check:
8
+ rake test
9
+ test:
10
+ rake test
11
+
12
+ %:
13
+ rake $@
data/NEWS CHANGED
@@ -1,3 +1,14 @@
1
+ Feb 22, 2011 (0.0.7)
2
+ - Add gdb "condition" command
3
+ - More complete command completion
4
+ - Add kill! alias to force without prompting
5
+ - Add eval (no args) and eval? to run current source line or source line
6
+ expression
7
+ - Add "set/show trace buffer on/off" to keep a history of recent places
8
+ we've stopped in the debugger
9
+ - Add "show macro *" to list all macro names.
10
+ - A number of bug fixes
11
+
1
12
  Feb 15, 2011 (0.0.6)
2
13
  - Repackage using rubinus platform 1.2 rather than 1.2.1
3
14
 
data/Rakefile CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env rake
2
2
  # Are we Rubinius? We'll test by checking the specific function we need.
3
- raise RuntimeError, 'This package is for Rubinius 1.2 or 1.2.1dev only!' unless
3
+ raise RuntimeError, 'This package is for Rubinius 1.2.x only!' unless
4
4
  Object.constants.include?('Rubinius') &&
5
5
  Rubinius.constants.include?('VM') &&
6
- %w(1.2.1 1.2.2dev).member?(Rubinius::VERSION)
6
+ Rubinius::VERSION =~ /1\.2.+/
7
7
 
8
8
  require 'rubygems'
9
9
  require 'rake/gempackagetask'
@@ -11,19 +11,20 @@ require 'rake/rdoctask'
11
11
  require 'rake/testtask'
12
12
 
13
13
  ROOT_DIR = File.dirname(__FILE__)
14
+ Gemspec_filename = 'rbx-trepanning.gemspec'
14
15
  require File.join %W(#{ROOT_DIR} app options)
15
16
 
16
17
  def gemspec
17
- @gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
18
+ @gemspec ||= eval(File.read(Gemspec_filename), binding, Gemspec_filename)
18
19
  end
19
20
 
20
21
  desc "Build the gem"
21
22
  task :package=>:gem
22
23
  task :gem=>:gemspec do
23
24
  Dir.chdir(ROOT_DIR) do
24
- sh "gem build .gemspec"
25
+ sh "gem build #{Gemspec_filename}"
25
26
  FileUtils.mkdir_p 'pkg'
26
- FileUtils.mv("#{gemspec.file_name}", "pkg/#{gemspec.file_name}")
27
+ FileUtils.mv("#{gemspec.file_name}", "pkg/")
27
28
  end
28
29
  end
29
30
 
data/app/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ /*.rbc
2
+ /*~
data/app/breakpoint.rb CHANGED
@@ -1,33 +1,30 @@
1
- # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
3
+
4
+ # Breakpoint objects
2
5
  class Trepan
3
6
  class Breakpoint
4
-
5
7
  attr_accessor :condition # If non-nil, this is a String to be eval'd
6
8
  # which must be true to enter the debugger
7
9
  attr_reader :event # Symbol. Optional type of event associated with
8
10
  # breakpoint.
9
- attr_accessor :hits # Fixnum. The number of timea a breakpoint
11
+ attr_accessor :hits # Fixnum. The number of times a breakpoint
10
12
  # has been hit (with a true condition). Do
11
13
  # we want to (also) record hits independent
12
14
  # of the condition?
13
15
  attr_reader :id # Fixnum. Name of breakpoint
14
-
16
+ attr_reader :ignore # Fixnum. How many more times do we have
17
+ # to encounter the breakpoint before we stop?
15
18
  @@next_id = 1
16
19
 
17
20
  BRKPT_DEFAULT_SETTINGS = {
18
21
  :condition => 'true',
19
22
  :enabled => 'true',
23
+ :ignore => 0,
20
24
  :temp => false,
21
25
  :event => :Unknown,
22
26
  } unless defined?(BRKPT_DEFAULT_SETTINGS)
23
27
 
24
- def self.for_ip(exec, ip, opts={})
25
- name = opts[:name] || :anon
26
- line = exec.line_from_ip(ip)
27
-
28
- Breakpoint.new(name, exec, ip, line, nil, opts)
29
- end
30
-
31
28
  def initialize(name, method, ip, line, id=nil, opts = {})
32
29
  @descriptor = name
33
30
  @id = id
@@ -47,12 +44,13 @@ class Trepan
47
44
  end
48
45
 
49
46
  @hits = 0
47
+
50
48
  # unless @id
51
49
  # @id = @@next_id
52
50
  # @@next_id += 1
53
51
  # end
54
52
 
55
- @set = false
53
+ @activated = false
56
54
  end
57
55
 
58
56
  attr_reader :method, :ip, :line, :descriptor
@@ -79,16 +77,27 @@ class Trepan
79
77
  end
80
78
 
81
79
  def activate
82
- @set = true
80
+ @activated = true
83
81
  @method.set_breakpoint @ip, self
84
82
  end
85
83
 
86
- # Return true if the breakpoint is relevant. That is, the
87
- # breakpoint is either not a scoped or it is scoped and test_scope
88
- # matches the desired scope. We also remove the breakpoint and any
89
- # related breakpoints if it was hit and temporary.
84
+ def active?
85
+ @activated
86
+ end
87
+
88
+ # FIXME: give this a better name.
89
+ # Return true if the breakpoint is a temporary breakpoint and is
90
+ # relevant. By releveant we mean that, the breakpoint is either
91
+ # not a scoped breakpoint or it is scoped and test_scope matches
92
+ # the desired scope. We also remove the breakpoint and any related
93
+ # breakpoints if it was hit and temporary.
94
+ #
95
+ # If the breakpoint is not a temporary breakpoint, return nil.
96
+ #
97
+ # See also "condition' below which is run to determine whether or
98
+ # not to stop.
90
99
  def hit!(test_scope)
91
- return true unless @temp
100
+ return nil unless @temp
92
101
  return false if @scope && test_scope != @scope
93
102
 
94
103
  @related_bp.each { |bp| bp.remove! }
@@ -96,26 +105,26 @@ class Trepan
96
105
  return true
97
106
  end
98
107
 
99
- # def condition?(bind)
100
- # if eval(@condition, bind)
101
- # if @ignore > 0
102
- # @ignore -= 1
103
- # return false
104
- # else
105
- # @hits += 1
106
- # return true
107
- # end
108
- # else
109
- # return false
110
- # end
111
- # end
108
+ def condition?(bind)
109
+ if eval(@condition, bind)
110
+ if @ignore > 0
111
+ @ignore -= 1
112
+ return false
113
+ else
114
+ @hits += 1
115
+ return true
116
+ end
117
+ else
118
+ return false
119
+ end
120
+ end
112
121
 
113
122
  def delete!
114
123
  remove!
115
124
  end
116
125
 
117
126
  def describe
118
- "#{descriptor} - #{location}"
127
+ "#{@descriptor} - #{location}"
119
128
  end
120
129
 
121
130
  def disable
@@ -147,9 +156,8 @@ class Trepan
147
156
  end
148
157
 
149
158
  def remove!
150
- return unless @set
151
-
152
- @set = false
159
+ return unless @activated
160
+ @activated = false
153
161
  @method.clear_breakpoint(@ip)
154
162
  end
155
163
 
@@ -157,6 +165,13 @@ class Trepan
157
165
  @temp
158
166
  end
159
167
 
168
+ def self.for_ip(exec, ip, opts={})
169
+ name = opts[:name] || :anon
170
+ line = exec.line_from_ip(ip)
171
+
172
+ Breakpoint.new(name, exec, ip, line, nil, opts)
173
+ end
174
+
160
175
  end
161
176
 
162
177
  class DeferredBreakpoint
@@ -212,8 +227,10 @@ end
212
227
 
213
228
  if __FILE__ == $0
214
229
  method = Rubinius::CompiledMethod.of_sender
215
- bp = Trepan::Breakpoint.new '<start>', method, 1, 2, 0
230
+ bp = Trepan::Breakpoint.new '<start>', method, 0, 2, 0
216
231
  %w(describe location icon_char hits temp? enabled? condition).each do |field|
217
232
  puts "#{field}: #{bp.send(field.to_sym)}"
218
233
  end
234
+ bp.activate
235
+ bp.remove!
219
236
  end
data/app/brkptmgr.rb CHANGED
@@ -13,6 +13,14 @@ class Trepan
13
13
  @set = Set.new
14
14
  end
15
15
 
16
+ # Remove all breakpoints that we have recorded
17
+ def finalize
18
+ @list.each do |bp|
19
+ bp.related_bp.each { |bp| bp.remove! }
20
+ bp.remove!
21
+ end
22
+ end
23
+
16
24
  def <<(brkpt)
17
25
  @list << brkpt
18
26
  @set.add(set_key(brkpt))
@@ -111,6 +119,7 @@ if __FILE__ == $0
111
119
  meth = Rubinius::CompiledMethod.of_sender
112
120
 
113
121
  brkpts = Trepan::BreakpointMgr.new
122
+ ObjectSpace.define_finalizer(brkpts, Proc.new {|arg| brkpts.finalize })
114
123
  brkpts.add("<start>", meth, 0, 0, 1)
115
124
  p brkpts[2]
116
125
  bp_status(brkpts, 1)
@@ -137,4 +146,5 @@ if __FILE__ == $0
137
146
  bp_status(brkpts, 6)
138
147
  brkpts.delete_by_brkpt(b3)
139
148
  bp_status(brkpts, 7)
149
+ brkpts.finalize
140
150
  end
data/app/complete.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
+
2
3
  class Trepan
4
+
5
+ # Command completion methods
3
6
  module Complete
4
7
 
5
8
  module_function
@@ -10,10 +13,11 @@ class Trepan
10
13
  complete_ary.select { |cmd| cmd.to_s.start_with?(prefix) }.sort
11
14
  end
12
15
 
13
- def complete_token_with_next(complete_hash, prefix)
16
+ def complete_token_with_next(complete_hash, prefix, cmd_prefix='')
14
17
  result = []
15
18
  complete_hash.each do |cmd_name, cmd_obj|
16
- result << [cmd_name, cmd_obj] if cmd_name.to_s.start_with?(prefix)
19
+ result << [cmd_name.to_s[cmd_prefix.size..-1], cmd_obj] if
20
+ cmd_name.to_s.start_with?(cmd_prefix + prefix)
17
21
  end
18
22
  result.sort{|a, b| a[0] <=> b[0]}
19
23
  end
@@ -41,6 +45,23 @@ class Trepan
41
45
  end
42
46
  result
43
47
  end
48
+
49
+ # Find the next token in str string from start_pos, we return
50
+ # the token and the next blank position after the token or
51
+ # str.size if this is the last token. Tokens are delimited by
52
+ # white space.
53
+ def next_token(str, start_pos)
54
+ look_at = str[start_pos..-1]
55
+ next_nonblank_pos = start_pos + (look_at =~ /\S/ || 0)
56
+ next_blank_pos =
57
+ if next_match = str[next_nonblank_pos..-1] =~ /\s/
58
+ next_nonblank_pos + next_match
59
+ else
60
+ str.size
61
+ end
62
+ return [next_blank_pos, str[next_nonblank_pos...next_blank_pos]]
63
+ end
64
+
44
65
  end
45
66
  end
46
67
 
@@ -49,4 +70,10 @@ if __FILE__ == $0
49
70
  hash = {'ab' => 1, 'aac' => 2, 'aa' => 3, 'b' => 4}
50
71
  p complete_token(hash.keys, 'a')
51
72
  p complete_token_with_next(hash, 'a')
73
+ ## 0 1
74
+ ## 0123456789012345678
75
+ x = ' now is the time'
76
+ [0, 2, 5, 8, 9, 13, 19].each do |pos|
77
+ p next_token(x, pos)
78
+ end
52
79
  end
data/app/condition.rb ADDED
@@ -0,0 +1,22 @@
1
+ # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
2
+ class Trepan
3
+ module Condition
4
+ def valid_condition?(str)
5
+ begin
6
+ Rubinius::Compiler.compile_string(str)
7
+ rescue SyntaxError
8
+ return nil
9
+ rescue
10
+ nil
11
+ end
12
+ end
13
+ module_function :valid_condition?
14
+ end
15
+ end
16
+ if __FILE__ == $0
17
+ include Trepan::Condition
18
+ p valid_condition?('a+2')
19
+ puts '-' * 20
20
+ p valid_condition?('1+')
21
+ puts '-' * 20
22
+ end
data/app/default.rb CHANGED
@@ -39,6 +39,7 @@ class Trepan
39
39
  :port => DEFAULT_SETTINGS[:port],
40
40
  :host => DEFAULT_SETTINGS[:host],
41
41
  :server => false, # Out-of-process debugging?
42
+ :readline => true, # Try to use GNU Readline?
42
43
  # Note that at most one of :server or :client can be true.
43
44
  } unless defined?(DEFAULT_CMDLINE_SETTINGS)
44
45
 
@@ -0,0 +1,147 @@
1
+ # Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
+ module Trace
3
+
4
+ class EventBuffer
5
+ EventStruct = Struct.new(:event, :arg, :frame) unless defined?(EventStruct)
6
+ attr_reader :buf
7
+ attr_accessor :marks # User position mark into buffer. If buffer is limited,
8
+ attr_reader :maxsize # Maximum size of buffer or nil if unlimited.
9
+ attr_reader :size # size of buffer
10
+ # then marks will drop out as they disappear from the buffer
11
+ def initialize(maxsize=nil)
12
+ @maxsize = maxsize
13
+ reset
14
+ end
15
+
16
+ def reset
17
+ @buf = []
18
+ @marks = []
19
+ @pos = -1
20
+ @size = 0
21
+ end
22
+
23
+ # Add a new event dropping off old events if that was declared
24
+ # marks are also dropped if buffer has a limit.
25
+ def append(event, frame, arg)
26
+ item = EventStruct.new(event, arg, frame)
27
+ @pos = self.succ_pos
28
+ @marks.shift if @marks[0] == @pos
29
+ @buf[@pos] = item
30
+ @size += 1 unless @maxsize && @size == @maxsize
31
+ end
32
+
33
+ # Add mark for the current event buffer position.
34
+ def add_mark
35
+ @marks << @pos
36
+ end
37
+
38
+ # Like add mark, but do only if the last marked position has
39
+ # changed
40
+ def add_mark_nodup
41
+ @marks << @pos unless @marks[-1] == @pos
42
+ end
43
+
44
+ def each(from=nil, to=nil)
45
+ from = self.succ_pos unless from
46
+ to = @pos unless to
47
+ if from <= to
48
+ from.upto(to).each do |pos|
49
+ yield @buf[pos]
50
+ end
51
+ else
52
+ from.upto(@size-1).each do |pos|
53
+ yield @buf[pos]
54
+ end
55
+ 0.upto(@pos).each do |pos|
56
+ yield @buf[pos]
57
+ end
58
+ end
59
+ end
60
+
61
+ def each_with_index(from=nil, to=nil)
62
+ from = succ_pos unless from
63
+ to = @pos unless to
64
+ if from <= to
65
+ from.upto(to).each do |pos|
66
+ yield [@buf[pos], pos]
67
+ end
68
+ else
69
+ from.upto(@size-1).each do |pos|
70
+ yield [@buf[pos], pos]
71
+ end
72
+ 0.upto(@pos).each do |pos|
73
+ yield [@buf[pos], pos]
74
+ end
75
+ end
76
+ end
77
+
78
+ def format_entry(item, long_format=true)
79
+ # require 'rbdbgr'; Debugger.debug
80
+ mess = "#{item.event} #{item.frame}"
81
+ # if long_format && item.iseq
82
+ # mess += "\n\t" + "VM offset #{item.pc_offset} of #{item.iseq.name}"
83
+ # end
84
+ mess
85
+ end
86
+
87
+ # Return the next event buffer position taking into account
88
+ # that we may have a fixed-sized buffer ring.
89
+ def succ_pos(inc=1)
90
+ pos = @pos + inc
91
+ @maxsize ? pos % @maxsize : pos
92
+ end
93
+
94
+ # Return the next event buffer position taking into account
95
+ # that we may have a fixed-sized buffer ring.
96
+ def pred_pos(dec=1)
97
+ pos = @pos - dec
98
+ @maxsize ? pos % @maxsize : pos
99
+ end
100
+
101
+ # Return the adjusted zeroth position in @buf.
102
+ def zero_pos
103
+ if !@maxsize || @buf.size < @maxsize
104
+ 0
105
+ else
106
+ self.succ_pos
107
+ end
108
+ end
109
+
110
+ end # EventBuffer
111
+ end # Trace
112
+
113
+ if __FILE__ == $0
114
+ def event_processor(event, frame, arg=nil)
115
+ begin
116
+ @eventbuf.append(event, frame, arg)
117
+ rescue
118
+ p $!
119
+ end
120
+ end
121
+ def dump_all
122
+ puts '-' * 40
123
+ @eventbuf.each do |e|
124
+ puts @eventbuf.format_entry(e) if e
125
+ end
126
+ end
127
+
128
+ require 'rubygems'; require 'set_trace'
129
+ @eventbuf = Trace::EventBuffer.new(5)
130
+ p @eventbuf.zero_pos
131
+ dump_all
132
+
133
+ # trace_filter = Trace::Filter.new
134
+ # trace_func = method(:event_processor).to_proc
135
+ # trace_filter << trace_func
136
+ # trace_filter.set_trace_func(trace_func)
137
+ # z=5
138
+ # z.times do |i|
139
+ # x = i
140
+ # y = x+2
141
+ # end
142
+ # trace_filter.set_trace_func(nil)
143
+ # p @eventbuf.buf[@eventbuf.zero_pos]
144
+ # dump_all
145
+ @eventbuf.reset
146
+ dump_all
147
+ end
data/app/frame.rb CHANGED
@@ -1,5 +1,7 @@
1
- # Frame code from reference debugger.
1
+ # Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
2
2
  class Trepan
3
+
4
+ # Call-Stack frame methods
3
5
  class Frame
4
6
  def initialize(debugger, number, vm_location)
5
7
  @debugger = debugger