Skip to content

Commit ce3ed08

Browse files
authored
Merge pull request #86 from equivalence1/ruby-attach-to-process
Some changes
2 parents 899d73a + 17e92ec commit ce3ed08

File tree

6 files changed

+19
-58
lines changed

6 files changed

+19
-58
lines changed

ext/Makefile

Lines changed: 0 additions & 10 deletions
This file was deleted.

ext/attach.c

Lines changed: 0 additions & 29 deletions
This file was deleted.

ext/attach.h

Lines changed: 0 additions & 9 deletions
This file was deleted.

lib/ruby-debug-ide/attach/gdb.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@ def switch_to_thread(thread_num)
3737
execute "thread #{thread_num}"
3838
end
3939

40+
def set_break(str)
41+
execute "tbreak #{str}"
42+
end
43+
4044
def call_start_attach
4145
super()
4246
execute "call dlopen(\"#{@path_to_attach}\", 2)"
43-
execute 'call start_attach()'
44-
set_tbreak(@tbreak)
47+
execute 'call debase_start_attach()'
48+
set_break(@tbreak)
4549
end
4650

4751
def print_delimiter

lib/ruby-debug-ide/attach/lldb.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@ def switch_to_thread(thread_num)
3535
execute "thread select #{thread_num}"
3636
end
3737

38+
def set_break(str)
39+
execute "breakpoint set --shlib #{@path_to_attach} --name #{str}"
40+
end
41+
3842
def call_start_attach
3943
super()
4044
execute "expr (void *) dlopen(\"#{@path_to_attach}\", 2)"
41-
execute 'expr (int) start_attach()'
42-
set_tbreak(@tbreak)
45+
execute 'expr (int) debase_start_attach()'
46+
set_break(@tbreak)
4347
end
4448

4549
def print_delimiter
@@ -51,7 +55,7 @@ def check_delimiter(line)
5155
end
5256

5357
def load_debugger
54-
execute "expr (VALUE) #{@eval_string}"
58+
execute "expr (void) #{@eval_string}"
5559
end
5660

5761
def to_s

lib/ruby-debug-ide/attach/native_debugger.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def initialize(executable, pid, flags, gems_to_include, debugger_loader_path, ar
2121
@debugger_loader_path = debugger_loader_path
2222
@argv = argv
2323

24-
@eval_string = "rb_eval_string_protect(\"require '#{@debugger_loader_path}'; load_debugger(#{@gems_to_include.gsub("\"", "'")}, #{@argv.gsub("\"", "'")})\", (int *)0)"
24+
@eval_string = "debase_rb_eval(\"require '#{@debugger_loader_path}'; load_debugger(#{@gems_to_include.gsub("\"", "'")}, #{@argv.gsub("\"", "'")})\", (int *)0)"
2525

2626
launch_string = "#{self} #{executable} #{flags}"
2727
@pipe = IO.popen(launch_string, 'r+')
@@ -30,7 +30,7 @@ def initialize(executable, pid, flags, gems_to_include, debugger_loader_path, ar
3030

3131
def find_attach_lib(debase_path)
3232
attach_lib = debase_path + '/attach'
33-
known_extensions = %w(.so .bundle .dll)
33+
known_extensions = %w(.so .bundle .dll .dylib)
3434
known_extensions.each do |ext|
3535
if File.file?(attach_lib + ext)
3636
return attach_lib + ext
@@ -60,8 +60,8 @@ def get_response
6060
content = ''
6161
loop do
6262
line = @pipe.readline
63-
break if check_delimiter(line)
6463
DebugPrinter.print_debug('respond line: ' + line)
64+
break if check_delimiter(line)
6565
next if line =~ /\(lldb\)/ # lldb repeats your input to its output
6666
content += line
6767
end
@@ -89,15 +89,16 @@ def switch_to_thread
8989

9090
end
9191

92-
def set_tbreak(str)
93-
execute "tbreak #{str}"
92+
def set_break(str)
93+
9494
end
9595

9696
def continue
9797
$stdout.puts 'continuing'
9898
@pipe.puts 'c'
9999
loop do
100100
line = @pipe.readline
101+
DebugPrinter.print_debug('respond line: ' + line)
101102
break if line =~ /#{Regexp.escape(@tbreak)}/
102103
end
103104
get_response

0 commit comments

Comments
 (0)