ruby-debug-base 0.9.3 → 0.10.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/AUTHORS +1 -0
- data/CHANGES +41 -0
- data/README +27 -13
- data/Rakefile +220 -0
- data/ext/ChangeLog +793 -0
- data/ext/ruby_debug.c +274 -34
- data/lib/ChangeLog +579 -0
- data/lib/ruby-debug-base.rb +17 -11
- data/test/test-ruby-debug-base.rb +76 -0
- metadata +15 -13
- data/ext/tags +0 -118
data/lib/ruby-debug-base.rb
CHANGED
@@ -22,7 +22,7 @@ module Debugger
|
|
22
22
|
if obj = frame_self(frame)
|
23
23
|
obj.instance_eval code
|
24
24
|
else
|
25
|
-
eval code
|
25
|
+
eval code, TOPLEVEL_BINDING
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -81,7 +81,7 @@ module Debugger
|
|
81
81
|
SCRIPT_LINES__[file] = File.readlines(file)
|
82
82
|
end
|
83
83
|
|
84
|
-
change_time =
|
84
|
+
change_time = File.stat(file).mtime
|
85
85
|
SCRIPT_TIMESTAMPS__[file] ||= change_time
|
86
86
|
if @reload_source_on_change && SCRIPT_TIMESTAMPS__[file] < change_time
|
87
87
|
SCRIPT_LINES__[file] = File.readlines(file)
|
@@ -134,18 +134,20 @@ module Debugger
|
|
134
134
|
# ...
|
135
135
|
# end
|
136
136
|
def post_mortem
|
137
|
-
raise "Post-mortem is already activated" if self.post_mortem?
|
138
|
-
self.post_mortem = true
|
139
137
|
if block_given?
|
138
|
+
old_post_mortem = self.post_mortem?
|
140
139
|
begin
|
140
|
+
self.post_mortem = true
|
141
141
|
yield
|
142
142
|
rescue Exception => exp
|
143
143
|
handle_post_mortem(exp)
|
144
144
|
raise
|
145
145
|
ensure
|
146
|
-
self.post_mortem =
|
146
|
+
self.post_mortem = old_post_mortem
|
147
147
|
end
|
148
148
|
else
|
149
|
+
return if post_mortem?
|
150
|
+
self.post_mortem = true
|
149
151
|
debug_at_exit do
|
150
152
|
handle_post_mortem($!) if $! && post_mortem?
|
151
153
|
end
|
@@ -172,16 +174,14 @@ module Debugger
|
|
172
174
|
end
|
173
175
|
end
|
174
176
|
|
175
|
-
class Exception # :nodoc:
|
176
|
-
attr_reader :__debug_file, :__debug_line, :__debug_binding, :__debug_context
|
177
|
-
end
|
178
|
-
|
179
177
|
module Kernel
|
180
178
|
#
|
181
|
-
#
|
179
|
+
# Enters the debugger in the current thread after a number of
|
180
|
+
# _steps_ made.
|
182
181
|
#
|
183
182
|
def debugger(steps = 1)
|
184
183
|
Debugger.start unless Debugger.started?
|
184
|
+
Debugger.run_init_script(StringIO.new)
|
185
185
|
Debugger.current_context.stop_next = steps
|
186
186
|
end
|
187
187
|
alias breakpoint debugger unless respond_to?(:breakpoint)
|
@@ -190,10 +190,16 @@ module Kernel
|
|
190
190
|
# Returns a binding of n-th call frame
|
191
191
|
#
|
192
192
|
def binding_n(n = 0)
|
193
|
-
Debugger.
|
193
|
+
Debugger.skip do
|
194
|
+
Debugger.current_context.frame_binding(n+2)
|
195
|
+
end
|
194
196
|
end
|
195
197
|
end
|
196
198
|
|
199
|
+
class Exception # :nodoc:
|
200
|
+
attr_reader :__debug_file, :__debug_line, :__debug_binding, :__debug_context
|
201
|
+
end
|
202
|
+
|
197
203
|
class Module
|
198
204
|
#
|
199
205
|
# Wraps the +meth+ method with Debugger.start {...} block.
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "test/unit"
|
3
|
+
|
4
|
+
$: << File.expand_path(File.dirname(__FILE__)) + '/../ext'
|
5
|
+
$: << File.expand_path(File.dirname(__FILE__)) + '/../lib'
|
6
|
+
require "ruby_debug"
|
7
|
+
|
8
|
+
# Test of C extension ruby_debug.so
|
9
|
+
class TestRubyDebug < Test::Unit::TestCase
|
10
|
+
include Debugger
|
11
|
+
|
12
|
+
# test current_context
|
13
|
+
def test_current_context
|
14
|
+
assert_equal(false, Debugger.started?,
|
15
|
+
"debugger should not initially be started.")
|
16
|
+
Debugger.start
|
17
|
+
assert(Debugger.started?,
|
18
|
+
"debugger should now be started.")
|
19
|
+
assert_equal(19, Debugger.current_context.frame_line)
|
20
|
+
assert_equal(nil, Debugger.current_context.frame_args_info,
|
21
|
+
"no frame args info.")
|
22
|
+
assert_equal(Debugger.current_context.frame_file,
|
23
|
+
Debugger.current_context.frame_file(0))
|
24
|
+
assert_equal("test-ruby-debug-base.rb",
|
25
|
+
File.basename(Debugger.current_context.frame_file))
|
26
|
+
assert_raises(ArgumentError) {Debugger.current_context.frame_file(1, 2)}
|
27
|
+
assert_raises(ArgumentError) {Debugger.current_context.frame_file(10)}
|
28
|
+
assert_equal(1, Debugger.current_context.stack_size)
|
29
|
+
assert_equal(TestRubyDebug, Debugger.current_context.frame_class)
|
30
|
+
assert_equal(false, Debugger.current_context.dead?, "Not dead yet!")
|
31
|
+
Debugger.stop
|
32
|
+
assert_equal(false, Debugger.started?,
|
33
|
+
"Debugger should no longer be started.")
|
34
|
+
end
|
35
|
+
|
36
|
+
# Test initial variables and setting/getting state.
|
37
|
+
def test_debugger_base
|
38
|
+
assert_equal(false, Debugger.started?,
|
39
|
+
"Debugger should not initially be started.")
|
40
|
+
Debugger.start
|
41
|
+
assert(Debugger.started?,
|
42
|
+
"Debugger should now be started.")
|
43
|
+
assert_equal(false, Debugger.debug,
|
44
|
+
"Debug variable should not be set.")
|
45
|
+
assert_equal(false, Debugger.post_mortem?,
|
46
|
+
"Post mortem debugging should not be set.")
|
47
|
+
a = Debugger.contexts
|
48
|
+
assert_equal(1, a.size,
|
49
|
+
"There should only be one context.")
|
50
|
+
assert_equal(Array, a.class,
|
51
|
+
"Context should be an array.")
|
52
|
+
Debugger.stop
|
53
|
+
assert_equal(false, Debugger.started?,
|
54
|
+
"debugger should no longer be started.")
|
55
|
+
end
|
56
|
+
|
57
|
+
# Test breakpoint handling
|
58
|
+
def test_breakpoints
|
59
|
+
Debugger.start
|
60
|
+
assert_equal(0, Debugger.breakpoints.size,
|
61
|
+
"There should not be any breakpoints set.")
|
62
|
+
brk = Debugger.add_breakpoint(__FILE__, 1)
|
63
|
+
assert_equal(Debugger::Breakpoint, brk.class,
|
64
|
+
"Breakpoint should have been set and returned.")
|
65
|
+
assert_equal(1, Debugger.breakpoints.size,
|
66
|
+
"There should now be one breakpoint set.")
|
67
|
+
Debugger.remove_breakpoint(0)
|
68
|
+
assert_equal(1, Debugger.breakpoints.size,
|
69
|
+
"There should still be one breakpoint set.")
|
70
|
+
Debugger.remove_breakpoint(1)
|
71
|
+
assert_equal(0, Debugger.breakpoints.size,
|
72
|
+
"There should no longer be any breakpoints set.")
|
73
|
+
Debugger.stop
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: ruby-debug-base
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-
|
8
|
-
summary: Fast Ruby debugger
|
6
|
+
version: 0.10.0
|
7
|
+
date: 2007-12-25 00:00:00 -05:00
|
8
|
+
summary: Fast Ruby debugger - core component
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
11
|
email: ksibilev@yahoo.com
|
12
12
|
homepage: http://rubyforge.org/projects/ruby-debug/
|
13
13
|
rubyforge_project: ruby-debug
|
14
|
-
description: ruby-debug is a fast implementation of the standard Ruby debugger debug.rb. It
|
14
|
+
description: ruby-debug is a fast implementation of the standard Ruby debugger debug.rb. It is implemented by utilizing a new Ruby C API hook. The core component provides support that front-ends can build on. It provides breakpoint handling, bindings for stack frames among other things.
|
15
15
|
autorequire: ruby-debug-base
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|
@@ -29,17 +29,19 @@ post_install_message:
|
|
29
29
|
authors:
|
30
30
|
- Kent Sibilev
|
31
31
|
files:
|
32
|
-
- README
|
33
|
-
- LICENSE
|
34
|
-
- CHANGES
|
35
32
|
- AUTHORS
|
33
|
+
- CHANGES
|
34
|
+
- LICENSE
|
35
|
+
- README
|
36
|
+
- Rakefile
|
36
37
|
- lib/ruby-debug-base.rb
|
37
|
-
-
|
38
|
+
- lib/ChangeLog
|
39
|
+
- ext/ChangeLog
|
38
40
|
- ext/ruby_debug.c
|
39
|
-
- ext/
|
40
|
-
-
|
41
|
-
test_files:
|
42
|
-
|
41
|
+
- ext/extconf.rb
|
42
|
+
- test/test-ruby-debug-base.rb
|
43
|
+
test_files:
|
44
|
+
- test/test-ruby-debug-base.rb
|
43
45
|
rdoc_options: []
|
44
46
|
|
45
47
|
extra_rdoc_files:
|
data/ext/tags
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
CTX_FL_SET ruby_debug.c /^#define CTX_FL_SET(c,f) do { (c)->flags |= (f); } /
|
2
|
-
CTX_FL_TEST ruby_debug.c /^#define CTX_FL_TEST(c,f) ((c)->flags & (f))$/
|
3
|
-
CTX_FL_UNSET ruby_debug.c /^#define CTX_FL_UNSET(c,f) do { (c)->flags &= ~(f);/
|
4
|
-
FRAME ruby_debug.c /^struct FRAME {$/
|
5
|
-
FRAME_N ruby_debug.c /^#define FRAME_N(n) (&debug_context->frames[debug_/
|
6
|
-
Init_breakpoint ruby_debug.c /^Init_breakpoint()$/
|
7
|
-
Init_context ruby_debug.c /^Init_context()$/
|
8
|
-
Init_ruby_debug ruby_debug.c /^Init_ruby_debug()$/
|
9
|
-
RVarmap ruby_debug.c /^struct RVarmap {$/
|
10
|
-
SCOPE ruby_debug.c /^struct SCOPE {$/
|
11
|
-
VALUE ruby_debug.c /^ typedef VALUE (*id2ref_func_t)(VALUE, VALUE);$/
|
12
|
-
add_to_locked ruby_debug.c /^add_to_locked(VALUE thread)$/
|
13
|
-
bp_type ruby_debug.c /^enum bp_type {BP_POS_TYPE, BP_METHOD_TYPE};$/
|
14
|
-
breakpoint_expr ruby_debug.c /^breakpoint_expr(VALUE self)$/
|
15
|
-
breakpoint_id ruby_debug.c /^breakpoint_id(VALUE self)$/
|
16
|
-
breakpoint_mark ruby_debug.c /^breakpoint_mark(void *data)$/
|
17
|
-
breakpoint_pos ruby_debug.c /^breakpoint_pos(VALUE self)$/
|
18
|
-
breakpoint_source ruby_debug.c /^breakpoint_source(VALUE self)$/
|
19
|
-
call_at_line ruby_debug.c /^call_at_line(VALUE context, debug_context_t *debug/
|
20
|
-
call_at_line_unprotected ruby_debug.c /^call_at_line_unprotected(VALUE args)$/
|
21
|
-
check_breakpoint_expression ruby_debug.c /^check_breakpoint_expression(VALUE breakpoint, VALU/
|
22
|
-
check_breakpoints_by_method ruby_debug.c /^check_breakpoints_by_method(debug_context_t *debug/
|
23
|
-
check_breakpoints_by_pos ruby_debug.c /^check_breakpoints_by_pos(debug_context_t *debug_co/
|
24
|
-
check_frame_number ruby_debug.c /^check_frame_number(debug_context_t *debug_context,/
|
25
|
-
check_thread_contexts ruby_debug.c /^check_thread_contexts()$/
|
26
|
-
classname_cmp ruby_debug.c /^classname_cmp(VALUE name, VALUE klass)$/
|
27
|
-
context_copy_locals ruby_debug.c /^context_copy_locals(debug_frame_t *debug_frame)$/
|
28
|
-
context_dead ruby_debug.c /^context_dead(VALUE self)$/
|
29
|
-
context_frame_binding ruby_debug.c /^context_frame_binding(VALUE self, VALUE frame)$/
|
30
|
-
context_frame_file ruby_debug.c /^context_frame_file(VALUE self, VALUE frame)$/
|
31
|
-
context_frame_id ruby_debug.c /^context_frame_id(VALUE self, VALUE frame)$/
|
32
|
-
context_frame_line ruby_debug.c /^context_frame_line(VALUE self, VALUE frame)$/
|
33
|
-
context_frame_locals ruby_debug.c /^context_frame_locals(VALUE self, VALUE frame)$/
|
34
|
-
context_frame_self ruby_debug.c /^context_frame_self(VALUE self, VALUE frame)$/
|
35
|
-
context_ignore ruby_debug.c /^context_ignore(VALUE self)$/
|
36
|
-
context_is_suspended ruby_debug.c /^context_is_suspended(VALUE self)$/
|
37
|
-
context_resume ruby_debug.c /^context_resume(VALUE self)$/
|
38
|
-
context_resume_0 ruby_debug.c /^context_resume_0(debug_context_t *debug_context)$/
|
39
|
-
context_set_tracing ruby_debug.c /^context_set_tracing(VALUE self, VALUE value)$/
|
40
|
-
context_stack_size ruby_debug.c /^context_stack_size(VALUE self)$/
|
41
|
-
context_step_over ruby_debug.c /^context_step_over(int argc, VALUE *argv, VALUE sel/
|
42
|
-
context_stop_frame ruby_debug.c /^context_stop_frame(VALUE self, VALUE frame)$/
|
43
|
-
context_stop_next ruby_debug.c /^context_stop_next(VALUE self, VALUE steps)$/
|
44
|
-
context_suspend ruby_debug.c /^context_suspend(VALUE self)$/
|
45
|
-
context_suspend_0 ruby_debug.c /^context_suspend_0(debug_context_t *debug_context)$/
|
46
|
-
context_thnum ruby_debug.c /^context_thnum(VALUE self)$/
|
47
|
-
context_thread ruby_debug.c /^context_thread(VALUE self)$/
|
48
|
-
context_thread_0 ruby_debug.c /^context_thread_0(debug_context_t *debug_context)$/
|
49
|
-
context_tracing ruby_debug.c /^context_tracing(VALUE self)$/
|
50
|
-
create_binding ruby_debug.c /^create_binding(VALUE self)$/
|
51
|
-
debug_add_breakpoint ruby_debug.c /^debug_add_breakpoint(int argc, VALUE *argv, VALUE /
|
52
|
-
debug_at_exit ruby_debug.c /^debug_at_exit(VALUE self)$/
|
53
|
-
debug_at_exit_c ruby_debug.c /^debug_at_exit_c(VALUE proc)$/
|
54
|
-
debug_at_exit_i ruby_debug.c /^debug_at_exit_i(VALUE proc)$/
|
55
|
-
debug_breakpoint_t ruby_debug.c /^} debug_breakpoint_t;$/
|
56
|
-
debug_breakpoints ruby_debug.c /^debug_breakpoints(VALUE self)$/
|
57
|
-
debug_catchpoint ruby_debug.c /^debug_catchpoint(VALUE self)$/
|
58
|
-
debug_check_started ruby_debug.c /^debug_check_started()$/
|
59
|
-
debug_context_create ruby_debug.c /^debug_context_create(VALUE thread)$/
|
60
|
-
debug_context_dup ruby_debug.c /^debug_context_dup(debug_context_t *debug_context)$/
|
61
|
-
debug_context_free ruby_debug.c /^debug_context_free(void *data)$/
|
62
|
-
debug_context_mark ruby_debug.c /^debug_context_mark(void *data)$/
|
63
|
-
debug_context_t ruby_debug.c /^} debug_context_t;$/
|
64
|
-
debug_contexts ruby_debug.c /^debug_contexts(VALUE self)$/
|
65
|
-
debug_current_context ruby_debug.c /^debug_current_context(VALUE self)$/
|
66
|
-
debug_debug_load ruby_debug.c /^debug_debug_load(VALUE self, VALUE file)$/
|
67
|
-
debug_event_hook ruby_debug.c /^debug_event_hook(rb_event_t event, NODE *node, VAL/
|
68
|
-
debug_frame_t ruby_debug.c /^} debug_frame_t;$/
|
69
|
-
debug_is_started ruby_debug.c /^debug_is_started(VALUE self)$/
|
70
|
-
debug_keep_frame_binding ruby_debug.c /^debug_keep_frame_binding(VALUE self)$/
|
71
|
-
debug_last_interrupted ruby_debug.c /^debug_last_interrupted(VALUE self)$/
|
72
|
-
debug_post_mortem ruby_debug.c /^debug_post_mortem(VALUE self)$/
|
73
|
-
debug_remove_breakpoint ruby_debug.c /^debug_remove_breakpoint(VALUE self, VALUE id_value/
|
74
|
-
debug_resume ruby_debug.c /^debug_resume(VALUE self)$/
|
75
|
-
debug_set_catchpoint ruby_debug.c /^debug_set_catchpoint(VALUE self, VALUE value)$/
|
76
|
-
debug_set_keep_frame_binding ruby_debug.c /^debug_set_keep_frame_binding(VALUE self, VALUE val/
|
77
|
-
debug_set_post_mortem ruby_debug.c /^debug_set_post_mortem(VALUE self, VALUE value)$/
|
78
|
-
debug_set_tracing ruby_debug.c /^debug_set_tracing(VALUE self, VALUE value)$/
|
79
|
-
debug_skip ruby_debug.c /^debug_skip(VALUE self)$/
|
80
|
-
debug_start ruby_debug.c /^debug_start(VALUE self)$/
|
81
|
-
debug_stop ruby_debug.c /^debug_stop(VALUE self)$/
|
82
|
-
debug_stop_i ruby_debug.c /^debug_stop_i(VALUE self)$/
|
83
|
-
debug_suspend ruby_debug.c /^debug_suspend(VALUE self)$/
|
84
|
-
debug_thread_context ruby_debug.c /^debug_thread_context(VALUE self, VALUE thread)$/
|
85
|
-
debug_thread_inherited ruby_debug.c /^debug_thread_inherited(VALUE klass)$/
|
86
|
-
debug_tracing ruby_debug.c /^debug_tracing(VALUE self)$/
|
87
|
-
eval_expression ruby_debug.c /^eval_expression(VALUE args)$/
|
88
|
-
filename_cmp ruby_debug.c /^filename_cmp(VALUE source, char *file)$/
|
89
|
-
find_last_context_func ruby_debug.c /^find_last_context_func(VALUE key, VALUE value, VAL/
|
90
|
-
get_breakpoint_at ruby_debug.c /^get_breakpoint_at(int index) $/
|
91
|
-
get_event_name ruby_debug.c /^get_event_name(rb_event_t event)$/
|
92
|
-
get_top_frame ruby_debug.c /^get_top_frame(debug_context_t *debug_context)$/
|
93
|
-
id2ref ruby_debug.c /^id2ref(VALUE id)$/
|
94
|
-
id2ref_error ruby_debug.c /^id2ref_error()$/
|
95
|
-
id2ref_unprotected ruby_debug.c /^id2ref_unprotected(VALUE id)$/
|
96
|
-
is_in_locked ruby_debug.c /^is_in_locked(VALUE thread_id)$/
|
97
|
-
is_thread_alive ruby_debug.c /^is_thread_alive(VALUE thread)$/
|
98
|
-
isdirsep ruby_debug.c /^#define isdirsep(x) ((x) == '\/' || (x) == '\\\\')/
|
99
|
-
locked_thread_t ruby_debug.c /^} locked_thread_t;$/
|
100
|
-
min ruby_debug.c /^#define min(x,y) ((x) < (y) ? (x) : (y))$/
|
101
|
-
ref2id ruby_debug.c /^ref2id(VALUE obj)$/
|
102
|
-
remove_from_locked ruby_debug.c /^remove_from_locked()$/
|
103
|
-
ruby_method_ptr ruby_debug.c /^ruby_method_ptr(VALUE class, ID meth_id)$/
|
104
|
-
save_call_frame ruby_debug.c /^save_call_frame(VALUE self, char *file, int line, /
|
105
|
-
save_current_position ruby_debug.c /^save_current_position(debug_context_t *debug_conte/
|
106
|
-
save_top_binding ruby_debug.c /^save_top_binding(debug_context_t *debug_context, V/
|
107
|
-
set_current_skipped_status ruby_debug.c /^set_current_skipped_status(VALUE status)$/
|
108
|
-
set_dyna_vars ruby_debug.c /^set_dyna_vars(debug_context_t *debug_context)$/
|
109
|
-
set_frame_source ruby_debug.c /^set_frame_source(debug_context_t *debug_context, c/
|
110
|
-
thread_context_lookup ruby_debug.c /^thread_context_lookup(VALUE thread, VALUE *context/
|
111
|
-
threads_table_check_i ruby_debug.c /^threads_table_check_i(VALUE key, VALUE value, VALU/
|
112
|
-
threads_table_clear ruby_debug.c /^threads_table_clear(VALUE table)$/
|
113
|
-
threads_table_clear_i ruby_debug.c /^threads_table_clear_i(VALUE key, VALUE value, VALU/
|
114
|
-
threads_table_create ruby_debug.c /^threads_table_create()$/
|
115
|
-
threads_table_free ruby_debug.c /^threads_table_free(void* data)$/
|
116
|
-
threads_table_mark ruby_debug.c /^threads_table_mark(void* data)$/
|
117
|
-
threads_table_mark_keyvalue ruby_debug.c /^threads_table_mark_keyvalue(VALUE key, VALUE value/
|
118
|
-
threads_table_t ruby_debug.c /^} threads_table_t;$/
|