Skip to content

Commit f3955ca

Browse files
equivalence1dmitrii.kravchenko
authored andcommitted
fixes for lldb-3.6. print does not work there. output works bad after thread select. replaced debug output with more representative.
1 parent c03250e commit f3955ca

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

bin/gdb_wrapper

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,7 @@ module DebugPrinter
2020

2121
def print_debug(msg)
2222
if DebugPrinter.cli_debug
23-
delimiter = '=' * 10
24-
upper_border = "\n#{delimiter}\n"
25-
lower_border = "#{delimiter}\n\n"
26-
27-
if msg.length > 0 and msg[msg.length - 1] != "\n"
28-
lower_border = "\n" + lower_border
29-
end
30-
31-
$stdout.puts upper_border + msg + lower_border
23+
$stderr.puts msg
3224
end
3325
end
3426
end
@@ -139,18 +131,17 @@ class NativeDebugger
139131

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

144136
content = ''
145137
loop do
146138
line = @pipe.readline
139+
break if check_delimiter(line)
140+
DebugPrinter.print_debug('respond line: ' + line)
147141
next if line =~ /\(lldb\)/ # lldb repeats your input to its output
148-
break if line =~ /\$\d+\s=\s"#{@delimiter}"/
149142
content += line
150143
end
151144

152-
DebugPrinter.print_debug(content)
153-
154145
content
155146
end
156147

@@ -162,6 +153,14 @@ class NativeDebugger
162153

163154
end
164155

156+
def print_delimiter
157+
158+
end
159+
160+
def check_delimiter(line)
161+
162+
end
163+
165164
def switch_to_thread
166165

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

249+
def print_delimiter
250+
@pipe.puts "script print \"#{@delimiter}\""
251+
end
252+
253+
def check_delimiter(line)
254+
line =~ /#{@delimiter}$/
255+
end
256+
251257
def load_debugger
252258
execute "expr (VALUE) #{@eval_string}"
253259
end
@@ -302,6 +308,14 @@ class GDB < NativeDebugger
302308
set_tbreak(@tbreak)
303309
end
304310

311+
def print_delimiter
312+
@pipe.puts "print \"#{@delimiter}\""
313+
end
314+
315+
def check_delimiter(line)
316+
line =~ /\$\d+\s=\s"#{@delimiter}"/
317+
end
318+
305319
def load_debugger
306320
execute "call #{@eval_string}"
307321
end

0 commit comments

Comments
 (0)