trepanning 0.1.0 → 0.1.1
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/.gitignore +4 -0
- data/ChangeLog +1279 -235
- data/Makefile +13 -0
- data/NEWS +30 -0
- data/Rakefile +50 -14
- data/app/.gitignore +1 -0
- data/app/breakpoint.rb +7 -2
- data/app/brkptmgr.rb +12 -0
- data/app/cmd_parse.citrus +167 -0
- data/app/cmd_parse.kpeg +221 -0
- data/app/cmd_parse.rb +201 -0
- data/app/cmd_parser.rb +1914 -0
- data/app/complete.rb +79 -0
- data/app/condition.rb +1 -1
- data/app/core.rb +7 -11
- data/app/default.rb +1 -1
- data/app/disassemble.rb +3 -2
- data/app/file.rb +12 -36
- data/app/frame.rb +3 -2
- data/app/irb.rb +9 -5
- data/app/iseq.rb +46 -0
- data/app/options.rb +6 -30
- data/app/run.rb +5 -2
- data/app/util.rb +1 -2
- data/app/yarv.rb +11 -1
- data/bin/.gitignore +1 -0
- data/bin/trepan +6 -6
- data/data/.gitignore +1 -0
- data/interface/.gitignore +1 -0
- data/interface/base_intf.rb +9 -5
- data/interface/comcodes.rb +10 -8
- data/interface/user.rb +76 -17
- data/io/.gitignore +1 -0
- data/io/input.rb +39 -15
- data/io/tcpclient.rb +7 -1
- data/io/tcpfns.rb +5 -3
- data/io/tcpserver.rb +13 -10
- data/lib/.gitignore +1 -0
- data/lib/trepanning.rb +50 -13
- data/processor/.gitignore +1 -0
- data/processor/Makefile +7 -0
- data/processor/breakpoint.rb +7 -2
- data/processor/command/.gitignore +1 -0
- data/processor/command/Makefile +7 -0
- data/processor/command/alias.rb +2 -2
- data/processor/command/backtrace.rb +4 -0
- data/processor/command/base/cmd.rb +45 -2
- data/processor/command/base/subcmd.rb +4 -2
- data/processor/command/base/submgr.rb +23 -19
- data/processor/command/base/subsubcmd.rb +23 -1
- data/processor/command/base/subsubmgr.rb +13 -0
- data/processor/command/break.rb +34 -29
- data/processor/command/complete.rb +37 -0
- data/processor/command/condition.rb +2 -0
- data/processor/command/continue.rb +15 -18
- data/processor/command/disassemble.rb +5 -0
- data/processor/command/down.rb +1 -1
- data/processor/command/eval.rb +70 -0
- data/processor/command/exit.rb +4 -1
- data/processor/command/finish.rb +6 -4
- data/processor/command/frame.rb +6 -3
- data/processor/command/help.rb +97 -54
- data/processor/command/help/.gitignore +1 -0
- data/processor/command/help/README +10 -0
- data/processor/command/help/command.txt +48 -0
- data/processor/command/help/filename.txt +40 -0
- data/processor/command/help/location.txt +37 -0
- data/processor/command/info_subcmd/.gitignore +1 -0
- data/processor/command/info_subcmd/breakpoints.rb +9 -9
- data/processor/command/info_subcmd/{file.rb → files.rb} +92 -27
- data/processor/command/info_subcmd/frame.rb +41 -15
- data/processor/command/info_subcmd/iseq.rb +39 -17
- data/processor/command/info_subcmd/program.rb +2 -8
- data/processor/command/info_subcmd/registers.rb +12 -10
- data/processor/command/info_subcmd/registers_subcmd/.gitignore +1 -0
- data/processor/command/info_subcmd/ruby.rb +60 -0
- data/processor/command/irb.rb +26 -3
- data/processor/command/kill.rb +21 -10
- data/processor/command/list.rb +1 -1
- data/processor/command/macro.rb +37 -23
- data/processor/command/pr.rb +1 -1
- data/processor/command/reload.rb +4 -0
- data/processor/command/reload_subcmd/.gitignore +1 -0
- data/processor/command/restart.rb +9 -9
- data/processor/command/save.rb +29 -36
- data/processor/command/set_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/auto_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/confirm.rb +23 -0
- data/processor/command/set_subcmd/debug_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/different.rb +2 -0
- data/processor/command/set_subcmd/events.rb +2 -0
- data/processor/command/set_subcmd/max.rb +9 -12
- data/processor/command/set_subcmd/max_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/substitute_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/trace.rb +7 -13
- data/processor/command/set_subcmd/trace_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/trace_subcmd/buffer.rb +12 -27
- data/processor/command/set_subcmd/trace_subcmd/print.rb +10 -8
- data/processor/command/set_subcmd/trace_subcmd/var.rb +6 -10
- data/processor/command/show.rb +12 -1
- data/processor/command/show_subcmd/.gitignore +1 -0
- data/processor/command/show_subcmd/alias.rb +11 -15
- data/processor/command/show_subcmd/auto_subcmd/.gitignore +1 -0
- data/processor/command/show_subcmd/basename.rb +1 -9
- data/processor/command/show_subcmd/confirm.rb +25 -0
- data/processor/command/show_subcmd/debug_subcmd/.gitignore +1 -0
- data/processor/command/show_subcmd/macro.rb +32 -14
- data/processor/command/show_subcmd/max_subcmd/.gitignore +1 -0
- data/processor/command/show_subcmd/trace_subcmd/.gitignore +1 -0
- data/processor/command/show_subcmd/trace_subcmd/buffer.rb +11 -31
- data/processor/command/show_subcmd/trace_subcmd/print.rb +4 -20
- data/processor/command/source.rb +7 -1
- data/processor/command/up.rb +7 -4
- data/processor/default.rb +3 -1
- data/processor/eval.rb +13 -0
- data/processor/eventbuf.rb +3 -2
- data/processor/frame.rb +19 -0
- data/processor/help.rb +20 -0
- data/processor/load_cmds.rb +143 -24
- data/processor/location.rb +61 -10
- data/processor/main.rb +30 -11
- data/processor/mock.rb +5 -3
- data/processor/msg.rb +17 -0
- data/processor/running.rb +1 -1
- data/processor/subcmd.rb +3 -2
- data/processor/validate.rb +173 -185
- data/sample/.gitignore +1 -0
- data/sample/list-terminal-colors.rb +139 -0
- data/sample/rocky-dot-trepanrc +14 -0
- data/sample/rocky-trepan-colors.rb +47 -0
- data/test/Makefile +7 -0
- data/test/data/.gitignore +1 -0
- data/test/data/debugger-stop.cmd +3 -0
- data/test/data/debugger-stop.right +5 -0
- data/test/data/fname-with-blank.right +0 -3
- data/test/data/quit.right +0 -1
- data/test/data/quit2.cmd +6 -0
- data/test/data/quit2.right +3 -0
- data/test/data/testing.cmd +1 -0
- data/test/example/.gitignore +1 -0
- data/test/example/debugger-stop.rb +14 -0
- data/test/functional/.gitignore +2 -0
- data/test/functional/fn_helper.rb +7 -9
- data/test/functional/test-break-long.rb +7 -7
- data/test/functional/test-break.rb +7 -7
- data/test/functional/test-condition.rb +4 -4
- data/test/functional/test-delete.rb +6 -5
- data/test/functional/test-eval.rb +115 -0
- data/test/functional/test-raise.rb +1 -1
- data/test/functional/test-return.rb +1 -1
- data/test/integration/.gitignore +2 -0
- data/test/integration/helper.rb +6 -3
- data/test/integration/test-debugger-stop.rb +22 -0
- data/test/integration/test-quit.rb +8 -0
- data/test/unit/.gitignore +1 -0
- data/test/unit/Makefile +7 -0
- data/test/unit/test-app-brkpt.rb +0 -1
- data/test/unit/test-app-cmd_parse.rb +107 -0
- data/test/unit/test-app-cmd_parser.rb +22 -0
- data/test/unit/test-app-complete.rb +38 -0
- data/test/unit/test-app-condition.rb +20 -0
- data/test/unit/test-app-iseq.rb +31 -0
- data/test/unit/test-app-options.rb +9 -1
- data/test/unit/test-app-util.rb +0 -1
- data/test/unit/test-base-cmd.rb +46 -0
- data/test/unit/test-base-subcmd.rb +11 -2
- data/test/unit/test-base-submgr.rb +23 -0
- data/test/unit/test-base-subsubcmd.rb +20 -0
- data/test/unit/test-cmd-break.rb +22 -23
- data/test/unit/test-cmd-help.rb +4 -0
- data/test/unit/test-completion.rb +43 -0
- data/test/unit/test-io-tcpclient.rb +3 -2
- data/test/unit/test-proc-load_cmds.rb +10 -1
- data/test/unit/test-proc-location.rb +39 -0
- data/test/unit/test-proc-main.rb +1 -1
- data/test/unit/test-proc-validate.rb +47 -31
- data/trepanning.gemspec +45 -0
- metadata +247 -179
- data/app/core.rb-consider +0 -198
- data/test/functional/tmp/b3.rb +0 -5
- data/test/functional/tmp/immediate-bug1.rb +0 -9
data/app/core.rb-consider
DELETED
@@ -1,198 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'thread_frame'
|
3
|
-
require 'trace'
|
4
|
-
# require_relative '../../rb-trace/app/trace'
|
5
|
-
require_relative '../processor/main'
|
6
|
-
class Debugger
|
7
|
-
# This class contains the Debugger core routines, such as an event
|
8
|
-
# processor which is responsible of handling what to do when an event is
|
9
|
-
# triggered.
|
10
|
-
#
|
11
|
-
# See also 'rdbgr' the top-level Debugger class and command-line routine
|
12
|
-
# which ultimately will call this.
|
13
|
-
|
14
|
-
class Core
|
15
|
-
attr_accessor :async_events # bitmask of asyncronous events - used all
|
16
|
-
# the time
|
17
|
-
attr_reader :dbgr # Debugger instance
|
18
|
-
attr_reader :event # String - event which triggering event
|
19
|
-
# processor
|
20
|
-
attr_reader :event_proc # Proc of method event_processor
|
21
|
-
attr_accessor :exception # Return exception to pass back. A 'raise'
|
22
|
-
# command can set this.
|
23
|
-
attr_reader :frame # ThreadFrame instance
|
24
|
-
attr_reader :hook_arg # 'arg' passed from trace hook
|
25
|
-
attr_accessor :mutex # mutex to lock out other threads from
|
26
|
-
# entering debugger while we are in it.
|
27
|
-
attr_accessor :processor # Debugger::CmdProc instance
|
28
|
-
attr_reader :settings # Hash of things you can configure
|
29
|
-
attr_accessor :step_count # Fixnum. Negative means no tracing,
|
30
|
-
# 0 means stop on next event, 1 means
|
31
|
-
# ignore one event. Step events gives the
|
32
|
-
# kind of things to count as a step.
|
33
|
-
attr_accessor :step_events # bitmask of events - used only when
|
34
|
-
# we are stepping
|
35
|
-
attr_accessor :unmaskable_events
|
36
|
-
|
37
|
-
include Trace
|
38
|
-
|
39
|
-
unless defined?(CORE_DEFAULT_SETTINGS)
|
40
|
-
# Synchronous events
|
41
|
-
STEPPING_EVENT_MASK =
|
42
|
-
LINE_EVENT_MASK | CLASS_EVENT_MASK | CALL_EVENT_MASK |
|
43
|
-
RETURN_EVENT_MASK | C_CALL_EVENT_MASK | C_RETURN_EVENT_MASK |
|
44
|
-
INSN_EVENT_MASK | BRKPT_EVENT_MASK
|
45
|
-
|
46
|
-
ASYNC_EVENT_MASK =
|
47
|
-
RAISE_EVENT_MASK | VM_EVENT_MASK | SWITCH_EVENT_MASK
|
48
|
-
|
49
|
-
CORE_DEFAULT_SETTINGS = {
|
50
|
-
:cmdproc_opts => {},
|
51
|
-
:debug_core_events => false,
|
52
|
-
:hook_name => :event_processor, # or :old_event_processor
|
53
|
-
:step_count => 0, # Stop at next event
|
54
|
-
:async_events => ASYNC_EVENT_MASK,
|
55
|
-
|
56
|
-
# FIXME:
|
57
|
-
# Somewhere inside the VM we allow I guess nested tracing which is messing
|
58
|
-
# up ThreadFrame pointers and information. When this is fixed we can do the below.
|
59
|
-
# Until then we need to at least remove C calls and returns and possibly other
|
60
|
-
# events as well.
|
61
|
-
# :step_events =>
|
62
|
-
# (DEFAULT_EVENT_MASK | INSN_EVENT_MASK)
|
63
|
-
|
64
|
-
:step_events =>
|
65
|
-
(DEFAULT_EVENT_MASK | INSN_EVENT_MASK) &
|
66
|
-
~(C_CALL_EVENT_MASK | C_RETURN_EVENT_MASK)
|
67
|
-
}
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
def initialize(debugger, settings={})
|
72
|
-
@dbgr = debugger
|
73
|
-
@exception = nil
|
74
|
-
@mutex = Mutex.new
|
75
|
-
@settings = CORE_DEFAULT_SETTINGS.merge(settings)
|
76
|
-
|
77
|
-
@step_count = @settings[:step_count]
|
78
|
-
@step_events = @settings[:step_events]
|
79
|
-
@async_events = @settings[:async_events]
|
80
|
-
@debug_events = @settings[:debug_core_events]
|
81
|
-
|
82
|
-
hook_name = @settings[:hook_name]
|
83
|
-
@event_proc = self.method(hook_name).to_proc
|
84
|
-
@processor = CmdProcessor.new(self, @settings[:cmdproc_opts])
|
85
|
-
@unmaskable_events = %w(brkpt raise switch vm)
|
86
|
-
end
|
87
|
-
|
88
|
-
def step_events_list
|
89
|
-
if 0 == @step_events
|
90
|
-
return nil
|
91
|
-
else
|
92
|
-
Trace.bitmask2events(@step_events).join(', ')
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
# A trace-hook processor with the interface a trace hook should have.
|
97
|
-
def event_processor(event, frame, arg=nil)
|
98
|
-
|
99
|
-
return_exception = nil
|
100
|
-
# FIXME: check for breakpoints or other unmaskable events.
|
101
|
-
# For now there are none.
|
102
|
-
|
103
|
-
@mutex.synchronize do
|
104
|
-
@frame = frame
|
105
|
-
while @frame.type == 'IFUNC'
|
106
|
-
@frame = @frame.prev
|
107
|
-
end
|
108
|
-
|
109
|
-
if @step_count > 0
|
110
|
-
@step_count -= 1
|
111
|
-
break
|
112
|
-
elsif @step_count < 0 && ! @unmaskable_events.member?(event)
|
113
|
-
break
|
114
|
-
end
|
115
|
-
|
116
|
-
@event = event
|
117
|
-
@hook_arg = arg
|
118
|
-
|
119
|
-
### debug:
|
120
|
-
### puts "#{frame.source_container[1]}:#{frame.source_location[0]}:in `#{frame.method}' #{event}" # if %w(line).member?(event)
|
121
|
-
@processor.process_commands(@frame)
|
122
|
-
|
123
|
-
# FIXME: There should be a Trace.event_mask which should return the first
|
124
|
-
# mask that matches the given trace hook.
|
125
|
-
if @step_count < 0
|
126
|
-
# If we are continuing, no need to stop at stepping events.
|
127
|
-
Trace.event_masks[0] &= ~STEPPING_EVENT_MASK
|
128
|
-
else
|
129
|
-
# Set to trace only those events we are interested in.
|
130
|
-
|
131
|
-
# Don't step/trace into Ruby routines called from here in the code
|
132
|
-
# below (e.g. "trace_hooks").
|
133
|
-
th = Thread.current
|
134
|
-
exec_event_tracing_old = th.exec_event_tracing
|
135
|
-
th.exec_event_tracing = true
|
136
|
-
|
137
|
-
# FIXME: this doesn't work. Bug in rb-trace?
|
138
|
-
# Trace.event_masks[0] = @step_events | @async_events
|
139
|
-
RubyVM::TraceHook::trace_hooks[0].event_mask =
|
140
|
-
@step_events | @async_events
|
141
|
-
th.exec_event_tracing = exec_event_tracing_old
|
142
|
-
end
|
143
|
-
|
144
|
-
# Nil out variables just in case...
|
145
|
-
|
146
|
-
return_exception = @exception
|
147
|
-
@frame = @event = @arg = @exception = nil
|
148
|
-
|
149
|
-
end
|
150
|
-
return return_exception
|
151
|
-
end
|
152
|
-
|
153
|
-
# A Ruby 1.8-style event processor. We don't use file, line, id, bind.
|
154
|
-
def old_event_processor(event, file, line, id, bind, klass)
|
155
|
-
event_processor(event, RubyVM::ThreadFrame.current.prev)
|
156
|
-
end
|
157
|
-
|
158
|
-
# Call this from inside the program you want to get a synchronous
|
159
|
-
# call to the debugger. set prev_count to the number of levels
|
160
|
-
# *before* the caller you want to skip.
|
161
|
-
def debugger(prev_count=0)
|
162
|
-
while @frame && @frame.type == 'IFUNC'
|
163
|
-
@frame = @frame.prev
|
164
|
-
end
|
165
|
-
frame = RubyVM::ThreadFrame.current.prev(prev_count+1)
|
166
|
-
@step_count = 0 # Make event processor stop
|
167
|
-
event_processor('debugger-call', frame)
|
168
|
-
end
|
169
|
-
|
170
|
-
# A trace-hook processor for 'trace var'
|
171
|
-
def trace_var_processor(val)
|
172
|
-
frame = RubyVM::ThreadFrame.current.prev
|
173
|
-
if 'CFUNC' == frame.type
|
174
|
-
# Don't need the C call that got us here.
|
175
|
-
prev = frame.prev
|
176
|
-
frame = frame.prev if prev
|
177
|
-
end
|
178
|
-
|
179
|
-
# Stop future tracing into the debugger
|
180
|
-
Thread.current.tracing = true
|
181
|
-
|
182
|
-
@step_count = 0 # Make event processor stop
|
183
|
-
event_processor('trace-var', frame)
|
184
|
-
end
|
185
|
-
|
186
|
-
end
|
187
|
-
end
|
188
|
-
if __FILE__ == $0
|
189
|
-
require_relative '../lib/trepan'
|
190
|
-
dbg = Debugger.new()
|
191
|
-
if ARGV.size > 0
|
192
|
-
def foo(dbg)
|
193
|
-
p 'foo here'
|
194
|
-
dbg.debugger(:immediate=>true)
|
195
|
-
end
|
196
|
-
foo(dbg)
|
197
|
-
end
|
198
|
-
end
|
data/test/functional/tmp/b3.rb
DELETED