readapt 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +16 -15
  3. data/.rspec +2 -2
  4. data/.travis.yml +18 -18
  5. data/CHANGELOG.md +72 -69
  6. data/Gemfile +4 -4
  7. data/LICENSE.txt +21 -21
  8. data/README.md +37 -29
  9. data/Rakefile +14 -14
  10. data/bin/console +14 -14
  11. data/bin/setup +8 -8
  12. data/exe/readapt +5 -5
  13. data/ext/readapt/breakpoints.c +83 -83
  14. data/ext/readapt/breakpoints.h +11 -11
  15. data/ext/readapt/extconf.rb +0 -0
  16. data/ext/readapt/frame.c +137 -137
  17. data/ext/readapt/frame.h +17 -17
  18. data/ext/readapt/hash_table.c +211 -211
  19. data/ext/readapt/hash_table.h +30 -30
  20. data/ext/readapt/inspector.c +51 -51
  21. data/ext/readapt/inspector.h +8 -8
  22. data/ext/readapt/monitor.c +1 -1
  23. data/ext/readapt/monitor.h +0 -0
  24. data/ext/readapt/normalize.c +59 -59
  25. data/ext/readapt/normalize.h +7 -7
  26. data/ext/readapt/readapt.c +18 -18
  27. data/ext/readapt/stack.c +86 -86
  28. data/ext/readapt/stack.h +20 -20
  29. data/ext/readapt/threads.c +15 -11
  30. data/ext/readapt/threads.h +1 -1
  31. data/lib/readapt.rb +21 -20
  32. data/lib/readapt/adapter.rb +98 -98
  33. data/lib/readapt/breakpoint.rb +20 -20
  34. data/lib/readapt/data_reader.rb +62 -62
  35. data/lib/readapt/debugger.rb +220 -220
  36. data/lib/readapt/error.rb +63 -63
  37. data/lib/readapt/finder.rb +20 -20
  38. data/lib/readapt/frame.rb +40 -40
  39. data/lib/readapt/input.rb +7 -7
  40. data/lib/readapt/message.rb +62 -62
  41. data/lib/readapt/message/attach.rb +11 -11
  42. data/lib/readapt/message/base.rb +32 -32
  43. data/lib/readapt/message/configuration_done.rb +11 -11
  44. data/lib/readapt/message/continue.rb +15 -15
  45. data/lib/readapt/message/disconnect.rb +13 -13
  46. data/lib/readapt/message/evaluate.rb +18 -18
  47. data/lib/readapt/message/initialize.rb +13 -13
  48. data/lib/readapt/message/launch.rb +11 -11
  49. data/lib/readapt/message/next.rb +12 -12
  50. data/lib/readapt/message/pause.rb +11 -11
  51. data/lib/readapt/message/scopes.rb +26 -26
  52. data/lib/readapt/message/set_breakpoints.rb +25 -25
  53. data/lib/readapt/message/set_exception_breakpoints.rb +8 -8
  54. data/lib/readapt/message/stack_trace.rb +38 -38
  55. data/lib/readapt/message/step_in.rb +11 -11
  56. data/lib/readapt/message/step_out.rb +11 -11
  57. data/lib/readapt/message/threads.rb +18 -18
  58. data/lib/readapt/message/variables.rb +61 -61
  59. data/lib/readapt/monitor.rb +0 -0
  60. data/lib/readapt/output.rb +25 -25
  61. data/lib/readapt/references.rb +27 -0
  62. data/lib/readapt/server.rb +22 -22
  63. data/lib/readapt/shell.rb +104 -104
  64. data/lib/readapt/snapshot.rb +0 -0
  65. data/lib/readapt/thread.rb +23 -23
  66. data/lib/readapt/variable.rb +1 -1
  67. data/lib/readapt/version.rb +3 -3
  68. data/readapt.gemspec +39 -39
  69. metadata +4 -3
@@ -1,30 +1,30 @@
1
- #ifndef HASH_TABLE_H_
2
- #define HASH_TABLE_H_
3
-
4
- typedef struct ht_long_array
5
- {
6
- long *items;
7
- long size;
8
- } ht_long_array;
9
-
10
- // ht_item is an item in the hash table
11
- typedef struct ht_item
12
- {
13
- char *key;
14
- ht_long_array *value;
15
- } ht_item;
16
-
17
- typedef struct ht_hash_table
18
- {
19
- long size;
20
- ht_item **items;
21
- } ht_hash_table;
22
-
23
- ht_hash_table *ht_new();
24
- void ht_del_hash_table(ht_hash_table *ht);
25
-
26
- void ht_insert(ht_hash_table *ht, char *key, const long *value, const long size);
27
- ht_long_array *ht_search(ht_hash_table *ht, char *key);
28
- void ht_delete(ht_hash_table *h, char *key);
29
-
30
- #endif // HASH_TABLE_H_
1
+ #ifndef HASH_TABLE_H_
2
+ #define HASH_TABLE_H_
3
+
4
+ typedef struct ht_long_array
5
+ {
6
+ long *items;
7
+ long size;
8
+ } ht_long_array;
9
+
10
+ // ht_item is an item in the hash table
11
+ typedef struct ht_item
12
+ {
13
+ char *key;
14
+ ht_long_array *value;
15
+ } ht_item;
16
+
17
+ typedef struct ht_hash_table
18
+ {
19
+ long size;
20
+ ht_item **items;
21
+ } ht_hash_table;
22
+
23
+ ht_hash_table *ht_new();
24
+ void ht_del_hash_table(ht_hash_table *ht);
25
+
26
+ void ht_insert(ht_hash_table *ht, char *key, const long *value, const long size);
27
+ ht_long_array *ht_search(ht_hash_table *ht, char *key);
28
+ void ht_delete(ht_hash_table *h, char *key);
29
+
30
+ #endif // HASH_TABLE_H_
@@ -1,51 +1,51 @@
1
- #include "ruby.h"
2
- #include "ruby/debug.h"
3
- #include "frame.h"
4
- #include "threads.h"
5
- #include "normalize.h"
6
-
7
- static VALUE process_inspection(const rb_debug_inspector_t *inspector, void *ptr)
8
- {
9
- VALUE locations;
10
- long i_size;
11
- long i;
12
- VALUE loc;
13
- VALUE path;
14
- int line;
15
- VALUE bnd;
16
- thread_reference_t *data;
17
- frame_t *frm;
18
- VALUE iseq;
19
-
20
- data = ptr;
21
-
22
- locations = rb_debug_inspector_backtrace_locations(inspector);
23
- i_size = locations == Qnil ? 0 : RARRAY_LENINT(locations);
24
- for (i = i_size - 1; i >= 0; i--)
25
- {
26
- iseq = rb_debug_inspector_frame_iseq_get(inspector, i);
27
- if (iseq != Qnil)
28
- {
29
- loc = rb_ary_entry(locations, i);
30
- path = rb_funcall(loc, rb_intern("absolute_path"), 0);
31
- line = NUM2INT(rb_funcall(loc, rb_intern("lineno"), 0));
32
- bnd = rb_debug_inspector_frame_binding_get(inspector, i);
33
-
34
- frm = malloc(sizeof(frame_t));
35
- frm->file = normalize_path_new_cstr(StringValueCStr(path));
36
- frm->line = line;
37
- frm->binding = bnd;
38
- stack_push(data->frames, frm);
39
- }
40
- }
41
-
42
- return Qnil;
43
- }
44
-
45
- /**
46
- * Get an array of frames from the Ruby debug inspector.
47
- */
48
- void inspector_inspect(thread_reference_t *data)
49
- {
50
- rb_debug_inspector_open(process_inspection, (void *)data);
51
- }
1
+ #include "ruby.h"
2
+ #include "ruby/debug.h"
3
+ #include "frame.h"
4
+ #include "threads.h"
5
+ #include "normalize.h"
6
+
7
+ static VALUE process_inspection(const rb_debug_inspector_t *inspector, void *ptr)
8
+ {
9
+ VALUE locations;
10
+ long i_size;
11
+ long i;
12
+ VALUE loc;
13
+ VALUE path;
14
+ int line;
15
+ VALUE bnd;
16
+ thread_reference_t *data;
17
+ frame_t *frm;
18
+ VALUE iseq;
19
+
20
+ data = ptr;
21
+
22
+ locations = rb_debug_inspector_backtrace_locations(inspector);
23
+ i_size = locations == Qnil ? 0 : RARRAY_LENINT(locations);
24
+ for (i = i_size - 1; i >= 0; i--)
25
+ {
26
+ iseq = rb_debug_inspector_frame_iseq_get(inspector, i);
27
+ if (iseq != Qnil)
28
+ {
29
+ loc = rb_ary_entry(locations, i);
30
+ path = rb_funcall(loc, rb_intern("absolute_path"), 0);
31
+ line = NUM2INT(rb_funcall(loc, rb_intern("lineno"), 0));
32
+ bnd = rb_debug_inspector_frame_binding_get(inspector, i);
33
+
34
+ frm = malloc(sizeof(frame_t));
35
+ frm->file = normalize_path_new_cstr(StringValueCStr(path));
36
+ frm->line = line;
37
+ frm->binding = bnd;
38
+ stack_push(data->frames, frm);
39
+ }
40
+ }
41
+
42
+ return Qnil;
43
+ }
44
+
45
+ /**
46
+ * Get an array of frames from the Ruby debug inspector.
47
+ */
48
+ void inspector_inspect(thread_reference_t *data)
49
+ {
50
+ rb_debug_inspector_open(process_inspection, (void *)data);
51
+ }
@@ -1,8 +1,8 @@
1
- #ifndef INSPECTOR_H_
2
- #define INSPECTOR_H_
3
-
4
- #include "ruby.h"
5
-
6
- void inspector_inspect(thread_reference_t *);
7
-
8
- #endif
1
+ #ifndef INSPECTOR_H_
2
+ #define INSPECTOR_H_
3
+
4
+ #include "ruby.h"
5
+
6
+ void inspector_inspect(thread_reference_t *);
7
+
8
+ #endif
@@ -52,7 +52,7 @@ monitor_debug(const char *file, const long line, VALUE tracepoint, thread_refere
52
52
  gc_disabled = rb_gc_disable();
53
53
  thread_reference_build_frames(ptr);
54
54
  snapshot = rb_funcall(c_Snapshot, rb_intern("new"), 4,
55
- LONG2NUM(ptr->id),
55
+ INT2NUM(ptr->id),
56
56
  rb_str_new_cstr(file),
57
57
  INT2NUM(line),
58
58
  ID2SYM(event)
File without changes
@@ -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
+ }
@@ -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
@@ -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
+ }
@@ -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
- 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
- }
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
+ }