readapt 1.4.0 → 1.4.4

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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +16 -16
  3. data/.rspec +2 -2
  4. data/.travis.yml +19 -19
  5. data/CHANGELOG.md +100 -87
  6. data/Gemfile +4 -4
  7. data/LICENSE.txt +21 -21
  8. data/README.md +37 -37
  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/inspector.c +51 -51
  19. data/ext/readapt/inspector.h +8 -8
  20. data/ext/readapt/lookup_table.c +211 -211
  21. data/ext/readapt/lookup_table.h +30 -30
  22. data/ext/readapt/monitor.c +2 -2
  23. data/ext/readapt/monitor.h +0 -0
  24. data/ext/readapt/normalize.c +62 -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 +13 -2
  30. data/ext/readapt/threads.h +2 -1
  31. data/lib/readapt/adapter.rb +98 -98
  32. data/lib/readapt/breakpoint.rb +21 -21
  33. data/lib/readapt/data_reader.rb +62 -62
  34. data/lib/readapt/debugger.rb +227 -228
  35. data/lib/readapt/error.rb +63 -63
  36. data/lib/readapt/finder.rb +34 -34
  37. data/lib/readapt/frame.rb +40 -40
  38. data/lib/readapt/input.rb +7 -7
  39. data/lib/readapt/message/attach.rb +11 -11
  40. data/lib/readapt/message/base.rb +32 -32
  41. data/lib/readapt/message/configuration_done.rb +11 -11
  42. data/lib/readapt/message/continue.rb +15 -15
  43. data/lib/readapt/message/disconnect.rb +13 -13
  44. data/lib/readapt/message/evaluate.rb +19 -18
  45. data/lib/readapt/message/initialize.rb +21 -21
  46. data/lib/readapt/message/launch.rb +11 -11
  47. data/lib/readapt/message/next.rb +12 -12
  48. data/lib/readapt/message/pause.rb +11 -11
  49. data/lib/readapt/message/scopes.rb +26 -26
  50. data/lib/readapt/message/set_breakpoints.rb +25 -25
  51. data/lib/readapt/message/set_exception_breakpoints.rb +11 -11
  52. data/lib/readapt/message/stack_trace.rb +38 -38
  53. data/lib/readapt/message/step_in.rb +11 -11
  54. data/lib/readapt/message/step_out.rb +11 -11
  55. data/lib/readapt/message/threads.rb +18 -18
  56. data/lib/readapt/message/variables.rb +53 -53
  57. data/lib/readapt/message.rb +62 -62
  58. data/lib/readapt/monitor.rb +0 -0
  59. data/lib/readapt/output.rb +25 -25
  60. data/lib/readapt/references.rb +27 -27
  61. data/lib/readapt/server.rb +22 -22
  62. data/lib/readapt/shell.rb +104 -104
  63. data/lib/readapt/snapshot.rb +0 -0
  64. data/lib/readapt/thread.rb +20 -25
  65. data/lib/readapt/variable.rb +0 -0
  66. data/lib/readapt/version.rb +3 -3
  67. data/lib/readapt.rb +21 -21
  68. data/readapt.gemspec +39 -39
  69. metadata +3 -3
@@ -1,211 +1,211 @@
1
- #include <math.h>
2
- #include <stdlib.h>
3
- #include <string.h>
4
-
5
- #include "lookup_table.h"
6
-
7
- static lt_long_array *copy_array(const long *value, const long size)
8
- {
9
- long i;
10
- long *items = malloc(sizeof(long) * size);
11
- lt_long_array *result;
12
-
13
- for (i = 0; i < size; i++)
14
- {
15
- items[i] = value[i];
16
- }
17
- result = malloc(sizeof(lt_long_array));
18
- result->items = (size ? items : NULL);
19
- result->size = size;
20
- return result;
21
- }
22
-
23
- /*
24
- * Initialize a new item
25
- */
26
- static lt_item *lt_new_item(char *key, const long *value, const long size)
27
- {
28
- lt_item *i = malloc(sizeof(lt_item));
29
- i->key = malloc(sizeof(char) * (strlen(key) + 1));
30
- strcpy(i->key, key);
31
- i->value = copy_array(value, size);
32
- return i;
33
- }
34
-
35
- /*
36
- * Delete the lt_item
37
- */
38
- static void lt_del_item(lt_item *i)
39
- {
40
- free(i->key);
41
- free(i->value->items);
42
- free(i);
43
- }
44
-
45
- /*
46
- * Initialize a new empty lookup table
47
- */
48
- lt_lookup_table *lt_new()
49
- {
50
- lt_lookup_table *ht = malloc(sizeof(lt_lookup_table));
51
- ht->items = NULL;
52
- ht->size = 0;
53
- return ht;
54
- }
55
-
56
- /*
57
- * Delete the lookup table
58
- */
59
- void lt_del_lookup_table(lt_lookup_table *ht)
60
- {
61
- int i;
62
- lt_item *item;
63
-
64
- // Iterate through items and delete any that are found
65
- for (i = 0; i < ht->size; i++)
66
- {
67
- item = ht->items[i];
68
- lt_del_item(item);
69
- }
70
- free(ht->items);
71
- free(ht);
72
- }
73
-
74
- static lt_long_array *lt_search_part(lt_lookup_table *ht, char *key, long cursor, long next)
75
- {
76
- int cmp;
77
-
78
- if (cursor >= ht->size)
79
- {
80
- return NULL;
81
- }
82
-
83
- cmp = strcmp(ht->items[cursor]->key, key);
84
- if (cmp == 0)
85
- {
86
- return ht->items[cursor]->value;
87
- }
88
- if (next > cursor && next < ht->size)
89
- {
90
- cmp = strcmp(ht->items[next]->key, key);
91
- if (cmp == 0)
92
- {
93
- return ht->items[next]->value;
94
- }
95
- else if (cmp < 0)
96
- {
97
- return lt_search_part(ht, key, next + 1, next + ((ht->size - next) / 2));
98
- }
99
- else
100
- {
101
- return lt_search_part(ht, key, cursor + 1, next / 2);
102
- }
103
- }
104
- return lt_search_part(ht, key, cursor + 1, next / 2);
105
- }
106
-
107
- static lt_long_array *lt_search_key(lt_lookup_table *ht, char *key)
108
- {
109
- return lt_search_part(ht, key, 0, ht->size / 2);
110
- }
111
-
112
- static void lt_delete_key(lt_lookup_table *ht, char *key)
113
- {
114
- lt_long_array *found;
115
- lt_item **tmp;
116
- long i;
117
- long cursor = 0;
118
-
119
- found = lt_search_key(ht, key);
120
- if (found)
121
- {
122
- tmp = malloc(sizeof(lt_item) * (ht->size - 1));
123
- for (i = 0; i < ht->size; i++)
124
- {
125
- if (ht->items[i]->key == key)
126
- {
127
- lt_del_item(ht->items[i]);
128
- }
129
- else
130
- {
131
- tmp[cursor] = ht->items[cursor];
132
- cursor++;
133
- }
134
- }
135
- free(ht->items);
136
- ht->items = tmp;
137
- ht->size--;
138
- }
139
- }
140
-
141
- static void lt_insert_key(lt_lookup_table *ht, char *key, const long *value, const long size)
142
- {
143
- lt_item *item;
144
- lt_item **tmp;
145
- long i;
146
- long cursor = 0;
147
- int inserted = 0;
148
- int cmp;
149
-
150
- lt_delete_key(ht, key);
151
-
152
- if (size == 0)
153
- {
154
- return;
155
- }
156
-
157
- item = lt_new_item(key, value, size);
158
- tmp = malloc(sizeof(lt_item) * (ht->size + 1));
159
-
160
- for (i = 0; i < ht->size; i++)
161
- {
162
- if (!inserted)
163
- {
164
- cmp = strcmp(item->key, ht->items[i]->key);
165
- if (cmp > 0)
166
- {
167
- tmp[cursor] = item;
168
- cursor++;
169
- inserted = 1;
170
- }
171
- tmp[cursor] = ht->items[i];
172
- cursor++;
173
- }
174
- else
175
- {
176
- tmp[cursor] = ht->items[i];
177
- cursor++;
178
- }
179
- }
180
- if (!inserted)
181
- {
182
- tmp[ht->size] = item;
183
- }
184
- free(ht->items);
185
- ht->items = tmp;
186
- ht->size++;
187
- }
188
-
189
- /*
190
- * Add an item to the lookup table
191
- */
192
- void lt_insert(lt_lookup_table *ht, char *key, const long *value, const long size)
193
- {
194
- lt_insert_key(ht, key, value, size);
195
- }
196
-
197
- /*
198
- * Get the key's value or NULL if it doesn't exist
199
- */
200
- lt_long_array *lt_search(lt_lookup_table *ht, char *key)
201
- {
202
- return lt_search_key(ht, key);
203
- }
204
-
205
- /*
206
- * Delete the key's item if it exists
207
- */
208
- void lt_delete(lt_lookup_table *ht, char *key)
209
- {
210
- lt_delete_key(ht, key);
211
- }
1
+ #include <math.h>
2
+ #include <stdlib.h>
3
+ #include <string.h>
4
+
5
+ #include "lookup_table.h"
6
+
7
+ static lt_long_array *copy_array(const long *value, const long size)
8
+ {
9
+ long i;
10
+ long *items = malloc(sizeof(long) * size);
11
+ lt_long_array *result;
12
+
13
+ for (i = 0; i < size; i++)
14
+ {
15
+ items[i] = value[i];
16
+ }
17
+ result = malloc(sizeof(lt_long_array));
18
+ result->items = (size ? items : NULL);
19
+ result->size = size;
20
+ return result;
21
+ }
22
+
23
+ /*
24
+ * Initialize a new item
25
+ */
26
+ static lt_item *lt_new_item(char *key, const long *value, const long size)
27
+ {
28
+ lt_item *i = malloc(sizeof(lt_item));
29
+ i->key = malloc(sizeof(char) * (strlen(key) + 1));
30
+ strcpy(i->key, key);
31
+ i->value = copy_array(value, size);
32
+ return i;
33
+ }
34
+
35
+ /*
36
+ * Delete the lt_item
37
+ */
38
+ static void lt_del_item(lt_item *i)
39
+ {
40
+ free(i->key);
41
+ free(i->value->items);
42
+ free(i);
43
+ }
44
+
45
+ /*
46
+ * Initialize a new empty lookup table
47
+ */
48
+ lt_lookup_table *lt_new()
49
+ {
50
+ lt_lookup_table *ht = malloc(sizeof(lt_lookup_table));
51
+ ht->items = NULL;
52
+ ht->size = 0;
53
+ return ht;
54
+ }
55
+
56
+ /*
57
+ * Delete the lookup table
58
+ */
59
+ void lt_del_lookup_table(lt_lookup_table *ht)
60
+ {
61
+ int i;
62
+ lt_item *item;
63
+
64
+ // Iterate through items and delete any that are found
65
+ for (i = 0; i < ht->size; i++)
66
+ {
67
+ item = ht->items[i];
68
+ lt_del_item(item);
69
+ }
70
+ free(ht->items);
71
+ free(ht);
72
+ }
73
+
74
+ static lt_long_array *lt_search_part(lt_lookup_table *ht, char *key, long cursor, long next)
75
+ {
76
+ int cmp;
77
+
78
+ if (cursor >= ht->size)
79
+ {
80
+ return NULL;
81
+ }
82
+
83
+ cmp = strcmp(ht->items[cursor]->key, key);
84
+ if (cmp == 0)
85
+ {
86
+ return ht->items[cursor]->value;
87
+ }
88
+ if (next > cursor && next < ht->size)
89
+ {
90
+ cmp = strcmp(ht->items[next]->key, key);
91
+ if (cmp == 0)
92
+ {
93
+ return ht->items[next]->value;
94
+ }
95
+ else if (cmp < 0)
96
+ {
97
+ return lt_search_part(ht, key, next + 1, next + ((ht->size - next) / 2));
98
+ }
99
+ else
100
+ {
101
+ return lt_search_part(ht, key, cursor + 1, next / 2);
102
+ }
103
+ }
104
+ return lt_search_part(ht, key, cursor + 1, next / 2);
105
+ }
106
+
107
+ static lt_long_array *lt_search_key(lt_lookup_table *ht, char *key)
108
+ {
109
+ return lt_search_part(ht, key, 0, ht->size / 2);
110
+ }
111
+
112
+ static void lt_delete_key(lt_lookup_table *ht, char *key)
113
+ {
114
+ lt_long_array *found;
115
+ lt_item **tmp;
116
+ long i;
117
+ long cursor = 0;
118
+
119
+ found = lt_search_key(ht, key);
120
+ if (found)
121
+ {
122
+ tmp = malloc(sizeof(lt_item) * (ht->size - 1));
123
+ for (i = 0; i < ht->size; i++)
124
+ {
125
+ if (ht->items[i]->key == key)
126
+ {
127
+ lt_del_item(ht->items[i]);
128
+ }
129
+ else
130
+ {
131
+ tmp[cursor] = ht->items[cursor];
132
+ cursor++;
133
+ }
134
+ }
135
+ free(ht->items);
136
+ ht->items = tmp;
137
+ ht->size--;
138
+ }
139
+ }
140
+
141
+ static void lt_insert_key(lt_lookup_table *ht, char *key, const long *value, const long size)
142
+ {
143
+ lt_item *item;
144
+ lt_item **tmp;
145
+ long i;
146
+ long cursor = 0;
147
+ int inserted = 0;
148
+ int cmp;
149
+
150
+ lt_delete_key(ht, key);
151
+
152
+ if (size == 0)
153
+ {
154
+ return;
155
+ }
156
+
157
+ item = lt_new_item(key, value, size);
158
+ tmp = malloc(sizeof(lt_item) * (ht->size + 1));
159
+
160
+ for (i = 0; i < ht->size; i++)
161
+ {
162
+ if (!inserted)
163
+ {
164
+ cmp = strcmp(item->key, ht->items[i]->key);
165
+ if (cmp > 0)
166
+ {
167
+ tmp[cursor] = item;
168
+ cursor++;
169
+ inserted = 1;
170
+ }
171
+ tmp[cursor] = ht->items[i];
172
+ cursor++;
173
+ }
174
+ else
175
+ {
176
+ tmp[cursor] = ht->items[i];
177
+ cursor++;
178
+ }
179
+ }
180
+ if (!inserted)
181
+ {
182
+ tmp[ht->size] = item;
183
+ }
184
+ free(ht->items);
185
+ ht->items = tmp;
186
+ ht->size++;
187
+ }
188
+
189
+ /*
190
+ * Add an item to the lookup table
191
+ */
192
+ void lt_insert(lt_lookup_table *ht, char *key, const long *value, const long size)
193
+ {
194
+ lt_insert_key(ht, key, value, size);
195
+ }
196
+
197
+ /*
198
+ * Get the key's value or NULL if it doesn't exist
199
+ */
200
+ lt_long_array *lt_search(lt_lookup_table *ht, char *key)
201
+ {
202
+ return lt_search_key(ht, key);
203
+ }
204
+
205
+ /*
206
+ * Delete the key's item if it exists
207
+ */
208
+ void lt_delete(lt_lookup_table *ht, char *key)
209
+ {
210
+ lt_delete_key(ht, key);
211
+ }
@@ -1,30 +1,30 @@
1
- #ifndef LOOKUP_TABLE_H_
2
- #define LOOKUP_TABLE_H_
3
-
4
- typedef struct lt_long_array
5
- {
6
- long *items;
7
- long size;
8
- } lt_long_array;
9
-
10
- // lt_item is an item in the lookup table
11
- typedef struct lt_item
12
- {
13
- char *key;
14
- lt_long_array *value;
15
- } lt_item;
16
-
17
- typedef struct lt_lookup_table
18
- {
19
- long size;
20
- lt_item **items;
21
- } lt_lookup_table;
22
-
23
- lt_lookup_table *lt_new();
24
- void lt_del_lookup_table(lt_lookup_table *ht);
25
-
26
- void lt_insert(lt_lookup_table *ht, char *key, const long *value, const long size);
27
- lt_long_array *lt_search(lt_lookup_table *ht, char *key);
28
- void lt_delete(lt_lookup_table *h, char *key);
29
-
30
- #endif // LOOKUP_TABLE_H_
1
+ #ifndef LOOKUP_TABLE_H_
2
+ #define LOOKUP_TABLE_H_
3
+
4
+ typedef struct lt_long_array
5
+ {
6
+ long *items;
7
+ long size;
8
+ } lt_long_array;
9
+
10
+ // lt_item is an item in the lookup table
11
+ typedef struct lt_item
12
+ {
13
+ char *key;
14
+ lt_long_array *value;
15
+ } lt_item;
16
+
17
+ typedef struct lt_lookup_table
18
+ {
19
+ long size;
20
+ lt_item **items;
21
+ } lt_lookup_table;
22
+
23
+ lt_lookup_table *lt_new();
24
+ void lt_del_lookup_table(lt_lookup_table *ht);
25
+
26
+ void lt_insert(lt_lookup_table *ht, char *key, const long *value, const long size);
27
+ lt_long_array *lt_search(lt_lookup_table *ht, char *key);
28
+ void lt_delete(lt_lookup_table *h, char *key);
29
+
30
+ #endif // LOOKUP_TABLE_H_
@@ -51,7 +51,7 @@ monitor_debug(const char *file, const long line, VALUE tracepoint, thread_refere
51
51
 
52
52
  // Disable garbage collection to avoid segfaults in Frame#frame_binding
53
53
  gc_disabled = rb_gc_disable();
54
- thread_reference_build_frames(ptr);
54
+ thread_reference_build_frames(ptr);
55
55
  snapshot = rb_funcall(c_Snapshot, rb_intern("new"), 4,
56
56
  INT2NUM(ptr->id),
57
57
  rb_str_new_cstr(file),
@@ -103,7 +103,7 @@ process_line_event(VALUE tracepoint, void *data)
103
103
  tp_file = StringValueCStr(tmp);
104
104
  normalize_path(tp_file);
105
105
  tmp = rb_tracearg_lineno(arg);
106
- tp_line = NUM2INT(tmp);
106
+ tp_line = NUM2LONG(tmp);
107
107
 
108
108
  dapEvent = id_continue;
109
109
  if (!firstLineEvent)
File without changes
@@ -1,59 +1,62 @@
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
+ if (isalpha(str[0]))
24
+ {
25
+ str[0] = toupper(str[0]);
26
+ }
27
+ len = strlen(str);
28
+ for (i = 0; i < len; i++)
29
+ {
30
+ if (str[i] == '\\')
31
+ {
32
+ str[i] = '/';
33
+ }
34
+ }
35
+ }
36
+ }
37
+
38
+ char *normalize_path_new_cstr(char *str)
39
+ {
40
+ char *buffer;
41
+
42
+ buffer = malloc((strlen(str) + 1) * sizeof(char));
43
+ strcpy(buffer, str);
44
+ normalize_path(buffer);
45
+ return buffer;
46
+ }
47
+
48
+ static VALUE
49
+ normalize_path_s(VALUE self, VALUE str)
50
+ {
51
+ char *path = normalize_path_new_cstr(StringValueCStr(str));
52
+ VALUE result = rb_str_new_cstr(path);
53
+ free(path);
54
+ return result;
55
+ }
56
+
57
+ void initialize_normalize(VALUE m_Readapt)
58
+ {
59
+ isWindows = checkIfWindows();
60
+
61
+ rb_define_singleton_method(m_Readapt, "normalize_path", normalize_path_s, 1);
62
+ }
@@ -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
+ }