diff options
| -rw-r--r-- | lldb/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py | 2 | ||||
| -rw-r--r-- | lldb/test/class_types/TestClassTypes.py | 4 | ||||
| -rw-r--r-- | lldb/test/conditional_break/TestConditionalBreak.py | 2 | ||||
| -rw-r--r-- | lldb/test/conditional_break/conditional_break.py | 4 | ||||
| -rw-r--r-- | lldb/test/cpp/dynamic-value/TestDynamicValue.py | 8 | ||||
| -rw-r--r-- | lldb/test/expression_command/test/TestExprs.py | 4 | ||||
| -rw-r--r-- | lldb/test/inferior-crashing/TestInferiorCrashing.py | 2 | ||||
| -rw-r--r-- | lldb/test/lldbutil.py | 85 | ||||
| -rw-r--r-- | lldb/test/python_api/lldbutil/TestPrintStackTraces.py | 2 |
9 files changed, 56 insertions, 57 deletions
diff --git a/lldb/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py b/lldb/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py index e231ac25f7a..27156c1f08f 100644 --- a/lldb/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py +++ b/lldb/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py @@ -108,7 +108,7 @@ class BreakpointIgnoreCountTestCase(TestBase): # Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and # frame#2 should be on main.c:48. - #lldbutil.PrintStackTraces(self.process) + #lldbutil.print_stacktraces(self.process) from lldbutil import get_stopped_thread thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint) self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint") diff --git a/lldb/test/class_types/TestClassTypes.py b/lldb/test/class_types/TestClassTypes.py index dd916c9d8ba..68867051226 100644 --- a/lldb/test/class_types/TestClassTypes.py +++ b/lldb/test/class_types/TestClassTypes.py @@ -140,8 +140,8 @@ class ClassTypesTestCase(TestBase): # The filename of frame #0 should be 'main.cpp' and the line number # should be 93. - self.expect("%s:%d" % (lldbutil.GetFilenames(thread)[0], - lldbutil.GetLineNumbers(thread)[0]), + self.expect("%s:%d" % (lldbutil.get_filenames(thread)[0], + lldbutil.get_line_numbers(thread)[0]), "Break correctly at main.cpp:%d" % self.line, exe=False, startstr = "main.cpp:") ### clang compiled code reported main.cpp:94? diff --git a/lldb/test/conditional_break/TestConditionalBreak.py b/lldb/test/conditional_break/TestConditionalBreak.py index 04a58412679..1fe21db80e7 100644 --- a/lldb/test/conditional_break/TestConditionalBreak.py +++ b/lldb/test/conditional_break/TestConditionalBreak.py @@ -79,7 +79,7 @@ class ConditionalBreakTestCase(TestBase): name0 = frame0.GetFunction().GetName() frame1 = thread.GetFrameAtIndex(1) name1 = frame1.GetFunction().GetName() - #lldbutil.PrintStackTrace(thread) + #lldbutil.print_stacktrace(thread) self.assertTrue(name0 == "c", "Break on function c()") if (name1 == "a"): # By design, we know that a() calls c() only from main.c:27. diff --git a/lldb/test/conditional_break/conditional_break.py b/lldb/test/conditional_break/conditional_break.py index 65e9c8d725e..b27fd14315b 100644 --- a/lldb/test/conditional_break/conditional_break.py +++ b/lldb/test/conditional_break/conditional_break.py @@ -19,9 +19,9 @@ def stop_if_called_from_a(): # command interpreter to continue execution. #print >> sys.stdout, "Checking call frames..." - #lldbutil.PrintStackTrace(thread) + #lldbutil.print_stacktrace(thread) if thread.GetNumFrames() >= 2: - funcs = lldbutil.GetFunctionNames(thread) + funcs = lldbutil.get_function_names(thread) #print >> sys.stdout, funcs[0], "called from", funcs[1] if (funcs[0] == 'c' and funcs[1] == 'a'): #print >> sys.stdout, "Stopped at c() with immediate caller as a()." diff --git a/lldb/test/cpp/dynamic-value/TestDynamicValue.py b/lldb/test/cpp/dynamic-value/TestDynamicValue.py index 69a0d559d50..93a47d5008c 100644 --- a/lldb/test/cpp/dynamic-value/TestDynamicValue.py +++ b/lldb/test/cpp/dynamic-value/TestDynamicValue.py @@ -119,7 +119,7 @@ class DynamicValueTestCase(TestBase): self.assertTrue(self.process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) - threads = lldbutil.GetThreadsStoppedAtBreakpoint (self.process, first_call_bpt) + threads = lldbutil.get_threads_stopped_at_breakpoint (self.process, first_call_bpt) self.assertTrue (len(threads) == 1) thread = threads[0] @@ -141,7 +141,7 @@ class DynamicValueTestCase(TestBase): # Okay now run to doSomething: - threads = lldbutil.ContinueToBreakpoint (self.process, do_something_bpt) + threads = lldbutil.continue_to_breakpoint (self.process, do_something_bpt) self.assertTrue (len(threads) == 1) thread = threads[0] @@ -194,7 +194,7 @@ class DynamicValueTestCase(TestBase): # Okay, now continue again, and when we hit the second breakpoint in main - threads = lldbutil.ContinueToBreakpoint (self.process, second_call_bpt) + threads = lldbutil.continue_to_breakpoint (self.process, second_call_bpt) self.assertTrue (len(threads) == 1) thread = threads[0] @@ -206,7 +206,7 @@ class DynamicValueTestCase(TestBase): # Finally continue to doSomething again, and make sure we get the right value for anotherA, # which this time around is just an "A". - threads = lldbutil.ContinueToBreakpoint (self.process, do_something_bpt) + threads = lldbutil.continue_to_breakpoint (self.process, do_something_bpt) self.assertTrue(len(threads) == 1) thread = threads[0] diff --git a/lldb/test/expression_command/test/TestExprs.py b/lldb/test/expression_command/test/TestExprs.py index 33d1e392b09..ace628c6a9c 100644 --- a/lldb/test/expression_command/test/TestExprs.py +++ b/lldb/test/expression_command/test/TestExprs.py @@ -119,10 +119,10 @@ class BasicExprCommandsTestCase(TestBase): StopReasonString(thread.GetStopReason())) # The filename of frame #0 should be 'main.cpp' and function is main. - self.expect(lldbutil.GetFilenames(thread)[0], + self.expect(lldbutil.get_filenames(thread)[0], "Break correctly at main.cpp", exe=False, startstr = "main.cpp") - self.expect(lldbutil.GetFunctionNames(thread)[0], + self.expect(lldbutil.get_function_names(thread)[0], "Break correctly at main()", exe=False, startstr = "main") diff --git a/lldb/test/inferior-crashing/TestInferiorCrashing.py b/lldb/test/inferior-crashing/TestInferiorCrashing.py index c5cc46463a1..45b090db99a 100644 --- a/lldb/test/inferior-crashing/TestInferiorCrashing.py +++ b/lldb/test/inferior-crashing/TestInferiorCrashing.py @@ -71,7 +71,7 @@ class CrashingInferiorTestCase(TestBase): self.fail("Fail to stop the thread upon bad access exception") if self.TraceOn(): - lldbutil.PrintStackTrace(thread) + lldbutil.print_stacktrace(thread) if __name__ == '__main__': import atexit diff --git a/lldb/test/lldbutil.py b/lldb/test/lldbutil.py index 4ca1d8aae5e..e78925fd49f 100644 --- a/lldb/test/lldbutil.py +++ b/lldb/test/lldbutil.py @@ -273,6 +273,32 @@ def get_stopped_thread(process, reason): return None return threads[0] +def get_threads_stopped_at_breakpoint (process, bkpt): + """ For a stopped process returns the thread stopped at the breakpoint passed in bkpt""" + stopped_threads = [] + threads = [] + + stopped_threads = get_stopped_threads (process, lldb.eStopReasonBreakpoint) + + if len(stopped_threads) == 0: + return threads + + for thread in stopped_threads: + # Make sure we've hit our breakpoint... + break_id = thread.GetStopReasonDataAtIndex (0) + if break_id == bkpt.GetID(): + threads.append(thread) + + return threads + +def continue_to_breakpoint (process, bkpt): + """ Continues the process, if it stops, returns the threads stopped at bkpt; otherwise, returns None""" + process.Continue() + if process.GetState() != lldb.eStateStopped: + return None + else: + return get_threads_stopped_at_breakpoint (process, bkpt) + def get_caller_symbol(thread): """ Returns the symbol name for the call site of the leaf function. @@ -287,7 +313,7 @@ def get_caller_symbol(thread): return None -def GetFunctionNames(thread): +def get_function_names(thread): """ Returns a sequence of function names from the stack frames of this thread. """ @@ -297,7 +323,7 @@ def GetFunctionNames(thread): return map(GetFuncName, range(thread.GetNumFrames())) -def GetSymbolNames(thread): +def get_symbol_names(thread): """ Returns a sequence of symbols for this thread. """ @@ -307,7 +333,7 @@ def GetSymbolNames(thread): return map(GetSymbol, range(thread.GetNumFrames())) -def GetPCAddresses(thread): +def get_pc_addresses(thread): """ Returns a sequence of pc addresses for this thread. """ @@ -317,7 +343,7 @@ def GetPCAddresses(thread): return map(GetPCAddress, range(thread.GetNumFrames())) -def GetFilenames(thread): +def get_filenames(thread): """ Returns a sequence of file names from the stack frames of this thread. """ @@ -327,7 +353,7 @@ def GetFilenames(thread): return map(GetFilename, range(thread.GetNumFrames())) -def GetLineNumbers(thread): +def get_line_numbers(thread): """ Returns a sequence of line numbers from the stack frames of this thread. """ @@ -337,7 +363,7 @@ def GetLineNumbers(thread): return map(GetLineNumber, range(thread.GetNumFrames())) -def GetModuleNames(thread): +def get_module_names(thread): """ Returns a sequence of module names from the stack frames of this thread. """ @@ -347,7 +373,7 @@ def GetModuleNames(thread): return map(GetModuleName, range(thread.GetNumFrames())) -def GetStackFrames(thread): +def get_stack_frames(thread): """ Returns a sequence of stack frames for this thread. """ @@ -357,7 +383,7 @@ def GetStackFrames(thread): return map(GetStackFrame, range(thread.GetNumFrames())) -def PrintStackTrace(thread, string_buffer = False): +def print_stacktrace(thread, string_buffer = False): """Prints a simple stack trace of this thread.""" output = StringIO.StringIO() if string_buffer else sys.stdout @@ -365,12 +391,12 @@ def PrintStackTrace(thread, string_buffer = False): depth = thread.GetNumFrames() - mods = GetModuleNames(thread) - funcs = GetFunctionNames(thread) - symbols = GetSymbolNames(thread) - files = GetFilenames(thread) - lines = GetLineNumbers(thread) - addrs = GetPCAddresses(thread) + mods = get_module_names(thread) + funcs = get_function_names(thread) + symbols = get_symbol_names(thread) + files = get_filenames(thread) + lines = get_line_numbers(thread) + addrs = get_pc_addresses(thread) if thread.GetStopReason() != lldb.eStopReasonInvalid: desc = "stop reason=" + StopReasonString(thread.GetStopReason()) @@ -396,7 +422,7 @@ def PrintStackTrace(thread, string_buffer = False): return output.getvalue() -def PrintStackTraces(process, string_buffer = False): +def print_stacktraces(process, string_buffer = False): """Prints the stack traces of all the threads.""" output = StringIO.StringIO() if string_buffer else sys.stdout @@ -404,34 +430,7 @@ def PrintStackTraces(process, string_buffer = False): print >> output, "Stack traces for " + repr(process) for i in range(process.GetNumThreads()): - print >> output, PrintStackTrace(process.GetThreadAtIndex(i), string_buffer=True) + print >> output, print_stacktrace(process.GetThreadAtIndex(i), string_buffer=True) if string_buffer: return output.getvalue() - -def GetThreadsStoppedAtBreakpoint (process, bkpt): - """ For a stopped process returns the thread stopped at the breakpoint passed in bkpt""" - stopped_threads = [] - threads = [] - - stopped_threads = get_stopped_threads (process, lldb.eStopReasonBreakpoint) - - if len(stopped_threads) == 0: - return threads - - for thread in stopped_threads: - # Make sure we've hit our breakpoint... - break_id = thread.GetStopReasonDataAtIndex (0) - if break_id == bkpt.GetID(): - threads.append(thread) - - return threads - -def ContinueToBreakpoint (process, bkpt): - """ Continues the process, if it stops, returns the threads stopped at bkpt; otherwise, returns None""" - process.Continue() - if process.GetState() != lldb.eStateStopped: - return None - else: - return GetThreadsStoppedAtBreakpoint (process, bkpt) - diff --git a/lldb/test/python_api/lldbutil/TestPrintStackTraces.py b/lldb/test/python_api/lldbutil/TestPrintStackTraces.py index 4bd4bda8c33..22b8d263f28 100644 --- a/lldb/test/python_api/lldbutil/TestPrintStackTraces.py +++ b/lldb/test/python_api/lldbutil/TestPrintStackTraces.py @@ -47,7 +47,7 @@ class ThreadsStackTracesTestCase(TestBase): lldbutil.StateTypeString(self.process.GetState())) if self.TraceOn(): - lldbutil.PrintStackTraces(self.process) + lldbutil.print_stacktraces(self.process) if __name__ == '__main__': |

