debase 0.2.2.beta10 → 0.2.2.beta11

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
- SHA1:
3
- metadata.gz: 79fde9e93badfd98fb0fbe1f7f625d154dc9b4f4
4
- data.tar.gz: 956c8b8bf4d1d2355440bbb98f76cd3df5ba256e
2
+ SHA256:
3
+ metadata.gz: 23acd95b1eb4482fcd7e41b5dd392a47acdc2bf14a1980ca516ae29cb116668b
4
+ data.tar.gz: ca237b3670f35fe7f98af42a378d94f65f919a5db9eb3130566994b61b171688
5
5
  SHA512:
6
- metadata.gz: be07ccaac91b1707899b07424dbf0a633c3c5ca4695d1cd424cbe17e4b65cbb826a12aee67e7a82d8d08f450a8a93d6b6c85c5a3502dd1b95932af9c76fc33e9
7
- data.tar.gz: 91a164dee212080ebe56f434579a49ff07951a41633eb80cd3e83ba2d6144d83a0b117f6dcf76926a70e6825ce63c0cfab8cef689330f421e44c29eb09aa0395
6
+ metadata.gz: f86e56b22ec68c0a515ed6fc0040a8f5b7e32779149ce7a54d51c3aa51d374ceaf6af1953465663e807df2241f7bf4619328d6cf9ea8a72b0868e72c55ec7389
7
+ data.tar.gz: 5e674cb7237a4100f0b6b22dbe5f21a302e49b62060810f4c0b5651840933f4e3f04af9c36d1d39db86c9ba767f22bb99ffa48e3ad78eaef962df2fb646f82f7
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  [gem]: https://rubygems.org/gems/debase
2
2
  [travis]: https://travis-ci.org/denofevil/debase
3
+ [jb_badges]: https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub
3
4
 
4
5
  # debase
5
6
  [![Gem Version](https://badge.fury.io/rb/debase.png)][gem]
6
7
  [![Build Status](https://secure.travis-ci.org/denofevil/debase.png)][travis]
8
+ [![official JetBrains project](http://jb.gg/badges/official.svg)][jb_badges]
7
9
 
8
10
  ## Overview
9
11
 
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
 
27
27
  s.extensions = ["ext/extconf.rb", "ext/attach/extconf.rb"]
28
28
 
29
- s.add_dependency "debase-ruby_core_source"
29
+ s.add_dependency "debase-ruby_core_source", ">= 0.9.11"
30
30
  s.add_development_dependency "test-unit"
31
31
  s.add_development_dependency "rake"
32
32
  end
@@ -1,15 +1,26 @@
1
1
  #include "attach.h"
2
2
 
3
+ #ifndef __GNUC__
4
+ #define __asm__ asm
5
+ #endif
6
+
3
7
  /*
4
8
  We need to prevent compiler from optimizing this function calls. For more details
5
9
  see "noinline" section here: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
6
10
  */
7
11
  static void
8
- __attribute__ ((noinline))
12
+ #if defined(_MSC_VER)
13
+ __declspec(noinline)
9
14
  __func_to_set_breakpoint_at()
10
15
  {
11
- asm("");
12
16
  }
17
+ #else
18
+ __attribute__((noinline))
19
+ __func_to_set_breakpoint_at()
20
+ {
21
+ __asm__("");
22
+ }
23
+ #endif
13
24
 
14
25
  static void
15
26
  __catch_line_event(rb_event_flag_t evflag, VALUE data, VALUE self, ID mid, VALUE klass)
@@ -48,4 +59,4 @@ Init_attach()
48
59
  gdb/lldb. So no initialization here, you should directly
49
60
  call functions above.
50
61
  */
51
- }
62
+ }
@@ -46,18 +46,26 @@ fill_stack(debug_context_t *context, const rb_debug_inspector_t *inspector) {
46
46
 
47
47
  locations = rb_debug_inspector_backtrace_locations(inspector);
48
48
  stack_size = locations == Qnil ? 0 : RARRAY_LENINT(locations);
49
- context->stack_size = stack_size;
50
-
49
+ context->stack_size = 0;
50
+
51
51
  for (i = 0; i < stack_size; i++) {
52
- frame = ALLOC(debug_frame_t);
52
+
53
53
  location = rb_ary_entry(locations, i);
54
- path = rb_funcall(location, rb_intern("path"), 0);
55
- lineno = rb_funcall(location, rb_intern("lineno"), 0);
56
- file = path != Qnil ? RSTRING_PTR(path) : "";
57
- line = FIX2INT(lineno);
58
- fill_frame(frame, file, line, rb_debug_inspector_frame_binding_get(inspector, i), rb_debug_inspector_frame_self_get(inspector, i));
59
- frame->prev = context->stack;
60
- context->stack = frame;
54
+ VALUE iseq = rb_debug_inspector_frame_iseq_get(inspector, i);
55
+
56
+ if(iseq != Qnil)
57
+ {
58
+ frame = ALLOC(debug_frame_t);
59
+ path = rb_funcall(location, rb_intern("path"), 0);
60
+ lineno = rb_funcall(location, rb_intern("lineno"), 0);
61
+ file = path != Qnil ? RSTRING_PTR(path) : "";
62
+ line = FIX2INT(lineno);
63
+
64
+ fill_frame(frame, file, line, rb_debug_inspector_frame_binding_get(inspector, i), rb_debug_inspector_frame_self_get(inspector, i));
65
+ frame->prev = context->stack;
66
+ context->stack = frame;
67
+ context->stack_size++;
68
+ }
61
69
  }
62
70
  }
63
71
 
@@ -127,6 +135,7 @@ Context_mark(debug_context_t *context)
127
135
 
128
136
  static void
129
137
  Context_free(debug_context_t *context) {
138
+ xfree(context->init_stack_files);
130
139
  xfree(context);
131
140
  }
132
141
 
@@ -134,11 +143,26 @@ extern VALUE
134
143
  context_create(VALUE thread, VALUE cDebugThread) {
135
144
  debug_context_t *context;
136
145
  VALUE locations;
146
+ VALUE location;
147
+ VALUE path;
148
+ VALUE lineno;
137
149
 
138
150
  context = ALLOC(debug_context_t);
139
151
  context->stack_size = 0;
140
152
  locations = rb_funcall(thread, rb_intern("backtrace_locations"), 1, INT2FIX(1));
141
- context->calced_stack_size = locations != Qnil ? RARRAY_LENINT(locations) : 0;
153
+ context->init_stack_size = context->calced_stack_size = locations != Qnil ? RARRAY_LENINT(locations) : 0;
154
+
155
+ context->init_stack_files = ruby_xmalloc2((context->init_stack_size),sizeof(char*));
156
+
157
+ int i;
158
+ for (i = 0; i < context->init_stack_size; i++) {
159
+ location = rb_ary_entry(locations, i);
160
+ path = rb_funcall(location, rb_intern("path"), 0);
161
+ lineno = rb_funcall(location, rb_intern("lineno"), 0);
162
+ context->init_stack_files[i] = path != Qnil ? RSTRING_PTR(path) : "";
163
+ }
164
+
165
+
142
166
  context->stack = NULL;
143
167
  context->thnum = ++thnum_current;
144
168
  context->thread = thread;
@@ -289,7 +313,10 @@ Context_stop_next(int argc, VALUE *argv, VALUE self)
289
313
  if(FIX2INT(steps) < 0) rb_raise(rb_eRuntimeError, "Steps argument can't be negative.");
290
314
 
291
315
  Data_Get_Struct(self, debug_context_t, context);
316
+
292
317
  context->stop_next = FIX2INT(steps);
318
+
319
+
293
320
  if(RTEST(force))
294
321
  CTX_FL_SET(context, CTX_FL_FORCE_MOVE);
295
322
  else
@@ -305,6 +332,7 @@ Context_step_over(int argc, VALUE *argv, VALUE self)
305
332
  debug_context_t *context;
306
333
 
307
334
  Data_Get_Struct(self, debug_context_t, context);
335
+
308
336
  if(context->stack_size == 0)
309
337
  rb_raise(rb_eRuntimeError, "No frames collected.");
310
338
 
@@ -335,6 +363,7 @@ Context_stop_frame(VALUE self, VALUE frame)
335
363
  debug_context_t *debug_context;
336
364
 
337
365
  Data_Get_Struct(self, debug_context_t, debug_context);
366
+
338
367
  if(FIX2INT(frame) < 0 && FIX2INT(frame) >= debug_context->calced_stack_size)
339
368
  rb_raise(rb_eRuntimeError, "Stop frame is out of range.");
340
369
  /* we decrease stack size by frame and 1 because we use stop_frame after
@@ -37,7 +37,7 @@ print_debug(const char *message, ...)
37
37
  va_end(ap);
38
38
  }
39
39
 
40
- inline int
40
+ static inline int
41
41
  check_stop_frame(debug_context_t *context) {
42
42
  return context->calced_stack_size == context->stop_frame && context->calced_stack_size >= 0;
43
43
  }
@@ -323,6 +323,7 @@ process_line_event(VALUE trace_point, void *data)
323
323
  char *file;
324
324
  int line;
325
325
  int moved;
326
+ int not_user_code = 0;
326
327
 
327
328
  context_object = Debase_current_context(mDebase);
328
329
  Data_Get_Struct(context_object, debug_context_t, context);
@@ -332,10 +333,21 @@ process_line_event(VALUE trace_point, void *data)
332
333
  path = rb_tracearg_path(tp);
333
334
 
334
335
  if (is_path_accepted(path)) {
336
+
335
337
  lineno = rb_tracearg_lineno(tp);
336
338
  file = RSTRING_PTR(path);
337
339
  line = FIX2INT(lineno);
338
340
 
341
+ int i;
342
+ if(context->calced_stack_size < context->init_stack_size) {
343
+ for(i = 0; i < context->init_stack_size; i++)
344
+ {
345
+ if(strcmp(file, context->init_stack_files[i]) == 0) {
346
+ not_user_code = 1;
347
+ }
348
+ }
349
+ }
350
+
339
351
  update_stack_size(context);
340
352
  print_event(tp, context);
341
353
 
@@ -372,7 +384,7 @@ process_line_event(VALUE trace_point, void *data)
372
384
  }
373
385
 
374
386
  breakpoint = breakpoint_find(breakpoints, path, lineno, trace_point);
375
- if (context->stop_next == 0 || context->stop_line == 0 || breakpoint != Qnil) {
387
+ if (not_user_code == 0 && (context->stop_next == 0 || context->stop_line == 0 || breakpoint != Qnil)) {
376
388
  rb_ensure(start_inspector, context_object, stop_inspector, Qnil);
377
389
  context->stop_reason = CTX_STOP_STEP;
378
390
  if (breakpoint != Qnil) {
@@ -57,6 +57,9 @@ typedef struct debug_context {
57
57
  /* dest_frame uses calced_stack_size for stepping */
58
58
  int dest_frame;
59
59
  int calced_stack_size;
60
+ int init_stack_size;
61
+
62
+ char **init_stack_files;
60
63
 
61
64
  char *last_file;
62
65
  int last_line;
@@ -29,6 +29,7 @@ require "debase/ruby_core_source"
29
29
 
30
30
  hdrs = proc {
31
31
  have_header("vm_core.h")
32
+ have_header("version.h")
32
33
  }
33
34
 
34
35
  # Allow use customization of compile options. For example, the
@@ -1,7 +1,14 @@
1
1
  #include <vm_core.h>
2
+ #include <version.h>
2
3
 
3
4
  #define ruby_current_thread ((rb_thread_t *)RTYPEDDATA_DATA(rb_thread_current()))
4
5
 
6
+ #if RUBY_API_VERSION_CODE >= 20500
7
+ #define TH_CFP(thread) ((rb_control_frame_t *)(thread)->ec.cfp)
8
+ #else
9
+ #define TH_CFP(thread) ((rb_control_frame_t *)(thread)->cfp)
10
+ #endif
11
+
5
12
  extern void
6
13
  update_stack_size(debug_context_t *context)
7
14
  {
@@ -9,7 +16,7 @@ update_stack_size(debug_context_t *context)
9
16
 
10
17
  thread = ruby_current_thread;
11
18
  /* see backtrace_each in vm_backtrace.c */
12
- context->stack_size = (int)(RUBY_VM_END_CONTROL_FRAME(thread) - thread->cfp - 1);
19
+ context->stack_size = (int)(RUBY_VM_END_CONTROL_FRAME(thread) - TH_CFP(thread) - 1);
13
20
  if (CTX_FL_TEST(context, CTX_FL_UPDATE_STACK)) {
14
21
  context->calced_stack_size = context->stack_size;
15
22
  CTX_FL_UNSET(context, CTX_FL_UPDATE_STACK);
@@ -1,3 +1,3 @@
1
1
  module Debase
2
- VERSION = "0.2.2.beta10" unless defined? VERSION
2
+ VERSION = "0.2.2.beta11" unless defined? VERSION
3
3
  end
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.2.2.beta10
4
+ version: 0.2.2.beta11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Ushakov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-08 00:00:00.000000000 Z
11
+ date: 2017-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debase-ruby_core_source
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.9.11
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.9.11
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: test-unit
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -135,33 +135,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  version: 1.3.1
136
136
  requirements: []
137
137
  rubyforge_project: debase
138
- rubygems_version: 2.5.1
138
+ rubygems_version: 2.6.14
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: debase is a fast implementation of the standard Ruby debugger debug.rb for
142
142
  Ruby 2.0
143
- test_files:
144
- - test/example/a/example.rb
145
- - test/example/at-exit.rb
146
- - test/example/b/example.rb
147
- - test/example/bp_loop_issue.rb
148
- - test/example/breakpoints-basename.rb
149
- - test/example/brkpt-class-bug.rb
150
- - test/example/classes.rb
151
- - test/example/dollar-0.rb
152
- - test/example/except-bug1.rb
153
- - test/example/file with space.rb
154
- - test/example/gcd.rb
155
- - test/example/info-var-bug.rb
156
- - test/example/info-var-bug2.rb
157
- - test/example/null.rb
158
- - test/example/output.rb
159
- - test/example/pm-bug.rb
160
- - test/example/pm.rb
161
- - test/example/raise.rb
162
- - test/helper.rb
163
- - test/test_base.rb
164
- - test/test_breakpoints.rb
165
- - test/test_catchpoint.rb
166
- - test/test_load.rb
167
- - test/test_reload_bug.rb
143
+ test_files: []