debase 0.1.2 → 0.1.3.beta1
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.
- checksums.yaml +4 -4
- data/ext/context.c +7 -4
- data/ext/debase_internals.c +24 -5
- data/ext/debase_internals.h +4 -1
- data/lib/debase.rb +18 -0
- data/lib/debase/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c12b5c66970a15c8070dc6ce49a074c549a85fad
|
4
|
+
data.tar.gz: b41b9cf71db312290e1f6470cbcc092fb9cfdd4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 045c4f73b463635eae68dbc1119dd1658aa53740f6a1d7594745472654cdb37f77e494f697051a69eb9fa84cb282cd2b744063786dff0f0e7812030396c2a301
|
7
|
+
data.tar.gz: cf1cd09d4ad03af0a0ad1a84b6927e71db577636276cdd5595fd28747cf18325fa5a1735d8b92250e6cfd957860e521b8d0743de9ed6cbc5291044cdd9a5ed10
|
data/ext/context.c
CHANGED
@@ -133,9 +133,12 @@ Context_free(debug_context_t *context) {
|
|
133
133
|
extern VALUE
|
134
134
|
context_create(VALUE thread, VALUE cDebugThread) {
|
135
135
|
debug_context_t *context;
|
136
|
+
VALUE locations;
|
136
137
|
|
137
138
|
context = ALLOC(debug_context_t);
|
138
139
|
context->stack_size = 0;
|
140
|
+
locations = rb_funcall(thread, rb_intern("backtrace_locations"), 1, INT2FIX(1));
|
141
|
+
context->calced_stack_size = locations != Qnil ? (int)RARRAY_LEN(locations) : 0;
|
139
142
|
context->stack = NULL;
|
140
143
|
context->thnum = ++thnum_current;
|
141
144
|
context->thread = thread;
|
@@ -306,15 +309,15 @@ Context_step_over(int argc, VALUE *argv, VALUE self)
|
|
306
309
|
rb_scan_args(argc, argv, "12", &lines, &frame, &force);
|
307
310
|
context->stop_line = FIX2INT(lines);
|
308
311
|
CTX_FL_UNSET(context, CTX_FL_STEPPED);
|
309
|
-
if(frame == Qnil)
|
312
|
+
if (frame == Qnil)
|
310
313
|
{
|
311
|
-
context->dest_frame = context->
|
314
|
+
context->dest_frame = context->calced_stack_size;
|
312
315
|
}
|
313
316
|
else
|
314
317
|
{
|
315
|
-
if(FIX2INT(frame) < 0 && FIX2INT(frame) >= context->
|
318
|
+
if (FIX2INT(frame) < 0 && FIX2INT(frame) >= context->calced_stack_size)
|
316
319
|
rb_raise(rb_eRuntimeError, "Destination frame is out of range.");
|
317
|
-
context->dest_frame = context->
|
320
|
+
context->dest_frame = context->calced_stack_size - FIX2INT(frame);
|
318
321
|
}
|
319
322
|
if(RTEST(force))
|
320
323
|
CTX_FL_SET(context, CTX_FL_FORCE_MOVE);
|
data/ext/debase_internals.c
CHANGED
@@ -106,6 +106,21 @@ check_start_processing(debug_context_t *context, VALUE thread)
|
|
106
106
|
return 1;
|
107
107
|
}
|
108
108
|
|
109
|
+
static inline const char*
|
110
|
+
symbol2str(VALUE symbol)
|
111
|
+
{
|
112
|
+
VALUE id;
|
113
|
+
static const char* nil_str= "nil";
|
114
|
+
if (symbol == Qnil) {
|
115
|
+
return nil_str;
|
116
|
+
}
|
117
|
+
id = SYM2ID(symbol);
|
118
|
+
if (symbol == Qnil) {
|
119
|
+
return nil_str;
|
120
|
+
}
|
121
|
+
return rb_id2name(id);
|
122
|
+
}
|
123
|
+
|
109
124
|
static inline void
|
110
125
|
print_event(rb_trace_point_t *tp, debug_context_t *context)
|
111
126
|
{
|
@@ -120,9 +135,11 @@ print_event(rb_trace_point_t *tp, debug_context_t *context)
|
|
120
135
|
line = rb_tracearg_lineno(tp);
|
121
136
|
event = rb_tracearg_event(tp);
|
122
137
|
mid = rb_tracearg_method_id(tp);
|
123
|
-
fprintf(stderr, "%s: file=%s, line=%d, mid=%s\n",
|
138
|
+
fprintf(stderr, "%s: file=%s, line=%d, mid=%s\n", symbol2str(event), RSTRING_PTR(path), FIX2INT(line), symbol2str(mid));
|
124
139
|
locations = rb_funcall(context->thread, rb_intern("backtrace_locations"), 1, INT2FIX(1));
|
125
|
-
fprintf(stderr, " stack_size=%d, thread=%d, real_stack_size=%d\n",
|
140
|
+
fprintf(stderr, " calced_stack_size=%d, stack_size=%d, thread=%d, real_stack_size=%d\n",
|
141
|
+
context->calced_stack_size, context->stack_size, context->thnum,
|
142
|
+
locations != Qnil ? (int)RARRAY_LEN(locations) : 0);
|
126
143
|
}
|
127
144
|
}
|
128
145
|
|
@@ -211,7 +228,7 @@ process_line_event(VALUE trace_point, void *data)
|
|
211
228
|
strcmp(context->last_file, file) != 0;
|
212
229
|
}
|
213
230
|
|
214
|
-
if(context->dest_frame == -1 || context->
|
231
|
+
if (context->dest_frame == -1 || context->calced_stack_size == context->dest_frame)
|
215
232
|
{
|
216
233
|
if(moved || !CTX_FL_TEST(context, CTX_FL_FORCE_MOVE))
|
217
234
|
context->stop_next--;
|
@@ -223,7 +240,7 @@ process_line_event(VALUE trace_point, void *data)
|
|
223
240
|
CTX_FL_UNSET(context, CTX_FL_STEPPED);
|
224
241
|
}
|
225
242
|
}
|
226
|
-
else if(context->
|
243
|
+
else if(context->calced_stack_size < context->dest_frame)
|
227
244
|
{
|
228
245
|
context->stop_next = 0;
|
229
246
|
}
|
@@ -252,6 +269,7 @@ process_return_event(VALUE trace_point, void *data)
|
|
252
269
|
Data_Get_Struct(context_object, debug_context_t, context);
|
253
270
|
if (!check_start_processing(context, rb_thread_current())) return;
|
254
271
|
|
272
|
+
--context->calced_stack_size;
|
255
273
|
update_stack_size(context);
|
256
274
|
if(context->stack_size == context->stop_frame)
|
257
275
|
{
|
@@ -274,6 +292,7 @@ process_call_event(VALUE trace_point, void *data)
|
|
274
292
|
Data_Get_Struct(context_object, debug_context_t, context);
|
275
293
|
if (!check_start_processing(context, rb_thread_current())) return;
|
276
294
|
|
295
|
+
++context->calced_stack_size;
|
277
296
|
update_stack_size(context);
|
278
297
|
print_event(TRACE_POINT, context);
|
279
298
|
cleanup(context);
|
@@ -323,7 +342,7 @@ process_raise_event(VALUE trace_point, void *data)
|
|
323
342
|
|
324
343
|
static VALUE
|
325
344
|
Debase_setup_tracepoints(VALUE self)
|
326
|
-
{
|
345
|
+
{
|
327
346
|
if (catchpoints != Qnil) return Qnil;
|
328
347
|
contexts = rb_hash_new();
|
329
348
|
breakpoints = rb_ary_new();
|
data/ext/debase_internals.h
CHANGED
@@ -49,11 +49,14 @@ typedef struct debug_context {
|
|
49
49
|
|
50
50
|
ctx_stop_reason stop_reason;
|
51
51
|
int stop_next;
|
52
|
-
int dest_frame;
|
53
52
|
int stop_line;
|
54
53
|
int stop_frame;
|
55
54
|
int thread_pause;
|
56
55
|
|
56
|
+
/* dest_frame uses calced_stack_size for stepping */
|
57
|
+
int dest_frame;
|
58
|
+
int calced_stack_size;
|
59
|
+
|
57
60
|
char *last_file;
|
58
61
|
int last_line;
|
59
62
|
} debug_context_t;
|
data/lib/debase.rb
CHANGED
@@ -49,6 +49,24 @@ module Debase
|
|
49
49
|
def add_catchpoint(exception)
|
50
50
|
catchpoints[exception] = 0
|
51
51
|
end
|
52
|
+
|
53
|
+
#call-seq:
|
54
|
+
# Debase.skip { block } -> obj or nil
|
55
|
+
#
|
56
|
+
#The code inside of the block is escaped from the debugger.
|
57
|
+
def skip
|
58
|
+
#it looks like no-op is ok for this method for now
|
59
|
+
#no-op
|
60
|
+
end
|
61
|
+
|
62
|
+
#call-seq:
|
63
|
+
# Debugger.last_interrupted -> context
|
64
|
+
#
|
65
|
+
#Returns last debugged context.
|
66
|
+
def last_context
|
67
|
+
# not sure why we need this so let's return nil for now ;)
|
68
|
+
nil
|
69
|
+
end
|
52
70
|
end
|
53
71
|
|
54
72
|
class DebugThread < Thread
|
data/lib/debase/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dennis Ushakov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debase-ruby_core_source
|
@@ -125,9 +125,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
|
-
- - "
|
128
|
+
- - ">"
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version:
|
130
|
+
version: 1.3.1
|
131
131
|
requirements: []
|
132
132
|
rubyforge_project: debase
|
133
133
|
rubygems_version: 2.2.2
|