[Lldb-commits] [lldb] r130174 - in /lldb/trunk/test: breakpoint_ignore_count/TestBreakpointIgnoreCount.py class_types/TestClassTypes.py conditional_break/TestConditionalBreak.py conditional_break/conditional_break.py cpp/dynamic-value/TestDynamicValue.py expression_command/test/TestExprs.py inferior-crashing/TestInferiorCrashing.py lldbutil.py python_api/lldbutil/TestPrintStackTraces.py

Johnny Chen johnny.chen at apple.com
Mon Apr 25 16:38:13 PDT 2011


Author: johnny
Date: Mon Apr 25 18:38:13 2011
New Revision: 130174

URL: http://llvm.org/viewvc/llvm-project?rev=130174&view=rev
Log:
For lldbutil.py, Change a bunch of function names to all lower case formats to be consistent.
And modify the test cases accordingly.

Modified:
    lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py
    lldb/trunk/test/class_types/TestClassTypes.py
    lldb/trunk/test/conditional_break/TestConditionalBreak.py
    lldb/trunk/test/conditional_break/conditional_break.py
    lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py
    lldb/trunk/test/expression_command/test/TestExprs.py
    lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py
    lldb/trunk/test/lldbutil.py
    lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py

Modified: lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py?rev=130174&r1=130173&r2=130174&view=diff
==============================================================================
--- lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py (original)
+++ lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py Mon Apr 25 18:38:13 2011
@@ -108,7 +108,7 @@
 
         # 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")

Modified: lldb/trunk/test/class_types/TestClassTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=130174&r1=130173&r2=130174&view=diff
==============================================================================
--- lldb/trunk/test/class_types/TestClassTypes.py (original)
+++ lldb/trunk/test/class_types/TestClassTypes.py Mon Apr 25 18:38:13 2011
@@ -140,8 +140,8 @@
 
         # 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?

Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/TestConditionalBreak.py?rev=130174&r1=130173&r2=130174&view=diff
==============================================================================
--- lldb/trunk/test/conditional_break/TestConditionalBreak.py (original)
+++ lldb/trunk/test/conditional_break/TestConditionalBreak.py Mon Apr 25 18:38:13 2011
@@ -79,7 +79,7 @@
                 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.

Modified: lldb/trunk/test/conditional_break/conditional_break.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/conditional_break.py?rev=130174&r1=130173&r2=130174&view=diff
==============================================================================
--- lldb/trunk/test/conditional_break/conditional_break.py (original)
+++ lldb/trunk/test/conditional_break/conditional_break.py Mon Apr 25 18:38:13 2011
@@ -19,9 +19,9 @@
     # 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()."

Modified: lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py?rev=130174&r1=130173&r2=130174&view=diff
==============================================================================
--- lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py (original)
+++ lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py Mon Apr 25 18:38:13 2011
@@ -119,7 +119,7 @@
         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 @@
 
         # 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 @@
 
         # 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 @@
         # 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]
 

Modified: lldb/trunk/test/expression_command/test/TestExprs.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/test/TestExprs.py?rev=130174&r1=130173&r2=130174&view=diff
==============================================================================
--- lldb/trunk/test/expression_command/test/TestExprs.py (original)
+++ lldb/trunk/test/expression_command/test/TestExprs.py Mon Apr 25 18:38:13 2011
@@ -119,10 +119,10 @@
                       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")
 

Modified: lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py?rev=130174&r1=130173&r2=130174&view=diff
==============================================================================
--- lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py (original)
+++ lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py Mon Apr 25 18:38:13 2011
@@ -71,7 +71,7 @@
             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

Modified: lldb/trunk/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=130174&r1=130173&r2=130174&view=diff
==============================================================================
--- lldb/trunk/test/lldbutil.py (original)
+++ lldb/trunk/test/lldbutil.py Mon Apr 25 18:38:13 2011
@@ -273,6 +273,32 @@
         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 @@
         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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
 
     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 @@
         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 @@
     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)
-

Modified: lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py?rev=130174&r1=130173&r2=130174&view=diff
==============================================================================
--- lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py (original)
+++ lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py Mon Apr 25 18:38:13 2011
@@ -47,7 +47,7 @@
                       lldbutil.StateTypeString(self.process.GetState()))
 
         if self.TraceOn():
-            lldbutil.PrintStackTraces(self.process)
+            lldbutil.print_stacktraces(self.process)
 
 
 if __name__ == '__main__':





More information about the lldb-commits mailing list