trepanning 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. data/.gitignore +4 -0
  2. data/ChangeLog +1279 -235
  3. data/Makefile +13 -0
  4. data/NEWS +30 -0
  5. data/Rakefile +50 -14
  6. data/app/.gitignore +1 -0
  7. data/app/breakpoint.rb +7 -2
  8. data/app/brkptmgr.rb +12 -0
  9. data/app/cmd_parse.citrus +167 -0
  10. data/app/cmd_parse.kpeg +221 -0
  11. data/app/cmd_parse.rb +201 -0
  12. data/app/cmd_parser.rb +1914 -0
  13. data/app/complete.rb +79 -0
  14. data/app/condition.rb +1 -1
  15. data/app/core.rb +7 -11
  16. data/app/default.rb +1 -1
  17. data/app/disassemble.rb +3 -2
  18. data/app/file.rb +12 -36
  19. data/app/frame.rb +3 -2
  20. data/app/irb.rb +9 -5
  21. data/app/iseq.rb +46 -0
  22. data/app/options.rb +6 -30
  23. data/app/run.rb +5 -2
  24. data/app/util.rb +1 -2
  25. data/app/yarv.rb +11 -1
  26. data/bin/.gitignore +1 -0
  27. data/bin/trepan +6 -6
  28. data/data/.gitignore +1 -0
  29. data/interface/.gitignore +1 -0
  30. data/interface/base_intf.rb +9 -5
  31. data/interface/comcodes.rb +10 -8
  32. data/interface/user.rb +76 -17
  33. data/io/.gitignore +1 -0
  34. data/io/input.rb +39 -15
  35. data/io/tcpclient.rb +7 -1
  36. data/io/tcpfns.rb +5 -3
  37. data/io/tcpserver.rb +13 -10
  38. data/lib/.gitignore +1 -0
  39. data/lib/trepanning.rb +50 -13
  40. data/processor/.gitignore +1 -0
  41. data/processor/Makefile +7 -0
  42. data/processor/breakpoint.rb +7 -2
  43. data/processor/command/.gitignore +1 -0
  44. data/processor/command/Makefile +7 -0
  45. data/processor/command/alias.rb +2 -2
  46. data/processor/command/backtrace.rb +4 -0
  47. data/processor/command/base/cmd.rb +45 -2
  48. data/processor/command/base/subcmd.rb +4 -2
  49. data/processor/command/base/submgr.rb +23 -19
  50. data/processor/command/base/subsubcmd.rb +23 -1
  51. data/processor/command/base/subsubmgr.rb +13 -0
  52. data/processor/command/break.rb +34 -29
  53. data/processor/command/complete.rb +37 -0
  54. data/processor/command/condition.rb +2 -0
  55. data/processor/command/continue.rb +15 -18
  56. data/processor/command/disassemble.rb +5 -0
  57. data/processor/command/down.rb +1 -1
  58. data/processor/command/eval.rb +70 -0
  59. data/processor/command/exit.rb +4 -1
  60. data/processor/command/finish.rb +6 -4
  61. data/processor/command/frame.rb +6 -3
  62. data/processor/command/help.rb +97 -54
  63. data/processor/command/help/.gitignore +1 -0
  64. data/processor/command/help/README +10 -0
  65. data/processor/command/help/command.txt +48 -0
  66. data/processor/command/help/filename.txt +40 -0
  67. data/processor/command/help/location.txt +37 -0
  68. data/processor/command/info_subcmd/.gitignore +1 -0
  69. data/processor/command/info_subcmd/breakpoints.rb +9 -9
  70. data/processor/command/info_subcmd/{file.rb → files.rb} +92 -27
  71. data/processor/command/info_subcmd/frame.rb +41 -15
  72. data/processor/command/info_subcmd/iseq.rb +39 -17
  73. data/processor/command/info_subcmd/program.rb +2 -8
  74. data/processor/command/info_subcmd/registers.rb +12 -10
  75. data/processor/command/info_subcmd/registers_subcmd/.gitignore +1 -0
  76. data/processor/command/info_subcmd/ruby.rb +60 -0
  77. data/processor/command/irb.rb +26 -3
  78. data/processor/command/kill.rb +21 -10
  79. data/processor/command/list.rb +1 -1
  80. data/processor/command/macro.rb +37 -23
  81. data/processor/command/pr.rb +1 -1
  82. data/processor/command/reload.rb +4 -0
  83. data/processor/command/reload_subcmd/.gitignore +1 -0
  84. data/processor/command/restart.rb +9 -9
  85. data/processor/command/save.rb +29 -36
  86. data/processor/command/set_subcmd/.gitignore +1 -0
  87. data/processor/command/set_subcmd/auto_subcmd/.gitignore +1 -0
  88. data/processor/command/set_subcmd/confirm.rb +23 -0
  89. data/processor/command/set_subcmd/debug_subcmd/.gitignore +1 -0
  90. data/processor/command/set_subcmd/different.rb +2 -0
  91. data/processor/command/set_subcmd/events.rb +2 -0
  92. data/processor/command/set_subcmd/max.rb +9 -12
  93. data/processor/command/set_subcmd/max_subcmd/.gitignore +1 -0
  94. data/processor/command/set_subcmd/substitute_subcmd/.gitignore +1 -0
  95. data/processor/command/set_subcmd/trace.rb +7 -13
  96. data/processor/command/set_subcmd/trace_subcmd/.gitignore +1 -0
  97. data/processor/command/set_subcmd/trace_subcmd/buffer.rb +12 -27
  98. data/processor/command/set_subcmd/trace_subcmd/print.rb +10 -8
  99. data/processor/command/set_subcmd/trace_subcmd/var.rb +6 -10
  100. data/processor/command/show.rb +12 -1
  101. data/processor/command/show_subcmd/.gitignore +1 -0
  102. data/processor/command/show_subcmd/alias.rb +11 -15
  103. data/processor/command/show_subcmd/auto_subcmd/.gitignore +1 -0
  104. data/processor/command/show_subcmd/basename.rb +1 -9
  105. data/processor/command/show_subcmd/confirm.rb +25 -0
  106. data/processor/command/show_subcmd/debug_subcmd/.gitignore +1 -0
  107. data/processor/command/show_subcmd/macro.rb +32 -14
  108. data/processor/command/show_subcmd/max_subcmd/.gitignore +1 -0
  109. data/processor/command/show_subcmd/trace_subcmd/.gitignore +1 -0
  110. data/processor/command/show_subcmd/trace_subcmd/buffer.rb +11 -31
  111. data/processor/command/show_subcmd/trace_subcmd/print.rb +4 -20
  112. data/processor/command/source.rb +7 -1
  113. data/processor/command/up.rb +7 -4
  114. data/processor/default.rb +3 -1
  115. data/processor/eval.rb +13 -0
  116. data/processor/eventbuf.rb +3 -2
  117. data/processor/frame.rb +19 -0
  118. data/processor/help.rb +20 -0
  119. data/processor/load_cmds.rb +143 -24
  120. data/processor/location.rb +61 -10
  121. data/processor/main.rb +30 -11
  122. data/processor/mock.rb +5 -3
  123. data/processor/msg.rb +17 -0
  124. data/processor/running.rb +1 -1
  125. data/processor/subcmd.rb +3 -2
  126. data/processor/validate.rb +173 -185
  127. data/sample/.gitignore +1 -0
  128. data/sample/list-terminal-colors.rb +139 -0
  129. data/sample/rocky-dot-trepanrc +14 -0
  130. data/sample/rocky-trepan-colors.rb +47 -0
  131. data/test/Makefile +7 -0
  132. data/test/data/.gitignore +1 -0
  133. data/test/data/debugger-stop.cmd +3 -0
  134. data/test/data/debugger-stop.right +5 -0
  135. data/test/data/fname-with-blank.right +0 -3
  136. data/test/data/quit.right +0 -1
  137. data/test/data/quit2.cmd +6 -0
  138. data/test/data/quit2.right +3 -0
  139. data/test/data/testing.cmd +1 -0
  140. data/test/example/.gitignore +1 -0
  141. data/test/example/debugger-stop.rb +14 -0
  142. data/test/functional/.gitignore +2 -0
  143. data/test/functional/fn_helper.rb +7 -9
  144. data/test/functional/test-break-long.rb +7 -7
  145. data/test/functional/test-break.rb +7 -7
  146. data/test/functional/test-condition.rb +4 -4
  147. data/test/functional/test-delete.rb +6 -5
  148. data/test/functional/test-eval.rb +115 -0
  149. data/test/functional/test-raise.rb +1 -1
  150. data/test/functional/test-return.rb +1 -1
  151. data/test/integration/.gitignore +2 -0
  152. data/test/integration/helper.rb +6 -3
  153. data/test/integration/test-debugger-stop.rb +22 -0
  154. data/test/integration/test-quit.rb +8 -0
  155. data/test/unit/.gitignore +1 -0
  156. data/test/unit/Makefile +7 -0
  157. data/test/unit/test-app-brkpt.rb +0 -1
  158. data/test/unit/test-app-cmd_parse.rb +107 -0
  159. data/test/unit/test-app-cmd_parser.rb +22 -0
  160. data/test/unit/test-app-complete.rb +38 -0
  161. data/test/unit/test-app-condition.rb +20 -0
  162. data/test/unit/test-app-iseq.rb +31 -0
  163. data/test/unit/test-app-options.rb +9 -1
  164. data/test/unit/test-app-util.rb +0 -1
  165. data/test/unit/test-base-cmd.rb +46 -0
  166. data/test/unit/test-base-subcmd.rb +11 -2
  167. data/test/unit/test-base-submgr.rb +23 -0
  168. data/test/unit/test-base-subsubcmd.rb +20 -0
  169. data/test/unit/test-cmd-break.rb +22 -23
  170. data/test/unit/test-cmd-help.rb +4 -0
  171. data/test/unit/test-completion.rb +43 -0
  172. data/test/unit/test-io-tcpclient.rb +3 -2
  173. data/test/unit/test-proc-load_cmds.rb +10 -1
  174. data/test/unit/test-proc-location.rb +39 -0
  175. data/test/unit/test-proc-main.rb +1 -1
  176. data/test/unit/test-proc-validate.rb +47 -31
  177. data/trepanning.gemspec +45 -0
  178. metadata +247 -179
  179. data/app/core.rb-consider +0 -198
  180. data/test/functional/tmp/b3.rb +0 -5
  181. 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
@@ -1,5 +0,0 @@
1
- a = 1
2
- b = 2
3
- c = 3
4
- d = 4
5
- e = 5
@@ -1,9 +0,0 @@
1
- # require_relative '../../../lib/rbdbgr'
2
- require 'rbdbgr'
3
- # cmds = ['step', 'continue']
4
- d = Debugger.new
5
- 2.times do
6
- x = 1
7
- d.debugger(:immediate => true)
8
- y = 2
9
- end