debase 0.2.2 → 0.2.3.beta2
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.
- checksums.yaml +4 -4
- data/ext/attach/extconf.rb +7 -1
- data/ext/context.c +1 -16
- data/ext/debase_internals.c +32 -12
- data/ext/debase_internals.h +6 -4
- data/ext/extconf.rb +7 -2
- data/lib/debase.rb +30 -1
- data/lib/debase/version.rb +1 -1
- metadata +4 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 6d0b4ffcf1b88d08e500071b97bd7d2679119dd8
         | 
| 4 | 
            +
              data.tar.gz: aea5553eb0fbac211cf081807605bf4226dfd08c
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 7e8c2f94ef8590ee3e94214f641434e5e9d67dc8eb8094830502666772a1896b8df22d9733e885213d6c28018eff2c524e680d12c906baeb7e47f68effdac90b
         | 
| 7 | 
            +
              data.tar.gz: a562cc46f2128e1fe54a71052aed7451687c6a2d28a238a7ae7994e8cc2499e23de94c6c93d5fc00c53eb7a718128cd92b543582e7061d78f9e688a3aae1c03b
         | 
    
        data/ext/attach/extconf.rb
    CHANGED
    
    | @@ -28,7 +28,13 @@ RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC'] | |
| 28 28 | 
             
            require "debase/ruby_core_source"
         | 
| 29 29 |  | 
| 30 30 | 
             
            hdrs = proc {
         | 
| 31 | 
            -
              have_header("vm_core.h")
         | 
| 31 | 
            +
              have_header("vm_core.h") and
         | 
| 32 | 
            +
              have_header("iseq.h") and
         | 
| 33 | 
            +
              have_header("version.h") and
         | 
| 34 | 
            +
              have_header("vm_core.h") and
         | 
| 35 | 
            +
              have_header("vm_insnhelper.h") and
         | 
| 36 | 
            +
              have_header("vm_core.h") and
         | 
| 37 | 
            +
              have_header("method.h")
         | 
| 32 38 | 
             
            }
         | 
| 33 39 |  | 
| 34 40 | 
             
            # Allow use customization of compile options. For example, the
         | 
    
        data/ext/context.c
    CHANGED
    
    | @@ -135,7 +135,6 @@ Context_mark(debug_context_t *context) | |
| 135 135 |  | 
| 136 136 | 
             
            static void
         | 
| 137 137 | 
             
            Context_free(debug_context_t *context) {
         | 
| 138 | 
            -
              xfree(context->init_stack_files);
         | 
| 139 138 | 
             
              xfree(context);
         | 
| 140 139 | 
             
            }
         | 
| 141 140 |  | 
| @@ -143,25 +142,11 @@ extern VALUE | |
| 143 142 | 
             
            context_create(VALUE thread, VALUE cDebugThread) {
         | 
| 144 143 | 
             
              debug_context_t *context;
         | 
| 145 144 | 
             
              VALUE locations;
         | 
| 146 | 
            -
              VALUE location;
         | 
| 147 | 
            -
              VALUE path;
         | 
| 148 | 
            -
              VALUE lineno;
         | 
| 149 145 |  | 
| 150 146 | 
             
              context = ALLOC(debug_context_t);
         | 
| 151 147 | 
             
              context->stack_size = 0;
         | 
| 152 148 | 
             
              locations = rb_funcall(thread, rb_intern("backtrace_locations"), 1, INT2FIX(1));
         | 
| 153 | 
            -
              context-> | 
| 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 | 
            -
             | 
| 149 | 
            +
              context->calced_stack_size = locations != Qnil ? RARRAY_LENINT(locations) : 0;
         | 
| 165 150 |  | 
| 166 151 | 
             
              context->stack = NULL;
         | 
| 167 152 | 
             
              context->thnum = ++thnum_current;
         | 
    
        data/ext/debase_internals.c
    CHANGED
    
    | @@ -323,7 +323,6 @@ 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;
         | 
| 327 326 |  | 
| 328 327 | 
             
              context_object = Debase_current_context(mDebase);
         | 
| 329 328 | 
             
              Data_Get_Struct(context_object, debug_context_t, context);
         | 
| @@ -338,16 +337,6 @@ process_line_event(VALUE trace_point, void *data) | |
| 338 337 | 
             
                file = RSTRING_PTR(path);
         | 
| 339 338 | 
             
                line = FIX2INT(lineno);
         | 
| 340 339 |  | 
| 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 | 
            -
             | 
| 351 340 | 
             
                update_stack_size(context);
         | 
| 352 341 | 
             
                print_event(tp, context);
         | 
| 353 342 |  | 
| @@ -384,7 +373,7 @@ process_line_event(VALUE trace_point, void *data) | |
| 384 373 | 
             
                }
         | 
| 385 374 |  | 
| 386 375 | 
             
                breakpoint = breakpoint_find(breakpoints, path, lineno, trace_point);
         | 
| 387 | 
            -
                if ( | 
| 376 | 
            +
                if (context->stop_next == 0 || context->stop_line == 0 || breakpoint != Qnil) {
         | 
| 388 377 | 
             
                  rb_ensure(start_inspector, context_object, stop_inspector, Qnil);
         | 
| 389 378 | 
             
                  context->stop_reason = CTX_STOP_STEP;
         | 
| 390 379 | 
             
                  if (breakpoint != Qnil) {
         | 
| @@ -648,6 +637,36 @@ Debase_enable_file_filtering(VALUE self, VALUE value) | |
| 648 637 | 
             
              return value;
         | 
| 649 638 | 
             
            }
         | 
| 650 639 |  | 
| 640 | 
            +
            #if RUBY_API_VERSION_CODE >= 20500
         | 
| 641 | 
            +
                static const rb_iseq_t *
         | 
| 642 | 
            +
                my_iseqw_check(VALUE iseqw)
         | 
| 643 | 
            +
                {
         | 
| 644 | 
            +
                    rb_iseq_t *iseq = DATA_PTR(iseqw);
         | 
| 645 | 
            +
             | 
| 646 | 
            +
                    if (!iseq->body) {
         | 
| 647 | 
            +
                        ibf_load_iseq_complete(iseq);
         | 
| 648 | 
            +
                    }
         | 
| 649 | 
            +
             | 
| 650 | 
            +
                    if (!iseq->body->location.label) {
         | 
| 651 | 
            +
                        rb_raise(rb_eTypeError, "uninitialized InstructionSequence");
         | 
| 652 | 
            +
                    }
         | 
| 653 | 
            +
                    return iseq;
         | 
| 654 | 
            +
                }
         | 
| 655 | 
            +
             | 
| 656 | 
            +
                static void
         | 
| 657 | 
            +
                Debase_set_trace_flag_to_iseq(VALUE self, VALUE rb_iseq)
         | 
| 658 | 
            +
                {
         | 
| 659 | 
            +
                    if (!SPECIAL_CONST_P(rb_iseq) && RBASIC_CLASS(rb_iseq) == rb_cISeq) {
         | 
| 660 | 
            +
                        rb_iseq_t *iseq = my_iseqw_check(rb_iseq);
         | 
| 661 | 
            +
                        rb_iseq_trace_set(iseq, RUBY_EVENT_TRACEPOINT_ALL);
         | 
| 662 | 
            +
                    }
         | 
| 663 | 
            +
                }
         | 
| 664 | 
            +
            #else
         | 
| 665 | 
            +
                  static void
         | 
| 666 | 
            +
                  Debase_set_trace_flag_to_iseq(VALUE self, VALUE rb_iseq) {
         | 
| 667 | 
            +
                  }
         | 
| 668 | 
            +
            #endif
         | 
| 669 | 
            +
             | 
| 651 670 | 
             
            static VALUE
         | 
| 652 671 | 
             
            Debase_init_variables()
         | 
| 653 672 | 
             
            {
         | 
| @@ -691,6 +710,7 @@ Init_debase_internals() | |
| 691 710 | 
             
              rb_define_module_function(mDebase, "enable_trace_points", Debase_enable_trace_points, 0);
         | 
| 692 711 | 
             
              rb_define_module_function(mDebase, "prepare_context", Debase_prepare_context, 0);
         | 
| 693 712 | 
             
              rb_define_module_function(mDebase, "init_variables", Debase_init_variables, 0);
         | 
| 713 | 
            +
              rb_define_module_function(mDebase, "set_trace_flag_to_iseq", Debase_set_trace_flag_to_iseq, 1);
         | 
| 694 714 |  | 
| 695 715 | 
             
              idAlive = rb_intern("alive?");
         | 
| 696 716 | 
             
              idAtLine = rb_intern("at_line");
         | 
    
        data/ext/debase_internals.h
    CHANGED
    
    | @@ -1,7 +1,12 @@ | |
| 1 1 | 
             
            #ifndef DEBASE_INTERNALS
         | 
| 2 2 | 
             
            #define DEBASE_INTERNALS
         | 
| 3 3 |  | 
| 4 | 
            -
            #include  | 
| 4 | 
            +
            #include "ruby.h"
         | 
| 5 | 
            +
            #include "vm_core.h"
         | 
| 6 | 
            +
            #include "version.h"
         | 
| 7 | 
            +
            #include "iseq.h"
         | 
| 8 | 
            +
            #include "vm_insnhelper.h"
         | 
| 9 | 
            +
            #include "method.h"
         | 
| 5 10 | 
             
            #include <ruby/debug.h>
         | 
| 6 11 |  | 
| 7 12 | 
             
            typedef struct rb_trace_arg_struct rb_trace_point_t;
         | 
| @@ -57,9 +62,6 @@ typedef struct debug_context { | |
| 57 62 | 
             
              /* dest_frame uses calced_stack_size for stepping */
         | 
| 58 63 | 
             
              int dest_frame;
         | 
| 59 64 | 
             
              int calced_stack_size;
         | 
| 60 | 
            -
              int init_stack_size;
         | 
| 61 | 
            -
             | 
| 62 | 
            -
              char **init_stack_files;
         | 
| 63 65 |  | 
| 64 66 | 
             
              char *last_file;
         | 
| 65 67 | 
             
              int last_line;
         | 
    
        data/ext/extconf.rb
    CHANGED
    
    | @@ -28,8 +28,13 @@ RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC'] | |
| 28 28 | 
             
            require "debase/ruby_core_source"
         | 
| 29 29 |  | 
| 30 30 | 
             
            hdrs = proc {
         | 
| 31 | 
            -
              have_header("vm_core.h")
         | 
| 32 | 
            -
              have_header(" | 
| 31 | 
            +
              have_header("vm_core.h") and
         | 
| 32 | 
            +
              have_header("iseq.h") and
         | 
| 33 | 
            +
              have_header("version.h") and
         | 
| 34 | 
            +
              have_header("vm_core.h") and
         | 
| 35 | 
            +
              have_header("vm_insnhelper.h") and
         | 
| 36 | 
            +
              have_header("vm_core.h") and
         | 
| 37 | 
            +
              have_header("method.h")
         | 
| 33 38 | 
             
            }
         | 
| 34 39 |  | 
| 35 40 | 
             
            # Allow use customization of compile options. For example, the
         | 
    
        data/lib/debase.rb
    CHANGED
    
    | @@ -20,7 +20,21 @@ module Debase | |
| 20 20 | 
             
                  Debugger.const_set('ARGV', ARGV.clone) unless defined? Debugger::ARGV
         | 
| 21 21 | 
             
                  Debugger.const_set('PROG_SCRIPT', $0) unless defined? Debugger::PROG_SCRIPT
         | 
| 22 22 | 
             
                  Debugger.const_set('INITIAL_DIR', Dir.pwd) unless  defined? Debugger::INITIAL_DIR
         | 
| 23 | 
            -
             | 
| 23 | 
            +
             | 
| 24 | 
            +
                  monkey_patch_prepend
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  Debugger.started? ? block && block.call(self) : Debugger.start_(&block)
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                def monkey_patch_prepend
         | 
| 30 | 
            +
                  class << RubyVM::InstructionSequence
         | 
| 31 | 
            +
                    def self.prepend(mod, *smth)
         | 
| 32 | 
            +
                      super
         | 
| 33 | 
            +
                      if mod.to_s.include? 'Bootsnap'
         | 
| 34 | 
            +
                        prepend InstructionSequenceMixin
         | 
| 35 | 
            +
                      end
         | 
| 36 | 
            +
                    end
         | 
| 37 | 
            +
                  end
         | 
| 24 38 | 
             
                end
         | 
| 25 39 |  | 
| 26 40 | 
             
                # @param [String] file
         | 
| @@ -81,6 +95,21 @@ module Debase | |
| 81 95 | 
             
                def file_filter
         | 
| 82 96 | 
             
                  @file_filter ||= FileFilter.new
         | 
| 83 97 | 
             
                end
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                module InstructionSequenceMixin
         | 
| 100 | 
            +
                  def load_iseq(path)
         | 
| 101 | 
            +
                    iseq = super(path)
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                    do_set_flags(iseq)
         | 
| 104 | 
            +
             | 
| 105 | 
            +
                    iseq
         | 
| 106 | 
            +
                  end
         | 
| 107 | 
            +
             | 
| 108 | 
            +
                  def do_set_flags(iseq)
         | 
| 109 | 
            +
                    Debugger.set_trace_flag_to_iseq(iseq)
         | 
| 110 | 
            +
                    iseq.each_child{|child_iseq| do_set_flags(child_iseq)}
         | 
| 111 | 
            +
                  end
         | 
| 112 | 
            +
                end
         | 
| 84 113 | 
             
              end
         | 
| 85 114 |  | 
| 86 115 | 
             
              class FileFilter
         | 
    
        data/lib/debase/version.rb
    CHANGED
    
    
    
        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. | 
| 4 | 
            +
              version: 0.2.3.beta2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Dennis Ushakov
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2018- | 
| 11 | 
            +
            date: 2018-07-30 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: debase-ruby_core_source
         | 
| @@ -130,9 +130,9 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 130 130 | 
             
                  version: '2.0'
         | 
| 131 131 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 132 132 | 
             
              requirements:
         | 
| 133 | 
            -
              - - " | 
| 133 | 
            +
              - - ">"
         | 
| 134 134 | 
             
                - !ruby/object:Gem::Version
         | 
| 135 | 
            -
                  version:  | 
| 135 | 
            +
                  version: 1.3.1
         | 
| 136 136 | 
             
            requirements: []
         | 
| 137 137 | 
             
            rubyforge_project: debase
         | 
| 138 138 | 
             
            rubygems_version: 2.6.10
         |