From d369908dace1e5e9e2ab66bd500f1ecb6f2d98f9 Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Mon, 25 Apr 2011 22:04:05 +0000 Subject: [PATCH] Move two functions around. llvm-svn: 130158 --- lldb/test/lldbutil.py | 76 ++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 40 deletions(-) diff --git a/lldb/test/lldbutil.py b/lldb/test/lldbutil.py index 89c9d8f3bc8d..4ca1d8aae5ed 100644 --- a/lldb/test/lldbutil.py +++ b/lldb/test/lldbutil.py @@ -128,46 +128,6 @@ def bytearray_to_int(bytes, bytesize): return unpacked[0] -# =========================================================== -# Returns the list of stopped thread(s) given an lldb process -# =========================================================== - -def get_stopped_threads(process, reason): - """Returns the thread(s) with the specified stop reason in a list.""" - threads = [] - for t in lldb_iter(process, 'GetNumThreads', 'GetThreadAtIndex'): - if t.GetStopReason() == reason: - threads.append(t) - return threads - -def get_stopped_thread(process, reason): - """A convenience function which returns the first thread with the given stop - reason or None. - - Example usages: - - 1. Get the stopped thread due to a breakpoint condition - - ... - from lldbutil import get_stopped_thread - thread = get_stopped_thread(self.process, lldb.eStopReasonPlanComplete) - self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") - ... - - 2. Get the thread stopped due to a breakpoint - - ... - 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") - ... - - """ - threads = get_stopped_threads(process, reason) - if len(threads) == 0: - return None - return threads[0] - # ============================================================== # Get the description of an lldb object or None if not available # ============================================================== @@ -277,6 +237,42 @@ def ValueTypeString(enum): # Utility functions related to Threads and Processes # ================================================== +def get_stopped_threads(process, reason): + """Returns the thread(s) with the specified stop reason in a list.""" + threads = [] + for t in lldb_iter(process, 'GetNumThreads', 'GetThreadAtIndex'): + if t.GetStopReason() == reason: + threads.append(t) + return threads + +def get_stopped_thread(process, reason): + """A convenience function which returns the first thread with the given stop + reason or None. + + Example usages: + + 1. Get the stopped thread due to a breakpoint condition + + ... + from lldbutil import get_stopped_thread + thread = get_stopped_thread(self.process, lldb.eStopReasonPlanComplete) + self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") + ... + + 2. Get the thread stopped due to a breakpoint + + ... + 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") + ... + + """ + threads = get_stopped_threads(process, reason) + if len(threads) == 0: + return None + return threads[0] + def get_caller_symbol(thread): """ Returns the symbol name for the call site of the leaf function.