trepanning 0.0.9 → 0.1.0
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.
- data/ChangeLog +237 -0
- data/NEWS +8 -0
- data/Rakefile +3 -2
- data/app/breakpoint.rb +8 -8
- data/app/brkptmgr.rb +86 -85
- data/app/client.rb +60 -0
- data/app/core.rb-consider +198 -0
- data/app/default.rb +17 -7
- data/app/disassemble.rb +12 -2
- data/app/options.rb +51 -20
- data/app/yarv.rb +183 -0
- data/bin/trepan +15 -9
- data/data/custom_require.rb +44 -0
- data/data/irbrc +41 -0
- data/data/prelude.rb +38 -0
- data/interface/base_intf.rb +10 -4
- data/interface/client.rb +79 -0
- data/interface/comcodes.rb +18 -0
- data/interface/server.rb +142 -0
- data/io/base_io.rb +57 -3
- data/io/tcpclient.rb +122 -0
- data/io/tcpfns.rb +31 -0
- data/io/tcpserver.rb +137 -0
- data/lib/trepanning.rb +57 -28
- data/processor/command/base/cmd.rb +10 -6
- data/processor/command/base/subcmd.rb +13 -1
- data/processor/command/directory.rb +15 -8
- data/processor/command/disassemble.rb +3 -2
- data/processor/command/help.rb +71 -19
- data/processor/command/info_subcmd/args.rb +2 -3
- data/processor/command/info_subcmd/breakpoints.rb +2 -3
- data/processor/command/info_subcmd/file.rb +2 -3
- data/processor/command/info_subcmd/frame.rb +2 -3
- data/processor/command/info_subcmd/iseq.rb +4 -5
- data/processor/command/info_subcmd/locals.rb +2 -3
- data/processor/command/info_subcmd/program.rb +2 -3
- data/processor/command/info_subcmd/registers.rb +2 -3
- data/processor/command/info_subcmd/return.rb +2 -3
- data/processor/command/info_subcmd/thread.rb +2 -3
- data/processor/command/list.rb +10 -6
- data/processor/command/reload.rb +1 -1
- data/processor/command/reload_subcmd/command.rb +29 -16
- data/processor/command/server.rb +70 -0
- data/processor/command/set_subcmd/auto.rb +2 -3
- data/processor/command/set_subcmd/basename.rb +2 -3
- data/processor/command/set_subcmd/debug.rb +2 -3
- data/processor/command/set_subcmd/different.rb +2 -3
- data/processor/command/set_subcmd/events.rb +2 -3
- data/processor/command/set_subcmd/hidelevel.rb +6 -7
- data/processor/command/set_subcmd/highlight.rb +32 -0
- data/processor/command/set_subcmd/max.rb +2 -3
- data/processor/command/set_subcmd/return.rb +2 -3
- data/processor/command/set_subcmd/sp.rb +2 -3
- data/processor/command/set_subcmd/substitute.rb +2 -3
- data/processor/command/set_subcmd/timer.rb +2 -3
- data/processor/command/set_subcmd/trace.rb +3 -4
- data/processor/command/show_subcmd/alias.rb +3 -3
- data/processor/command/show_subcmd/args.rb +2 -3
- data/processor/command/show_subcmd/auto.rb +1 -2
- data/processor/command/show_subcmd/basename.rb +2 -3
- data/processor/command/show_subcmd/debug.rb +1 -2
- data/processor/command/show_subcmd/different.rb +2 -1
- data/processor/command/show_subcmd/events.rb +2 -2
- data/processor/command/show_subcmd/hidelevel.rb +2 -3
- data/processor/command/show_subcmd/highlight.rb +23 -0
- data/processor/command/show_subcmd/macro.rb +2 -1
- data/processor/command/show_subcmd/max.rb +2 -3
- data/processor/command/show_subcmd/trace.rb +2 -3
- data/processor/command/source.rb +78 -28
- data/processor/default.rb +3 -2
- data/processor/load_cmds.rb +39 -19
- data/processor/location.rb +11 -7
- data/processor/main.rb +31 -15
- data/processor/mock.rb +22 -7
- data/processor/msg.rb +24 -8
- data/test/data/fname-with-blank.right +3 -0
- data/test/data/quit.right +2 -0
- data/test/functional/test-break-long.rb +87 -0
- data/test/functional/tmp/b3.rb +5 -0
- data/test/functional/tmp/immediate-bug1.rb +9 -0
- data/test/integration/helper.rb +14 -11
- data/test/integration/test-fname-with-blank.rb +5 -1
- data/test/integration/test-quit.rb +6 -2
- data/test/unit/cmd-helper.rb +9 -4
- data/test/unit/mock-helper.rb +9 -0
- data/test/unit/test-app-brkpt.rb +4 -4
- data/test/unit/test-app-brkptmgr.rb +2 -2
- data/test/unit/test-app-file.rb +0 -1
- data/test/unit/test-app-options.rb +26 -5
- data/test/unit/test-base-subcmd.rb +0 -1
- data/test/unit/test-cmd-alias.rb +0 -1
- data/test/unit/test-cmd-break.rb +0 -4
- data/test/unit/test-cmd-endisable.rb +1 -3
- data/test/unit/test-cmd-help.rb +0 -1
- data/test/unit/test-cmd-kill.rb +4 -5
- data/test/unit/test-cmd-quit.rb +4 -7
- data/test/unit/test-cmd-source.rb +33 -0
- data/test/unit/test-cmd-step.rb +0 -2
- data/test/unit/test-io-tcp.rb +32 -0
- data/test/unit/test-io-tcpclient.rb +53 -0
- data/test/unit/test-io-tcpserver.rb +49 -0
- data/test/unit/test-proc-main.rb +2 -2
- metadata +195 -175
- data/processor/command/stepi.rb +0 -63
- data/test/functional/tmp/b1.rb +0 -5
- data/test/functional/tmp/s1.rb +0 -9
- data/test/functional/tmp/t2.rb +0 -6
- data/test/integration/try-test-enable.rb +0 -11
data/ChangeLog
CHANGED
@@ -1,3 +1,240 @@
|
|
1
|
+
2011-02-01 rocky <rockyb@rubyforge.org>
|
2
|
+
|
3
|
+
* ChangeLog, NEWS: One more small NEWS update
|
4
|
+
|
5
|
+
2011-02-01 rocky <rockyb@rubyforge.org>
|
6
|
+
|
7
|
+
* app/options.rb: Get ready for release
|
8
|
+
|
9
|
+
2011-02-01 rocky <rockyb@rubyforge.org>
|
10
|
+
|
11
|
+
* ChangeLog, NEWS, app/disassemble.rb, app/yarv.rb,
|
12
|
+
processor/command/disassemble.rb: Feb 1, 2011 (0.1.0) * Add Remote debugging interface. Add options --server --port * Add Syntax highlighting on Ruby and YARV listings and locations * Section highlighting on some commands * Use ;; to allow multiple debugger commands. Document debugger
|
13
|
+
command syntax * include data files for debugging custom-require * Numerous bug fixes and code cleanups
|
14
|
+
|
15
|
+
2011-02-01 rocky <rockyb@rubyforge.org>
|
16
|
+
|
17
|
+
* processor/msg.rb: Sync with rbx-trepanning.
|
18
|
+
|
19
|
+
2011-01-30 rocky <rockyb@rubyforge.org>
|
20
|
+
|
21
|
+
* .gemspec: Install data files.
|
22
|
+
|
23
|
+
2011-01-30 rocky <rockyb@rubyforge.org>
|
24
|
+
|
25
|
+
* processor/command/set_subcmd/hidelevel.rb,
|
26
|
+
processor/command/set_subcmd/trace.rb: Minor cleanup.
|
27
|
+
|
28
|
+
2011-01-30 rocky <rockyb@rubyforge.org>
|
29
|
+
|
30
|
+
* processor/main.rb: Wrong method in macro handling. Need more
|
31
|
+
though.
|
32
|
+
|
33
|
+
2011-01-30 rocky <rockyb@rubyforge.org>
|
34
|
+
|
35
|
+
* processor/command/list.rb, sample/rocky-trepan-colors.rb: Color
|
36
|
+
tweaks
|
37
|
+
|
38
|
+
2011-01-30 rocky <rockyb@rubyforge.org>
|
39
|
+
|
40
|
+
* processor/command/show_subcmd/alias.rb, processor/msg.rb,
|
41
|
+
sample/list-terminal-colors.rb, sample/rocky-trepan-colors.rb: Try
|
42
|
+
italic error messages. Update comments for terminal colors.
|
43
|
+
alias.rb: use sectioning for title.
|
44
|
+
|
45
|
+
2011-01-30 rocky <rockyb@rubyforge.org>
|
46
|
+
|
47
|
+
* processor/command/show_subcmd/alias.rb,
|
48
|
+
processor/command/show_subcmd/args.rb,
|
49
|
+
processor/command/show_subcmd/auto.rb,
|
50
|
+
processor/command/show_subcmd/basename.rb,
|
51
|
+
processor/command/show_subcmd/debug.rb,
|
52
|
+
processor/command/show_subcmd/different.rb,
|
53
|
+
processor/command/show_subcmd/events.rb,
|
54
|
+
processor/command/show_subcmd/hidelevel.rb,
|
55
|
+
processor/command/show_subcmd/macro.rb,
|
56
|
+
processor/command/show_subcmd/max.rb,
|
57
|
+
processor/command/show_subcmd/trace.rb: DRY code for show_subcmd:
|
58
|
+
Remove explicit NAME and PREFIX setting.
|
59
|
+
|
60
|
+
2011-01-30 rocky <rockyb@rubyforge.org>
|
61
|
+
|
62
|
+
* Rakefile, processor/command/info_subcmd/args.rb,
|
63
|
+
processor/command/info_subcmd/breakpoints.rb,
|
64
|
+
processor/command/info_subcmd/file.rb,
|
65
|
+
processor/command/info_subcmd/frame.rb,
|
66
|
+
processor/command/info_subcmd/iseq.rb,
|
67
|
+
processor/command/info_subcmd/locals.rb,
|
68
|
+
processor/command/info_subcmd/program.rb,
|
69
|
+
processor/command/info_subcmd/registers.rb,
|
70
|
+
processor/command/info_subcmd/return.rb,
|
71
|
+
processor/command/info_subcmd/thread.rb,
|
72
|
+
processor/command/reload.rb,
|
73
|
+
processor/command/reload_subcmd/command.rb,
|
74
|
+
processor/command/set_subcmd/auto.rb,
|
75
|
+
processor/command/set_subcmd/basename.rb,
|
76
|
+
processor/command/set_subcmd/debug.rb,
|
77
|
+
processor/command/set_subcmd/different.rb,
|
78
|
+
processor/command/set_subcmd/events.rb,
|
79
|
+
processor/command/set_subcmd/hidelevel.rb,
|
80
|
+
processor/command/set_subcmd/max.rb,
|
81
|
+
processor/command/set_subcmd/return.rb,
|
82
|
+
processor/command/set_subcmd/sp.rb,
|
83
|
+
processor/command/set_subcmd/substitute.rb,
|
84
|
+
processor/command/set_subcmd/timer.rb,
|
85
|
+
processor/command/set_subcmd/trace.rb, processor/load_cmds.rb:
|
86
|
+
reload.rb: allow loading of a new debugger command files
|
87
|
+
load_cmds.rb: allow loading files as well as directories. Use send
|
88
|
+
over eval since it is better in reporting errors. *_subcmd/*.rb:
|
89
|
+
DRY code for setting NAME and PREFIX
|
90
|
+
|
91
|
+
2011-01-29 rocky <rockyb@rubyforge.org>
|
92
|
+
|
93
|
+
* processor/command/info_subcmd/iseq.rb, processor/command/list.rb:
|
94
|
+
Don't limit list output strings.
|
95
|
+
|
96
|
+
2011-01-28 rocky <rockyb@rubyforge.org>
|
97
|
+
|
98
|
+
* processor/command/info_subcmd/iseq.rb: iseq.source ->
|
99
|
+
iseq.eval_source
|
100
|
+
|
101
|
+
2011-01-28 rocky <rockyb@rubyforge.org>
|
102
|
+
|
103
|
+
* app/options.rb, bin/trepan, lib/trepanning.rb,
|
104
|
+
processor/command/help.rb, processor/command/list.rb,
|
105
|
+
processor/command/set_subcmd/highlight.rb,
|
106
|
+
processor/command/set_subcmd/terminal.rb,
|
107
|
+
processor/command/show_subcmd/highlight.rb,
|
108
|
+
processor/command/show_subcmd/terminal.rb, processor/default.rb,
|
109
|
+
processor/location.rb, processor/main.rb, processor/msg.rb,
|
110
|
+
sample/rocky-dot-trepanrc: set/show terminal -> set/show highlight
|
111
|
+
|
112
|
+
2011-01-28 rocky <rockyb@rubyforge.org>
|
113
|
+
|
114
|
+
* .gemspec: Update other min versions for rb-threadframe and
|
115
|
+
rb-trace.
|
116
|
+
|
117
|
+
2011-01-28 rocky <rockyb@rubyforge.org>
|
118
|
+
|
119
|
+
* .gemspec: it's ~> not =~.
|
120
|
+
|
121
|
+
2011-01-28 rocky <rockyb@rubyforge.org>
|
122
|
+
|
123
|
+
* bin/trepan, lib/trepanning.rb, processor/command/base/subcmd.rb,
|
124
|
+
processor/command/list.rb,
|
125
|
+
processor/command/set_subcmd/terminal.rb,
|
126
|
+
processor/command/show_subcmd/terminal.rb, processor/default.rb,
|
127
|
+
processor/main.rb, sample/.gitignore,
|
128
|
+
sample/list-terminal-colors.rb, sample/rocky-dot-trepanrc,
|
129
|
+
sample/rocky-trepan-colors.rb: Syntax highlighting. Finally.
|
130
|
+
|
131
|
+
2011-01-28 rocky <rockyb@rubyforge.org>
|
132
|
+
|
133
|
+
* processor/command/base/cmd.rb, processor/command/base/subcmd.rb,
|
134
|
+
processor/command/disassemble.rb, processor/command/help.rb,
|
135
|
+
processor/mock.rb, processor/msg.rb, test/unit/cmd-helper.rb,
|
136
|
+
test/unit/test-proc-main.rb: Add 'help all' and add sectioning-type
|
137
|
+
message.
|
138
|
+
|
139
|
+
2011-01-28 rocky <rockyb@rubyforge.org>
|
140
|
+
|
141
|
+
* app/breakpoint.rb, app/brkptmgr.rb, test/unit/test-app-brkpt.rb,
|
142
|
+
test/unit/test-app-brkptmgr.rb, test/unit/test-cmd-endisable.rb:
|
143
|
+
Trepanning::Breakpoint -> Trepan::Breakpoint
|
144
|
+
|
145
|
+
2011-01-28 rocky <rockyb@rubyforge.org>
|
146
|
+
|
147
|
+
* .gemspec, Rakefile, app/default.rb, app/options.rb, bin/trepan,
|
148
|
+
io/tcpserver.rb, lib/trepanning.rb, processor/command/server.rb,
|
149
|
+
processor/command/source.rb, processor/default.rb,
|
150
|
+
processor/mock.rb, test/unit/test-app-options.rb,
|
151
|
+
test/unit/test-cmd-break.rb: Remove module Trepanning. Trepanning ->
|
152
|
+
Trepan.
|
153
|
+
|
154
|
+
2011-01-28 rocky <rockyb@rubyforge.org>
|
155
|
+
|
156
|
+
* .gemspec, processor/location.rb: Rework for syntax-enabled
|
157
|
+
linecache. tf.source -> tf.eval_source
|
158
|
+
|
159
|
+
2011-01-16 rocky <rockyb@rubyforge.org>
|
160
|
+
|
161
|
+
* processor/command/source.rb, test/unit/test-cmd-source.rb: Add
|
162
|
+
unit test source options. Fix bug in source option processing.
|
163
|
+
|
164
|
+
2011-01-13 rocky <rockyb@rubyforge.org>
|
165
|
+
|
166
|
+
* processor/command/server.rb, processor/command/source.rb: Sync
|
167
|
+
with rbx-trepanning
|
168
|
+
|
169
|
+
2011-01-13 rocky <rockyb@rubyforge.org>
|
170
|
+
|
171
|
+
* app/client.rb, app/default.rb, app/options.rb,
|
172
|
+
interface/base_intf.rb, processor/command/server.rb,
|
173
|
+
processor/command/source.rb: server.rb: Add command to go server
|
174
|
+
mode. source.rb: use optparse to parse options. client.rb: handle
|
175
|
+
user EOF. default.rb: DRY host/port options. base_intf.rb: close()
|
176
|
+
guards against uninitialized I/O.
|
177
|
+
|
178
|
+
2011-01-12 rocky <rockyb@rubyforge.org>
|
179
|
+
|
180
|
+
* interface/server.rb, io/tcpserver.rb: Out-of-process debugging
|
181
|
+
works now.
|
182
|
+
|
183
|
+
2011-01-11 rocky <rockyb@rubyforge.org>
|
184
|
+
|
185
|
+
* app/client.rb, app/default.rb, app/options.rb, bin/trepan,
|
186
|
+
interface/base_intf.rb, interface/client.rb, interface/comcodes.rb,
|
187
|
+
interface/server.rb, io/tcpclient.rb, io/tcpserver.rb,
|
188
|
+
lib/trepanning.rb, processor/main.rb,
|
189
|
+
test/data/fname-with-blank.right, test/data/quit.right,
|
190
|
+
test/integration/helper.rb,
|
191
|
+
test/integration/test-fname-with-blank.rb,
|
192
|
+
test/integration/test-quit.rb, test/unit/test-app-options.rb,
|
193
|
+
test/unit/test-io-tcp.rb, test/unit/test-io-tcpclient.rb,
|
194
|
+
test/unit/test-io-tcpserver.rb: Add out-of-process code from
|
195
|
+
rbx-trepanning. Not working yet though. Sync with rbx-trepanning:
|
196
|
+
some I/O initialization fixed.
|
197
|
+
|
198
|
+
2011-01-11 rocky <rockyb@rubyforge.org>
|
199
|
+
|
200
|
+
* : commit ca6a6ce7ba4599c5edecda1b70cac3656cf50b54 Author: rocky
|
201
|
+
<rockyb@rubyforge.org> Date: Tue Jan 11 19:28:29 2011 -0500
|
202
|
+
|
203
|
+
2011-01-11 rocky <rockyb@rubyforge.org>
|
204
|
+
|
205
|
+
* processor/command/directory.rb: revise help and glob expand
|
206
|
+
directory. More in (sync with suitable adjustments) to
|
207
|
+
rbx-trepanning
|
208
|
+
|
209
|
+
2010-12-28 rocky <rockyb@rubyforge.org>
|
210
|
+
|
211
|
+
* : commit 6585edc946e7c7bc3b8cd20b86860435569d7dd9 Author: rocky
|
212
|
+
<rockyb@rubyforge.org> Date: Tue Dec 28 14:04:16 2010 -0500
|
213
|
+
|
214
|
+
2010-12-27 rocky <rockyb@rubyforge.org>
|
215
|
+
|
216
|
+
* .gemspec, processor/main.rb, test/unit/test-app-file.rb: .gemspec:
|
217
|
+
need 1.9.2frame main.rb: wrong fn any -> all? But will rewrite more
|
218
|
+
completely later. test-app-file.rb: remove debug statement.
|
219
|
+
|
220
|
+
2010-12-27 rocky <rockyb@rubyforge.org>
|
221
|
+
|
222
|
+
* : commit 5fa8ccdc95a478e19f2a1f4874c8d24663aff36d Author: rocky
|
223
|
+
<rockyb@rubyforge.org> Date: Mon Dec 27 10:48:14 2010 -0500
|
224
|
+
|
225
|
+
2010-12-25 rocky <rockyb@rubyforge.org>
|
226
|
+
|
227
|
+
* lib/trepanning.rb, test/unit/test-app-file.rb: Get ready for 0.0.9
|
228
|
+
release
|
229
|
+
|
230
|
+
2010-12-24 rocky <rockyb@rubyforge.org>
|
231
|
+
|
232
|
+
* NEWS: Update NEWS
|
233
|
+
|
234
|
+
2010-12-24 rocky <rockyb@rubyforge.org>
|
235
|
+
|
236
|
+
* ChangeLog: What's up (ChangeLog).
|
237
|
+
|
1
238
|
2010-12-20 rocky <rockyb@rubyforge.org>
|
2
239
|
|
3
240
|
* processor/breakpoint.rb: Fix bug introduced in recent
|
data/NEWS
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
Feb 1, 2011 (0.1.0)
|
2
|
+
* Add Remote debugging interface. Add options --server --port
|
3
|
+
* Add Syntax highlighting on Ruby and YARV listings and locations
|
4
|
+
* Section highlighting on some commands; italics on error if term mode
|
5
|
+
* Use ;; to allow multiple debugger commands. Document debugger command syntax
|
6
|
+
* include data files for debugging custom-require
|
7
|
+
* Numerous bug fixes and code cleanups
|
8
|
+
|
1
9
|
Dec 25, 2010 (0.0.9)
|
2
10
|
* Minor fixes. Remove some Ruby warnings
|
3
11
|
|
data/Rakefile
CHANGED
@@ -50,12 +50,13 @@ def run_standalone_ruby_files(list)
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
def run_standalone_ruby_file(directory)
|
53
|
+
def run_standalone_ruby_file(directory, opts={})
|
54
54
|
puts ('*' * 10) + ' ' + directory + ' ' + ('*' * 10)
|
55
55
|
Dir.chdir(directory) do
|
56
56
|
Dir.glob('*.rb').each do |ruby_file|
|
57
57
|
puts ('-' * 20) + ' ' + ruby_file + ' ' + ('-' * 20)
|
58
58
|
system(RUBY_PATH, ruby_file)
|
59
|
+
break if $?.exitstatus != 0 && !opts[:continue]
|
59
60
|
end
|
60
61
|
end
|
61
62
|
end
|
@@ -158,7 +159,7 @@ require 'rake/rdoctask'
|
|
158
159
|
desc "Generate rdoc documentation"
|
159
160
|
Rake::RDocTask.new("rdoc") do |rdoc|
|
160
161
|
rdoc.rdoc_dir = 'doc'
|
161
|
-
rdoc.title = "Trepanning #{
|
162
|
+
rdoc.title = "Trepanning #{Trepan::VERSION} Documentation"
|
162
163
|
|
163
164
|
rdoc.rdoc_files.include('lib/*.rb', 'app/*.rb', 'bin/trepan')
|
164
165
|
end
|
data/app/breakpoint.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
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 'thread_frame'
|
4
4
|
|
5
5
|
# Breakpoint objects
|
6
|
-
|
6
|
+
class Trepan
|
7
7
|
class Breakpoint
|
8
8
|
attr_accessor :condition # If non-nil, this is a String to be eval'd
|
9
9
|
# which must be true to enter the debugger
|
@@ -131,11 +131,11 @@ end
|
|
131
131
|
if __FILE__ == $0
|
132
132
|
tf = RubyVM::ThreadFrame.current
|
133
133
|
iseq = tf.iseq
|
134
|
-
b1 =
|
134
|
+
b1 = Trepan::Breakpoint.new(iseq, 0)
|
135
135
|
p b1
|
136
136
|
p b1.source_location
|
137
137
|
p b1.source_container
|
138
|
-
b2 =
|
138
|
+
b2 = Trepan::Breakpoint.new(iseq, 0, :temp => true)
|
139
139
|
p b2
|
140
140
|
puts "b2 id: #{b2.id}"
|
141
141
|
puts "b2 hits: #{b2.hits}"
|
@@ -147,11 +147,11 @@ if __FILE__ == $0
|
|
147
147
|
puts "TypeError (expected): #{e}"
|
148
148
|
end
|
149
149
|
begin
|
150
|
-
b3 =
|
150
|
+
b3 = Trepan::Breakpoint.new(5, iseq.iseq_size)
|
151
151
|
rescue TypeError => e
|
152
152
|
puts "TypeError (expected): #{e}"
|
153
153
|
end
|
154
|
-
puts
|
155
|
-
|
156
|
-
puts
|
154
|
+
puts Trepan::Breakpoint.class_variable_get('@@next_id')
|
155
|
+
Trepan::Breakpoint.reset
|
156
|
+
puts Trepan::Breakpoint.class_variable_get('@@next_id')
|
157
157
|
end
|
data/app/brkptmgr.rb
CHANGED
@@ -1,111 +1,112 @@
|
|
1
|
-
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
1
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
2
|
require 'set'
|
3
3
|
require_relative 'breakpoint'
|
4
|
-
class
|
4
|
+
class Trepan
|
5
|
+
class BreakpointMgr
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
attr_reader :list
|
8
|
+
attr_reader :set
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
def initialize
|
11
|
+
@list = []
|
12
|
+
@next_id = 1
|
13
|
+
@set = Set.new
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
def <<(brkpt)
|
17
|
+
@list << brkpt
|
18
|
+
@set.add(set_key(brkpt))
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
def [](index)
|
22
|
+
raise TypeError,
|
23
|
+
"index #{index} should be a Fixnum, is #{index.class}" unless
|
24
|
+
index.is_a?(Fixnum)
|
25
|
+
@list.detect {|bp| bp.id == index }
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
+
alias detect []
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
def delete(index)
|
31
|
+
bp = detect(index)
|
32
|
+
if bp
|
33
|
+
delete_by_brkpt(bp)
|
34
|
+
return bp
|
35
|
+
else
|
36
|
+
return nil
|
37
|
+
end
|
36
38
|
end
|
37
|
-
end
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
def delete_by_brkpt(delete_bp)
|
41
|
+
@list = @list.reject{|candidate| candidate == delete_bp}
|
42
|
+
@set = Set.new(@list.map{|bp| set_key(bp)})
|
43
|
+
delete_bp.remove! unless @set.member?(set_key(delete_bp))
|
44
|
+
return delete_bp
|
45
|
+
end
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
def add(*args)
|
48
|
+
if args[2]
|
49
|
+
unless args[2].member?(:id)
|
50
|
+
args[2][:id] = @next_id
|
51
|
+
@next_id += 1
|
52
|
+
end
|
53
|
+
else
|
54
|
+
args[2] = {:id => @next_id}
|
50
55
|
@next_id += 1
|
51
56
|
end
|
52
|
-
else
|
53
|
-
args[2] = {:id => @next_id}
|
54
|
-
@next_id += 1
|
55
|
-
end
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
brkpt = Trepan::Breakpoint.new(*args)
|
59
|
+
@list << brkpt
|
60
|
+
@set.add(set_key(brkpt))
|
61
|
+
return brkpt
|
62
|
+
end
|
62
63
|
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
def empty?
|
65
|
+
@list.empty?
|
66
|
+
end
|
66
67
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
def line_breaks(container)
|
69
|
+
result = {}
|
70
|
+
@list.each do |bp|
|
71
|
+
if bp.source_container == container
|
72
|
+
bp.source_location.each do |line|
|
73
|
+
result[line] = bp
|
74
|
+
end
|
73
75
|
end
|
74
76
|
end
|
77
|
+
result
|
75
78
|
end
|
76
|
-
result
|
77
|
-
end
|
78
79
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
80
|
+
def find(iseq, offset, bind)
|
81
|
+
@list.detect do |bp|
|
82
|
+
if bp.enabled? && bp.iseq.equal?(iseq) && bp.offset == offset
|
83
|
+
begin
|
84
|
+
return bp if bp.condition?(bind)
|
85
|
+
rescue
|
86
|
+
end
|
87
|
+
end
|
86
88
|
end
|
87
89
|
end
|
88
|
-
end
|
89
90
|
|
90
|
-
|
91
|
-
|
92
|
-
|
91
|
+
def max
|
92
|
+
@list.map{|bp| bp.id}.max
|
93
|
+
end
|
93
94
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
95
|
+
# Key used in @set to list unique instruction-sequence offsets.
|
96
|
+
def set_key(bp)
|
97
|
+
[bp.iseq, bp.offset]
|
98
|
+
end
|
98
99
|
|
99
|
-
|
100
|
-
|
101
|
-
|
100
|
+
def size
|
101
|
+
@list.size
|
102
|
+
end
|
102
103
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
104
|
+
def reset
|
105
|
+
@list.each{|bp| bp.remove!}
|
106
|
+
@list = []
|
107
|
+
@set = Set.new
|
108
|
+
end
|
107
109
|
end
|
108
|
-
|
109
110
|
end
|
110
111
|
if __FILE__ == $0
|
111
112
|
def bp_status(brkpts, i)
|
@@ -118,12 +119,12 @@ if __FILE__ == $0
|
|
118
119
|
|
119
120
|
frame = RubyVM::ThreadFrame.current
|
120
121
|
iseq = frame.iseq
|
121
|
-
brkpts = BreakpointMgr.new
|
122
|
+
brkpts = Trepan::BreakpointMgr.new
|
122
123
|
brkpts.add(iseq, 0)
|
123
124
|
p brkpts[2]
|
124
125
|
bp_status(brkpts, 1)
|
125
126
|
offset = frame.pc_offset
|
126
|
-
b2 =
|
127
|
+
b2 = Trepan::Breakpoint.new(iseq, offset)
|
127
128
|
brkpts << b2
|
128
129
|
p brkpts.find(b2.iseq, b2.offset, nil)
|
129
130
|
p brkpts[2]
|
@@ -136,10 +137,10 @@ if __FILE__ == $0
|
|
136
137
|
# Two of the same breakpoints but delete 1 and see that the
|
137
138
|
# other still stays
|
138
139
|
offset = frame.pc_offset
|
139
|
-
b2 =
|
140
|
+
b2 = Trepan::Breakpoint.new(iseq, offset)
|
140
141
|
brkpts << b2
|
141
142
|
bp_status(brkpts, 4)
|
142
|
-
b3 =
|
143
|
+
b3 = Trepan::Breakpoint.new(iseq, offset)
|
143
144
|
brkpts << b3
|
144
145
|
bp_status(brkpts, 5)
|
145
146
|
brkpts.delete_by_brkpt(b2)
|