debase 0.2.2.beta8 → 0.2.2.beta9

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
  SHA1:
3
- metadata.gz: 2a1e87cdd51f0c7a810d7a2b756db948a0bd13e5
4
- data.tar.gz: 12f174215bb14d1f654c056dc6aa1a47398ebac2
3
+ metadata.gz: 72f6bca149dbf44230032e0bc5232ed4dfbf1790
4
+ data.tar.gz: 1e1d31d2b83bcbd464ea32d0ad46b1f0f5c276d3
5
5
  SHA512:
6
- metadata.gz: 543fbe0eaf3d28f83c5c253c29e882aa8c18ab69af027ad7b221bd256c0399db06a3479ee3dcee45f8faf18946b4dc73a86ec88bae59bfb1bef19451c507cdd6
7
- data.tar.gz: 543fae8f7f04950feb679caa18593da3f4bc94470b71ad7afcba979e6bab2aa0fac1b85cd8fe8e34d51cf26d189da0bc22db0881eb720e9dea2242a7cf60c6ba
6
+ metadata.gz: ef7fbb2819851e3fc04bda8532eb07a2da3c8be2c206dfdd0d8c056f4e19e376a48842b3f35ad350b2ffedc0e9aec4ec7b621bebd0a612cd830eedda45cb2f48
7
+ data.tar.gz: 7ca7fe17d565d711e67b6754fc04b04174bf8bad8a86fd4a0ed9d20905c42d4655eee94d8a1893674ac8713c4f6e3deebe381e8d135be6113c6d3f3978f46d74
data/Rakefile CHANGED
@@ -13,6 +13,14 @@ task :clean do
13
13
  derived_files = Dir.glob(".o") + Dir.glob("*.so") + Dir.glob("*.bundle")
14
14
  rm derived_files unless derived_files.empty?
15
15
  end
16
+ cd "ext/attach" do
17
+ if File.exists?("Makefile")
18
+ sh "make clean"
19
+ rm "Makefile"
20
+ end
21
+ derived_files = Dir.glob(".o") + Dir.glob("*.so") + Dir.glob("*.bundle")
22
+ rm derived_files unless derived_files.empty?
23
+ end
16
24
  if File.exists?('pkg')
17
25
  cd 'pkg' do
18
26
  derived_files = Dir.glob('*.gem')
@@ -27,6 +35,10 @@ task :lib => :clean do
27
35
  system("#{Gem.ruby} extconf.rb && make")
28
36
  exit $?.to_i if $?.to_i != 0
29
37
  end
38
+ Dir.chdir("ext/attach") do
39
+ system("#{Gem.ruby} extconf.rb && make")
40
+ exit $?.to_i if $?.to_i != 0
41
+ end
30
42
  end
31
43
 
32
44
  desc "Test debase."
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
25
25
  s.require_paths = ["lib"]
26
26
 
27
- s.extensions = ["ext/extconf.rb"]
27
+ s.extensions = ["ext/extconf.rb", "ext/attach/extconf.rb"]
28
28
 
29
29
  s.add_dependency "debase-ruby_core_source"
30
30
  s.add_development_dependency "test-unit"
@@ -0,0 +1,51 @@
1
+ #include "attach.h"
2
+
3
+ /*
4
+ We need to prevent compiler from optimizing this function calls. For more details
5
+ see "noinline" section here: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
6
+ */
7
+ static void
8
+ __attribute__ ((noinline))
9
+ __func_to_set_breakpoint_at()
10
+ {
11
+ asm("");
12
+ }
13
+
14
+ static void
15
+ __catch_line_event(rb_event_flag_t evflag, VALUE data, VALUE self, ID mid, VALUE klass)
16
+ {
17
+ (void)sizeof(evflag);
18
+ (void)sizeof(self);
19
+ (void)sizeof(mid);
20
+ (void)sizeof(klass);
21
+
22
+ rb_remove_event_hook(__catch_line_event);
23
+ if (rb_during_gc())
24
+ return;
25
+ __func_to_set_breakpoint_at();
26
+ }
27
+
28
+ int
29
+ debase_start_attach()
30
+ {
31
+ if (rb_during_gc())
32
+ return 1;
33
+ rb_add_event_hook(__catch_line_event, RUBY_EVENT_LINE, (VALUE) NULL);
34
+ return 0;
35
+ }
36
+
37
+ void
38
+ debase_rb_eval(const char *string_to_eval)
39
+ {
40
+ rb_eval_string_protect(string_to_eval, NULL);
41
+ }
42
+
43
+ void
44
+ Init_attach()
45
+ {
46
+ /*
47
+ The only purpose of this library is to be dlopen'ed inside
48
+ gdb/lldb. So no initialization here, you should directly
49
+ call functions above.
50
+ */
51
+ }
@@ -0,0 +1,10 @@
1
+ #ifndef __ATTACH_H__
2
+ #define __ATTACH_H__
3
+
4
+ #include <ruby.h>
5
+ #include <ruby/debug.h>
6
+
7
+ int debase_start_attach();
8
+ void debase_rb_eval(const char *);
9
+
10
+ #endif //__ATTACH_H__
@@ -0,0 +1,54 @@
1
+ if defined?(RUBY_ENGINE) && 'rbx' == RUBY_ENGINE
2
+ # create dummy Makefile to indicate success
3
+ f = File.open(File.join(File.dirname(__FILE__), "Makefile"), "w")
4
+ f.write("all:\n\techo all\ninstall:\n\techo installed\n")
5
+ f.close
6
+ return
7
+ end
8
+
9
+ # autodetect ruby headers
10
+ unless ARGV.any? {|arg| arg.include?('--with-ruby-include') }
11
+ require 'rbconfig'
12
+ bindir = RbConfig::CONFIG['bindir']
13
+ if bindir =~ %r{(^.*/\.rbenv/versions)/([^/]+)/bin$}
14
+ ruby_include = "#{$1}/#{$2}/include/ruby-1.9.1/ruby-#{$2}"
15
+ ruby_include = "#{ENV['RBENV_ROOT']}/sources/#{$2}/ruby-#{$2}" unless File.exist?(ruby_include)
16
+ ARGV << "--with-ruby-include=#{ruby_include}"
17
+ elsif bindir =~ %r{(^.*/\.rvm/rubies)/([^/]+)/bin$}
18
+ ruby_include = "#{$1}/#{$2}/include/ruby-1.9.1/#{$2}"
19
+ ruby_include = "#{ENV['rvm_path']}/src/#{$2}" unless File.exist?(ruby_include)
20
+ ARGV << "--with-ruby-include=#{ruby_include}"
21
+ end
22
+ end
23
+
24
+ require "mkmf"
25
+
26
+ RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
27
+
28
+ require "debase/ruby_core_source"
29
+
30
+ hdrs = proc {
31
+ have_header("vm_core.h")
32
+ }
33
+
34
+ # Allow use customization of compile options. For example, the
35
+ # following lines could be put in config_options to to turn off
36
+ # optimization:
37
+ # $CFLAGS='-fPIC -fno-strict-aliasing -g3 -ggdb -O2 -fPIC'
38
+ config_file = File.join(File.dirname(__FILE__), 'config_options.rb')
39
+ load config_file if File.exist?(config_file)
40
+
41
+ if ENV['debase_debug']
42
+ $CFLAGS+=' -Wall -Werror'
43
+ $CFLAGS+=' -g3'
44
+ end
45
+
46
+ dir_config("ruby")
47
+ if !Debase::RubyCoreSource.create_makefile_with_core(hdrs, "attach")
48
+ STDERR.print("Makefile creation failed\n")
49
+ STDERR.print("*************************************************************\n\n")
50
+ STDERR.print(" NOTE: If your headers were not found, try passing\n")
51
+ STDERR.print(" --with-ruby-include=PATH_TO_HEADERS \n\n")
52
+ STDERR.print("*************************************************************\n\n")
53
+ exit(1)
54
+ end
@@ -219,9 +219,15 @@ breakpoint_find(VALUE breakpoints, VALUE source, VALUE pos)
219
219
  }
220
220
 
221
221
  extern void
222
- Init_breakpoint(VALUE mDebase)
222
+ breakpoint_init_variables()
223
223
  {
224
224
  breakpoint_max = 0;
225
+ }
226
+
227
+ extern void
228
+ Init_breakpoint(VALUE mDebase)
229
+ {
230
+ breakpoint_init_variables();
225
231
  cBreakpoint = rb_define_class_under(mDebase, "Breakpoint", rb_cObject);
226
232
  rb_define_singleton_method(cBreakpoint, "find", Breakpoint_find, 3);
227
233
  rb_define_singleton_method(cBreakpoint, "remove", Breakpoint_remove, 2);
@@ -345,6 +345,12 @@ Context_stop_frame(VALUE self, VALUE frame)
345
345
  return frame;
346
346
  }
347
347
 
348
+ extern void
349
+ context_init_variables()
350
+ {
351
+ thnum_current = 0;
352
+ }
353
+
348
354
  /*
349
355
  * Document-class: Context
350
356
  *
@@ -373,6 +379,7 @@ Init_context(VALUE mDebase)
373
379
  rb_define_method(cContext, "pause", Context_pause, 0);
374
380
 
375
381
  idAlive = rb_intern("alive?");
382
+ context_init_variables();
376
383
 
377
384
  return cContext;
378
385
  // rb_define_method(cContext, "suspend", context_suspend, 0);
@@ -24,6 +24,8 @@ static VALUE idAtCatchpoint;
24
24
  static VALUE idFileFilter;
25
25
  static VALUE idAccept;
26
26
 
27
+ static int started = 0;
28
+
27
29
  static void
28
30
  print_debug(const char *message, ...)
29
31
  {
@@ -472,7 +474,9 @@ process_raise_event(VALUE trace_point, void *data)
472
474
  static VALUE
473
475
  Debase_setup_tracepoints(VALUE self)
474
476
  {
475
- if (catchpoints != Qnil) return Qnil;
477
+ if (started) return Qnil;
478
+ started = 1;
479
+
476
480
  contexts = rb_hash_new();
477
481
  breakpoints = rb_ary_new();
478
482
  catchpoints = rb_hash_new();
@@ -496,19 +500,13 @@ Debase_setup_tracepoints(VALUE self)
496
500
 
497
501
  static VALUE
498
502
  Debase_remove_tracepoints(VALUE self)
499
- {
500
- contexts = Qnil;
501
- breakpoints = Qnil;
502
- catchpoints = Qnil;
503
+ {
504
+ started = 0;
503
505
 
504
506
  if (tpLine != Qnil) rb_tracepoint_disable(tpLine);
505
- tpLine = Qnil;
506
507
  if (tpReturn != Qnil) rb_tracepoint_disable(tpReturn);
507
- tpReturn = Qnil;
508
508
  if (tpCall != Qnil) rb_tracepoint_disable(tpCall);
509
- tpCall = Qnil;
510
509
  if (tpRaise != Qnil) rb_tracepoint_disable(tpRaise);
511
- tpRaise = Qnil;
512
510
 
513
511
  return Qnil;
514
512
  }
@@ -530,6 +528,14 @@ debase_prepare_context(VALUE self, VALUE file, VALUE stop)
530
528
  return self;
531
529
  }
532
530
 
531
+ static VALUE
532
+ Debase_prepare_context(VALUE self)
533
+ {
534
+ Debase_current_context(self);
535
+
536
+ return self;
537
+ }
538
+
533
539
  static VALUE
534
540
  Debase_debug_load(int argc, VALUE *argv, VALUE self)
535
541
  {
@@ -589,7 +595,7 @@ Debase_catchpoints(VALUE self)
589
595
  static VALUE
590
596
  Debase_started(VALUE self)
591
597
  {
592
- return catchpoints != Qnil ? Qtrue : Qfalse;
598
+ return started ? Qtrue : Qfalse;
593
599
  }
594
600
 
595
601
  /*
@@ -630,6 +636,23 @@ Debase_enable_file_filtering(VALUE self, VALUE value)
630
636
  return value;
631
637
  }
632
638
 
639
+ static VALUE
640
+ Debase_init_variables()
641
+ {
642
+ started = 0;
643
+ verbose = Qfalse;
644
+ locker = Qnil;
645
+ file_filter_enabled = Qfalse;
646
+ contexts = Qnil;
647
+ catchpoints = Qnil;
648
+ breakpoints = Qnil;
649
+
650
+ context_init_variables();
651
+ breakpoint_init_variables();
652
+
653
+ return Qtrue;
654
+ }
655
+
633
656
  /*
634
657
  * Document-class: Debase
635
658
  *
@@ -654,6 +677,8 @@ Init_debase_internals()
654
677
  rb_define_module_function(mDebase, "verbose=", Debase_set_verbose, 1);
655
678
  rb_define_module_function(mDebase, "enable_file_filtering", Debase_enable_file_filtering, 1);
656
679
  rb_define_module_function(mDebase, "enable_trace_points", Debase_enable_trace_points, 0);
680
+ rb_define_module_function(mDebase, "prepare_context", Debase_prepare_context, 0);
681
+ rb_define_module_function(mDebase, "init_variables", Debase_init_variables, 0);
657
682
 
658
683
  idAlive = rb_intern("alive?");
659
684
  idAtLine = rb_intern("at_line");
@@ -665,9 +690,7 @@ Init_debase_internals()
665
690
  cContext = Init_context(mDebase);
666
691
  Init_breakpoint(mDebase);
667
692
  cDebugThread = rb_define_class_under(mDebase, "DebugThread", rb_cThread);
668
- contexts = Qnil;
669
- catchpoints = Qnil;
670
- breakpoints = Qnil;
693
+ Debase_init_variables();
671
694
 
672
695
  rb_global_variable(&locker);
673
696
  rb_global_variable(&breakpoints);
@@ -105,4 +105,7 @@ typedef struct
105
105
  extern VALUE catchpoint_hit_count(VALUE catchpoints, VALUE exception, VALUE *exception_name);
106
106
  extern VALUE breakpoint_find(VALUE breakpoints, VALUE source, VALUE pos);
107
107
  extern void Init_breakpoint(VALUE mDebase);
108
+
109
+ extern void breakpoint_init_variables();
110
+ extern void context_init_variables();
108
111
  #endif
@@ -1,3 +1,3 @@
1
1
  module Debase
2
- VERSION = "0.2.2.beta8" unless defined? VERSION
2
+ VERSION = "0.2.2.beta9" 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.beta8
4
+ version: 0.2.2.beta9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Ushakov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-27 00:00:00.000000000 Z
11
+ date: 2016-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debase-ruby_core_source
@@ -62,6 +62,7 @@ email:
62
62
  executables: []
63
63
  extensions:
64
64
  - ext/extconf.rb
65
+ - ext/attach/extconf.rb
65
66
  extra_rdoc_files: []
66
67
  files:
67
68
  - ".gitignore"
@@ -72,6 +73,9 @@ files:
72
73
  - README.md
73
74
  - Rakefile
74
75
  - debase.gemspec
76
+ - ext/attach/attach.c
77
+ - ext/attach/attach.h
78
+ - ext/attach/extconf.rb
75
79
  - ext/breakpoint.c
76
80
  - ext/context.c
77
81
  - ext/debase_internals.c
@@ -131,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
135
  version: 1.3.1
132
136
  requirements: []
133
137
  rubyforge_project: debase
134
- rubygems_version: 2.5.1
138
+ rubygems_version: 2.4.8
135
139
  signing_key:
136
140
  specification_version: 4
137
141
  summary: debase is a fast implementation of the standard Ruby debugger debug.rb for
@@ -161,3 +165,4 @@ test_files:
161
165
  - test/test_catchpoint.rb
162
166
  - test/test_load.rb
163
167
  - test/test_reload_bug.rb
168
+ has_rdoc: