Skip to content

Commit

Permalink
fixes for lldb-3.6. print does not work there. output works bad aft…
Browse files Browse the repository at this point in the history
…er `thread select`. replaced debug output with more representative.
  • Loading branch information
equivalence1 authored and dmitrii.kravchenko committed Oct 4, 2016
1 parent c03250e commit f3955ca
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions bin/gdb_wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,7 @@ module DebugPrinter

def print_debug(msg)
if DebugPrinter.cli_debug
delimiter = '=' * 10
upper_border = "\n#{delimiter}\n"
lower_border = "#{delimiter}\n\n"

if msg.length > 0 and msg[msg.length - 1] != "\n"
lower_border = "\n" + lower_border
end

$stdout.puts upper_border + msg + lower_border
$stderr.puts msg
end
end
end
Expand Down Expand Up @@ -139,18 +131,17 @@ class NativeDebugger

def get_response
# we need this hack to understand that debugger gave us all output from last executed command
@pipe.puts "print \"#{@delimiter}\""
print_delimiter

content = ''
loop do
line = @pipe.readline
break if check_delimiter(line)
DebugPrinter.print_debug('respond line: ' + line)
next if line =~ /\(lldb\)/ # lldb repeats your input to its output
break if line =~ /\$\d+\s=\s"#{@delimiter}"/
content += line
end

DebugPrinter.print_debug(content)

content
end

Expand All @@ -162,6 +153,14 @@ class NativeDebugger

end

def print_delimiter

end

def check_delimiter(line)

end

def switch_to_thread

end
Expand Down Expand Up @@ -220,7 +219,6 @@ class LLDB < NativeDebugger
info_threads = (execute 'thread list').split("\n")
info_threads.each do |thread_info|
next unless thread_info =~ /[\s*]*thread\s#\d+.*/
$stdout.puts "thread_info: #{thread_info}"
is_main = thread_info[0] == '*'
thread_num = thread_info.sub(/[\s*]*thread\s#/, '').sub(/:\s.*$/, '').to_i
thread = ProcessThread.new(thread_num, is_main, thread_info, self)
Expand Down Expand Up @@ -248,6 +246,14 @@ class LLDB < NativeDebugger
set_tbreak(@tbreak)
end

def print_delimiter
@pipe.puts "script print \"#{@delimiter}\""
end

def check_delimiter(line)
line =~ /#{@delimiter}$/
end

def load_debugger
execute "expr (VALUE) #{@eval_string}"
end
Expand Down Expand Up @@ -302,6 +308,14 @@ class GDB < NativeDebugger
set_tbreak(@tbreak)
end

def print_delimiter
@pipe.puts "print \"#{@delimiter}\""
end

def check_delimiter(line)
line =~ /\$\d+\s=\s"#{@delimiter}"/
end

def load_debugger
execute "call #{@eval_string}"
end
Expand Down

0 comments on commit f3955ca

Please sign in to comment.