trepanning 1.93.35 → 2.15.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ChangeLog +491 -55
- data/LICENSE +1 -1
- data/NEWS +18 -14
- data/README.md +5 -22
- data/Rakefile +22 -1
- data/app/breakpoint.rb +5 -3
- data/app/core.rb +147 -179
- data/app/default.rb +47 -46
- data/app/file.rb +6 -7
- data/app/frame.rb +183 -176
- data/app/markdown.rb +2 -9
- data/app/options.rb +1 -1
- data/app/run.rb +71 -37
- data/interface/script.rb +8 -8
- data/io.rb +19 -20
- data/lib/trepanning.rb +292 -297
- data/processor.rb +332 -344
- data/processor/breakpoint.rb +98 -96
- data/processor/command/base/submgr.rb +9 -9
- data/processor/command/break.rb +40 -38
- data/processor/command/continue.rb +15 -10
- data/processor/command/debug.rb +6 -25
- data/processor/command/delete.rb +21 -12
- data/processor/command/directory.rb +15 -13
- data/processor/command/disable.rb +12 -9
- data/processor/command/disassemble.rb +80 -74
- data/processor/command/display.rb +15 -12
- data/processor/command/down.rb +8 -3
- data/processor/command/edit.rb +37 -23
- data/processor/command/enable.rb +11 -8
- data/processor/command/eval.rb +24 -22
- data/processor/command/finish.rb +50 -48
- data/processor/command/help.rb +1 -1
- data/processor/command/info_subcmd/breakpoints.rb +7 -7
- data/processor/command/info_subcmd/files.rb +195 -196
- data/processor/command/info_subcmd/frame.rb +7 -4
- data/processor/command/info_subcmd/locals.rb +29 -12
- data/processor/command/info_subcmd/program.rb +48 -39
- data/processor/command/info_subcmd/registers_subcmd/ep.rb +46 -0
- data/processor/command/info_subcmd/registers_subcmd/helper.rb +32 -35
- data/processor/command/info_subcmd/registers_subcmd/sp.rb +29 -23
- data/processor/command/info_subcmd/return.rb +28 -10
- data/processor/command/info_subcmd/variables_subcmd/class.rb +3 -3
- data/processor/command/info_subcmd/variables_subcmd/constants.rb +77 -0
- data/processor/command/info_subcmd/variables_subcmd/globals.rb +7 -7
- data/processor/command/info_subcmd/variables_subcmd/instance.rb +68 -22
- data/processor/command/info_subcmd/variables_subcmd/locals.rb +148 -67
- data/processor/command/list.rb +14 -8
- data/processor/command/macro.rb +1 -1
- data/processor/command/next.rb +1 -0
- data/processor/command/set_subcmd/auto.rb +3 -3
- data/processor/command/set_subcmd/different.rb +30 -29
- data/processor/command/set_subcmd/events.rb +74 -48
- data/processor/command/set_subcmd/max_subcmd/list.rb +12 -5
- data/processor/command/set_subcmd/max_subcmd/width.rb +28 -19
- data/processor/command/set_subcmd/register.rb +37 -0
- data/processor/command/set_subcmd/register_subcmd/pc.rb +67 -0
- data/processor/command/set_subcmd/register_subcmd/sp.rb +75 -0
- data/processor/command/set_subcmd/reload.rb +12 -10
- data/processor/command/set_subcmd/return.rb +68 -44
- data/processor/command/shell.rb +3 -2
- data/processor/command/show_subcmd/different.rb +17 -14
- data/processor/command/show_subcmd/events.rb +25 -25
- data/processor/default.rb +1 -1
- data/processor/eval.rb +14 -15
- data/processor/frame.rb +43 -36
- data/processor/help.rb +5 -5
- data/processor/hook.rb +26 -29
- data/processor/location.rb +54 -51
- data/processor/mock.rb +4 -3
- data/processor/running.rb +113 -103
- data/processor/validate.rb +401 -373
- data/test/data/debug.cmd +8 -0
- data/test/data/debug.right +13 -0
- data/test/data/debugger-stop.right +6 -4
- data/test/data/fname-with-blank.cmd +1 -1
- data/test/data/fname-with-blank.right +5 -0
- data/test/data/pc.cmd +8 -0
- data/test/data/pc.right +10 -0
- data/test/data/quit.right +3 -1
- data/test/data/trace.cmd +2 -2
- data/test/data/trace.right +41 -20
- data/test/example/assign.rb +6 -0
- data/test/functional/fn_helper.rb +11 -17
- data/test/functional/test-break-long.rb +15 -16
- data/test/functional/test-break.rb +6 -8
- data/test/functional/test-condition.rb +8 -10
- data/test/functional/test-debugger-call-bug.rb +21 -22
- data/test/functional/test-delete.rb +57 -59
- data/test/functional/test-eval.rb +101 -103
- data/test/functional/test-finish.rb +24 -33
- data/test/functional/test-immediate-step-bug.rb +6 -10
- data/test/functional/test-next.rb +64 -65
- data/test/functional/test-raise.rb +63 -64
- data/test/functional/test-recursive-bt.rb +81 -76
- data/test/functional/test-remap.rb +6 -7
- data/test/functional/test-return.rb +44 -38
- data/test/functional/test-step.rb +55 -53
- data/test/functional/test-stepbug.rb +6 -9
- data/test/functional/test-watchg.rb +40 -39
- data/test/integration/test-debug.rb +12 -0
- data/test/integration/test-debugger-stop.rb +7 -7
- data/test/integration/test-pc.rb +24 -0
- data/test/integration/test-trace.rb +1 -1
- data/test/unit/cmd-helper.rb +0 -1
- data/test/unit/test-app-brkpt.rb +21 -21
- data/test/unit/test-app-brkptmgr.rb +7 -8
- data/test/unit/test-app-display.rb +3 -4
- data/test/unit/test-app-frame.rb +4 -5
- data/test/unit/test-base-subsubcmd.rb +2 -2
- data/test/unit/test-cmd-break.rb +6 -6
- data/test/unit/test-cmd-endisable.rb +7 -6
- data/test/unit/test-cmd-parse_list_cmd.rb +24 -24
- data/test/unit/test-io-tcpserver.rb +39 -35
- data/test/unit/test-proc-default.rb +23 -22
- data/test/unit/test-proc-eval.rb +1 -2
- data/test/unit/test-proc-frame.rb +8 -9
- data/test/unit/test-proc-list.rb +1 -1
- data/test/unit/test-proc-location.rb +2 -2
- data/test/unit/test-proc-main.rb +10 -10
- data/test/unit/test-proc-validate.rb +11 -13
- data/test/unit/test-subcmd-help.rb +1 -2
- data/trepanning.gemspec +8 -13
- metadata +44 -95
- data/COPYING +0 -57
- data/data/custom_require.rb +0 -44
- data/data/perldb.bindings +0 -17
- data/data/prelude.rb +0 -38
- data/processor/command/info_subcmd/variables_subcmd/constant.rb +0 -41
- data/processor/command/raise.rb +0 -48
- data/processor/command/set_subcmd/pc.rb +0 -62
- data/processor/command/set_subcmd/sp.rb +0 -67
- data/processor/eventbuf.rb +0 -133
data/LICENSE
CHANGED
data/NEWS
CHANGED
@@ -1,22 +1,26 @@
|
|
1
|
-
(
|
2
|
-
- remove stray space after backtick in markdown
|
3
|
-
- list command continues where it last left off
|
4
|
-
- empty debugger command repeats last command
|
5
|
-
- Use markdown in Gem description
|
1
|
+
(2.15.33) Mar 8, 2015
|
6
2
|
|
7
|
-
|
8
|
-
-
|
9
|
-
|
10
|
-
(1.93.31) Mar 8, 2015
|
11
|
-
|
12
|
-
- Remove threadframe dependency - it's built into patched Ruby
|
3
|
+
- Remove threadframe dependency - it's built into patched Ruby, replace with
|
4
|
+
rubyvm-frame.rb
|
13
5
|
- add dependencies for coderay and ansi-termcolor
|
14
6
|
- More subcommand help converted to markdown format.
|
15
7
|
|
16
|
-
(
|
17
|
-
- Make it work on a patched Ruby 1.
|
18
|
-
|
8
|
+
(2.15.30) Mar 5, 2015
|
9
|
+
- Make it work on a patched Ruby 2.1.5 with runtime debugger support
|
10
|
+
This means:
|
11
|
+
* high-speed breakpoints, "step over" (next), and "step out" (finish)
|
12
|
+
* when stopped in a C function, we can get parameter values
|
13
|
+
* the source location of C functions is memory address (gdb can
|
14
|
+
use this)
|
15
|
+
* VM inspection, including sp, pc, instruction sequences,
|
16
|
+
and local table
|
17
|
+
* can change return values in Ruby code, often
|
18
|
+
* can see/set the runtime event masks debugger triggers on
|
19
|
+
* can get the eval string when stopped in an eval()
|
19
20
|
- Help text is rendered via redcloth/markdown
|
21
|
+
- When we are in a raise event which is non-local, indicate that
|
22
|
+
- Remove aliases 'd' and 'u' for "down" and "up"; gdb has different meanings for
|
23
|
+
these letters
|
20
24
|
|
21
25
|
(0.1.6) Nov 25, 2012
|
22
26
|
- Make it work on Ruby 1.9.3 p327
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
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 [
|
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 2.1.5, 1.9.3 or 1.9.2 found the [ruby-debugger-runtime project](https://sourceforge.net/projects/ruby-debugger-runtime/). The additional run-time support in the MRI is what gives this [powerful features](https://github.com/rocky/rb-trepanning/wiki/Cool-things) that you won't find in other MRI 2.1 or 1.9 debuggers that don't use this runtime.
|
2
2
|
|
3
3
|
See the [installation instructions](https://github.com/rocky/rb-trepanning/wiki/How-to-Install-rb-trepanning).
|
4
4
|
|
@@ -36,27 +36,10 @@ The return value from Trepan is the return value of the block, i.e. the final va
|
|
36
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
37
|
|
38
38
|
```ruby
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
require 'trepanning'
|
40
|
+
...
|
41
|
+
debugger # stop here
|
42
42
|
```
|
43
43
|
|
44
|
-
The above is really shorthand for something like:
|
45
44
|
|
46
|
-
|
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.
|
45
|
+
There is extensive on-line help, much in markdown format that displays nicely in a terminal. Run `help` inside the debugger.
|
data/Rakefile
CHANGED
@@ -1,12 +1,33 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
# -*- Ruby -*-
|
3
3
|
require 'rubygems'
|
4
|
+
require 'rbconfig'
|
4
5
|
|
5
|
-
ROOT_DIR = File.dirname(__FILE__)
|
6
6
|
GEM_PROG = ENV['GEM_PROG'] || 'gem'
|
7
|
+
ROOT_DIR = File.dirname(__FILE__)
|
7
8
|
Gemspec_filename='trepanning.gemspec'
|
8
9
|
require_relative './app/options'
|
9
10
|
|
11
|
+
unless defined? RubyVM::Frame and RbConfig::CONFIG.member?('rb-threadframe')
|
12
|
+
raise RuntimeError,
|
13
|
+
'This package is for MRI Ruby 2.1.5 with debugger runtime support!\nDownload from ' +
|
14
|
+
'http://downloads.sourceforge.net/project/ruby-debugger-runtime/ruby-2.1/'
|
15
|
+
end
|
16
|
+
|
17
|
+
ruby_version = RbConfig::CONFIG['RUBY_PROGRAM_VERSION']
|
18
|
+
if ruby_version == '1.9.3'
|
19
|
+
raise RuntimeError,
|
20
|
+
"This is version trepanning #{Trepan::VERSION}. " +
|
21
|
+
"Ruby #{ruby_version} you want version 1.93..."
|
22
|
+
elsif ruby_version == '1.9.2'
|
23
|
+
raise RuntimeError,
|
24
|
+
"This is version trepanning #{Trepan::VERSION}. " +
|
25
|
+
"Ruby #{ruby_version} you want version 1.92..."
|
26
|
+
elsif ruby_version != '2.1.5'
|
27
|
+
raise RuntimeError,
|
28
|
+
"This package only works on version Ruby version 2.1.5. You have #{ruby_version}."
|
29
|
+
end
|
30
|
+
|
10
31
|
def gemspec
|
11
32
|
@gemspec ||= eval(File.read(Gemspec_filename), binding, Gemspec_filename)
|
12
33
|
end
|
data/app/breakpoint.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010-2011, 2013,
|
2
|
+
# Copyright (C) 2010-2011, 2013,2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
|
4
4
|
# Breakpoint objects
|
5
5
|
class Trepan
|
@@ -11,7 +11,8 @@ class Trepan
|
|
11
11
|
# we want to (also) record hits independent
|
12
12
|
# of the condition?
|
13
13
|
attr_reader :id # Fixnum. Name of breakpoint
|
14
|
-
attr_reader :ignore # Fixnum. Number of times
|
14
|
+
attr_reader :ignore # Fixnum. Number of times to ignore
|
15
|
+
# before triggering
|
15
16
|
attr_reader :iseq # Instruction sequence associated with this
|
16
17
|
# breakpoint. From this we can derive
|
17
18
|
# information such as source location.
|
@@ -62,8 +63,9 @@ class Trepan
|
|
62
63
|
@id = @@next_id
|
63
64
|
@@next_id += 1
|
64
65
|
end
|
66
|
+
|
65
67
|
raise RuntimeError,
|
66
|
-
"Unable to set breakpoint in #{iseq.name} at offset #{offset}" unless set
|
68
|
+
"Unable to set breakpoint in #{iseq.name} at offset #{@offset}" unless set
|
67
69
|
end
|
68
70
|
|
69
71
|
def condition?(bind)
|
data/app/core.rb
CHANGED
@@ -1,203 +1,171 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
-
|
4
|
-
require '
|
5
|
-
# require_relative '../../rb-trace/app/trace'
|
2
|
+
# Copyright (C) 2010, 2014-2015 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
|
4
|
+
require 'set'
|
6
5
|
require_relative '../processor'
|
7
|
-
class Trepan
|
8
|
-
# This class contains the Trepan core routines, such as an event
|
9
|
-
# processor which is responsible of handling what to do when an event is
|
10
|
-
# triggered.
|
11
|
-
#
|
12
|
-
# See also 'rdbgr' the top-level Trepan class and command-line routine
|
13
|
-
# which ultimately will call this.
|
14
|
-
|
15
|
-
class Core
|
16
|
-
attr_accessor :async_events # bitmask of asyncronous events - used all
|
17
|
-
# the time
|
18
|
-
attr_reader :dbgr # Trepan instance
|
19
|
-
attr_reader :event # String - event which triggering event
|
20
|
-
# processor
|
21
|
-
attr_reader :event_proc # Proc of method event_processor
|
22
|
-
attr_accessor :exception # Return exception to pass back. A 'raise'
|
23
|
-
# command can set this.
|
24
|
-
attr_reader :frame # ThreadFrame instance
|
25
|
-
attr_reader :hook_arg # 'arg' passed from trace hook
|
26
|
-
attr_accessor :mutex # mutex to lock out other threads from
|
27
|
-
# entering debugger while we are in it.
|
28
|
-
attr_accessor :processor # Trepan::CmdProc instance
|
29
|
-
attr_reader :settings # Hash of things you can configure
|
30
|
-
attr_accessor :step_count # Fixnum. Negative means no tracing,
|
31
|
-
# 0 means stop on next event, 1 means
|
32
|
-
# ignore one event. Step events gives the
|
33
|
-
# kind of things to count as a step.
|
34
|
-
attr_accessor :step_events # bitmask of events - used only when
|
35
|
-
# we are stepping
|
36
|
-
attr_accessor :unmaskable_events
|
37
|
-
|
38
|
-
include Trace
|
39
|
-
|
40
|
-
unless defined?(CORE_DEFAULT_SETTINGS)
|
41
|
-
# Synchronous events
|
42
|
-
STEPPING_EVENT_MASK =
|
43
|
-
LINE_EVENT_MASK | CLASS_EVENT_MASK | CALL_EVENT_MASK |
|
44
|
-
RETURN_EVENT_MASK | C_CALL_EVENT_MASK | C_RETURN_EVENT_MASK |
|
45
|
-
INSN_EVENT_MASK | BRKPT_EVENT_MASK | YIELD_EVENT_MASK |
|
46
|
-
LEAVE_EVENT_MASK | SEND_EVENT_MASK
|
47
|
-
|
48
|
-
ASYNC_EVENT_MASK =
|
49
|
-
RAISE_EVENT_MASK | VM_EVENT_MASK | SWITCH_EVENT_MASK
|
50
|
-
|
51
|
-
CORE_DEFAULT_SETTINGS = {
|
52
|
-
:cmdproc_opts => {},
|
53
|
-
:debug_core_events => false,
|
54
|
-
:hook_name => :event_processor, # or :old_event_processor
|
55
|
-
:step_count => 0, # Stop at next event
|
56
|
-
:async_events => ASYNC_EVENT_MASK,
|
57
|
-
|
58
|
-
# Not sure what the "right" set really is. The below is just
|
59
|
-
# a guess. Use "set events" or customize in ~/.trepanrc
|
60
|
-
:step_events =>
|
61
|
-
# (DEFAULT_EVENT_MASK | INSN_EVENT_MASK) &
|
62
|
-
(DEFAULT_EVENT_MASK ) &
|
63
|
-
~(C_CALL_EVENT_MASK | C_RETURN_EVENT_MASK | SEND_EVENT_MASK)
|
64
|
-
}
|
65
6
|
|
66
|
-
|
7
|
+
class Trepan
|
8
|
+
# This class contains the Trepan core routines, such as an event
|
9
|
+
# processor which is responsible of handling what to do when an event is
|
10
|
+
# triggered.
|
11
|
+
#
|
12
|
+
# See also lib/trepanning.rb, the top-level Trepan class, and command-line routine
|
13
|
+
# bin/trepan which ultimately will call this.
|
14
|
+
|
15
|
+
class Core
|
16
|
+
attr_accessor :async_events # bitmask of asyncronous events - used all
|
17
|
+
# the time
|
18
|
+
attr_reader :dbgr # Trepan instance
|
19
|
+
attr_reader :event # String - event which triggering event
|
20
|
+
# processor
|
21
|
+
attr_reader :event_proc # Proc of method event_processor
|
22
|
+
attr_accessor :exception # Return exception to pass back. A 'raise'
|
23
|
+
# command can set this.
|
24
|
+
attr_reader :frame # ThreadFrame instance
|
25
|
+
attr_reader :hook_arg # 'arg' passed from trace hook
|
26
|
+
attr_accessor :mutex # mutex to lock out other threads from
|
27
|
+
# entering debugger while we are in it.
|
28
|
+
attr_accessor :processor # Trepan::CmdProc instance
|
29
|
+
attr_reader :settings # Hash of things you can configure
|
30
|
+
attr_accessor :step_count # Fixnum. Negative means no tracing,
|
31
|
+
# 0 means stop on next event, 1 means
|
32
|
+
# ignore one event. Step events gives the
|
33
|
+
# kind of things to count as a step.
|
34
|
+
attr_accessor :top_skip # Number of top frames to ignore
|
35
|
+
attr_accessor :step_events # bitmask of events - used only when
|
36
|
+
# we are stepping
|
37
|
+
attr_accessor :unmaskable_events
|
38
|
+
attr_reader :trace_point
|
39
|
+
|
40
|
+
unless defined?(CORE_DEFAULT_SETTINGS)
|
41
|
+
# Synchronous events
|
42
|
+
STEPPING_EVENTS = Set.new([:line, :class, :call, :return, :c_call,
|
43
|
+
:c_return, :raise, :b_call, :b_return,
|
44
|
+
:thread_begin, :thread_end, :brkpt])
|
45
|
+
ASYNC_EVENTS = Set.new([:raise])
|
46
|
+
|
47
|
+
CORE_DEFAULT_SETTINGS = {
|
48
|
+
:cmdproc_opts => {},
|
49
|
+
:debug_core_events => false,
|
50
|
+
:hook_name => :event_processor,
|
51
|
+
:step_count => 0, # Stop at next event
|
52
|
+
:async_events => ASYNC_EVENTS,
|
53
|
+
|
54
|
+
# Not sure what the "right" set really is. The below is just
|
55
|
+
# a guess. Use "set events" or customize in ~/.trepanrc
|
56
|
+
:step_events => STEPPING_EVENTS - [:c_call, :c_return]
|
57
|
+
}
|
67
58
|
|
68
|
-
|
69
|
-
@dbgr = debugger
|
70
|
-
@exception = nil
|
71
|
-
@mutex = Mutex.new
|
72
|
-
@settings = CORE_DEFAULT_SETTINGS.merge(settings)
|
73
|
-
|
74
|
-
@step_count = @settings[:step_count]
|
75
|
-
@step_events = @settings[:step_events]
|
76
|
-
@async_events = @settings[:async_events]
|
77
|
-
@debug_events = @settings[:debug_core_events]
|
78
|
-
|
79
|
-
hook_name = @settings[:hook_name]
|
80
|
-
@event_proc = self.method(hook_name).to_proc
|
81
|
-
@processor = CmdProcessor.new(self, @settings[:cmdproc_opts])
|
82
|
-
@unmaskable_events = %w(brkpt raise switch vm)
|
83
|
-
@current_thread = nil
|
84
|
-
end
|
59
|
+
end
|
85
60
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
61
|
+
def initialize(debugger, settings={})
|
62
|
+
@dbgr = debugger
|
63
|
+
@exception = nil
|
64
|
+
@mutex = Mutex.new
|
65
|
+
@settings = CORE_DEFAULT_SETTINGS.merge(settings)
|
66
|
+
|
67
|
+
@step_count = @settings[:step_count]
|
68
|
+
@step_events = @settings[:step_events]
|
69
|
+
@async_events = @settings[:async_events]
|
70
|
+
@debug_events = @settings[:debug_core_events]
|
71
|
+
|
72
|
+
hook_name = @settings[:hook_name]
|
73
|
+
@event_proc = self.method(hook_name).to_proc
|
74
|
+
@processor = CmdProcessor.new(self, @settings[:cmdproc_opts])
|
75
|
+
@unmaskable_events = %w(brkpt raise switch vm)
|
76
|
+
@current_thread = nil
|
77
|
+
@top_skip = 0
|
78
|
+
@trace_point = nil
|
79
|
+
end
|
93
80
|
|
94
|
-
|
95
|
-
|
81
|
+
def step_events_list
|
82
|
+
if @trace_point
|
83
|
+
@trace_point.event_mask
|
84
|
+
else
|
85
|
+
nil
|
86
|
+
end
|
87
|
+
end
|
96
88
|
|
97
|
-
|
98
|
-
|
99
|
-
|
89
|
+
# A trace-hook processor for tracepoints
|
90
|
+
def event_processor_tp(tp)
|
91
|
+
## FIXME: tracepoint has an arg param. Figure out how to use it.
|
92
|
+
@trace_point = tp
|
93
|
+
# RubyVM::Frame.get.frame.trace_off = true
|
94
|
+
# p @trace_point
|
95
|
+
# p @trace_point.event, @trace_point.frame.source_location
|
96
|
+
retval = event_processor(tp.frame, tp.event)
|
97
|
+
@trace_point = nil
|
98
|
+
return retval
|
99
|
+
end
|
100
100
|
|
101
|
-
|
101
|
+
# A trace-hook processor with the interface a trace hook should have.
|
102
|
+
def event_processor(frame, event, hook_arg=nil)
|
102
103
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
while @frame.type == 'IFUNC'
|
107
|
-
@frame = @frame.prev
|
108
|
-
end
|
104
|
+
return_exception = nil
|
105
|
+
# FIXME: check for breakpoints or other unmaskable events.
|
106
|
+
# For now there are none.
|
109
107
|
|
110
|
-
|
111
|
-
@step_count -= 1
|
112
|
-
break
|
113
|
-
elsif @step_count < 0 && ! @unmaskable_events.member?(event)
|
114
|
-
break
|
115
|
-
end
|
108
|
+
return if @mutex.locked? and Thread.current == @current_thread
|
116
109
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
### debug:
|
121
|
-
### puts "#{frame.file[1]}:#{frame.source_location[0]}:in `#{frame.method}' #{event}" # if %w(line).member?(event)
|
122
|
-
@processor.process_commands(@frame)
|
123
|
-
|
124
|
-
# FIXME: There should be a Trace.event_mask which should return the first
|
125
|
-
# mask that matches the given trace hook.
|
126
|
-
if @step_count < 0
|
127
|
-
# If we are continuing, no need to stop at stepping events.
|
128
|
-
Trace.event_masks[0] &= ~STEPPING_EVENT_MASK
|
129
|
-
else
|
130
|
-
# Set to trace only those events we are interested in.
|
131
|
-
|
132
|
-
# Don't step/trace into Ruby routines called from here in the code
|
133
|
-
# below (e.g. "trace_hooks").
|
134
|
-
step_count_save = step_count
|
135
|
-
@step_count = -1
|
136
|
-
|
137
|
-
unless @event_proc == dbgr.trace_filter.hook_proc
|
138
|
-
dbgr.trace_filter.add_trace_func(@event_proc)
|
139
|
-
## debug: p '+++1', @event_proc, dbgr.trace_filter.hook_proc
|
140
|
-
end
|
141
|
-
|
142
|
-
# FIXME: this doesn't work. Bug in rb-trace?
|
143
|
-
# Trace.event_masks[0] = @step_events | @async_events
|
144
|
-
RubyVM::TraceHook::trace_hooks[0].event_mask =
|
145
|
-
@step_events | @async_events
|
146
|
-
@step_count = step_count_save
|
147
|
-
end
|
110
|
+
@mutex.synchronize do
|
111
|
+
@current_thread = Thread.current
|
112
|
+
@frame = frame
|
148
113
|
|
149
|
-
|
114
|
+
if dbgr.trace_filter.member?(@frame.method)
|
115
|
+
# puts "Not tracing #{@frame.method}"
|
116
|
+
return
|
117
|
+
end
|
150
118
|
|
151
|
-
|
152
|
-
|
119
|
+
if @step_count > 0
|
120
|
+
@step_count -= 1
|
121
|
+
break
|
122
|
+
elsif @step_count < 0 && ! @unmaskable_events.member?(event.to_s)
|
123
|
+
break
|
124
|
+
end
|
153
125
|
|
154
|
-
|
155
|
-
|
156
|
-
end
|
126
|
+
@event = event
|
127
|
+
@hook_arg = hook_arg
|
157
128
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
129
|
+
### debug:
|
130
|
+
### puts "#{frame.file[1]}:#{frame.source_location[0]}:in `#{frame.method}' #{event}"
|
131
|
+
# if %w(line).member?(event)
|
132
|
+
@processor.process_commands(@frame, top_skip)
|
162
133
|
|
163
|
-
|
164
|
-
# call to the debugger. set prev_count to the number of levels
|
165
|
-
# *before* the caller you want to skip.
|
166
|
-
def debugger(prev_count=0)
|
167
|
-
while @frame && @frame.type == 'IFUNC'
|
168
|
-
@frame = @frame.prev
|
169
|
-
end
|
170
|
-
frame = RubyVM::Frame.current.prev(prev_count+1)
|
171
|
-
@step_count = 0 # Make event processor stop
|
172
|
-
event_processor('debugger-call', frame)
|
173
|
-
end
|
134
|
+
# Nil out variables just in case...
|
174
135
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
frame = frame.prev if prev
|
182
|
-
end
|
136
|
+
return_exception = @exception
|
137
|
+
@frame = @event = @arg = @exception = nil
|
138
|
+
@top_skip = 0
|
139
|
+
end
|
140
|
+
return return_exception
|
141
|
+
end
|
183
142
|
|
184
|
-
|
185
|
-
|
143
|
+
# A trace-hook processor for 'trace var'
|
144
|
+
def trace_var_processor(var_name, value)
|
145
|
+
frame = RubyVM::Frame.get
|
146
|
+
frame.trace_off = true
|
147
|
+
frame.prev.trace_off = true
|
148
|
+
# We need to skip this frame and the lamdba that in trace_var()
|
149
|
+
# and a C call() in that lambda. See command/watchg.rb
|
150
|
+
frame = RubyVM::Frame.get(3)
|
151
|
+
|
152
|
+
@step_count = 0 # Make event processor stop
|
153
|
+
event_processor(frame, 'trace-var', [var_name, value])
|
154
|
+
end
|
186
155
|
|
187
|
-
@step_count = 0 # Make event processor stop
|
188
|
-
event_processor('trace-var', frame, [var_name, value])
|
189
156
|
end
|
190
|
-
|
191
|
-
end
|
192
157
|
end
|
193
158
|
if __FILE__ == $0
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
159
|
+
require_relative '../lib/trepanning'
|
160
|
+
dbg = Trepan.new()
|
161
|
+
if ARGV.size > 0
|
162
|
+
def foo(dbg)
|
163
|
+
p 'foo here'
|
164
|
+
dbg.debugger
|
165
|
+
end
|
166
|
+
foo(dbg)
|
167
|
+
x = 5
|
168
|
+
y = File.basename("foo.rb", ".rb")
|
169
|
+
puts "yeah"
|
200
170
|
end
|
201
|
-
foo(dbg)
|
202
|
-
end
|
203
171
|
end
|