readapt 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e935059da5afc7fe4f6a68e6574ad096dcf90c2b166b81f3c0e50260e3d740ba
4
- data.tar.gz: 26f8dce0349345c4f0fa5953f179e833c8848e5cf90f57632661f97603967d4b
3
+ metadata.gz: ad64fe3f51193626e5680b735f161da45661c7aba6cede8c1b46fa92e3d19cad
4
+ data.tar.gz: 52a5fc764ca16387d5e0c9a18bbf17f183bdf81de5ce87bfed3104060df68f3c
5
5
  SHA512:
6
- metadata.gz: 979309cb99c3e4eb81768965b2a564ae14dd057f424383b28ae4e9f4a38dded3a2afc135aaca70d04207e470fd241c195ed207ae4712e98e6efbf19ae79ec6a2
7
- data.tar.gz: a22d57be02bb01fb3535cb7c6c3047dcb33ec6a132ead776dbea44022924cfe026de4e99eb28632e6690a3a0e920f78d2131f2a7f5dac70ecb6dda939b79e4fb
6
+ metadata.gz: 7f3ec831e7e0c0a998083407b09e14a7c2217394ab0b606e00b5d13862ba1f8b5fb1e84fd903541661717ba4b177c558d8150ec2bb026393847bbd491877eace
7
+ data.tar.gz: d554b97e4f41d461ce33d0f9ebcf1b282e8b06da5a0a9a2dfdbdecb85ac585f4a0373a6068c5b9d6786449645181900ca848a6ecc4db1c49cee772a4cce736cb
@@ -1,3 +1,8 @@
1
+ # 0.5.0 = August 20, 2019
2
+ - Monitor stores paths as C strings
3
+ - Fixed malloc size for normalized paths
4
+ - Fixed table insertion before existing items
5
+
1
6
  # 0.4.0 - August 19. 2019
2
7
  - Breakpoints use C implementation of hash tables
3
8
  - Simplified entry point detection
@@ -158,34 +158,30 @@ static void ht_insert_key(ht_hash_table *ht, char *key, const long *value, const
158
158
  item = ht_new_item(key, value, size);
159
159
  tmp = malloc(sizeof(ht_item) * (ht->size + 1));
160
160
 
161
- for (i = 0; i <= ht->size; i++)
161
+ for (i = 0; i < ht->size; i++)
162
162
  {
163
163
  if (!inserted)
164
164
  {
165
- if (i == ht->size)
165
+ cmp = strcmp(item->key, ht->items[i]->key);
166
+ if (cmp > 0)
166
167
  {
167
- tmp[i] = item;
168
+ tmp[cursor] = item;
169
+ cursor++;
168
170
  inserted = 1;
169
171
  }
170
- else
171
- {
172
- cmp = strcmp(item->key, ht->items[i]->key);
173
- if (cmp > 0)
174
- {
175
- tmp[i] = item;
176
- tmp[i + 1] = ht->items[cursor];
177
- inserted = 1;
178
- cursor++;
179
- i++;
180
- }
181
- }
172
+ tmp[cursor] = ht->items[i];
173
+ cursor++;
182
174
  }
183
175
  else
184
176
  {
185
- tmp[i] = ht->items[cursor];
177
+ tmp[cursor] = ht->items[i];
186
178
  cursor++;
187
179
  }
188
180
  }
181
+ if (!inserted)
182
+ {
183
+ tmp[ht->size] = item;
184
+ }
189
185
  free(ht->items);
190
186
  ht->items = tmp;
191
187
  ht->size++;
@@ -16,7 +16,7 @@ static VALUE tpThreadBegin;
16
16
  static VALUE tpThreadEnd;
17
17
  static VALUE debugProc;
18
18
  static int firstLineEvent = 0;
19
- static VALUE entryFile;
19
+ static char *entryFile;
20
20
 
21
21
  static ID id_continue;
22
22
  static ID id_pause;
@@ -44,7 +44,7 @@ static int match_step(thread_reference_t *ptr)
44
44
  }
45
45
 
46
46
  static ID
47
- monitor_debug(VALUE file, long line, VALUE tracepoint, thread_reference_t *ptr, ID event)
47
+ monitor_debug(const char *file, const long line, VALUE tracepoint, thread_reference_t *ptr, ID event)
48
48
  {
49
49
  VALUE bind, bid, snapshot, result;
50
50
 
@@ -53,7 +53,7 @@ monitor_debug(VALUE file, long line, VALUE tracepoint, thread_reference_t *ptr,
53
53
  snapshot = rb_funcall(c_Snapshot, rb_intern("new"), 7,
54
54
  LONG2NUM(ptr->id),
55
55
  bid,
56
- file,
56
+ rb_str_new_cstr(file),
57
57
  INT2NUM(line),
58
58
  Qnil,
59
59
  ID2SYM(event),
@@ -74,7 +74,8 @@ monitor_debug(VALUE file, long line, VALUE tracepoint, thread_reference_t *ptr,
74
74
  static void
75
75
  process_line_event(VALUE tracepoint, void *data)
76
76
  {
77
- VALUE ref, tp_file;
77
+ VALUE ref, tmp;
78
+ char *tp_file;
78
79
  long tp_line;
79
80
  thread_reference_t *ptr;
80
81
  rb_trace_arg_t *tp;
@@ -93,13 +94,14 @@ process_line_event(VALUE tracepoint, void *data)
93
94
  return;
94
95
  }
95
96
  tp = rb_tracearg_from_tracepoint(tracepoint);
96
- tp_file = normalize_path(rb_tracearg_path(tp));
97
+ tmp = rb_tracearg_path(tp);
98
+ tp_file = normalize_path_new_cstr(StringValueCStr(tmp));
97
99
  tp_line = NUM2LONG(rb_tracearg_lineno(tp));
98
100
 
99
101
  dapEvent = id_continue;
100
102
  if (!firstLineEvent)
101
103
  {
102
- if (rb_str_equal(tp_file, entryFile))
104
+ if (strcmp(tp_file, entryFile) == 0)
103
105
  {
104
106
  firstLineEvent = 1;
105
107
  ptr->control = rb_intern("entry");
@@ -114,7 +116,7 @@ process_line_event(VALUE tracepoint, void *data)
114
116
  {
115
117
  dapEvent = rb_intern("step");
116
118
  }
117
- else if (breakpoints_match(StringValueCStr(tp_file), tp_line))
119
+ else if (breakpoints_match(tp_file, tp_line))
118
120
  {
119
121
  dapEvent = rb_intern("breakpoint");
120
122
  }
@@ -127,6 +129,8 @@ process_line_event(VALUE tracepoint, void *data)
127
129
  {
128
130
  monitor_debug(tp_file, tp_line, tracepoint, ptr, dapEvent);
129
131
  }
132
+
133
+ free(tp_file);
130
134
  }
131
135
  }
132
136
  }
@@ -162,7 +166,7 @@ process_return_event(VALUE tracepoint, void *data)
162
166
  static void
163
167
  process_thread_begin_event(VALUE tracepoint, void *data)
164
168
  {
165
- VALUE list, here, prev, ref;
169
+ VALUE list, here, prev, ref, tmp;
166
170
  thread_reference_t *ptr;
167
171
 
168
172
  list = rb_funcall(rb_cThread, rb_intern("list"), 0);
@@ -178,8 +182,9 @@ process_thread_begin_event(VALUE tracepoint, void *data)
178
182
  {
179
183
  ref = thread_add_reference(here);
180
184
  ptr = thread_reference_pointer(ref);
185
+ tmp = rb_funcall(tracepoint, rb_intern("path"), 0);
181
186
  monitor_debug(
182
- rb_funcall(tracepoint, rb_intern("path"), 0),
187
+ StringValueCStr(tmp),
183
188
  NUM2LONG(rb_funcall(tracepoint, rb_intern("lineno"), 0)),
184
189
  tracepoint,
185
190
  ptr,
@@ -194,7 +199,7 @@ process_thread_begin_event(VALUE tracepoint, void *data)
194
199
  static void
195
200
  process_thread_end_event(VALUE tracepoint, void *data)
196
201
  {
197
- VALUE thr, ref;
202
+ VALUE thr, ref, tmp;
198
203
  thread_reference_t *ptr;
199
204
 
200
205
  thr = rb_thread_current();
@@ -202,7 +207,8 @@ process_thread_end_event(VALUE tracepoint, void *data)
202
207
  if (ref != Qnil)
203
208
  {
204
209
  ptr = thread_reference_pointer(ref);
205
- monitor_debug(rb_funcall(tracepoint, rb_intern("path"), 0), NUM2LONG(rb_funcall(tracepoint, rb_intern("lineno"), 0)), tracepoint, ptr, rb_intern("thread_end"));
210
+ tmp = rb_funcall(tracepoint, rb_intern("path"), 0);
211
+ monitor_debug(StringValueCStr(tmp), NUM2LONG(rb_funcall(tracepoint, rb_intern("lineno"), 0)), tracepoint, ptr, rb_intern("thread_end"));
206
212
  thread_delete_reference(thr);
207
213
  }
208
214
  }
@@ -220,13 +226,21 @@ monitor_enable_s(VALUE self, VALUE file)
220
226
  rb_raise(rb_eArgError, "must be called with a block");
221
227
  }
222
228
 
223
- entryFile = file;
224
- firstLineEvent = (entryFile == Qnil ? 1 : 0);
229
+ if (file == Qnil)
230
+ {
231
+ entryFile = NULL;
232
+ firstLineEvent = 1;
233
+ }
234
+ else
235
+ {
236
+ entryFile = normalize_path_new_cstr(StringValueCStr(file));
237
+ firstLineEvent = 0;
238
+ }
225
239
 
226
240
  ref = thread_add_reference(rb_thread_current());
227
241
  ptr = thread_reference_pointer(ref);
228
242
  monitor_debug(
229
- Qnil,
243
+ "",
230
244
  0,
231
245
  Qnil,
232
246
  ptr,
@@ -254,6 +268,9 @@ monitor_disable_s(VALUE self)
254
268
  rb_tracepoint_disable(tpThreadBegin);
255
269
  rb_tracepoint_disable(tpThreadEnd);
256
270
 
271
+ free(entryFile);
272
+ entryFile = NULL;
273
+
257
274
  return previous;
258
275
  }
259
276
 
@@ -301,5 +318,4 @@ void initialize_monitor(VALUE m_Readapt)
301
318
  rb_global_variable(&tpReturn);
302
319
  rb_global_variable(&tpThreadBegin);
303
320
  rb_global_variable(&tpThreadEnd);
304
- rb_global_variable(&entryFile);
305
321
  }
@@ -14,17 +14,15 @@ checkIfWindows()
14
14
  return result == Qnil ? 0 : 1;
15
15
  }
16
16
 
17
- VALUE
18
- normalize_path(VALUE str)
17
+ char *normalize_path_new_cstr(char *str)
19
18
  {
20
- VALUE result;
21
19
  char *buffer;
22
20
  long i, len;
23
21
 
22
+ buffer = malloc((strlen(str) + 1) * sizeof(char));
23
+ strcpy(buffer, str);
24
24
  if (isWindows)
25
25
  {
26
- buffer = malloc((rb_str_strlen(str) + 1) * sizeof(char));
27
- strcpy(buffer, StringValueCStr(str));
28
26
  buffer[0] = toupper(buffer[0]);
29
27
  len = strlen(buffer);
30
28
  for (i = 2; i < len; i++)
@@ -34,17 +32,17 @@ normalize_path(VALUE str)
34
32
  buffer[i] = '/';
35
33
  }
36
34
  }
37
- result = rb_str_new_cstr(buffer);
38
- free(buffer);
39
- return result;
40
35
  }
41
- return str;
36
+ return buffer;
42
37
  }
43
38
 
44
39
  static VALUE
45
40
  normalize_path_s(VALUE self, VALUE str)
46
41
  {
47
- return normalize_path(str);
42
+ char *path = normalize_path_new_cstr(StringValueCStr(str));
43
+ VALUE result = rb_str_new_cstr(path);
44
+ free(path);
45
+ return result;
48
46
  }
49
47
 
50
48
  void initialize_normalize(VALUE m_Readapt)
@@ -2,6 +2,6 @@
2
2
  #define NORMALIZE_H_
3
3
 
4
4
  void initialize_normalize(VALUE);
5
- VALUE normalize_path(VALUE);
5
+ char *normalize_path_new_cstr(char *str);
6
6
 
7
7
  #endif
@@ -1,3 +1,3 @@
1
1
  module Readapt
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: readapt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-19 00:00:00.000000000 Z
11
+ date: 2019-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backport