For lldbutil.py, Change a bunch of function names to all lower case formats to be consistent.
And modify the test cases accordingly. llvm-svn: 130174
This commit is contained in:
parent
24ac1599fc
commit
d0fef81e38
|
@ -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")
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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()."
|
||||
|
|
|
@ -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]
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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__':
|
||||
|
|
Loading…
Reference in New Issue