[Lldb-commits] [lldb] r118404 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.h source/Symbol/ClangASTContext.cpp

Greg Clayton gclayton at apple.com
Sun Nov 7 20:29:11 PST 2010


Author: gclayton
Date: Sun Nov  7 22:29:11 2010
New Revision: 118404

URL: http://llvm.org/viewvc/llvm-project?rev=118404&view=rev
Log:
Cleaned up the pseudo terminal code in ProcessGDBRemote as it was spawning
a pseudo terminal even when the process being attached to. 

Fixed a possible crasher in the in:

    bool
    ClangASTContext::IsAggregateType (clang_type_t clang_type);
    
It seems that if you pass in a record decl, enum decl, or objc class decl
and ask it if it is an aggregate type, clang will crash. 


Modified:
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
    lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=118404&r1=118403&r2=118404&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sun Nov  7 22:29:11 2010
@@ -3229,7 +3229,6 @@
 				INFOPLIST_FILE = "lldb-Info.plist";
 				INSTALL_PATH = /Developer/usr/bin;
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
-				ONLY_ACTIVE_ARCH = YES;
 				OTHER_CFLAGS = "-Wparentheses";
 				OTHER_LDFLAGS = (
 					"-sectcreate",

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=118404&r1=118403&r2=118404&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Sun Nov  7 22:29:11 2010
@@ -393,6 +393,7 @@
         char host_port[128];
         snprintf (host_port, sizeof(host_port), "localhost:%u", get_random_port ());
 
+        const bool launch_process = true;
         bool start_debugserver_with_inferior_args = false;
         if (start_debugserver_with_inferior_args)
         {
@@ -403,6 +404,7 @@
                                              argv,
                                              envp,
                                              NULL, //stdin_path,
+                                             launch_process,
                                              LLDB_INVALID_PROCESS_ID,
                                              NULL, false,
                                              (launch_flags & eLaunchFlagDisableASLR) != 0,
@@ -421,7 +423,8 @@
             error = StartDebugserverProcess (host_port,
                                              NULL,
                                              NULL,
-                                             NULL, //stdin_path,
+                                             NULL, //stdin_path
+                                             launch_process,
                                              LLDB_INVALID_PROCESS_ID,
                                              NULL, false,
                                              (launch_flags & eLaunchFlagDisableASLR) != 0,
@@ -644,9 +647,10 @@
                                          NULL,                      // inferior_argv
                                          NULL,                      // inferior_envp
                                          NULL,                      // stdin_path
-                                         LLDB_INVALID_PROCESS_ID,   // attach_pid
-                                         NULL,                      // attach_pid_name
-                                         false,                     // wait_for_launch
+                                         false,                     // launch_process == false (we are attaching)
+                                         LLDB_INVALID_PROCESS_ID,   // Don't send any attach to pid options to debugserver
+                                         NULL,                      // Don't send any attach by process name option to debugserver
+                                         false,                     // Don't send any attach wait_for_launch flag as an option to debugserver
                                          false,                     // disable_aslr
                                          arch_spec);
         
@@ -745,9 +749,10 @@
                                          NULL,                      // inferior_argv
                                          NULL,                      // inferior_envp
                                          NULL,                      // stdin_path
-                                         LLDB_INVALID_PROCESS_ID,   // attach_pid
-                                         NULL,                      // attach_pid_name
-                                         false,                     // wait_for_launch
+                                         false,                     // launch_process == false (we are attaching)
+                                         LLDB_INVALID_PROCESS_ID,   // Don't send any attach to pid options to debugserver
+                                         NULL,                      // Don't send any attach by process name option to debugserver
+                                         false,                     // Don't send any attach wait_for_launch flag as an option to debugserver
                                          false,                     // disable_aslr
                                          arch_spec);
         if (error.Fail())
@@ -1655,10 +1660,11 @@
     char const *inferior_argv[],    // Arguments for the inferior program including the path to the inferior itself as the first argument
     char const *inferior_envp[],    // Environment to pass along to the inferior program
     char const *stdio_path,
-    lldb::pid_t attach_pid,         // If inferior inferior_argv == NULL, and attach_pid != LLDB_INVALID_PROCESS_ID then attach to this attach_pid
+    bool launch_process,            // Set to true if we are going to be launching a the process
+    lldb::pid_t attach_pid,         // If inferior inferior_argv == NULL, and attach_pid != LLDB_INVALID_PROCESS_ID send this pid as an argument to debugserver
     const char *attach_name,        // Wait for the next process to launch whose basename matches "attach_name"
     bool wait_for_launch,           // Wait for the process named "attach_name" to launch
-    bool disable_aslr,               // Disable ASLR
+    bool disable_aslr,              // Disable ASLR
     ArchSpec& inferior_arch         // The arch of the inferior that we will launch
 )
 {
@@ -1741,30 +1747,12 @@
 
             Args debugserver_args;
             char arg_cstr[PATH_MAX];
-            bool launch_process = true;
-
-            if (inferior_argv == NULL && attach_pid != LLDB_INVALID_PROCESS_ID)
-                launch_process = false;
-            else if (attach_name)
-                launch_process = false; // Wait for a process whose basename matches that in inferior_argv[0]
 
-            bool pass_stdio_path_to_debugserver = true;
             lldb_utility::PseudoTerminal pty;
-            if (stdio_path == NULL)
+            if (launch_process && stdio_path == NULL && m_local_debugserver)
             {
-                if (! m_local_debugserver)
-                    pass_stdio_path_to_debugserver = false;
                 if (pty.OpenFirstAvailableMaster(O_RDWR|O_NOCTTY, NULL, 0))
-                {
-                    struct termios stdin_termios;
-                    if (::tcgetattr (pty.GetMasterFileDescriptor(), &stdin_termios) == 0)
-                    {
-                        stdin_termios.c_lflag &= ~ECHO;     // Turn off echoing
-                        stdin_termios.c_lflag &= ~ICANON;   // Get one char at a time
-                        ::tcsetattr (pty.GetMasterFileDescriptor(), TCSANOW, &stdin_termios);
-                    }
                     stdio_path = pty.GetSlaveName (NULL, 0);
-                }
             }
 
             // Start args with "debugserver /file/path -r --"
@@ -1780,15 +1768,10 @@
                 debugserver_args.AppendArguments("--disable-aslr");
             
             // Only set the inferior
-            if (launch_process)
+            if (launch_process && stdio_path)
             {
-                if (stdio_path && pass_stdio_path_to_debugserver)
-                {
-                    debugserver_args.AppendArgument("-s");    // short for --stdio-path
-                    StreamString strm;
-                    strm.Printf("%s", stdio_path);
-                    debugserver_args.AppendArgument(strm.GetData());    // path to file to have inferior open as it's STDIO
-                }
+                debugserver_args.AppendArgument("--stdio-path");
+                debugserver_args.AppendArgument(stdio_path);
             }
 
             const char *env_debugserver_log_file = getenv("LLDB_DEBUGSERVER_LOG_FILE");
@@ -1883,14 +1866,17 @@
 
             if (m_debugserver_pid != LLDB_INVALID_PROCESS_ID)
             {
-                std::auto_ptr<ConnectionFileDescriptor> conn_ap(new ConnectionFileDescriptor (pty.ReleaseMasterFileDescriptor(), true));
-                if (conn_ap.get())
+                if (pty.GetMasterFileDescriptor() != lldb_utility::PseudoTerminal::invalid_fd)
                 {
-                    m_stdio_communication.SetConnection(conn_ap.release());
-                    if (m_stdio_communication.IsConnected())
+                    std::auto_ptr<ConnectionFileDescriptor> conn_ap(new ConnectionFileDescriptor (pty.ReleaseMasterFileDescriptor(), true));
+                    if (conn_ap.get())
                     {
-                        m_stdio_communication.SetReadThreadBytesReceivedCallback (STDIOReadThreadBytesReceived, this);
-                        m_stdio_communication.StartReadThread();
+                        m_stdio_communication.SetConnection(conn_ap.release());
+                        if (m_stdio_communication.IsConnected())
+                        {
+                            m_stdio_communication.SetReadThreadBytesReceivedCallback (STDIOReadThreadBytesReceived, this);
+                            m_stdio_communication.StartReadThread();
+                        }
                     }
                 }
             }

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=118404&r1=118403&r2=118404&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Sun Nov  7 22:29:11 2010
@@ -286,14 +286,15 @@
     UpdateThreadListIfNeeded ();
 
     lldb_private::Error
-    StartDebugserverProcess (const char *debugserver_url,      // The connection string to use in the spawned debugserver ("localhost:1234" or "/dev/tty...")
+    StartDebugserverProcess (const char *debugserver_url,   // The connection string to use in the spawned debugserver ("localhost:1234" or "/dev/tty...")
                              char const *inferior_argv[],
                              char const *inferior_envp[],
                              const char *stdin_path,
-                             lldb::pid_t attach_pid,         // If inferior inferior_argv == NULL, then attach to this pid
-                             const char *attach_pid_name,    // Wait for the next process to launch whose basename matches "attach_wait_name"
-                             bool wait_for_launch,           // Wait for the process named "attach_wait_name" to launch
-                             bool disable_aslr,               // Disable ASLR
+                             bool launch_process,           // Set to true if we are going to be launching a the process
+                             lldb::pid_t attach_pid,        // If inferior inferior_argv == NULL, then attach to this pid
+                             const char *attach_pid_name,   // Wait for the next process to launch whose basename matches "attach_wait_name"
+                             bool wait_for_launch,          // Wait for the process named "attach_wait_name" to launch
+                             bool disable_aslr,             // Disable ASLR
                              lldb_private::ArchSpec& arch_spec);
 
     void

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=118404&r1=118403&r2=118404&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Sun Nov  7 22:29:11 2010
@@ -1785,9 +1785,6 @@
 
     QualType qual_type (QualType::getFromOpaquePtr(clang_type));
 
-    if (qual_type->isAggregateType ())
-        return true;
-
     const clang::Type::TypeClass type_class = qual_type->getTypeClass();
     switch (type_class)
     {





More information about the lldb-commits mailing list