[Lldb-commits] [lldb] r139852 - in /lldb/trunk: include/lldb/Core/Debugger.h include/lldb/Target/Process.h tools/driver/Driver.cpp

Jim Ingham jingham at apple.com
Thu Sep 15 14:30:02 PDT 2011


Author: jingham
Date: Thu Sep 15 16:30:02 2011
New Revision: 139852

URL: http://llvm.org/viewvc/llvm-project?rev=139852&view=rev
Log:
Track whether a process was Launched or Attached to.  If Attached, the detach when the debugger is destroyed, rather than killing the process.  Also added a Debugger::Clear, which gets called in Debugger::Destroy to deal with all the targets in the Debugger.  Also made the Driver's main loop call Destroy on the debugger, rather than just Destroying the currently selected Target's process.

Modified:
    lldb/trunk/include/lldb/Core/Debugger.h
    lldb/trunk/include/lldb/Target/Process.h
    lldb/trunk/tools/driver/Driver.cpp

Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=139852&r1=139851&r2=139852&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Thu Sep 15 16:30:02 2011
@@ -276,6 +276,8 @@
     Destroy (lldb::DebuggerSP &debugger_sp);
 
     ~Debugger ();
+    
+    void Clear();
 
     lldb::DebuggerSP
     GetSP ();

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=139852&r1=139851&r2=139852&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Thu Sep 15 16:30:02 2011
@@ -1364,59 +1364,14 @@
     
     virtual Error
     ConnectRemote (const char *remote_url);
-    //------------------------------------------------------------------
-    /// List the processes matching the given partial name.
-    ///
-    /// FIXME: Is it too heavyweight to create an entire process object to do this?
-    /// The problem is for remote processes we're going to have to set up the same transport
-    /// to get this data as to actually attach.  So we need to factor out transport
-    /// and process before we can do this separately from the process.
-    ///
-    /// @param[in] name
-    ///     A partial name to match against the current process list.
-    ///
-    /// @param[out] matches
-    ///     The list of process names matching \a name.
-    ///
-    /// @param[in] pids
-    ///     A vector filled with the pids that correspond to the names in \a matches.
-    ///
-    /// @return
-    ///     Returns the number of matching processes.
-    //------------------------------------------------------------------
 
-//    virtual uint32_t
-//    ListProcessesMatchingName (const char *name, StringList &matches, std::vector<lldb::pid_t> &pids);
-    
-    //------------------------------------------------------------------
-    /// Find the architecture of a process by pid.
-    ///
-    /// FIXME: See comment for ListProcessesMatchingName.
-    ///
-    /// @param[in] pid
-    ///     A pid to inspect.
-    ///
-    /// @return
-    ///     Returns the architecture of the process or an invalid architecture if the process can't be found.
-    //------------------------------------------------------------------
-//    virtual ArchSpec
-//    GetArchSpecForExistingProcess (lldb::pid_t pid);
+    bool
+    AttachedToProcess() const
+    {
+        return m_attached_to_process;
+    }
     
     //------------------------------------------------------------------
-    /// Find the architecture of a process by name.
-    ///
-    /// FIXME: See comment for ListProcessesMatchingName.
-    ///
-    /// @param[in] process_name
-    ///     The process name to inspect.
-    ///
-    /// @return
-    ///     Returns the architecture of the process or an invalid architecture if the process can't be found.
-    //------------------------------------------------------------------
-//    virtual ArchSpec
-//    GetArchSpecForExistingProcess (const char *process_name);
-
-    //------------------------------------------------------------------
     /// Get the image information address for the current process.
     ///
     /// Some runtimes have system functions that can help dynamic
@@ -2810,6 +2765,7 @@
     std::string                 m_stdout_data;
     MemoryCache                 m_memory_cache;
     AllocatedMemoryCache        m_allocated_memory_cache;
+    bool                        m_attached_to_process;   /// Did we launch the process or attach to it?
 
     typedef std::map<lldb::LanguageType, lldb::LanguageRuntimeSP> LanguageRuntimeCollection; 
     LanguageRuntimeCollection m_language_runtimes;

Modified: lldb/trunk/tools/driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=139852&r1=139851&r2=139852&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Thu Sep 15 16:30:02 2011
@@ -69,18 +69,33 @@
 
 static OptionDefinition g_options[] =
 {
-    { LLDB_OPT_SET_1,    true , "help"           , 'h', no_argument      , NULL,  eArgTypeNone,         "Prints out the usage information for the LLDB debugger." },
-    { LLDB_OPT_SET_2,    true , "version"        , 'v', no_argument      , NULL,  eArgTypeNone,         "Prints out the current version number of the LLDB debugger." },
-    { LLDB_OPT_SET_3,    true , "arch"           , 'a', required_argument, NULL,  eArgTypeArchitecture, "Tells the debugger to use the specified architecture when starting and running the program.  <architecture> must be one of the architectures for which the program was compiled." },
-    { LLDB_OPT_SET_3,    true , "file"           , 'f', required_argument, NULL,  eArgTypeFilename,     "Tells the debugger to use the file <filename> as the program to be debugged." },
-    { LLDB_OPT_SET_4,    true , "attach-name"    , 'n', required_argument, NULL,  eArgTypeProcessName,  "Tells the debugger to attach to a process with the given name." },
-    { LLDB_OPT_SET_4,    true , "wait-for"       , 'w', no_argument      , NULL,  eArgTypeNone,         "Tells the debugger to wait for a process with the given pid or name to launch before attaching." },
-    { LLDB_OPT_SET_5,    true , "attach-pid"     , 'p', required_argument, NULL,  eArgTypePid,          "Tells the debugger to attach to a process with the given pid." },
-    { LLDB_3_TO_5,       false, "script-language", 'l', required_argument, NULL,  eArgTypeScriptLang,   "Tells the debugger to use the specified scripting language for user-defined scripts, rather than the default.  Valid scripting languages that can be specified include Python, Perl, Ruby and Tcl.  Currently only the Python extensions have been implemented." },
-    { LLDB_3_TO_5,       false, "debug"          , 'd', no_argument      , NULL,  eArgTypeNone,         "Tells the debugger to print out extra information for debugging itself." },
-    { LLDB_3_TO_5,       false, "source"         , 's', required_argument, NULL,  eArgTypeFilename,     "Tells the debugger to read in and execute the file <file>, which should contain lldb commands." },
-    { LLDB_3_TO_5,       false, "editor"         , 'e', no_argument      , NULL,  eArgTypeNone,         "Tells the debugger to open source files using the host's \"external editor\" mechanism." },
-    { LLDB_3_TO_5,       false, "no-lldbinit"    , 'x', no_argument      , NULL,  eArgTypeNone,         "Do not automatically parse any '.lldbinit' files." },
+    { LLDB_OPT_SET_1,    true , "help"           , 'h', no_argument      , NULL,  eArgTypeNone,         
+        "Prints out the usage information for the LLDB debugger." },
+    { LLDB_OPT_SET_2,    true , "version"        , 'v', no_argument      , NULL,  eArgTypeNone,         
+        "Prints out the current version number of the LLDB debugger." },
+    { LLDB_OPT_SET_3,    true , "arch"           , 'a', required_argument, NULL,  eArgTypeArchitecture, 
+        "Tells the debugger to use the specified architecture when starting and running the program.  <architecture> must "
+        "be one of the architectures for which the program was compiled." },
+    { LLDB_OPT_SET_3,    true , "file"           , 'f', required_argument, NULL,  eArgTypeFilename,     
+        "Tells the debugger to use the file <filename> as the program to be debugged." },
+    { LLDB_OPT_SET_4,    true , "attach-name"    , 'n', required_argument, NULL,  eArgTypeProcessName,  
+        "Tells the debugger to attach to a process with the given name." },
+    { LLDB_OPT_SET_4,    true , "wait-for"       , 'w', no_argument      , NULL,  eArgTypeNone,         
+        "Tells the debugger to wait for a process with the given pid or name to launch before attaching." },
+    { LLDB_OPT_SET_5,    true , "attach-pid"     , 'p', required_argument, NULL,  eArgTypePid,          
+        "Tells the debugger to attach to a process with the given pid." },
+    { LLDB_3_TO_5,       false, "script-language", 'l', required_argument, NULL,  eArgTypeScriptLang,   
+        "Tells the debugger to use the specified scripting language for user-defined scripts, rather than the default.  "
+        "Valid scripting languages that can be specified include Python, Perl, Ruby and Tcl.  Currently only the Python "
+        "extensions have been implemented." },
+    { LLDB_3_TO_5,       false, "debug"          , 'd', no_argument      , NULL,  eArgTypeNone,         
+        "Tells the debugger to print out extra information for debugging itself." },
+    { LLDB_3_TO_5,       false, "source"         , 's', required_argument, NULL,  eArgTypeFilename,     
+        "Tells the debugger to read in and execute the file <file>, which should contain lldb commands." },
+    { LLDB_3_TO_5,       false, "editor"         , 'e', no_argument      , NULL,  eArgTypeNone,         
+        "Tells the debugger to open source files using the host's \"external editor\" mechanism." },
+    { LLDB_3_TO_5,       false, "no-lldbinit"    , 'x', no_argument      , NULL,  eArgTypeNone,         
+        "Do not automatically parse any '.lldbinit' files." },
     { 0,                 false, NULL             , 0  , 0                , NULL,  eArgTypeNone,         NULL }
 };
 
@@ -1365,9 +1380,7 @@
                 }
             }
 
-            SBProcess process = m_debugger.GetSelectedTarget().GetProcess();
-            if (process.IsValid())
-                process.Destroy();
+            SBDebugger::Destroy (m_debugger);
         }
     }
 }





More information about the lldb-commits mailing list