readapt 0.8.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +16 -14
- data/.rspec +2 -2
- data/.travis.yml +18 -13
- data/CHANGELOG.md +80 -60
- data/Gemfile +4 -4
- data/LICENSE.txt +21 -21
- data/README.md +37 -29
- data/Rakefile +14 -14
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/exe/readapt +5 -5
- data/ext/readapt/breakpoints.c +83 -83
- data/ext/readapt/breakpoints.h +11 -11
- data/ext/readapt/extconf.rb +0 -0
- data/ext/readapt/frame.c +137 -137
- data/ext/readapt/frame.h +17 -17
- data/ext/readapt/inspector.c +51 -51
- data/ext/readapt/inspector.h +8 -8
- data/ext/readapt/{hash_table.c → lookup_table.c} +211 -211
- data/ext/readapt/lookup_table.h +30 -0
- data/ext/readapt/monitor.c +42 -5
- data/ext/readapt/monitor.h +0 -0
- data/ext/readapt/normalize.c +59 -59
- data/ext/readapt/normalize.h +7 -7
- data/ext/readapt/readapt.c +18 -18
- data/ext/readapt/stack.c +86 -86
- data/ext/readapt/stack.h +20 -20
- data/ext/readapt/threads.c +15 -11
- data/ext/readapt/threads.h +2 -2
- data/lib/readapt.rb +21 -18
- data/lib/readapt/adapter.rb +98 -138
- data/lib/readapt/breakpoint.rb +21 -20
- data/lib/readapt/data_reader.rb +62 -0
- data/lib/readapt/debugger.rb +220 -224
- data/lib/readapt/error.rb +63 -0
- data/lib/readapt/finder.rb +34 -20
- data/lib/readapt/frame.rb +40 -40
- data/lib/readapt/input.rb +7 -0
- data/lib/readapt/message.rb +62 -62
- data/lib/readapt/message/attach.rb +11 -11
- data/lib/readapt/message/base.rb +32 -32
- data/lib/readapt/message/configuration_done.rb +11 -11
- data/lib/readapt/message/continue.rb +15 -15
- data/lib/readapt/message/disconnect.rb +13 -14
- data/lib/readapt/message/evaluate.rb +18 -18
- data/lib/readapt/message/initialize.rb +13 -13
- data/lib/readapt/message/launch.rb +11 -11
- data/lib/readapt/message/next.rb +12 -12
- data/lib/readapt/message/pause.rb +11 -11
- data/lib/readapt/message/scopes.rb +26 -26
- data/lib/readapt/message/set_breakpoints.rb +25 -25
- data/lib/readapt/message/set_exception_breakpoints.rb +8 -8
- data/lib/readapt/message/stack_trace.rb +38 -38
- data/lib/readapt/message/step_in.rb +11 -11
- data/lib/readapt/message/step_out.rb +11 -11
- data/lib/readapt/message/threads.rb +18 -18
- data/lib/readapt/message/variables.rb +61 -61
- data/lib/readapt/monitor.rb +0 -0
- data/lib/readapt/output.rb +25 -0
- data/lib/readapt/references.rb +27 -0
- data/lib/readapt/server.rb +22 -0
- data/lib/readapt/shell.rb +104 -41
- data/lib/readapt/snapshot.rb +0 -0
- data/lib/readapt/thread.rb +25 -28
- data/lib/readapt/variable.rb +1 -1
- data/lib/readapt/version.rb +3 -3
- data/readapt.gemspec +39 -39
- metadata +15 -9
- data/ext/readapt/hash_table.h +0 -30
data/ext/readapt/monitor.c
CHANGED
@@ -14,6 +14,7 @@ static VALUE tpCall;
|
|
14
14
|
static VALUE tpReturn;
|
15
15
|
static VALUE tpThreadBegin;
|
16
16
|
static VALUE tpThreadEnd;
|
17
|
+
static VALUE tpRaise;
|
17
18
|
static VALUE debugProc;
|
18
19
|
static int firstLineEvent = 0;
|
19
20
|
static char *entryFile;
|
@@ -52,7 +53,7 @@ monitor_debug(const char *file, const long line, VALUE tracepoint, thread_refere
|
|
52
53
|
gc_disabled = rb_gc_disable();
|
53
54
|
thread_reference_build_frames(ptr);
|
54
55
|
snapshot = rb_funcall(c_Snapshot, rb_intern("new"), 4,
|
55
|
-
|
56
|
+
INT2NUM(ptr->id),
|
56
57
|
rb_str_new_cstr(file),
|
57
58
|
INT2NUM(line),
|
58
59
|
ID2SYM(event)
|
@@ -99,7 +100,6 @@ process_line_event(VALUE tracepoint, void *data)
|
|
99
100
|
|
100
101
|
arg = rb_tracearg_from_tracepoint(tracepoint);
|
101
102
|
tmp = rb_tracearg_path(arg);
|
102
|
-
// tp_file = normalize_path_new_cstr(StringValueCStr(tmp));
|
103
103
|
tp_file = StringValueCStr(tmp);
|
104
104
|
normalize_path(tp_file);
|
105
105
|
tmp = rb_tracearg_lineno(arg);
|
@@ -136,8 +136,6 @@ process_line_event(VALUE tracepoint, void *data)
|
|
136
136
|
{
|
137
137
|
monitor_debug(tp_file, tp_line, tracepoint, ptr, dapEvent);
|
138
138
|
}
|
139
|
-
|
140
|
-
// free(tp_file);
|
141
139
|
}
|
142
140
|
}
|
143
141
|
|
@@ -210,6 +208,40 @@ process_thread_end_event(VALUE tracepoint, void *data)
|
|
210
208
|
}
|
211
209
|
}
|
212
210
|
|
211
|
+
static void
|
212
|
+
process_raise_event(VALUE tracepoint, void *data)
|
213
|
+
{
|
214
|
+
rb_trace_arg_t *arg;
|
215
|
+
VALUE exception;
|
216
|
+
VALUE ref;
|
217
|
+
thread_reference_t *ptr;
|
218
|
+
VALUE tmp;
|
219
|
+
char *tp_file;
|
220
|
+
long tp_line;
|
221
|
+
|
222
|
+
ref = thread_current_reference();
|
223
|
+
if (ref != Qnil)
|
224
|
+
{
|
225
|
+
arg = rb_tracearg_from_tracepoint(tracepoint);
|
226
|
+
exception = rb_tracearg_raised_exception(arg);
|
227
|
+
if (rb_class_inherited_p(rb_obj_class(exception), rb_eStandardError)) {
|
228
|
+
ptr = thread_reference_pointer(ref);
|
229
|
+
tmp = rb_tracearg_path(arg);
|
230
|
+
tp_file = StringValueCStr(tmp);
|
231
|
+
normalize_path(tp_file);
|
232
|
+
tmp = rb_tracearg_lineno(arg);
|
233
|
+
tp_line = NUM2INT(tmp);
|
234
|
+
monitor_debug(
|
235
|
+
tp_file,
|
236
|
+
tp_line,
|
237
|
+
tracepoint,
|
238
|
+
ptr,
|
239
|
+
rb_intern("raise")
|
240
|
+
);
|
241
|
+
}
|
242
|
+
}
|
243
|
+
}
|
244
|
+
|
213
245
|
static VALUE
|
214
246
|
monitor_enable_s(VALUE self, VALUE file)
|
215
247
|
{
|
@@ -218,7 +250,6 @@ monitor_enable_s(VALUE self, VALUE file)
|
|
218
250
|
|
219
251
|
if (rb_block_given_p()) {
|
220
252
|
debugProc = rb_block_proc();
|
221
|
-
rb_global_variable(&debugProc);
|
222
253
|
} else {
|
223
254
|
rb_raise(rb_eArgError, "must be called with a block");
|
224
255
|
}
|
@@ -250,6 +281,7 @@ monitor_enable_s(VALUE self, VALUE file)
|
|
250
281
|
rb_tracepoint_enable(tpReturn);
|
251
282
|
rb_tracepoint_enable(tpThreadBegin);
|
252
283
|
rb_tracepoint_enable(tpThreadEnd);
|
284
|
+
rb_tracepoint_enable(tpRaise);
|
253
285
|
return previous;
|
254
286
|
}
|
255
287
|
|
@@ -264,6 +296,7 @@ monitor_disable_s(VALUE self)
|
|
264
296
|
rb_tracepoint_disable(tpReturn);
|
265
297
|
rb_tracepoint_disable(tpThreadBegin);
|
266
298
|
rb_tracepoint_disable(tpThreadEnd);
|
299
|
+
rb_tracepoint_disable(tpRaise);
|
267
300
|
|
268
301
|
free(entryFile);
|
269
302
|
entryFile = NULL;
|
@@ -304,6 +337,7 @@ void initialize_monitor(VALUE m_Readapt)
|
|
304
337
|
tpReturn = rb_tracepoint_new(Qnil, RUBY_EVENT_RETURN | RUBY_EVENT_B_RETURN | RUBY_EVENT_END | RUBY_EVENT_C_RETURN, process_return_event, NULL);
|
305
338
|
tpThreadBegin = rb_tracepoint_new(Qnil, RUBY_EVENT_THREAD_BEGIN, process_thread_begin_event, NULL);
|
306
339
|
tpThreadEnd = rb_tracepoint_new(Qnil, RUBY_EVENT_THREAD_END, process_thread_end_event, NULL);
|
340
|
+
tpRaise = rb_tracepoint_new(Qnil, RUBY_EVENT_RAISE, process_raise_event, NULL);
|
307
341
|
debugProc = Qnil;
|
308
342
|
|
309
343
|
id_continue = rb_intern("continue");
|
@@ -316,4 +350,7 @@ void initialize_monitor(VALUE m_Readapt)
|
|
316
350
|
rb_global_variable(&tpReturn);
|
317
351
|
rb_global_variable(&tpThreadBegin);
|
318
352
|
rb_global_variable(&tpThreadEnd);
|
353
|
+
rb_global_variable(&tpRaise);
|
354
|
+
|
355
|
+
rb_global_variable(&debugProc);
|
319
356
|
}
|
data/ext/readapt/monitor.h
CHANGED
File without changes
|
data/ext/readapt/normalize.c
CHANGED
@@ -1,59 +1,59 @@
|
|
1
|
-
#include "ruby.h"
|
2
|
-
#include "ruby/debug.h"
|
3
|
-
#include <ctype.h>
|
4
|
-
|
5
|
-
static int isWindows;
|
6
|
-
|
7
|
-
static int
|
8
|
-
checkIfWindows()
|
9
|
-
{
|
10
|
-
VALUE regexp, result;
|
11
|
-
|
12
|
-
regexp = rb_reg_new("/cygwin|mswin|mingw|bccwin|wince|emx/", 37, 0);
|
13
|
-
result = rb_reg_match(regexp, rb_str_new_cstr(RUBY_PLATFORM));
|
14
|
-
return result == Qnil ? 0 : 1;
|
15
|
-
}
|
16
|
-
|
17
|
-
void normalize_path(char *str)
|
18
|
-
{
|
19
|
-
long i, len;
|
20
|
-
|
21
|
-
if (isWindows)
|
22
|
-
{
|
23
|
-
str[0] = toupper(str[0]);
|
24
|
-
len = strlen(str);
|
25
|
-
for (i = 2; i < len; i++)
|
26
|
-
{
|
27
|
-
if (str[i] == '\\')
|
28
|
-
{
|
29
|
-
str[i] = '/';
|
30
|
-
}
|
31
|
-
}
|
32
|
-
}
|
33
|
-
}
|
34
|
-
|
35
|
-
char *normalize_path_new_cstr(char *str)
|
36
|
-
{
|
37
|
-
char *buffer;
|
38
|
-
|
39
|
-
buffer = malloc((strlen(str) + 1) * sizeof(char));
|
40
|
-
strcpy(buffer, str);
|
41
|
-
normalize_path(buffer);
|
42
|
-
return buffer;
|
43
|
-
}
|
44
|
-
|
45
|
-
static VALUE
|
46
|
-
normalize_path_s(VALUE self, VALUE str)
|
47
|
-
{
|
48
|
-
char *path = normalize_path_new_cstr(StringValueCStr(str));
|
49
|
-
VALUE result = rb_str_new_cstr(path);
|
50
|
-
free(path);
|
51
|
-
return result;
|
52
|
-
}
|
53
|
-
|
54
|
-
void initialize_normalize(VALUE m_Readapt)
|
55
|
-
{
|
56
|
-
isWindows = checkIfWindows();
|
57
|
-
|
58
|
-
rb_define_singleton_method(m_Readapt, "normalize_path", normalize_path_s, 1);
|
59
|
-
}
|
1
|
+
#include "ruby.h"
|
2
|
+
#include "ruby/debug.h"
|
3
|
+
#include <ctype.h>
|
4
|
+
|
5
|
+
static int isWindows;
|
6
|
+
|
7
|
+
static int
|
8
|
+
checkIfWindows()
|
9
|
+
{
|
10
|
+
VALUE regexp, result;
|
11
|
+
|
12
|
+
regexp = rb_reg_new("/cygwin|mswin|mingw|bccwin|wince|emx/", 37, 0);
|
13
|
+
result = rb_reg_match(regexp, rb_str_new_cstr(RUBY_PLATFORM));
|
14
|
+
return result == Qnil ? 0 : 1;
|
15
|
+
}
|
16
|
+
|
17
|
+
void normalize_path(char *str)
|
18
|
+
{
|
19
|
+
long i, len;
|
20
|
+
|
21
|
+
if (isWindows)
|
22
|
+
{
|
23
|
+
str[0] = toupper(str[0]);
|
24
|
+
len = strlen(str);
|
25
|
+
for (i = 2; i < len; i++)
|
26
|
+
{
|
27
|
+
if (str[i] == '\\')
|
28
|
+
{
|
29
|
+
str[i] = '/';
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
char *normalize_path_new_cstr(char *str)
|
36
|
+
{
|
37
|
+
char *buffer;
|
38
|
+
|
39
|
+
buffer = malloc((strlen(str) + 1) * sizeof(char));
|
40
|
+
strcpy(buffer, str);
|
41
|
+
normalize_path(buffer);
|
42
|
+
return buffer;
|
43
|
+
}
|
44
|
+
|
45
|
+
static VALUE
|
46
|
+
normalize_path_s(VALUE self, VALUE str)
|
47
|
+
{
|
48
|
+
char *path = normalize_path_new_cstr(StringValueCStr(str));
|
49
|
+
VALUE result = rb_str_new_cstr(path);
|
50
|
+
free(path);
|
51
|
+
return result;
|
52
|
+
}
|
53
|
+
|
54
|
+
void initialize_normalize(VALUE m_Readapt)
|
55
|
+
{
|
56
|
+
isWindows = checkIfWindows();
|
57
|
+
|
58
|
+
rb_define_singleton_method(m_Readapt, "normalize_path", normalize_path_s, 1);
|
59
|
+
}
|
data/ext/readapt/normalize.h
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
#ifndef NORMALIZE_H_
|
2
|
-
#define NORMALIZE_H_
|
3
|
-
|
4
|
-
void initialize_normalize(VALUE);
|
5
|
-
char *normalize_path_new_cstr(char *str);
|
6
|
-
void normalize_path(char *str);
|
7
|
-
#endif
|
1
|
+
#ifndef NORMALIZE_H_
|
2
|
+
#define NORMALIZE_H_
|
3
|
+
|
4
|
+
void initialize_normalize(VALUE);
|
5
|
+
char *normalize_path_new_cstr(char *str);
|
6
|
+
void normalize_path(char *str);
|
7
|
+
#endif
|
data/ext/readapt/readapt.c
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
#include "ruby.h"
|
2
|
-
#include "ruby/debug.h"
|
3
|
-
#include "monitor.h"
|
4
|
-
#include "normalize.h"
|
5
|
-
#include "breakpoints.h"
|
6
|
-
#include "frame.h"
|
7
|
-
|
8
|
-
static VALUE m_Readapt;
|
9
|
-
|
10
|
-
void Init_readapt()
|
11
|
-
{
|
12
|
-
m_Readapt = rb_define_module("Readapt");
|
13
|
-
|
14
|
-
initialize_normalize(m_Readapt);
|
15
|
-
initialize_breakpoints(m_Readapt);
|
16
|
-
initialize_frame(m_Readapt);
|
17
|
-
initialize_monitor(m_Readapt);
|
18
|
-
}
|
1
|
+
#include "ruby.h"
|
2
|
+
#include "ruby/debug.h"
|
3
|
+
#include "monitor.h"
|
4
|
+
#include "normalize.h"
|
5
|
+
#include "breakpoints.h"
|
6
|
+
#include "frame.h"
|
7
|
+
|
8
|
+
static VALUE m_Readapt;
|
9
|
+
|
10
|
+
void Init_readapt()
|
11
|
+
{
|
12
|
+
m_Readapt = rb_define_module("Readapt");
|
13
|
+
|
14
|
+
initialize_normalize(m_Readapt);
|
15
|
+
initialize_breakpoints(m_Readapt);
|
16
|
+
initialize_frame(m_Readapt);
|
17
|
+
initialize_monitor(m_Readapt);
|
18
|
+
}
|
data/ext/readapt/stack.c
CHANGED
@@ -1,86 +1,86 @@
|
|
1
|
-
#include <stdlib.h>
|
2
|
-
#include "stack.h"
|
3
|
-
|
4
|
-
#define STACK_CAPACITY 20
|
5
|
-
|
6
|
-
/**
|
7
|
-
* Allocate a stack. The `elem_size` is the expected size of each element,
|
8
|
-
* e.g., `sizeof(some_struct)`. The optional `free_func` argument is a pointer
|
9
|
-
* to a function that will be called when an element is popped off the stack.
|
10
|
-
*/
|
11
|
-
|
12
|
-
{
|
13
|
-
|
14
|
-
s->elem_size = elem_size;
|
15
|
-
s->free_func = free_func;
|
16
|
-
s->size = 0;
|
17
|
-
s->capacity = 0;
|
18
|
-
return s;
|
19
|
-
}
|
20
|
-
|
21
|
-
/**
|
22
|
-
* Add an element to the end of the stack
|
23
|
-
*/
|
24
|
-
void stack_push(
|
25
|
-
{
|
26
|
-
if (stack->size == stack->capacity)
|
27
|
-
{
|
28
|
-
if (stack->capacity == 0)
|
29
|
-
{
|
30
|
-
stack->capacity = STACK_CAPACITY;
|
31
|
-
stack->elements = malloc(stack->elem_size * stack->capacity);
|
32
|
-
}
|
33
|
-
else
|
34
|
-
{
|
35
|
-
stack->capacity += STACK_CAPACITY;
|
36
|
-
stack->elements = realloc(stack->elements, stack->elem_size * stack->capacity);
|
37
|
-
}
|
38
|
-
}
|
39
|
-
stack->elements[stack->size] = element;
|
40
|
-
stack->size++;
|
41
|
-
}
|
42
|
-
|
43
|
-
/**
|
44
|
-
* Get a pointer to the last element in the stack.
|
45
|
-
*/
|
46
|
-
void *stack_peek(
|
47
|
-
{
|
48
|
-
return stack->size == 0 ? NULL : stack->elements[stack->size - 1];
|
49
|
-
}
|
50
|
-
|
51
|
-
/**
|
52
|
-
* Pop the last element off the stack and pass it to free_func.
|
53
|
-
*/
|
54
|
-
void stack_pop(
|
55
|
-
{
|
56
|
-
void *e;
|
57
|
-
|
58
|
-
if (stack->size > 0)
|
59
|
-
{
|
60
|
-
e = stack->elements[stack->size - 1];
|
61
|
-
if (stack->free_func)
|
62
|
-
{
|
63
|
-
stack->free_func(e);
|
64
|
-
}
|
65
|
-
// stack->elements[stack->size - 1] = NULL;
|
66
|
-
stack->size--;
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
|
-
/**
|
71
|
-
* Free the stack from memory. If it still contains any elements, pass them to
|
72
|
-
* free_func.
|
73
|
-
*/
|
74
|
-
void stack_free(
|
75
|
-
{
|
76
|
-
int i;
|
77
|
-
|
78
|
-
if (stack->free_func)
|
79
|
-
{
|
80
|
-
for (i = 0; i < stack->size; i++)
|
81
|
-
{
|
82
|
-
stack->free_func(stack->elements[i]);
|
83
|
-
}
|
84
|
-
}
|
85
|
-
free(stack);
|
86
|
-
}
|
1
|
+
#include <stdlib.h>
|
2
|
+
#include "stack.h"
|
3
|
+
|
4
|
+
#define STACK_CAPACITY 20
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Allocate a stack. The `elem_size` is the expected size of each element,
|
8
|
+
* e.g., `sizeof(some_struct)`. The optional `free_func` argument is a pointer
|
9
|
+
* to a function that will be called when an element is popped off the stack.
|
10
|
+
*/
|
11
|
+
readapt_stack_t *stack_alloc(size_t elem_size, void (*free_func)(void *))
|
12
|
+
{
|
13
|
+
readapt_stack_t *s = malloc(sizeof(readapt_stack_t));
|
14
|
+
s->elem_size = elem_size;
|
15
|
+
s->free_func = free_func;
|
16
|
+
s->size = 0;
|
17
|
+
s->capacity = 0;
|
18
|
+
return s;
|
19
|
+
}
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Add an element to the end of the stack
|
23
|
+
*/
|
24
|
+
void stack_push(readapt_stack_t *stack, void *element)
|
25
|
+
{
|
26
|
+
if (stack->size == stack->capacity)
|
27
|
+
{
|
28
|
+
if (stack->capacity == 0)
|
29
|
+
{
|
30
|
+
stack->capacity = STACK_CAPACITY;
|
31
|
+
stack->elements = malloc(stack->elem_size * stack->capacity);
|
32
|
+
}
|
33
|
+
else
|
34
|
+
{
|
35
|
+
stack->capacity += STACK_CAPACITY;
|
36
|
+
stack->elements = realloc(stack->elements, stack->elem_size * stack->capacity);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
stack->elements[stack->size] = element;
|
40
|
+
stack->size++;
|
41
|
+
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Get a pointer to the last element in the stack.
|
45
|
+
*/
|
46
|
+
void *stack_peek(readapt_stack_t *stack)
|
47
|
+
{
|
48
|
+
return stack->size == 0 ? NULL : stack->elements[stack->size - 1];
|
49
|
+
}
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Pop the last element off the stack and pass it to free_func.
|
53
|
+
*/
|
54
|
+
void stack_pop(readapt_stack_t *stack)
|
55
|
+
{
|
56
|
+
void *e;
|
57
|
+
|
58
|
+
if (stack->size > 0)
|
59
|
+
{
|
60
|
+
e = stack->elements[stack->size - 1];
|
61
|
+
if (stack->free_func)
|
62
|
+
{
|
63
|
+
stack->free_func(e);
|
64
|
+
}
|
65
|
+
// stack->elements[stack->size - 1] = NULL;
|
66
|
+
stack->size--;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
/**
|
71
|
+
* Free the stack from memory. If it still contains any elements, pass them to
|
72
|
+
* free_func.
|
73
|
+
*/
|
74
|
+
void stack_free(readapt_stack_t *stack)
|
75
|
+
{
|
76
|
+
int i;
|
77
|
+
|
78
|
+
if (stack->free_func)
|
79
|
+
{
|
80
|
+
for (i = 0; i < stack->size; i++)
|
81
|
+
{
|
82
|
+
stack->free_func(stack->elements[i]);
|
83
|
+
}
|
84
|
+
}
|
85
|
+
free(stack);
|
86
|
+
}
|