[Lldb-commits] [lldb] r131213 - in /lldb/trunk/test: ./ python_api/lldbutil/ python_api/lldbutil/frame/ python_api/lldbutil/iter/ python_api/lldbutil/process/

Johnny Chen johnny.chen at apple.com
Wed May 11 17:32:42 PDT 2011


Author: johnny
Date: Wed May 11 19:32:41 2011
New Revision: 131213

URL: http://llvm.org/viewvc/llvm-project?rev=131213&view=rev
Log:
Add two utility functions:

    o get_parent_frame(frame)
    o get_args_as_string(frame)

to lldbutil.py and create TestFrameUtils.py to exercise the utils.
Plus re-arrange the test/python_api/lldbutil to have three directories
for testing iteration, process stack traces, and the just added frame utils.

Added:
    lldb/trunk/test/python_api/lldbutil/frame/
    lldb/trunk/test/python_api/lldbutil/frame/Makefile
      - copied, changed from r131194, lldb/trunk/test/python_api/lldbutil/Makefile
    lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py
    lldb/trunk/test/python_api/lldbutil/frame/main.c
    lldb/trunk/test/python_api/lldbutil/iter/
    lldb/trunk/test/python_api/lldbutil/iter/Makefile
      - copied, changed from r131194, lldb/trunk/test/python_api/lldbutil/Makefile
    lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py
      - copied, changed from r131194, lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py
    lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py
      - copied, changed from r131194, lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py
    lldb/trunk/test/python_api/lldbutil/iter/main.cpp
      - copied unchanged from r131194, lldb/trunk/test/python_api/lldbutil/main.cpp
    lldb/trunk/test/python_api/lldbutil/process/
    lldb/trunk/test/python_api/lldbutil/process/Makefile
      - copied, changed from r131194, lldb/trunk/test/python_api/lldbutil/Makefile
    lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py
      - copied, changed from r131194, lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py
    lldb/trunk/test/python_api/lldbutil/process/main.cpp
      - copied unchanged from r131194, lldb/trunk/test/python_api/lldbutil/main.cpp
Removed:
    lldb/trunk/test/python_api/lldbutil/Makefile
    lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py
    lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py
    lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py
    lldb/trunk/test/python_api/lldbutil/main.cpp
Modified:
    lldb/trunk/test/lldbutil.py

Modified: lldb/trunk/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=131213&r1=131212&r2=131213&view=diff
==============================================================================
--- lldb/trunk/test/lldbutil.py (original)
+++ lldb/trunk/test/lldbutil.py Wed May 11 19:32:41 2011
@@ -409,6 +409,37 @@
 # Utility functions related to Frames
 # ===================================
 
+def get_parent_frame(frame):
+    """
+    Returns the parent frame of the input frame object; None if not available.
+    """
+    thread = frame.GetThread()
+    parent_found = False
+    for f in thread:
+        if parent_found:
+            return f
+        if f.GetFrameID() == frame.GetFrameID():
+            parent_found = True
+
+    # If we reach here, no parent has been found, return None.
+    return None
+
+def get_args_as_string(frame):
+    """
+    Returns the args of the input frame object as a string.
+    """
+    # arguments     => True
+    # locals        => False
+    # statics       => False
+    # in_scope_only => True
+    vars = frame.GetVariables(True, False, False, True) # type of SBValueList
+    args = [] # list of strings
+    for var in vars:
+        args.append("(%s)%s=%s" % (var.GetTypeName(),
+                                   var.GetName(),
+                                   var.GetValue(frame)))
+    return "%s(%s)" % (frame.GetFunction().GetName(), ", ".join(args))
+
 def print_registers(frame, string_buffer = False):
     """Prints all the register sets of the frame."""
 

Removed: lldb/trunk/test/python_api/lldbutil/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/Makefile?rev=131212&view=auto
==============================================================================
--- lldb/trunk/test/python_api/lldbutil/Makefile (original)
+++ lldb/trunk/test/python_api/lldbutil/Makefile (removed)
@@ -1,6 +0,0 @@
-LEVEL = ../../make
-
-CXX_SOURCES := main.cpp
-MAKE_DSYM :=NO
-
-include $(LEVEL)/Makefile.rules

Removed: lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py?rev=131212&view=auto
==============================================================================
--- lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py (original)
+++ lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py (removed)
@@ -1,133 +0,0 @@
-"""
-Test the iteration protocol for some lldb container objects.
-"""
-
-import os, time
-import re
-import unittest2
-import lldb
-from lldbtest import *
-
-class LLDBIteratorTestCase(TestBase):
-
-    mydir = "python_api/lldbutil"
-
-    def setUp(self):
-        # Call super's setUp().
-        TestBase.setUp(self)
-        # Find the line numbers to break inside main().
-        self.line1 = line_number('main.cpp', '// Set break point at this line.')
-        self.line2 = line_number('main.cpp', '// And that line.')
-
-    def test_lldb_iter_1(self):
-        """Test module_iter works correctly for SBTarget -> SBModule."""
-        self.buildDefault()
-        self.lldb_iter_1()
-
-    def test_lldb_iter_2(self):
-        """Test breakpoint_iter works correctly for SBTarget -> SBBreakpoint."""
-        self.buildDefault()
-        self.lldb_iter_2()
-
-    def test_lldb_iter_3(self):
-        """Test iterator works correctly for SBProcess->SBThread->SBFrame."""
-        self.buildDefault()
-        self.lldb_iter_3()
-
-    def lldb_iter_1(self):
-        exe = os.path.join(os.getcwd(), "a.out")
-
-        target = self.dbg.CreateTarget(exe)
-        self.assertTrue(target.IsValid(), VALID_TARGET)
-
-        breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line1)
-        self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
-
-        # Now launch the process, and do not stop at entry point.
-        rc = lldb.SBError()
-        self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc)
-
-        if not rc.Success() or not self.process.IsValid():
-            self.fail("SBTarget.LaunchProcess() failed")
-
-        from lldbutil import get_description
-        yours = []
-        for i in range(target.GetNumModules()):
-            yours.append(target.GetModuleAtIndex(i))
-        mine = []
-        for m in target.module_iter():
-            mine.append(m)
-
-        self.assertTrue(len(yours) == len(mine))
-        for i in range(len(yours)):
-            if self.TraceOn():
-                print "yours[%d]='%s'" % (i, get_description(yours[i]))
-                print "mine[%d]='%s'" % (i, get_description(mine[i]))
-            self.assertTrue(yours[i] == mine[i],
-                            "UUID+FileSpec of yours[{0}] and mine[{0}] matches".format(i))
-
-    def lldb_iter_2(self):
-        exe = os.path.join(os.getcwd(), "a.out")
-
-        target = self.dbg.CreateTarget(exe)
-        self.assertTrue(target.IsValid(), VALID_TARGET)
-
-        breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line1)
-        self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
-        breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line2)
-        self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
-
-        self.assertTrue(target.GetNumBreakpoints() == 2)
-
-        from lldbutil import get_description
-        yours = []
-        for i in range(target.GetNumBreakpoints()):
-            yours.append(target.GetBreakpointAtIndex(i))
-        mine = []
-        for m in target.breakpoint_iter():
-            mine.append(m)
-
-        self.assertTrue(len(yours) == len(mine))
-        for i in range(len(yours)):
-            if self.TraceOn():
-                print "yours[%d]='%s'" % (i, get_description(yours[i]))
-                print "mine[%d]='%s'" % (i, get_description(mine[i]))
-            self.assertTrue(yours[i] == mine[i],
-                            "ID of yours[{0}] and mine[{0}] matches".format(i))
-
-    def lldb_iter_3(self):
-        exe = os.path.join(os.getcwd(), "a.out")
-
-        target = self.dbg.CreateTarget(exe)
-        self.assertTrue(target.IsValid(), VALID_TARGET)
-
-        breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line1)
-        self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
-
-        # Now launch the process, and do not stop at entry point.
-        rc = lldb.SBError()
-        self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc)
-
-        if not rc.Success() or not self.process.IsValid():
-            self.fail("SBTarget.LaunchProcess() failed")
-
-        from lldbutil import print_stacktrace
-        stopped_due_to_breakpoint = False
-        for thread in self.process:
-            if self.TraceOn():
-                print_stacktrace(thread)
-            ID = thread.GetThreadID()
-            if thread.GetStopReason() == lldb.eStopReasonBreakpoint:
-                stopped_due_to_breakpoint = True
-            for frame in thread:
-                self.assertTrue(frame.GetThread().GetThreadID() == ID)
-                if self.TraceOn():
-                    print frame
-
-        self.assertTrue(stopped_due_to_breakpoint)
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()

Removed: lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py?rev=131212&view=auto
==============================================================================
--- lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py (original)
+++ lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py (removed)
@@ -1,57 +0,0 @@
-"""
-Test SBprocess and SBThread APIs with printing of the stack traces using lldbutil.
-"""
-
-import os, time
-import re
-import unittest2
-import lldb
-from lldbtest import *
-
-class ThreadsStackTracesTestCase(TestBase):
-
-    mydir = "python_api/lldbutil"
-
-    def setUp(self):
-        # Call super's setUp().
-        TestBase.setUp(self)
-        # Find the line number to break inside main().
-        self.line = line_number('main.cpp', '// Set break point at this line.')
-
-    def test_stack_traces(self):
-        """Test SBprocess and SBThread APIs with printing of the stack traces."""
-        self.buildDefault()
-        self.break_and_print_stacktraces()
-
-    def break_and_print_stacktraces(self):
-        """Break at main.cpp:68 and do a threads dump"""
-        exe = os.path.join(os.getcwd(), "a.out")
-
-        target = self.dbg.CreateTarget(exe)
-        self.assertTrue(target.IsValid(), VALID_TARGET)
-
-        breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)
-        self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
-
-        # Now launch the process, and do not stop at entry point.
-        rc = lldb.SBError()
-        self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc)
-
-        if not rc.Success() or not self.process.IsValid():
-            self.fail("SBTarget.LaunchProcess() failed")
-
-        import lldbutil
-        if self.process.GetState() != lldb.eStateStopped:
-            self.fail("Process should be in the 'stopped' state, "
-                      "instead the actual state is: '%s'" %
-                      lldbutil.state_type_to_str(self.process.GetState()))
-
-        if self.TraceOn():
-            lldbutil.print_stacktraces(self.process)
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()

Removed: lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py?rev=131212&view=auto
==============================================================================
--- lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py (original)
+++ lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py (removed)
@@ -1,72 +0,0 @@
-"""
-Test the iteration protocol for frame registers.
-"""
-
-import os, time
-import re
-import unittest2
-import lldb
-from lldbtest import *
-
-class RegistersIteratorTestCase(TestBase):
-
-    mydir = "python_api/lldbutil"
-
-    def setUp(self):
-        # Call super's setUp().
-        TestBase.setUp(self)
-        # Find the line number to break inside main().
-        self.line1 = line_number('main.cpp', '// Set break point at this line.')
-
-    def test_iter_registers(self):
-        """Test iterator works correctly for lldbutil.iter_registers()."""
-        self.buildDefault()
-        self.iter_registers()
-
-    def iter_registers(self):
-        exe = os.path.join(os.getcwd(), "a.out")
-
-        target = self.dbg.CreateTarget(exe)
-        self.assertTrue(target.IsValid(), VALID_TARGET)
-
-        breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line1)
-        self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
-
-        # Now launch the process, and do not stop at entry point.
-        rc = lldb.SBError()
-        self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc)
-
-        if not rc.Success() or not self.process.IsValid():
-            self.fail("SBTarget.LaunchProcess() failed")
-
-        import lldbutil
-        for thread in self.process:
-            if thread.GetStopReason() == lldb.eStopReasonBreakpoint:
-                for frame in thread:
-                    # Dump the registers of this frame using iter_registers().
-                    if self.TraceOn():
-                        print frame
-
-                    for kind in ["General Purpose Registers",
-                                 "Floating Point Registers",
-                                 "Exception State Registers"]:
-                        REGs = lldbutil.get_registers(frame, kind)
-                        if self.TraceOn():
-                            print "%s:" % kind
-                        for reg in REGs:
-                            self.assertTrue(reg.IsValid())
-                            if self.TraceOn():
-                                print "%s => %s" % (reg.GetName(), reg.GetValue(frame))
-
-                    # And these should also work.
-                    self.assertTrue(lldbutil.get_GPRs(frame))
-                    self.assertTrue(lldbutil.get_FPRs(frame))
-                    self.assertTrue(lldbutil.get_ESRs(frame))
-                    break
-
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()

Copied: lldb/trunk/test/python_api/lldbutil/frame/Makefile (from r131194, lldb/trunk/test/python_api/lldbutil/Makefile)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/frame/Makefile?p2=lldb/trunk/test/python_api/lldbutil/frame/Makefile&p1=lldb/trunk/test/python_api/lldbutil/Makefile&r1=131194&r2=131213&rev=131213&view=diff
==============================================================================
--- lldb/trunk/test/python_api/lldbutil/Makefile (original)
+++ lldb/trunk/test/python_api/lldbutil/frame/Makefile Wed May 11 19:32:41 2011
@@ -1,6 +1,6 @@
-LEVEL = ../../make
+LEVEL = ../../../make
 
-CXX_SOURCES := main.cpp
+C_SOURCES := main.c
 MAKE_DSYM :=NO
 
 include $(LEVEL)/Makefile.rules

Added: lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py?rev=131213&view=auto
==============================================================================
--- lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py (added)
+++ lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py Wed May 11 19:32:41 2011
@@ -0,0 +1,62 @@
+"""
+Test utility functions for the frame object.
+"""
+
+import os
+import unittest2
+import lldb
+from lldbtest import *
+
+class FrameUtilsTestCase(TestBase):
+
+    mydir = "python_api/lldbutil/frame"
+
+    def setUp(self):
+        # Call super's setUp().
+        TestBase.setUp(self)
+        # Find the line number to break inside main().
+        self.line = line_number('main.c',
+                                "// Find the line number here.")
+
+    def test_frame_utils(self):
+        """Test utility functions for the frame object."""
+        self.buildDefault(dictionary={'C_SOURCES': 'main.c'})
+        self.frame_utils()
+
+    def frame_utils(self):
+        exe = os.path.join(os.getcwd(), "a.out")
+
+        target = self.dbg.CreateTarget(exe)
+        self.assertTrue(target.IsValid(), VALID_TARGET)
+
+        breakpoint = target.BreakpointCreateByLocation("main.c", self.line)
+        self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT)
+
+        # Now launch the process, and do not stop at entry point.
+        self.process = target.LaunchSimple(None, None, os.getcwd())
+
+        if not self.process.IsValid():
+            self.fail("SBTarget.LaunchProcess() failed")
+        self.assertTrue(self.process.GetState() == lldb.eStateStopped,
+                        PROCESS_STOPPED)
+
+        import lldbutil
+        thread = lldbutil.get_stopped_thread(self.process, lldb.eStopReasonBreakpoint)
+        frame0 = thread.GetFrameAtIndex(0)
+        frame1 = thread.GetFrameAtIndex(1)
+        parent = lldbutil.get_parent_frame(frame0)
+        self.assertTrue(parent.IsValid() and parent.GetFrameID() == frame1.GetFrameID())
+        frame0_args = lldbutil.get_args_as_string(frame0)
+        parent_args = lldbutil.get_args_as_string(parent)
+        self.assertTrue(frame0_args and parent_args)
+        if self.TraceOn():
+            lldbutil.print_stacktrace(thread)
+            print "Current frame: %s" % frame0_args
+            print "Parent frame: %s" % parent_args
+
+
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()

Added: lldb/trunk/test/python_api/lldbutil/frame/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/frame/main.c?rev=131213&view=auto
==============================================================================
--- lldb/trunk/test/python_api/lldbutil/frame/main.c (added)
+++ lldb/trunk/test/python_api/lldbutil/frame/main.c Wed May 11 19:32:41 2011
@@ -0,0 +1,47 @@
+//===-- main.c --------------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
+int a(int);
+int b(int);
+int c(int);
+
+int a(int val)
+{
+    if (val <= 1)
+        return b(val);
+    else if (val >= 3)
+        return c(val);
+
+    return val;
+}
+
+int b(int val)
+{
+    return c(val);
+}
+
+int c(int val)
+{
+    return val + 3; // Find the line number here.
+}
+
+int main (int argc, char const *argv[])
+{
+    int A1 = a(1);  // a(1) -> b(1) -> c(1)
+    printf("a(1) returns %d\n", A1);
+    
+    int B2 = b(2);  // b(2) -> c(2)
+    printf("b(2) returns %d\n", B2);
+    
+    int A3 = a(3);  // a(3) -> c(3)
+    printf("a(3) returns %d\n", A3);
+    
+    return 0;
+}

Copied: lldb/trunk/test/python_api/lldbutil/iter/Makefile (from r131194, lldb/trunk/test/python_api/lldbutil/Makefile)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/iter/Makefile?p2=lldb/trunk/test/python_api/lldbutil/iter/Makefile&p1=lldb/trunk/test/python_api/lldbutil/Makefile&r1=131194&r2=131213&rev=131213&view=diff
==============================================================================
--- lldb/trunk/test/python_api/lldbutil/Makefile (original)
+++ lldb/trunk/test/python_api/lldbutil/iter/Makefile Wed May 11 19:32:41 2011
@@ -1,4 +1,4 @@
-LEVEL = ../../make
+LEVEL = ../../../make
 
 CXX_SOURCES := main.cpp
 MAKE_DSYM :=NO

Copied: lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py (from r131194, lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py?p2=lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py&p1=lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py&r1=131194&r2=131213&rev=131213&view=diff
==============================================================================
--- lldb/trunk/test/python_api/lldbutil/TestLLDBIterator.py (original)
+++ lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py Wed May 11 19:32:41 2011
@@ -10,7 +10,7 @@
 
 class LLDBIteratorTestCase(TestBase):
 
-    mydir = "python_api/lldbutil"
+    mydir = "python_api/lldbutil/iter"
 
     def setUp(self):
         # Call super's setUp().

Copied: lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py (from r131194, lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py?p2=lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py&p1=lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py&r1=131194&r2=131213&rev=131213&view=diff
==============================================================================
--- lldb/trunk/test/python_api/lldbutil/TestRegistersIterator.py (original)
+++ lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py Wed May 11 19:32:41 2011
@@ -10,7 +10,7 @@
 
 class RegistersIteratorTestCase(TestBase):
 
-    mydir = "python_api/lldbutil"
+    mydir = "python_api/lldbutil/iter"
 
     def setUp(self):
         # Call super's setUp().

Removed: lldb/trunk/test/python_api/lldbutil/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/main.cpp?rev=131212&view=auto
==============================================================================
--- lldb/trunk/test/python_api/lldbutil/main.cpp (original)
+++ lldb/trunk/test/python_api/lldbutil/main.cpp (removed)
@@ -1,128 +0,0 @@
-//===-- main.cpp ------------------------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// C includes
-#include <pthread.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-pthread_t g_thread_1 = NULL;
-pthread_t g_thread_2 = NULL;
-pthread_t g_thread_3 = NULL;
-
-typedef enum {
-    eGet,
-    eAssign,
-    eClearBits
-} MaskAction;
-
-uint32_t mask_access (MaskAction action, uint32_t mask = 0);
-
-uint32_t
-mask_access (MaskAction action, uint32_t mask)
-{
-    static pthread_mutex_t g_mask_mutex = PTHREAD_MUTEX_INITIALIZER;
-    static uint32_t g_mask = 0;
-    ::pthread_mutex_lock (&g_mask_mutex);
-    switch (action)
-    {
-    case eGet:
-        break;
-
-    case eAssign:
-        g_mask |= mask;
-        break;
-
-    case eClearBits:
-        g_mask &= ~mask;
-        break;
-    }
-    uint32_t new_mask = g_mask;
-    ::pthread_mutex_unlock (&g_mask_mutex);
-    return new_mask;
-}
-
-void *
-thread_func (void *arg)
-{
-    uint32_t thread_index = *((uint32_t *)arg);
-    uint32_t thread_mask = (1u << (thread_index));
-    printf ("%s (thread index = %u) startng...\n", __FUNCTION__, thread_index);
-
-    while (mask_access(eGet) & thread_mask)
-    {
-        // random micro second sleep from zero to 3 seconds
-        int usec = ::rand() % 3000000;
-        printf ("%s (thread = %u) doing a usleep (%d)...\n", __FUNCTION__, thread_index, usec);
-        ::usleep (usec);
-        printf ("%s (thread = %u) after usleep ...\n", __FUNCTION__, thread_index); // Set break point at this line.
-    }
-    printf ("%s (thread index = %u) exiting...\n", __FUNCTION__, thread_index);
-    return NULL;
-}
-
-
-int main (int argc, char const *argv[])
-{
-    int err;
-    void *thread_result = NULL;
-    uint32_t thread_index_1 = 1;
-    uint32_t thread_index_2 = 2;
-    uint32_t thread_index_3 = 3;
-    uint32_t thread_mask_1 = (1u << thread_index_1);
-    uint32_t thread_mask_2 = (1u << thread_index_2);
-    uint32_t thread_mask_3 = (1u << thread_index_3);
-
-    // Make a mask that will keep all threads alive
-    mask_access (eAssign, thread_mask_1 | thread_mask_2 | thread_mask_3); // And that line.
-
-    // Create 3 threads
-    err = ::pthread_create (&g_thread_1, NULL, thread_func, &thread_index_1);
-    err = ::pthread_create (&g_thread_2, NULL, thread_func, &thread_index_2);
-    err = ::pthread_create (&g_thread_3, NULL, thread_func, &thread_index_3);
-
-    char line[64];
-    while (mask_access(eGet) != 0)
-    {
-        printf ("Enter thread index to kill or ENTER for all:\n");
-        fflush (stdout);
-        // Kill threads by index, or ENTER for all threads
-
-        if (fgets (line, sizeof(line), stdin))
-        {
-            if (line[0] == '\n' || line[0] == '\r' || line[0] == '\0')
-            {
-                printf ("Exiting all threads...\n");
-                break;
-            }
-            int32_t index = strtoul (line, NULL, 0);
-            switch (index)
-            {
-                case 1: mask_access (eClearBits, thread_mask_1); break;
-                case 2: mask_access (eClearBits, thread_mask_2); break;
-                case 3: mask_access (eClearBits, thread_mask_3); break;
-            }
-            continue;
-        }
-
-        break;
-    }
-
-    // Clear all thread bits to they all exit
-    mask_access (eClearBits, UINT32_MAX);
-
-    // Join all of our threads
-    err = ::pthread_join (g_thread_1, &thread_result);
-    err = ::pthread_join (g_thread_2, &thread_result);
-    err = ::pthread_join (g_thread_3, &thread_result);
-
-    return 0;
-}

Copied: lldb/trunk/test/python_api/lldbutil/process/Makefile (from r131194, lldb/trunk/test/python_api/lldbutil/Makefile)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/process/Makefile?p2=lldb/trunk/test/python_api/lldbutil/process/Makefile&p1=lldb/trunk/test/python_api/lldbutil/Makefile&r1=131194&r2=131213&rev=131213&view=diff
==============================================================================
--- lldb/trunk/test/python_api/lldbutil/Makefile (original)
+++ lldb/trunk/test/python_api/lldbutil/process/Makefile Wed May 11 19:32:41 2011
@@ -1,4 +1,4 @@
-LEVEL = ../../make
+LEVEL = ../../../make
 
 CXX_SOURCES := main.cpp
 MAKE_DSYM :=NO

Copied: lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py (from r131194, lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py?p2=lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py&p1=lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py&r1=131194&r2=131213&rev=131213&view=diff
==============================================================================
--- lldb/trunk/test/python_api/lldbutil/TestPrintStackTraces.py (original)
+++ lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py Wed May 11 19:32:41 2011
@@ -10,7 +10,7 @@
 
 class ThreadsStackTracesTestCase(TestBase):
 
-    mydir = "python_api/lldbutil"
+    mydir = "python_api/lldbutil/process"
 
     def setUp(self):
         # Call super's setUp().





More information about the lldb-commits mailing list