[Lldb-commits] [lldb] r115902 - in /lldb/trunk: examples/python/ include/lldb/ include/lldb/API/ scripts/ scripts/Python/ source/API/ source/Commands/ source/Plugins/Process/MacOSX-User/source/ source/Plugins/Process/gdb-remote/ source/Target/

Greg Clayton gclayton at apple.com
Wed Oct 6 21:19:01 PDT 2010


Author: gclayton
Date: Wed Oct  6 23:19:01 2010
New Revision: 115902

URL: http://llvm.org/viewvc/llvm-project?rev=115902&view=rev
Log:
Cleaned up the SWIG stuff so all includes happen as they should, no pulling
tricks to get types to resolve. I did this by correctly including the correct
files: stdint.h and all lldb-*.h files first before including the API files.
This allowed me to remove all of the hacks that were in the lldb.swig file
and it also allows all of the #defines in lldb-defines.h and enumerations
in lldb-enumerations.h to appear in the lldb.py module. This will make the
python script code a lot more readable.

Cleaned up the "process launch" command to not execute a "process continue"
command, it now just does what it should have with the internal API calls
instead of executing another command line command.

Made the lldb_private::Process set the state to launching and attaching if
WillLaunch/WillAttach return no error respectively.


Modified:
    lldb/trunk/examples/python/disasm.py
    lldb/trunk/include/lldb/API/SBBreakpoint.h
    lldb/trunk/include/lldb/API/SBCommandInterpreter.h
    lldb/trunk/include/lldb/API/SBTarget.h
    lldb/trunk/include/lldb/lldb-defines.h
    lldb/trunk/scripts/Python/build-swig-Python.sh
    lldb/trunk/scripts/Python/python-extensions.swig
    lldb/trunk/scripts/lldb.swig
    lldb/trunk/source/API/SBBreakpoint.cpp
    lldb/trunk/source/API/SBFrame.cpp
    lldb/trunk/source/API/SBFunction.cpp
    lldb/trunk/source/API/SBProcess.cpp
    lldb/trunk/source/API/SBTarget.cpp
    lldb/trunk/source/API/SBThread.cpp
    lldb/trunk/source/Commands/CommandObjectProcess.cpp
    lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/examples/python/disasm.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/disasm.py?rev=115902&r1=115901&r2=115902&view=diff
==============================================================================
--- lldb/trunk/examples/python/disasm.py (original)
+++ lldb/trunk/examples/python/disasm.py Wed Oct  6 23:19:01 2010
@@ -28,52 +28,65 @@
 debugger.SetAsync (False)
 
 # Create a target from a file and arch
-target = debugger.CreateTargetWithFileAndArch (sys.argv[1], "x86_64")
+print "Creating a target for '%s'" % sys.argv[1]
+
+target = debugger.CreateTargetWithFileAndArch (sys.argv[1], lldb.LLDB_ARCH_DEFAULT)
 
 if target.IsValid():
     # If the target is valid set a breakpoint at main
     main_bp = target.BreakpointCreateByName ("main", sys.argv[1]);
-    
+
+    print main_bp
+
     # Launch the process. Since we specified synchronous mode, we won't return
     # from this function until we hit the breakpoint at main
-    process = target.LaunchProcess (sys.argv[2:], [''], "/dev/stdout", 0, False)
+    process = target.LaunchProcess ([''], [''], "/dev/stdout", 0, False)
     
     # Make sure the launch went ok
     if process.IsValid():
         # Print some simple process info
-        print "process:", process, "\n"
-        # Get the first thread
-        thread = process.GetThreadAtIndex (0)
-        if thread.IsValid():
-            # Print some simple thread info
-            print "thread: ", thread
-            # Get the first frame
-            frame = thread.GetFrameAtIndex (0)
-            if frame.IsValid():
-                # Print some simple frame info
-                print "frame: ", frame
-                function = frame.GetFunction()
-                # See if we have debug info (a function)
-                if function.IsValid():
-                    # We do have a function, print some info for the function
-                    print "function: ", function, "\n"
-                    # Now get all instructions for this function and print them
-                    insts = function.GetInstructions(target)
-                    disassemble_instructions (insts)
-                else:
-                    # See if we have a symbol in the symbol table for where we stopped
-                    symbol = frame.GetSymbol();
-                    if symbol.IsValid():
-                        # We do have a symbol, print some info for the symbol
-                        print "symbol: ", symbol, "\n"
-                        # Now get all instructions for this symbol and print them
-                        insts = symbol.GetInstructions(target)
+        state = process.GetState ()
+        print process
+        if state == lldb.eStateStopped:
+            # Get the first thread
+            thread = process.GetThreadAtIndex (0)
+            if thread.IsValid():
+                # Print some simple thread info
+                print thread
+                # Get the first frame
+                frame = thread.GetFrameAtIndex (0)
+                if frame.IsValid():
+                    # Print some simple frame info
+                    print frame
+                    function = frame.GetFunction()
+                    # See if we have debug info (a function)
+                    if function.IsValid():
+                        # We do have a function, print some info for the function
+                        print function
+                        # Now get all instructions for this function and print them
+                        insts = function.GetInstructions(target)
                         disassemble_instructions (insts)
-        # Now continue to the program exit
-        process.Continue()
-        # When we return from the above function we will hopefully be at the
-        # program exit. Print out some process info
-        print "process:", process, "\n"
+                    else:
+                        # See if we have a symbol in the symbol table for where we stopped
+                        symbol = frame.GetSymbol();
+                        if symbol.IsValid():
+                            # We do have a symbol, print some info for the symbol
+                            print symbol
+                            # Now get all instructions for this symbol and print them
+                            insts = symbol.GetInstructions(target)
+                            disassemble_instructions (insts)
+            print "Hit the breakpoint at main, continue and wait for program to exit..."
+            # Now continue to the program exit
+            process.Continue()
+            # When we return from the above function we will hopefully be at the
+            # program exit. Print out some process info
+            print process
+        elif state == lldb.eStateExited:
+            print "Didn't hit the breakpoint at main, program has exited..."
+        else:
+            print "Unexpected process state: %s, killing process..." % debugger.StateAsCString (state)
+            process.Kill()
+
         
 
 lldb.SBDebugger.Terminate()

Modified: lldb/trunk/include/lldb/API/SBBreakpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpoint.h?rev=115902&r1=115901&r2=115902&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBBreakpoint.h (original)
+++ lldb/trunk/include/lldb/API/SBBreakpoint.h Wed Oct  6 23:19:01 2010
@@ -105,7 +105,7 @@
     GetNumLocations() const;
 
     bool
-    GetDescription (const char *description_level, lldb::SBStream &description);
+    GetDescription (lldb::SBStream &description);
 
     static lldb::BreakpointEventType
     GetBreakpointEventTypeFromEvent (const lldb::SBEvent& event);

Modified: lldb/trunk/include/lldb/API/SBCommandInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandInterpreter.h?rev=115902&r1=115901&r2=115902&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBCommandInterpreter.h (original)
+++ lldb/trunk/include/lldb/API/SBCommandInterpreter.h Wed Oct  6 23:19:01 2010
@@ -72,7 +72,7 @@
                       const char *last_char,
                       int match_start_point,
                       int max_return_elements,
-                      SBStringList &matches);
+                      lldb::SBStringList &matches);
 
 protected:
 

Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=115902&r1=115901&r2=115902&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Wed Oct  6 23:19:01 2010
@@ -57,29 +57,29 @@
 
     // DEPRECATED in favor of the function below that contains an SBError as the
     // last parameter.
-//     lldb::SBProcess
-//     LaunchProcess (char const **argv,
-//                    char const **envp,
-//                    const char *tty,
-//                    uint32_t launch_flags,   // See lldb::LaunchFlags
-//                    bool stop_at_entry);
-
     lldb::SBProcess
     LaunchProcess (char const **argv,
                    char const **envp,
                    const char *tty,
-                   uint32_t launch_flags,   // See lldb::LaunchFlags
-                   bool stop_at_entry,
-                   SBError& error);
+                   uint32_t launch_flags,   // See LaunchFlags
+                   bool stop_at_entry);
 
     lldb::SBProcess
-    AttachToProcess (lldb::pid_t pid, // The process ID to attach to
-                     SBError& error); // An error explaining what went wrong if attach fails
+    Launch (char const **argv,
+            char const **envp,
+            const char *tty,
+            uint32_t launch_flags,   // See LaunchFlags
+            bool stop_at_entry,
+            lldb::SBError& error);
+    
+    lldb::SBProcess
+    AttachToProcessWithID (lldb::pid_t pid, // The process ID to attach to
+                           lldb::SBError& error); // An error explaining what went wrong if attach fails
 
     lldb::SBProcess
-    AttachToProcess (const char *name,  // basename of process to attach to
-                     bool wait_for,     // if true wait for a new instance of "name" to be launched
-                     SBError& error);   // An error explaining what went wrong if attach fails
+    AttachToProcessWithName (const char *name,  // basename of process to attach to
+                             bool wait_for,     // if true wait for a new instance of "name" to be launched
+                             lldb::SBError& error);   // An error explaining what went wrong if attach fails
 
     lldb::SBFileSpec
     GetExecutable ();

Modified: lldb/trunk/include/lldb/lldb-defines.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-defines.h?rev=115902&r1=115901&r2=115902&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-defines.h (original)
+++ lldb/trunk/include/lldb/lldb-defines.h Wed Oct  6 23:19:01 2010
@@ -23,12 +23,12 @@
 //----------------------------------------------------------------------
 // lldb defines
 //----------------------------------------------------------------------
-#define LLDB_GENERIC_ERROR              ((uint32_t)UINT32_MAX)
+#define LLDB_GENERIC_ERROR              UINT32_MAX
 
 //----------------------------------------------------------------------
 // Breakpoints
 //----------------------------------------------------------------------
-#define LLDB_INVALID_BREAK_ID           ((lldb::break_id_t)0)
+#define LLDB_INVALID_BREAK_ID           0
 #define LLDB_DEFAULT_BREAK_SIZE         0
 #define LLDB_BREAK_ID_IS_VALID(bid)     ((bid) != (LLDB_INVALID_BREAK_ID))
 #define LLDB_BREAK_ID_IS_INTERNAL(bid)  ((bid) < 0)
@@ -36,7 +36,7 @@
 //----------------------------------------------------------------------
 // Watchpoints
 //----------------------------------------------------------------------
-#define LLDB_INVALID_WATCH_ID           ((lldb::user_id_t)0)
+#define LLDB_INVALID_WATCH_ID           0
 #define LLDB_WATCH_ID_IS_VALID(uid)     ((uid) != (LLDB_INVALID_WATCH_ID))
 #define LLDB_WATCH_TYPE_READ            (1u << 0)
 #define LLDB_WATCH_TYPE_WRITE           (1u << 1)
@@ -53,14 +53,14 @@
 //----------------------------------------------------------------------
 /// Invalid value definitions
 //----------------------------------------------------------------------
-#define LLDB_INVALID_ADDRESS            (~((lldb::addr_t)0))
-#define LLDB_INVALID_INDEX32            ((uint32_t)UINT32_MAX)
-#define LLDB_INVALID_REGNUM             ((uint32_t)UINT32_MAX)
-#define LLDB_INVALID_UID                ((lldb::user_id_t)UINT32_MAX)
-#define LLDB_INVALID_PROCESS_ID         ((lldb::pid_t)0)
-#define LLDB_INVALID_THREAD_ID          ((lldb::tid_t)0)
-#define LLDB_INVALID_FRAME_ID           ((uint32_t) UINT32_MAX)
-#define LLDB_INVALID_SIGNAL_NUMBER      ((int32_t) INT32_MAX)
+#define LLDB_INVALID_ADDRESS            UINT64_MAX
+#define LLDB_INVALID_INDEX32            UINT32_MAX
+#define LLDB_INVALID_REGNUM             UINT32_MAX
+#define LLDB_INVALID_UID                UINT32_MAX
+#define LLDB_INVALID_PROCESS_ID         0
+#define LLDB_INVALID_THREAD_ID          0
+#define LLDB_INVALID_FRAME_ID           UINT32_MAX
+#define LLDB_INVALID_SIGNAL_NUMBER      INT32_MAX
 
 //----------------------------------------------------------------------
 /// CPU Type defintions

Modified: lldb/trunk/scripts/Python/build-swig-Python.sh
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/build-swig-Python.sh?rev=115902&r1=115901&r2=115902&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/build-swig-Python.sh (original)
+++ lldb/trunk/scripts/Python/build-swig-Python.sh Wed Oct  6 23:19:01 2010
@@ -29,7 +29,7 @@
 fi
 
 
-HEADER_FILES="${SRC_ROOT}/include/lldb/lldb-types.h"\
+HEADER_FILES="${SRC_ROOT}/include/lldb/lldb-include.h"\
 " ${SRC_ROOT}/include/lldb/API/SBAddress.h"\
 " ${SRC_ROOT}/include/lldb/API/SBBlock.h"\
 " ${SRC_ROOT}/include/lldb/API/SBBreakpoint.h"\
@@ -37,6 +37,7 @@
 " ${SRC_ROOT}/include/lldb/API/SBBroadcaster.h"\
 " ${SRC_ROOT}/include/lldb/API/SBCommandInterpreter.h"\
 " ${SRC_ROOT}/include/lldb/API/SBCommandReturnObject.h"\
+" ${SRC_ROOT}/include/lldb/API/SBCommunication.h"\
 " ${SRC_ROOT}/include/lldb/API/SBCompileUnit.h"\
 " ${SRC_ROOT}/include/lldb/API/SBDebugger.h"\
 " ${SRC_ROOT}/include/lldb/API/SBError.h"\
@@ -44,6 +45,8 @@
 " ${SRC_ROOT}/include/lldb/API/SBFileSpec.h"\
 " ${SRC_ROOT}/include/lldb/API/SBFrame.h"\
 " ${SRC_ROOT}/include/lldb/API/SBFunction.h"\
+" ${SRC_ROOT}/include/lldb/API/SBHostOS.h"\
+" ${SRC_ROOT}/include/lldb/API/SBInputReader.h"\
 " ${SRC_ROOT}/include/lldb/API/SBInstruction.h"\
 " ${SRC_ROOT}/include/lldb/API/SBInstructionList.h"\
 " ${SRC_ROOT}/include/lldb/API/SBLineEntry.h"\
@@ -55,6 +58,7 @@
 " ${SRC_ROOT}/include/lldb/API/SBStringList.h"\
 " ${SRC_ROOT}/include/lldb/API/SBSymbol.h"\
 " ${SRC_ROOT}/include/lldb/API/SBSymbolContext.h"\
+" ${SRC_ROOT}/include/lldb/API/SBSymbolContextList.h"\
 " ${SRC_ROOT}/include/lldb/API/SBTarget.h"\
 " ${SRC_ROOT}/include/lldb/API/SBThread.h"\
 " ${SRC_ROOT}/include/lldb/API/SBType.h"\
@@ -143,7 +147,7 @@
 
 # Build the SWIG C++ wrapper file for Python.
 
-swig -c++ -shadow -python -I"${SRC_ROOT}/include" -I./. -outdir "${CONFIG_BUILD_DIR}" -o "${swig_output_file}" "${swig_input_file}"
+swig -c++ -shadow -python -I"/usr/include" -I"${SRC_ROOT}/include" -I./. -outdir "${CONFIG_BUILD_DIR}" -o "${swig_output_file}" "${swig_input_file}"
 
 # Append global variable to lldb Python module.
 

Modified: lldb/trunk/scripts/Python/python-extensions.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-extensions.swig?rev=115902&r1=115901&r2=115902&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/python-extensions.swig (original)
+++ lldb/trunk/scripts/Python/python-extensions.swig Wed Oct  6 23:19:01 2010
@@ -16,7 +16,7 @@
 %extend lldb::SBBreakpoint {
         PyObject *lldb::SBBreakpoint::__repr__ (){
                 lldb::SBStream description;
-                $self->GetDescription ("full", description);
+                $self->GetDescription (description);
                 return PyString_FromString (description.GetData());
         }
 }

Modified: lldb/trunk/scripts/lldb.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=115902&r1=115901&r2=115902&view=diff
==============================================================================
--- lldb/trunk/scripts/lldb.swig (original)
+++ lldb/trunk/scripts/lldb.swig Wed Oct  6 23:19:01 2010
@@ -13,17 +13,6 @@
 
 %module lldb
 
-%typemap(in) lldb::ReturnStatus {
-  $1 = (int) $input;
-}
-
-%typemap(freearg) lldb::ReturnStatus {
-}
-
-%typemap(out) lldb::ReturnStatus {
-  $result = SWIG_From_unsigned_SS_int(static_cast< unsigned int >($1));
-}
-
 /* Typemap definitions, to allow SWIG to properly handle 'char**' data types. */
 
 %typemap(in) char ** {
@@ -70,7 +59,7 @@
 /* The liblldb header files to be included. */
 
 %{
-#include "lldb/lldb-types.h"
+#include "lldb/lldb-include.h"
 #include "lldb/API/SBAddress.h"
 #include "lldb/API/SBBlock.h"
 #include "lldb/API/SBBreakpoint.h"
@@ -78,6 +67,7 @@
 #include "lldb/API/SBBroadcaster.h"
 #include "lldb/API/SBCommandInterpreter.h"
 #include "lldb/API/SBCommandReturnObject.h"
+#include "lldb/API/SBCommunication.h"
 #include "lldb/API/SBCompileUnit.h"
 #include "lldb/API/SBDebugger.h"
 #include "lldb/API/SBError.h"
@@ -85,6 +75,8 @@
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBFrame.h"
 #include "lldb/API/SBFunction.h"
+#include "lldb/API/SBHostOS.h"
+#include "lldb/API/SBInputReader.h"
 #include "lldb/API/SBInstruction.h"
 #include "lldb/API/SBInstructionList.h"
 #include "lldb/API/SBLineEntry.h"
@@ -96,6 +88,7 @@
 #include "lldb/API/SBStringList.h"
 #include "lldb/API/SBSymbol.h"
 #include "lldb/API/SBSymbolContext.h"
+#include "lldb/API/SBSymbolContextList.h"
 #include "lldb/API/SBTarget.h"
 #include "lldb/API/SBThread.h"
 #include "lldb/API/SBType.h"
@@ -109,35 +102,15 @@
 #include "lldb/Target/StackFrame.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
-#include "lldb/lldb-forward-rtti.h"
-using namespace lldb_private;
 %}
 
 /* Various liblldb typedefs that SWIG needs to know about.  */
-
-%{
-typedef unsigned int uint32_t;
-typedef int int32_t;
-typedef uint32_t tid_t;
-typedef uint64_t addr_t;
-typedef int32_t break_id_t;
-typedef lldb::SBStringList SBStringList;
-typedef lldb::RegisterKind RegisterKind;
-const RegisterKind kNumRegisterKinds = lldb::kNumRegisterKinds ;
-%}
-
-typedef unsigned int uint32_t;
-typedef int int32_t;
-typedef uint32_t tid_t;
-typedef uint64_t addr_t;
-typedef int32_t break_id_t;
-typedef lldb::SBStringList SBStringList;
-typedef lldb::RegisterKind RegisterKind;
-const RegisterKind kNumRegisterKinds = lldb::kNumRegisterKinds ;
-typedef int StateType;
-typedef int StopReason;
-
-
+%include <stdint.h>
+%include "lldb/lldb-defines.h"
+%include "lldb/lldb-enumerations.h"
+%include "lldb/lldb-forward.h"
+%include "lldb/lldb-forward-rtti.h"
+%include "lldb/lldb-types.h"
 %include "lldb/API/SBAddress.h"
 %include "lldb/API/SBBlock.h"
 %include "lldb/API/SBBreakpoint.h"
@@ -145,6 +118,7 @@
 %include "lldb/API/SBBroadcaster.h"
 %include "lldb/API/SBCommandInterpreter.h"
 %include "lldb/API/SBCommandReturnObject.h"
+%include "lldb/API/SBCommunication.h"
 %include "lldb/API/SBCompileUnit.h"
 %include "lldb/API/SBDebugger.h"
 %include "lldb/API/SBError.h"
@@ -152,6 +126,8 @@
 %include "lldb/API/SBFileSpec.h"
 %include "lldb/API/SBFrame.h"
 %include "lldb/API/SBFunction.h"
+%include "lldb/API/SBHostOS.h"
+%include "lldb/API/SBInputReader.h"
 %include "lldb/API/SBInstruction.h"
 %include "lldb/API/SBInstructionList.h"
 %include "lldb/API/SBLineEntry.h"
@@ -163,12 +139,12 @@
 %include "lldb/API/SBStringList.h"
 %include "lldb/API/SBSymbol.h"
 %include "lldb/API/SBSymbolContext.h"
+%include "lldb/API/SBSymbolContextList.h"
 %include "lldb/API/SBTarget.h"
 %include "lldb/API/SBThread.h"
 %include "lldb/API/SBType.h"
 %include "lldb/API/SBValue.h"
 %include "lldb/API/SBValueList.h"
-%include "lldb/lldb-types.h"
 
 %include "./Python/python-extensions.swig"
 
@@ -177,21 +153,24 @@
 
 
 bool
-ScriptInterpreterPython::BreakpointCallbackFunction (void *baton,
-                                                     StoppointCallbackContext *context,
-                                                     lldb::user_id_t break_id,
-                                                     lldb::user_id_t break_loc_id)
+lldb_private::ScriptInterpreterPython::BreakpointCallbackFunction 
+(
+    void *baton,
+    lldb_private::StoppointCallbackContext *context,
+    lldb::user_id_t break_id,
+    lldb::user_id_t break_loc_id
+)
 {
     bool ret_value = true;
     
-    BreakpointOptions::CommandData *bp_option_data = (BreakpointOptions::CommandData *) baton;
+    lldb_private::BreakpointOptions::CommandData *bp_option_data = (lldb_private::BreakpointOptions::CommandData *) baton;
     const char *python_function_name = bp_option_data->script_source.GetStringAtIndex (0);
     
     if (python_function_name != NULL 
         && python_function_name[0] != '\0')
     {
-        Thread *thread = context->exe_ctx.thread;
-        Target *target = context->exe_ctx.target;
+        lldb_private::Thread *thread = context->exe_ctx.thread;
+        lldb_private::Target *target = context->exe_ctx.target;
         const lldb::StackFrameSP stop_frame_sp = thread->GetStackFrameSPForStackFramePtr (context->exe_ctx.frame);
         lldb::BreakpointSP breakpoint_sp = target->GetBreakpointByID (break_id);
         const lldb::BreakpointLocationSP bp_loc_sp = breakpoint_sp->FindLocationByID (break_loc_id);

Modified: lldb/trunk/source/API/SBBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=115902&r1=115901&r2=115902&view=diff
==============================================================================
--- lldb/trunk/source/API/SBBreakpoint.cpp (original)
+++ lldb/trunk/source/API/SBBreakpoint.cpp Wed Oct  6 23:19:01 2010
@@ -323,28 +323,19 @@
 }
 
 bool
-SBBreakpoint::GetDescription (const char *description_level, SBStream &description)
+SBBreakpoint::GetDescription (SBStream &s)
 {
     if (m_opaque_sp)
     {
-        DescriptionLevel level;
-        if (strcmp (description_level, "brief") == 0)
-            level = eDescriptionLevelBrief;
-        else if (strcmp (description_level, "full") == 0)
-            level = eDescriptionLevelFull;
-        else if (strcmp (description_level, "verbose") == 0)
-            level = eDescriptionLevelVerbose;
-        else
-            level = eDescriptionLevelBrief;
-
-        description.ref();
-        m_opaque_sp->GetDescription (description.get(), level);
-        description.get()->EOL();
+        s.Printf("SBBreakpoint: id = %i, ", m_opaque_sp->GetID());
+        m_opaque_sp->GetResolverDescription (s.get());
+        m_opaque_sp->GetFilterDescription (s.get());
+        const size_t num_locations = m_opaque_sp->GetNumLocations ();
+        s.Printf(", locations = %zu", num_locations);
+        return true;
     }
-    else
-        description.Printf ("No value");
-
-    return true;
+    s.Printf ("No value");
+    return false;
 }
 
 bool

Modified: lldb/trunk/source/API/SBFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=115902&r1=115901&r2=115902&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFrame.cpp (original)
+++ lldb/trunk/source/API/SBFrame.cpp Wed Oct  6 23:19:01 2010
@@ -402,8 +402,7 @@
 {
     if (m_opaque_sp)
     {
-        description.ref();
-        m_opaque_sp->DumpUsingSettingsFormat (description.get());
+        description.Printf("SBFrame: idx = %u", m_opaque_sp->GetFrameIndex());
     }
     else
         description.Printf ("No value");

Modified: lldb/trunk/source/API/SBFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFunction.cpp?rev=115902&r1=115901&r2=115902&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFunction.cpp (original)
+++ lldb/trunk/source/API/SBFunction.cpp Wed Oct  6 23:19:01 2010
@@ -14,6 +14,7 @@
 #include "lldb/Core/Module.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/Type.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Target.h"
 
@@ -70,17 +71,20 @@
 }
 
 bool
-SBFunction::GetDescription (SBStream &description)
+SBFunction::GetDescription (SBStream &s)
 {
     if (m_opaque_ptr)
     {
-        description.ref();
-        m_opaque_ptr->Dump (description.get(), false);
+        s.Printf ("SBFunction: id = 0x%8.8x, name = %s", 
+                            m_opaque_ptr->GetID(),
+                            m_opaque_ptr->GetName().AsCString());
+        Type *func_type = m_opaque_ptr->GetType();
+        if (func_type)
+            s.Printf(", type = %s", func_type->GetName().AsCString());
+        return true;
     }
-    else
-        description.Printf ("No value");
-
-    return true;
+    s.Printf ("No value");
+    return false;
 }
 
 SBInstructionList

Modified: lldb/trunk/source/API/SBProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=115902&r1=115901&r2=115902&view=diff
==============================================================================
--- lldb/trunk/source/API/SBProcess.cpp (original)
+++ lldb/trunk/source/API/SBProcess.cpp Wed Oct  6 23:19:01 2010
@@ -488,11 +488,11 @@
         if (exe_module)
             exe_name = exe_module->GetFileSpec().GetFilename().AsCString();
 
-        description.Printf ("Process {pid: %d, state: %s, threads: %d%s%s}", 
+        description.Printf ("SBProcess: pid = %d, state = %s, threads = %d%s%s", 
                             m_opaque_sp->GetID(),
                             SBDebugger::StateAsCString (GetState()), 
                             GetNumThreads(),
-                            exe_name ? ", executable: " : "",
+                            exe_name ? ", executable = " : "",
                             exe_name ? exe_name : "");
     }
     else

Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=115902&r1=115901&r2=115902&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Wed Oct  6 23:19:01 2010
@@ -119,21 +119,6 @@
 }
 
 
-// SBProcess
-// SBTarget::LaunchProcess
-// (
-//     char const **argv,
-//     char const **envp,
-//     const char *tty,
-//     uint32_t launch_flags,
-//     bool stop_at_entry
-// )
-// {
-//     SBError sb_error;    
-//     return LaunchProcess (argv, envp, tty, launch_flags, stop_at_entry, sb_error);
-// }
-
-
 SBProcess
 SBTarget::LaunchProcess
 (
@@ -141,6 +126,20 @@
     char const **envp,
     const char *tty,
     uint32_t launch_flags,
+    bool stop_at_entry
+)
+{
+    SBError sb_error;    
+    return Launch (argv, envp, tty, launch_flags, stop_at_entry, sb_error);
+}
+
+SBProcess
+SBTarget::Launch
+(
+    char const **argv,
+    char const **envp,
+    const char *tty,
+    uint32_t launch_flags,
     bool stop_at_entry,
     SBError &error
 )
@@ -165,14 +164,14 @@
             error.SetError (sb_process->Launch (argv, envp, launch_flags, tty, tty, tty));
             if (error.Success())
             {
-                // We we are stopping at the entry point, we can return now!
-                if (stop_at_entry)
-                    return sb_process;
-
                 // Make sure we are stopped at the entry
                 StateType state = sb_process->WaitForProcessToStop (NULL);
                 if (state == eStateStopped)
                 {
+                    // We we are stopping at the entry point, we can return now!
+                    if (stop_at_entry)
+                        return sb_process;
+
                     // resume the process to skip the entry point
                     error.SetError (sb_process->Resume());
                     if (error.Success())
@@ -199,7 +198,7 @@
 
 
 lldb::SBProcess
-SBTarget::AttachToProcess 
+SBTarget::AttachToProcessWithID 
 (
     lldb::pid_t pid,// The process ID to attach to
     SBError& error  // An error explaining what went wrong if attach fails
@@ -238,7 +237,7 @@
 }
 
 lldb::SBProcess
-SBTarget::AttachToProcess 
+SBTarget::AttachToProcessWithName 
 (
     const char *name,   // basename of process to attach to
     bool wait_for,      // if true wait for a new instance of "name" to be launched

Modified: lldb/trunk/source/API/SBThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=115902&r1=115901&r2=115902&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThread.cpp (original)
+++ lldb/trunk/source/API/SBThread.cpp Wed Oct  6 23:19:01 2010
@@ -452,7 +452,10 @@
 SBThread::GetDescription (SBStream &description)
 {
     if (m_opaque_sp)
-        m_opaque_sp->DumpUsingSettingsFormat (description.ref(), 0);
+    {
+        StreamString strm;
+        description.Printf("SBThread: tid = 0x%4.4x", m_opaque_sp->GetID());
+    }
     else
         description.Printf ("No value");
     

Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=115902&r1=115901&r2=115902&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Wed Oct  6 23:19:01 2010
@@ -133,13 +133,9 @@
     }
 
     bool
-    Execute (Args& launch_args,
-             CommandReturnObject &result)
+    Execute (Args& launch_args, CommandReturnObject &result)
     {
         Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
-        bool synchronous_execution = m_interpreter.GetSynchronous ();
-    //    bool launched = false;
-    //    bool stopped_after_launch = false;
 
         if (target == NULL)
         {
@@ -235,22 +231,29 @@
         if (error.Success())
         {
             result.AppendMessageWithFormat ("Launching '%s'  (%s)\n", filename, archname);
-            result.SetStatus (eReturnStatusSuccessContinuingNoResult);
+            result.SetDidChangeProcessState (true);
             if (m_options.stop_at_entry == false)
             {
+                result.SetStatus (eReturnStatusSuccessContinuingNoResult);
                 StateType state = process->WaitForProcessToStop (NULL);
 
                 if (state == eStateStopped)
                 {
-                    // Call continue_command.
-                    CommandReturnObject continue_result;
-                    m_interpreter.HandleCommand("process continue", false, continue_result);
-                }
-
-                if (synchronous_execution)
-                {
-                    result.SetDidChangeProcessState (true);
-                    result.SetStatus (eReturnStatusSuccessFinishNoResult);
+                    error = process->Resume();
+                    if (error.Success())
+                    {
+                        bool synchronous_execution = m_interpreter.GetSynchronous ();
+                        if (synchronous_execution)
+                        {
+                            state = process->WaitForProcessToStop (NULL);
+                            result.SetDidChangeProcessState (true);
+                            result.SetStatus (eReturnStatusSuccessFinishResult);
+                        }
+                        else
+                        {
+                            result.SetStatus (eReturnStatusSuccessContinuingNoResult);
+                        }
+                    }
                 }
             }
         }

Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp?rev=115902&r1=115901&r2=115902&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp Wed Oct  6 23:19:01 2010
@@ -360,7 +360,6 @@
     Log *log = ProcessMacOSXLog::GetLogIfAllCategoriesSet (PD_LOG_PROCESS);
     if (attach_pid != LLDB_INVALID_PROCESS_ID)
     {
-        SetPrivateState (eStateAttaching);
         SetID(attach_pid);
         // Let ourselves know we are going to be using SBS if the correct flag bit is set...
 #if defined (__arm__)
@@ -1642,8 +1641,6 @@
 
             if (launch_type == eLaunchPosixSpawn)
             {
-
-                //SetState (eStateAttaching);
                 errno = 0;
                 if (::ptrace (PT_ATTACHEXC, pid, 0, 0) == 0)
                     launch_err.Clear();
@@ -1967,7 +1964,6 @@
 //            m_args.push_back(arg);
         Task().StartExceptionThread();
         StartSTDIOThread();
-        SetState (eStateAttaching);
         int err = ptrace (PT_ATTACHEXC, m_pid, 0, 0);
         if (err == 0)
         {

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=115902&r1=115901&r2=115902&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Wed Oct  6 23:19:01 2010
@@ -652,7 +652,6 @@
     
     if (attach_pid != LLDB_INVALID_PROCESS_ID)
     {
-        SetPrivateState (eStateAttaching);
         char host_port[128];
         snprintf (host_port, sizeof(host_port), "localhost:%u", get_random_port ());
         error = StartDebugserverProcess (host_port,                 // debugserver_url
@@ -753,8 +752,6 @@
     //Log *log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS);
     if (process_name && process_name[0])
     {
-
-        SetPrivateState (eStateAttaching);
         char host_port[128];
         ArchSpec arch_spec = GetTarget().GetArchitecture();
         snprintf (host_port, sizeof(host_port), "localhost:%u", get_random_port ());

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=115902&r1=115901&r2=115902&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Wed Oct  6 23:19:01 2010
@@ -198,9 +198,14 @@
 {
     EventSP event_sp;
     uint32_t i;
-    StateType state = eStateUnloaded;
+    StateType state = GetState();
     while (state != eStateInvalid)
     {
+        // If we are exited or detached, we won't ever get back to any
+        // other valid state...
+        if (state == eStateDetached || state == eStateExited)
+            return state;
+
         state = WaitForStateChangedEvents (timeout, event_sp);
 
         for (i=0; i<num_match_states; ++i)
@@ -1006,6 +1011,7 @@
             error = WillLaunch (exe_module);
             if (error.Success())
             {
+                SetPublicState (eStateLaunching);
                 // The args coming in should not contain the application name, the
                 // lldb_private::Process class will add this in case the executable
                 // gets resolved to a different file than was given on the command
@@ -1147,6 +1153,8 @@
     Error error (WillAttachToProcessWithID(attach_pid));
     if (error.Success())
     {
+        SetPublicState (eStateAttaching);
+
         error = DoAttachToProcessWithID (attach_pid);
         if (error.Success())
         {
@@ -1190,6 +1198,7 @@
     Error error (WillAttachToProcessWithName(process_name, wait_for_launch));
     if (error.Success())
     {
+        SetPublicState (eStateAttaching);
         StartPrivateStateThread();
         error = DoAttachToProcessWithName (process_name, wait_for_launch);
         if (error.Fail())





More information about the lldb-commits mailing list