From bf66372b2b5b49ba4a93d8ac4f573ceb7857f5b8 Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Fri, 24 Oct 2014 17:38:36 +0200 Subject: [PATCH] Fix attach in case of multiple threads. --- .../linux/lldb_threads_settrace.py | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/python/helpers/pydev/pydevd_attach_to_process/linux/lldb_threads_settrace.py b/python/helpers/pydev/pydevd_attach_to_process/linux/lldb_threads_settrace.py index f08330cfaf1a..b457e1547cd2 100644 --- a/python/helpers/pydev/pydevd_attach_to_process/linux/lldb_threads_settrace.py +++ b/python/helpers/pydev/pydevd_attach_to_process/linux/lldb_threads_settrace.py @@ -3,20 +3,34 @@ def __lldb_init_module(debugger, internal_dict): # Command Initialization code goes here print('Startup LLDB in Python!') + import lldb try: - show_debug_info = 0 + show_debug_info = 1 is_debug = 0 target = debugger.GetSelectedTarget() if target: process = target.GetProcess() if process: - for t in process: + for thread in process: # Get the first frame - frame = t.GetFrameAtIndex (t.GetNumFrames()-1) - if frame: - print('Will settrace in: %s' % (frame,)) - frame.EvaluateExpression("expr (int) SetSysTraceFunc(%s, %s);" % ( - show_debug_info, is_debug)) + print('Thread %s, suspended %s\n'%(thread, thread.IsStopped())) + + process.SetSelectedThread(thread) + + if not thread.IsStopped(): + error = process.Stop() + print(error) + + if thread: + frame = thread.GetSelectedFrame() + if frame: + print('Will settrace in: %s' % (frame,)) + res = frame.EvaluateExpression("(int) SetSysTraceFunc(%s, %s)" % ( + show_debug_info, is_debug), lldb.eDynamicCanRunTarget) + error = res.GetError() + if error: + print(error) + thread.Resume() except: import traceback;traceback.print_exc()