trepanning 0.1.6 → 1.93.32
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/COPYING +57 -0
- data/ChangeLog +585 -736
- data/NEWS +26 -12
- data/README.md +62 -0
- data/Rakefile +15 -9
- data/app/breakpoint.rb +11 -12
- data/app/complete.rb +14 -14
- data/app/core.rb +34 -30
- data/app/default.rb +8 -7
- data/app/markdown.rb +191 -0
- data/app/options.rb +104 -99
- data/app/run.rb +9 -1
- data/app/util.rb +7 -7
- data/bin/trepan +7 -7
- data/interface.rb +0 -4
- data/interface/user.rb +11 -11
- data/io/input.rb +13 -13
- data/lib/trepanning.rb +30 -29
- data/processor.rb +40 -40
- data/processor/command.rb +13 -9
- data/processor/command/alias.rb +21 -15
- data/processor/command/backtrace.rb +27 -19
- data/processor/command/break.rb +24 -21
- data/processor/command/complete.rb +5 -2
- data/processor/command/condition.rb +14 -9
- data/processor/command/debug.rb +8 -8
- data/processor/command/down.rb +6 -6
- data/processor/command/edit.rb +4 -0
- data/processor/command/eval.rb +2 -2
- data/processor/command/exit.rb +12 -9
- data/processor/command/finish.rb +25 -23
- data/processor/command/frame.rb +30 -26
- data/processor/command/help.rb +203 -185
- data/processor/command/help/{command.txt → command.md} +21 -18
- data/processor/command/help/examples.md +20 -0
- data/processor/command/help/filename.md +46 -0
- data/processor/command/help/location.md +34 -0
- data/processor/command/help/suffixes.md +19 -0
- data/processor/command/info.rb +6 -4
- data/processor/command/info_subcmd/breakpoints.rb +13 -13
- data/processor/command/info_subcmd/files.rb +35 -31
- data/processor/command/info_subcmd/frame.rb +82 -33
- data/processor/command/info_subcmd/macro.rb +1 -1
- data/processor/command/info_subcmd/program.rb +8 -5
- data/processor/command/info_subcmd/registers.rb +15 -13
- data/processor/command/kill.rb +23 -17
- data/processor/command/list.rb +63 -56
- data/processor/command/macro.rb +45 -28
- data/processor/command/next.rb +29 -23
- data/processor/command/pp.rb +11 -9
- data/processor/command/pr.rb +10 -8
- data/processor/command/ps.rb +5 -5
- data/processor/command/quit.rb +24 -17
- data/processor/command/raise.rb +6 -6
- data/processor/command/reload.rb +9 -2
- data/processor/command/reload_subcmd/command.rb +4 -4
- data/processor/command/restart.rb +9 -4
- data/processor/command/save.rb +9 -9
- data/processor/command/server.rb +18 -17
- data/processor/command/set.rb +8 -6
- data/processor/command/set_subcmd/confirm.rb +15 -2
- data/processor/command/set_subcmd/different.rb +7 -5
- data/processor/command/set_subcmd/highlight.rb +14 -3
- data/processor/command/set_subcmd/pc.rb +62 -0
- data/processor/command/set_subcmd/sp.rb +8 -2
- data/processor/command/shell.rb +25 -23
- data/processor/command/show.rb +9 -7
- data/processor/command/show_subcmd/confirm.rb +12 -1
- data/processor/command/show_subcmd/highlight.rb +13 -3
- data/processor/command/source.rb +27 -26
- data/processor/command/step.rb +52 -43
- data/processor/command/tbreak.rb +9 -4
- data/processor/command/unalias.rb +9 -7
- data/processor/command/undisplay.rb +11 -7
- data/processor/command/up.rb +18 -13
- data/processor/command/watchg.rb +20 -17
- data/processor/complete.rb +120 -0
- data/processor/default.rb +47 -43
- data/processor/list.rb +23 -6
- data/processor/load_cmds.rb +25 -105
- data/processor/location.rb +104 -96
- data/processor/mock.rb +12 -12
- data/processor/msg.rb +61 -52
- data/processor/validate.rb +36 -27
- data/test/data/fname-with-blank.right +0 -1
- data/test/data/trace-mingw.right +28 -0
- data/test/data/trace.right +0 -2
- data/test/functional/test-raise.rb +3 -0
- data/test/integration/helper.rb +16 -16
- data/test/integration/test-debugger-stop.rb +8 -2
- data/test/integration/test-quit.rb +16 -15
- data/test/integration/test-trace.rb +19 -10
- data/test/unit/cmd-helper.rb +4 -1
- data/test/unit/test-app-complete.rb +3 -1
- data/test/unit/test-app-options.rb +7 -1
- data/test/unit/test-app-run.rb +9 -1
- data/test/unit/test-cmd-alias.rb +1 -1
- data/test/unit/test-cmd-edit.rb +2 -0
- data/test/unit/test-cmd-help.rb +10 -5
- data/test/unit/test-cmd-parse_list_cmd.rb +3 -3
- data/test/unit/test-completion.rb +2 -2
- data/test/unit/test-proc-default.rb +34 -0
- data/trepanning.gemspec +15 -14
- metadata +70 -44
- data/README.textile +0 -50
- data/processor/command/help/examples.txt +0 -16
- data/processor/command/help/filename.txt +0 -40
- data/processor/command/help/location.txt +0 -37
- data/processor/command/help/suffixes.txt +0 -17
- data/processor/command/info_subcmd/registers_subcmd/dfp.rb +0 -28
- data/processor/command/info_subcmd/registers_subcmd/lfp.rb +0 -47
- data/processor/command/nocache.rb +0 -32
- data/processor/command/parsetree.rb +0 -56
data/NEWS
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
(1.93.32) Mar 8, 2015
|
2
|
+
- Remove reference to threadframe
|
3
|
+
|
4
|
+
(1.93.31) Mar 8, 2015
|
5
|
+
|
6
|
+
- Remove threadframe dependency - it's built into patched Ruby
|
7
|
+
- add dependencies for coderay and ansi-termcolor
|
8
|
+
- More subcommand help converted to markdown format.
|
9
|
+
|
10
|
+
(1.93.30) Mar 5, 2015
|
11
|
+
- Make it work on a patched Ruby 1.9.3 p551
|
12
|
+
- include columnize and linecache-tf gems
|
13
|
+
- Help text is rendered via redcloth/markdown
|
14
|
+
|
1
15
|
(0.1.6) Nov 25, 2012
|
2
16
|
- Make it work on Ruby 1.9.3 p327
|
3
17
|
- Incompatible change: Remove aliases 'd' and 'u' for down and up
|
@@ -8,7 +22,7 @@
|
|
8
22
|
- Internal RubyVM::ThreadFrame -> RubyVM::Frame
|
9
23
|
|
10
24
|
Oct 27, 2011 (0.1.4)
|
11
|
-
- Add debugger commands:
|
25
|
+
- Add debugger commands:
|
12
26
|
* info iv (is in ruby-debug)
|
13
27
|
* info variables (is in ruby-debug)
|
14
28
|
* info locals as alternative to "info variables locals" (is in gdb)
|
@@ -48,7 +62,7 @@ June 12, 2011 (0.1.3) Fleetwood Release
|
|
48
62
|
- Add options from ruby-debug:
|
49
63
|
* --cd
|
50
64
|
* --include
|
51
|
-
* --require
|
65
|
+
* --require
|
52
66
|
* --debug
|
53
67
|
- fix bugs, and improve help
|
54
68
|
|
@@ -64,7 +78,7 @@ March 15, 2011 (0.1.1)
|
|
64
78
|
* VM offsets are now specified via @ rather than o or O
|
65
79
|
* Filenames can be quoted and blanks and characters inside escaped
|
66
80
|
- Document command syntax by adding it as a new category with sub help
|
67
|
-
- More controlled parsing of method names
|
81
|
+
- More controlled parsing of method names
|
68
82
|
- Add eval (no args) and eval? to run current source line or source line
|
69
83
|
eval? strips:
|
70
84
|
* leading "if", "elsif", "while", "until" "return" or "case", or "unless"
|
@@ -72,17 +86,17 @@ March 15, 2011 (0.1.1)
|
|
72
86
|
- Save and restore some debugger state across a restart
|
73
87
|
- Redo command completion
|
74
88
|
- "disassemble" command: allow disassembly of specified line numbers
|
75
|
-
- GNU Readline:
|
76
|
-
* Start GNU readline tab (command) completion.
|
89
|
+
- GNU Readline:
|
90
|
+
* Start GNU readline tab (command) completion.
|
77
91
|
* Save and restore command history
|
78
92
|
* add --readline and --no-readline options to trepanx
|
79
93
|
- Macros can return more than one command now
|
80
|
-
- help
|
94
|
+
- help
|
81
95
|
* "help macros" shows all macro names
|
82
96
|
* "help aliases" shows all alias names
|
83
97
|
* "help *" lists macros and aliases now
|
84
98
|
- start "info line"
|
85
|
-
- "info file" has/shows File::stat()'s mtime and ctime
|
99
|
+
- "info file" has/shows File::stat()'s mtime and ctime
|
86
100
|
- be able to pass --verbose to ruby to rake
|
87
101
|
|
88
102
|
Feb 1, 2011 (0.1.0)
|
@@ -90,7 +104,7 @@ Feb 1, 2011 (0.1.0)
|
|
90
104
|
* Add Syntax highlighting on Ruby and YARV listings and locations
|
91
105
|
* Section highlighting on some commands; italics on error if term mode
|
92
106
|
* Use ;; to allow multiple debugger commands. Document debugger command syntax
|
93
|
-
* include data files for debugging custom-require
|
107
|
+
* include data files for debugging custom-require
|
94
108
|
* Numerous bug fixes and code cleanups
|
95
109
|
|
96
110
|
Dec 25, 2010 (0.0.9)
|
@@ -103,10 +117,10 @@ Dec 10, 2010 (0.0.8) Phel. Mad release
|
|
103
117
|
* debugger { code here } work better
|
104
118
|
* source -q silences all prompt and debugger messages
|
105
119
|
* Show instruction-sequence options on demand
|
106
|
-
* Nuke debugger set_restart => true. We now have a more reliable way to
|
120
|
+
* Nuke debugger set_restart => true. We now have a more reliable way to
|
107
121
|
do this. Rubinius showing the way here.
|
108
122
|
* Improvements to the "list" command.
|
109
|
-
* Get/show eval string using rb-threadframe patch
|
123
|
+
* Get/show eval string using rb-threadframe patch
|
110
124
|
|
111
125
|
Oct 27, 2010 (0.0.6)
|
112
126
|
|
@@ -122,11 +136,11 @@ First release under the name trepanning
|
|
122
136
|
|
123
137
|
* Add gdb-like "directory" command
|
124
138
|
* Add "set max list" to set number of lines to list by default.
|
125
|
-
* "break line" searches parent instruction sequences in the same file. This
|
139
|
+
* "break line" searches parent instruction sequences in the same file. This
|
126
140
|
should allow more line numbers to be breakpointable.
|
127
141
|
* remap file name in custom_requre.rb
|
128
142
|
* Some small bug fixes
|
129
|
-
|
143
|
+
|
130
144
|
Sept 13, 2010
|
131
145
|
|
132
146
|
First public (gemcutter) release.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
The trepanning debugger gdb-like debugger. As such, it is both a high-level and low-level debugger. It is a also a rewrite of *ruby-debug*. But to provide all of the functionality that it has, it requires a patched version of MRI Ruby 1.9.3 or 1.9.2 found the [rb-threadframe project](https://rocky/rb-threadframe). The additional run-time support in the MRI is what gives this some debugger power that you won't find in other MRI 1.9 debuggers.
|
2
|
+
|
3
|
+
See the [installation instructions](https://github.com/rocky/rb-trepanning/wiki/How-to-Install-rb-trepanning).
|
4
|
+
|
5
|
+
There is a [google group mailing list](http://groups.google.com/group/ruby-debugger) for Ruby debuggers.
|
6
|
+
|
7
|
+
If *trepanning* is installed, here is how to run:
|
8
|
+
|
9
|
+
```console
|
10
|
+
$ trepan ruby-program [program]
|
11
|
+
```
|
12
|
+
|
13
|
+
If your program needs options of its own:
|
14
|
+
|
15
|
+
```console
|
16
|
+
$ trepan -- ruby-program [program args...]
|
17
|
+
```
|
18
|
+
|
19
|
+
If you want to run from the source tree you can do that too:
|
20
|
+
|
21
|
+
```console
|
22
|
+
|
23
|
+
cd place-where-trepan-is-installed
|
24
|
+
./bin/trepan -- ruby-program [program args...]
|
25
|
+
```
|
26
|
+
|
27
|
+
Running from inside *irb*:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
require 'trepanning'
|
31
|
+
Trepan.debug { your code }
|
32
|
+
```
|
33
|
+
|
34
|
+
The return value from Trepan is the return value of the block, i.e. the final value in the block.
|
35
|
+
|
36
|
+
You can run the same thing inside your Ruby program, but probably you don't want to give a block. Instead, you may want to have debugging start on the next statement in the code:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
require 'trepan'
|
40
|
+
Trepan.debug # Don't stop here...
|
41
|
+
work # but stop here.
|
42
|
+
```
|
43
|
+
|
44
|
+
The above is really shorthand for something like:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
$trepan = Trepan.new
|
48
|
+
$trepan.debugger
|
49
|
+
```
|
50
|
+
|
51
|
+
The global variable *$trepan* set holds debugger settings, such as `autolist` or `autoeval` settings and breakpoint information.
|
52
|
+
|
53
|
+
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:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
|
57
|
+
# ... work, work, work
|
58
|
+
mydbg.debugger(:immediate=>true) # enter debugger here
|
59
|
+
# ... work, work, work
|
60
|
+
```
|
61
|
+
|
62
|
+
There is extensive on-line help. Run `help` inside the debugger.
|
data/Rakefile
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'rubygems'
|
4
4
|
|
5
5
|
ROOT_DIR = File.dirname(__FILE__)
|
6
|
+
GEM_PROG = ENV['GEM_PROG'] || 'gem'
|
6
7
|
Gemspec_filename='trepanning.gemspec'
|
7
8
|
require_relative './app/options'
|
8
9
|
|
@@ -15,7 +16,7 @@ desc "Build the gem"
|
|
15
16
|
task :package=>:gem
|
16
17
|
task :gem=>:gemspec do
|
17
18
|
Dir.chdir(ROOT_DIR) do
|
18
|
-
sh "
|
19
|
+
sh "#{GEM_PROG} build #{Gemspec_filename}"
|
19
20
|
FileUtils.mkdir_p 'pkg'
|
20
21
|
FileUtils.mv gemspec.file_name, 'pkg'
|
21
22
|
end
|
@@ -24,7 +25,7 @@ end
|
|
24
25
|
desc 'Install the gem locally'
|
25
26
|
task :install => :gem do
|
26
27
|
Dir.chdir(ROOT_DIR) do
|
27
|
-
sh %{
|
28
|
+
sh %{#{GEM_PROG} install --local pkg/#{gemspec.file_name}}
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
@@ -96,7 +97,7 @@ task :test do
|
|
96
97
|
e
|
97
98
|
end
|
98
99
|
end.compact
|
99
|
-
|
100
|
+
|
100
101
|
exceptions.each {|e| puts e;puts e.backtrace }
|
101
102
|
raise 'Test failures' unless exceptions.empty?
|
102
103
|
end
|
@@ -145,6 +146,11 @@ task :'check:functional' do
|
|
145
146
|
run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} test functional)))
|
146
147
|
end
|
147
148
|
|
149
|
+
desc 'Run integration tests in standalone mode.'
|
150
|
+
task :'check:functional' do
|
151
|
+
run_standalone_ruby_file(File.join(%W(#{ROOT_DIR} test ingtegration)))
|
152
|
+
end
|
153
|
+
|
148
154
|
desc 'Run command parser grammar.'
|
149
155
|
task :'check:cmd_parse' do
|
150
156
|
sh "kpeg --test --debug #{File.join(ROOT_DIR, %w(app cmd_parse.kpeg))}"
|
@@ -153,12 +159,12 @@ end
|
|
153
159
|
desc 'Generate command parser.'
|
154
160
|
task :'cmd_parse' do
|
155
161
|
require 'tmpdir'
|
156
|
-
temp_file =
|
157
|
-
File.join(Dir.tmpdir,
|
162
|
+
temp_file =
|
163
|
+
File.join(Dir.tmpdir,
|
158
164
|
Dir::Tmpname.make_tmpname(['cmd_parser_', '.rb'], nil))
|
159
165
|
|
160
|
-
sh("kpeg --name CmdParse --verbose --stand-alone " +
|
161
|
-
"#{File.join(ROOT_DIR, %w(app cmd_parse.kpeg))} " +
|
166
|
+
sh("kpeg --name CmdParse --verbose --stand-alone " +
|
167
|
+
"#{File.join(ROOT_DIR, %w(app cmd_parse.kpeg))} " +
|
162
168
|
"--output #{temp_file}")
|
163
169
|
end
|
164
170
|
|
@@ -188,7 +194,7 @@ Rake::RDocTask.new("rdoc") do |rdoc|
|
|
188
194
|
rdoc.rdoc_dir = 'doc'
|
189
195
|
rdoc.title = "Trepanning #{Trepan::VERSION} Documentation"
|
190
196
|
|
191
|
-
rdoc.rdoc_files.include(%w(lib/*.rb
|
197
|
+
rdoc.rdoc_files.include(%w(lib/*.rb
|
192
198
|
app/*.rb intf/*.rb io/*.rb
|
193
199
|
bin/trepan
|
194
200
|
))
|
@@ -216,5 +222,5 @@ task :rm_tilde_backups do
|
|
216
222
|
end
|
217
223
|
|
218
224
|
desc 'Remove built files'
|
219
|
-
task :clean => [:clobber_package, :clobber_rdoc, :rm_patch_residue,
|
225
|
+
task :clean => [:clobber_package, :clobber_rdoc, :rm_patch_residue,
|
220
226
|
:rm_tilde_backups]
|
data/app/breakpoint.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010,
|
3
|
-
require 'thread_frame'
|
2
|
+
# Copyright (C) 2010-2011, 2013, 2015 Rocky Bernstein <rockyb@rubyforge.net>
|
4
3
|
|
5
4
|
# Breakpoint objects
|
6
5
|
class Trepan
|
7
6
|
class Breakpoint
|
8
7
|
attr_accessor :condition # If non-nil, this is a String to be eval'd
|
9
8
|
# which must be true to enter the debugger
|
10
|
-
attr_accessor :hits # Fixnum. The number of
|
9
|
+
attr_accessor :hits # Fixnum. The number of times a breakpoint
|
11
10
|
# has been hit (with a true condition). Do
|
12
11
|
# we want to (also) record hits independent
|
13
12
|
# of the condition?
|
@@ -19,7 +18,7 @@ class Trepan
|
|
19
18
|
attr_reader :offset # Fixnum. Offset into an instruction
|
20
19
|
# sequence for the location of the
|
21
20
|
# breakpoint
|
22
|
-
attr_reader :negate # Boolean. Negate sense of condition. Used in
|
21
|
+
attr_reader :negate # Boolean. Negate sense of condition. Used in
|
23
22
|
# break if .. and break unless ..
|
24
23
|
# breakpoint
|
25
24
|
attr_reader :type # String. 'line' if breakpoint requested
|
@@ -35,20 +34,20 @@ class Trepan
|
|
35
34
|
:negate => false,
|
36
35
|
:type => 'line',
|
37
36
|
} unless defined?(BRKPT_DEFAULT_SETTINGS)
|
38
|
-
|
37
|
+
|
39
38
|
def initialize(iseq, offset, opts = {})
|
40
|
-
raise TypeError,
|
41
|
-
"#{iseq} is not an instruction sequence" unless
|
39
|
+
raise TypeError,
|
40
|
+
"#{iseq} is not an instruction sequence" unless
|
42
41
|
iseq.is_a?(RubyVM::InstructionSequence)
|
43
42
|
@iseq = iseq
|
44
43
|
|
45
|
-
raise TypeError,
|
46
|
-
"offset #{offset.inspect} not found in instruction sequence" unless
|
44
|
+
raise TypeError,
|
45
|
+
"offset #{offset.inspect} not found in instruction sequence" unless
|
47
46
|
iseq.offset2lines(offset)
|
48
47
|
@offset = iseq
|
49
48
|
|
50
|
-
raise TypeError,
|
51
|
-
"type mismatch: #{offset.class} given, Fixnum expected" unless
|
49
|
+
raise TypeError,
|
50
|
+
"type mismatch: #{offset.class} given, Fixnum expected" unless
|
52
51
|
offset.is_a?(Fixnum)
|
53
52
|
@offset = offset
|
54
53
|
|
@@ -60,7 +59,7 @@ class Trepan
|
|
60
59
|
@hits = 0
|
61
60
|
|
62
61
|
unless @id
|
63
|
-
@id = @@next_id
|
62
|
+
@id = @@next_id
|
64
63
|
@@next_id += 1
|
65
64
|
end
|
66
65
|
raise RuntimeError,
|
data/app/complete.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
1
|
+
# Copyright (C) 2011, 2013 Rocky Bernstein <rockyb@rubyforge.net>
|
2
2
|
|
3
3
|
class Trepan
|
4
4
|
|
@@ -12,21 +12,21 @@ class Trepan
|
|
12
12
|
def complete_token(complete_ary, prefix)
|
13
13
|
complete_ary.select { |cmd| cmd.to_s.start_with?(prefix) }.sort
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def complete_token_with_next(complete_hash, prefix, cmd_prefix='')
|
17
17
|
result = []
|
18
|
-
complete_hash.each do |cmd_name, cmd_obj|
|
19
|
-
result << [cmd_name.to_s[cmd_prefix.size..-1], cmd_obj] if
|
18
|
+
complete_hash.each do |cmd_name, cmd_obj|
|
19
|
+
result << [cmd_name.to_s[cmd_prefix.size..-1], cmd_obj] if
|
20
20
|
cmd_name.to_s.start_with?(cmd_prefix + prefix)
|
21
21
|
end
|
22
22
|
result.sort{|a, b| a[0] <=> b[0]}
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
# Find all starting matches in Hash +aliases+ that start with +prefix+,
|
26
26
|
# but filter out any matches already in +expanded+.
|
27
27
|
def complete_token_filtered(aliases, prefix, expanded)
|
28
28
|
complete_ary = aliases.keys
|
29
|
-
complete_ary.select { |cmd|
|
29
|
+
complete_ary.select { |cmd|
|
30
30
|
cmd.to_s.start_with?(prefix) && ! expanded.member?(aliases[cmd])}.sort
|
31
31
|
end
|
32
32
|
|
@@ -37,31 +37,31 @@ class Trepan
|
|
37
37
|
complete_ary = aliases.keys
|
38
38
|
expanded_ary = expanded.keys
|
39
39
|
result = []
|
40
|
-
complete_ary.each do |cmd|
|
41
|
-
if cmd.to_s.start_with?(prefix) &&
|
40
|
+
complete_ary.each do |cmd|
|
41
|
+
if cmd.to_s.start_with?(prefix) &&
|
42
42
|
!expanded_ary.member?(aliases[cmd])
|
43
|
-
result << [cmd, commands[aliases[cmd]]]
|
43
|
+
result << [cmd, commands[aliases[cmd]]]
|
44
44
|
end
|
45
45
|
end
|
46
|
-
result
|
46
|
+
result.sort
|
47
47
|
end
|
48
48
|
|
49
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
|
50
|
+
# the token and the next blank position after the token or
|
51
51
|
# str.size if this is the last token. Tokens are delimited by
|
52
52
|
# white space.
|
53
53
|
def next_token(str, start_pos)
|
54
54
|
look_at = str[start_pos..-1]
|
55
55
|
next_nonblank_pos = start_pos + (look_at =~ /\S/ || 0)
|
56
|
-
next_blank_pos =
|
56
|
+
next_blank_pos =
|
57
57
|
if next_match = str[next_nonblank_pos..-1] =~ /\s/
|
58
|
-
next_nonblank_pos + next_match
|
58
|
+
next_nonblank_pos + next_match
|
59
59
|
else
|
60
60
|
str.size
|
61
61
|
end
|
62
62
|
return [next_blank_pos, str[next_nonblank_pos...next_blank_pos]]
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
data/app/core.rb
CHANGED
@@ -8,7 +8,7 @@ class Trepan
|
|
8
8
|
# This class contains the Trepan core routines, such as an event
|
9
9
|
# processor which is responsible of handling what to do when an event is
|
10
10
|
# triggered.
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# See also 'rdbgr' the top-level Trepan class and command-line routine
|
13
13
|
# which ultimately will call this.
|
14
14
|
|
@@ -28,24 +28,24 @@ class Trepan
|
|
28
28
|
attr_accessor :processor # Trepan::CmdProc instance
|
29
29
|
attr_reader :settings # Hash of things you can configure
|
30
30
|
attr_accessor :step_count # Fixnum. Negative means no tracing,
|
31
|
-
# 0 means stop on next event, 1 means
|
31
|
+
# 0 means stop on next event, 1 means
|
32
32
|
# ignore one event. Step events gives the
|
33
33
|
# kind of things to count as a step.
|
34
|
-
attr_accessor :step_events # bitmask of events - used only when
|
34
|
+
attr_accessor :step_events # bitmask of events - used only when
|
35
35
|
# we are stepping
|
36
|
-
attr_accessor :unmaskable_events
|
36
|
+
attr_accessor :unmaskable_events
|
37
37
|
|
38
38
|
include Trace
|
39
39
|
|
40
40
|
unless defined?(CORE_DEFAULT_SETTINGS)
|
41
41
|
# Synchronous events
|
42
|
-
STEPPING_EVENT_MASK =
|
42
|
+
STEPPING_EVENT_MASK =
|
43
43
|
LINE_EVENT_MASK | CLASS_EVENT_MASK | CALL_EVENT_MASK |
|
44
44
|
RETURN_EVENT_MASK | C_CALL_EVENT_MASK | C_RETURN_EVENT_MASK |
|
45
45
|
INSN_EVENT_MASK | BRKPT_EVENT_MASK | YIELD_EVENT_MASK |
|
46
46
|
LEAVE_EVENT_MASK | SEND_EVENT_MASK
|
47
47
|
|
48
|
-
ASYNC_EVENT_MASK =
|
48
|
+
ASYNC_EVENT_MASK =
|
49
49
|
RAISE_EVENT_MASK | VM_EVENT_MASK | SWITCH_EVENT_MASK
|
50
50
|
|
51
51
|
CORE_DEFAULT_SETTINGS = {
|
@@ -57,11 +57,11 @@ class Trepan
|
|
57
57
|
|
58
58
|
# Not sure what the "right" set really is. The below is just
|
59
59
|
# a guess. Use "set events" or customize in ~/.trepanrc
|
60
|
-
:step_events =>
|
60
|
+
:step_events =>
|
61
61
|
# (DEFAULT_EVENT_MASK | INSN_EVENT_MASK) &
|
62
62
|
(DEFAULT_EVENT_MASK ) &
|
63
63
|
~(C_CALL_EVENT_MASK | C_RETURN_EVENT_MASK | SEND_EVENT_MASK)
|
64
|
-
}
|
64
|
+
}
|
65
65
|
|
66
66
|
end
|
67
67
|
|
@@ -80,6 +80,7 @@ class Trepan
|
|
80
80
|
@event_proc = self.method(hook_name).to_proc
|
81
81
|
@processor = CmdProcessor.new(self, @settings[:cmdproc_opts])
|
82
82
|
@unmaskable_events = %w(brkpt raise switch vm)
|
83
|
+
@current_thread = nil
|
83
84
|
end
|
84
85
|
|
85
86
|
def step_events_list
|
@@ -94,15 +95,18 @@ class Trepan
|
|
94
95
|
def event_processor(event, frame, arg=nil)
|
95
96
|
|
96
97
|
return_exception = nil
|
97
|
-
# FIXME: check for breakpoints or other unmaskable events.
|
98
|
+
# FIXME: check for breakpoints or other unmaskable events.
|
98
99
|
# For now there are none.
|
99
100
|
|
101
|
+
return if @mutex.locked? and Thread.current == @current_thread
|
102
|
+
|
100
103
|
@mutex.synchronize do
|
104
|
+
@current_thread = Thread.current
|
101
105
|
@frame = frame
|
102
106
|
while @frame.type == 'IFUNC'
|
103
107
|
@frame = @frame.prev
|
104
108
|
end
|
105
|
-
|
109
|
+
|
106
110
|
if @step_count > 0
|
107
111
|
@step_count -= 1
|
108
112
|
break
|
@@ -112,52 +116,52 @@ class Trepan
|
|
112
116
|
|
113
117
|
@event = event
|
114
118
|
@hook_arg = arg
|
115
|
-
|
119
|
+
|
116
120
|
### debug:
|
117
121
|
### puts "#{frame.file[1]}:#{frame.source_location[0]}:in `#{frame.method}' #{event}" # if %w(line).member?(event)
|
118
122
|
@processor.process_commands(@frame)
|
119
|
-
|
123
|
+
|
120
124
|
# FIXME: There should be a Trace.event_mask which should return the first
|
121
125
|
# mask that matches the given trace hook.
|
122
126
|
if @step_count < 0
|
123
127
|
# If we are continuing, no need to stop at stepping events.
|
124
|
-
Trace.event_masks[0] &= ~STEPPING_EVENT_MASK
|
128
|
+
Trace.event_masks[0] &= ~STEPPING_EVENT_MASK
|
125
129
|
else
|
126
|
-
# Set to trace only those events we are interested in.
|
127
|
-
|
130
|
+
# Set to trace only those events we are interested in.
|
131
|
+
|
128
132
|
# Don't step/trace into Ruby routines called from here in the code
|
129
133
|
# below (e.g. "trace_hooks").
|
130
134
|
step_count_save = step_count
|
131
|
-
@step_count = -1
|
132
|
-
|
135
|
+
@step_count = -1
|
136
|
+
|
133
137
|
unless @event_proc == dbgr.trace_filter.hook_proc
|
134
|
-
dbgr.trace_filter.add_trace_func(@event_proc)
|
138
|
+
dbgr.trace_filter.add_trace_func(@event_proc)
|
135
139
|
## debug: p '+++1', @event_proc, dbgr.trace_filter.hook_proc
|
136
140
|
end
|
137
|
-
|
138
|
-
# FIXME: this doesn't work. Bug in rb-trace?
|
141
|
+
|
142
|
+
# FIXME: this doesn't work. Bug in rb-trace?
|
139
143
|
# Trace.event_masks[0] = @step_events | @async_events
|
140
|
-
RubyVM::TraceHook::trace_hooks[0].event_mask =
|
144
|
+
RubyVM::TraceHook::trace_hooks[0].event_mask =
|
141
145
|
@step_events | @async_events
|
142
146
|
@step_count = step_count_save
|
143
147
|
end
|
144
|
-
|
148
|
+
|
145
149
|
# Nil out variables just in case...
|
146
|
-
|
150
|
+
|
147
151
|
return_exception = @exception
|
148
152
|
@frame = @event = @arg = @exception = nil
|
149
|
-
|
153
|
+
|
150
154
|
end
|
151
|
-
return return_exception
|
155
|
+
return return_exception
|
152
156
|
end
|
153
157
|
|
154
|
-
# A Ruby 1.8-style event processor. We don't use file, line, id, bind.
|
158
|
+
# A Ruby 1.8-style event processor. We don't use file, line, id, bind.
|
155
159
|
def old_event_processor(event, file, line, id, bind, klass)
|
156
160
|
event_processor(event, RubyVM::Frame.current.prev)
|
157
161
|
end
|
158
162
|
|
159
163
|
# Call this from inside the program you want to get a synchronous
|
160
|
-
# call to the debugger. set prev_count to the number of levels
|
164
|
+
# call to the debugger. set prev_count to the number of levels
|
161
165
|
# *before* the caller you want to skip.
|
162
166
|
def debugger(prev_count=0)
|
163
167
|
while @frame && @frame.type == 'IFUNC'
|
@@ -167,7 +171,7 @@ class Trepan
|
|
167
171
|
@step_count = 0 # Make event processor stop
|
168
172
|
event_processor('debugger-call', frame)
|
169
173
|
end
|
170
|
-
|
174
|
+
|
171
175
|
# A trace-hook processor for 'trace var'
|
172
176
|
def trace_var_processor(var_name, value)
|
173
177
|
frame = RubyVM::Frame.current.prev(2)
|
@@ -178,8 +182,8 @@ class Trepan
|
|
178
182
|
end
|
179
183
|
|
180
184
|
# Stop future tracing into the debugger
|
181
|
-
Thread.current.tracing = true
|
182
|
-
|
185
|
+
Thread.current.tracing = true
|
186
|
+
|
183
187
|
@step_count = 0 # Make event processor stop
|
184
188
|
event_processor('trace-var', frame, [var_name, value])
|
185
189
|
end
|