diff --git a/ext/Makefile b/ext/Makefile deleted file mode 100644 index 6c52c90..0000000 --- a/ext/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -all: libAttach.so - -libAttach.so: libAttach.o - gcc -shared -o libAttach.so libAttach.o - -libAttach.o: attach.c - gcc -Wall -g -fPIC -c -I/home/equi/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0 -I/home/equi/.rvm/rubies/ruby-2.3.1/include/ruby-2.3.0/x86_64-linux/ attach.c -o libAttach.o - -clean: - rm libAttach.* diff --git a/ext/attach.c b/ext/attach.c deleted file mode 100644 index d4d4dbe..0000000 --- a/ext/attach.c +++ /dev/null @@ -1,29 +0,0 @@ -#include "attach.h" - -static void -__func_to_set_breakpoint_at() -{ -} - -static void -__catch_line_event(rb_event_flag_t evflag, VALUE data, VALUE self, ID mid, VALUE klass) -{ - (void)sizeof(evflag); - (void)sizeof(self); - (void)sizeof(mid); - (void)sizeof(klass); - - rb_remove_event_hook(__catch_line_event); - if (rb_during_gc()) - return; - __func_to_set_breakpoint_at(); -} - -int -start_attach() -{ - if (rb_during_gc()) - return 1; - rb_add_event_hook(__catch_line_event, RUBY_EVENT_LINE, (VALUE) NULL); - return 0; -} diff --git a/ext/attach.h b/ext/attach.h deleted file mode 100644 index 9c98192..0000000 --- a/ext/attach.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __ATTACH_H__ -#define __ATTACH_H__ - -#include -#include - -int start_attach(); - -#endif //__ATTACH_H__ \ No newline at end of file diff --git a/lib/ruby-debug-ide/attach/gdb.rb b/lib/ruby-debug-ide/attach/gdb.rb index a507880..bf9085c 100644 --- a/lib/ruby-debug-ide/attach/gdb.rb +++ b/lib/ruby-debug-ide/attach/gdb.rb @@ -37,11 +37,15 @@ def switch_to_thread(thread_num) execute "thread #{thread_num}" end + def set_break(str) + execute "tbreak #{str}" + end + def call_start_attach super() execute "call dlopen(\"#{@path_to_attach}\", 2)" - execute 'call start_attach()' - set_tbreak(@tbreak) + execute 'call debase_start_attach()' + set_break(@tbreak) end def print_delimiter diff --git a/lib/ruby-debug-ide/attach/lldb.rb b/lib/ruby-debug-ide/attach/lldb.rb index 87245df..b9bdc31 100644 --- a/lib/ruby-debug-ide/attach/lldb.rb +++ b/lib/ruby-debug-ide/attach/lldb.rb @@ -35,11 +35,15 @@ def switch_to_thread(thread_num) execute "thread select #{thread_num}" end + def set_break(str) + execute "breakpoint set --shlib #{@path_to_attach} --name #{str}" + end + def call_start_attach super() execute "expr (void *) dlopen(\"#{@path_to_attach}\", 2)" - execute 'expr (int) start_attach()' - set_tbreak(@tbreak) + execute 'expr (int) debase_start_attach()' + set_break(@tbreak) end def print_delimiter @@ -51,7 +55,7 @@ def check_delimiter(line) end def load_debugger - execute "expr (VALUE) #{@eval_string}" + execute "expr (void) #{@eval_string}" end def to_s diff --git a/lib/ruby-debug-ide/attach/native_debugger.rb b/lib/ruby-debug-ide/attach/native_debugger.rb index d48ed1e..87eebc9 100644 --- a/lib/ruby-debug-ide/attach/native_debugger.rb +++ b/lib/ruby-debug-ide/attach/native_debugger.rb @@ -21,7 +21,7 @@ def initialize(executable, pid, flags, gems_to_include, debugger_loader_path, ar @debugger_loader_path = debugger_loader_path @argv = argv - @eval_string = "rb_eval_string_protect(\"require '#{@debugger_loader_path}'; load_debugger(#{@gems_to_include.gsub("\"", "'")}, #{@argv.gsub("\"", "'")})\", (int *)0)" + @eval_string = "debase_rb_eval(\"require '#{@debugger_loader_path}'; load_debugger(#{@gems_to_include.gsub("\"", "'")}, #{@argv.gsub("\"", "'")})\", (int *)0)" launch_string = "#{self} #{executable} #{flags}" @pipe = IO.popen(launch_string, 'r+') @@ -30,7 +30,7 @@ def initialize(executable, pid, flags, gems_to_include, debugger_loader_path, ar def find_attach_lib(debase_path) attach_lib = debase_path + '/attach' - known_extensions = %w(.so .bundle .dll) + known_extensions = %w(.so .bundle .dll .dylib) known_extensions.each do |ext| if File.file?(attach_lib + ext) return attach_lib + ext @@ -60,8 +60,8 @@ def get_response content = '' loop do line = @pipe.readline - break if check_delimiter(line) DebugPrinter.print_debug('respond line: ' + line) + break if check_delimiter(line) next if line =~ /\(lldb\)/ # lldb repeats your input to its output content += line end @@ -89,8 +89,8 @@ def switch_to_thread end - def set_tbreak(str) - execute "tbreak #{str}" + def set_break(str) + end def continue @@ -98,6 +98,7 @@ def continue @pipe.puts 'c' loop do line = @pipe.readline + DebugPrinter.print_debug('respond line: ' + line) break if line =~ /#{Regexp.escape(@tbreak)}/ end get_response