[Lldb-commits] [lldb] r195541 - Improved platform support.

Greg Clayton gclayton at apple.com
Fri Nov 22 17:58:16 PST 2013


Author: gclayton
Date: Fri Nov 22 19:58:15 2013
New Revision: 195541

URL: http://llvm.org/viewvc/llvm-project?rev=195541&view=rev
Log:
Improved platform support.

Improved the detection of a valid GDB server where we actually can connect to a socket, but then it doesn't read or write anything (which happens with some USB mux software).

Host::MakeDirectory() now can make as many intermediate directories as needed.

The testsuite now has very initial support for remote test suite running. When running on a remote platform, the setUp function for the test will make a new directory and select it as the working directory on the remote host. 

Added a common function that can be used to create the short option string for getopt_long calls.


Removed:
    lldb/trunk/lldb-gdbserver/
Modified:
    lldb/trunk/include/lldb/Host/OptionParser.h
    lldb/trunk/source/Host/common/Host.cpp
    lldb/trunk/source/Host/common/OptionParser.cpp
    lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    lldb/trunk/test/dotest.py
    lldb/trunk/test/lldbtest.py
    lldb/trunk/tools/lldb-gdbserver/lldb-gdbserver.cpp
    lldb/trunk/tools/lldb-platform/lldb-platform.cpp

Modified: lldb/trunk/include/lldb/Host/OptionParser.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/OptionParser.h?rev=195541&r1=195540&r2=195541&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/OptionParser.h (original)
+++ lldb/trunk/include/lldb/Host/OptionParser.h Fri Nov 22 19:58:15 2013
@@ -10,6 +10,10 @@
 #ifndef liblldb_OptionParser_h_
 #define liblldb_OptionParser_h_
 
+#include <string>
+
+struct option;
+
 namespace lldb_private {
 
 typedef struct Option
@@ -46,6 +50,7 @@ public:
     static char* GetOptionArgument();
     static int GetOptionIndex();
     static int GetOptionErrorCause();
+    static std::string GetShortOptionString(struct option *long_options);
 };
 
 }

Modified: lldb/trunk/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=195541&r1=195540&r2=195541&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Fri Nov 22 19:58:15 2013
@@ -1908,8 +1908,59 @@ Error
 Host::MakeDirectory (const char* path, uint32_t file_permissions)
 {
     Error error;
-    if (::mkdir(path, file_permissions) != 0)
-        error.SetErrorToErrno();
+    if (path && path[0])
+    {
+        printf("mkdir('%s', %o) ", path, file_permissions);
+        if (::mkdir(path, file_permissions) != 0)
+        {
+            error.SetErrorToErrno();
+            printf(" %i (%s)\n", error.GetError(), error.AsCString());
+            switch (error.GetError())
+            {
+            case ENOENT:
+                {
+                    // Parent directory doesn't exist, so lets make it if we can
+                    FileSpec spec(path, false);
+                    if (spec.GetDirectory() && spec.GetFilename())
+                    {
+                        // Make the parent directory and try again
+                        Error error2 = Host::MakeDirectory(spec.GetDirectory().GetCString(), file_permissions);
+                        if (error2.Success())
+                        {
+                            // Try and make the directory again now that the parent directory was made successfully
+                            printf("mkdir('%s', %o) ", path, file_permissions);
+                            if (::mkdir(path, file_permissions) == 0)
+                            {
+                                puts("success");
+                                error.Clear();
+                            }
+                            else
+                            {
+                                error.SetErrorToErrno();
+                                printf(" %i (%s)\n", error.GetError(), error.AsCString());
+                            }
+                        }
+                    }
+                }
+                break;
+            case EEXIST:
+                {
+                    FileSpec path_spec(path, false);
+                    if (path_spec.IsDirectory())
+                        error.Clear(); // It is a directory and it already exists
+                }
+                break;
+            }
+        }
+        else
+        {
+            puts("success");
+        }
+    }
+    else
+    {
+        error.SetErrorString("empty path");
+    }
     return error;
 }
 

Modified: lldb/trunk/source/Host/common/OptionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/OptionParser.cpp?rev=195541&r1=195540&r2=195541&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/OptionParser.cpp (original)
+++ lldb/trunk/source/Host/common/OptionParser.cpp Fri Nov 22 19:58:15 2013
@@ -47,17 +47,61 @@ OptionParser::Parse (int argc,
     return getopt_long_only(argc, argv, optstring, (const option*)longopts, longindex);
 }
 
-char* OptionParser::GetOptionArgument()
+char*
+OptionParser::GetOptionArgument()
 {
     return optarg;
 }
 
-int OptionParser::GetOptionIndex()
+int
+OptionParser::GetOptionIndex()
 {
     return optind;
 }
 
-int OptionParser::GetOptionErrorCause()
+int
+OptionParser::GetOptionErrorCause()
 {
     return optopt;
 }
+
+std::string
+OptionParser::GetShortOptionString(struct option *long_options)
+{
+    std::string s;
+    int i=0;
+    bool done = false;
+    while (!done)
+    {
+        if (long_options[i].name    == 0 &&
+            long_options[i].has_arg == 0 &&
+            long_options[i].flag    == 0 &&
+            long_options[i].val     == 0)
+        {
+            done = true;
+        }
+        else
+        {
+            if (long_options[i].flag == NULL &&
+                isalpha(long_options[i].val))
+            {
+                s.append(1, (char)long_options[i].val);
+                switch (long_options[i].has_arg)
+                {
+                    default:
+                    case no_argument:
+                        break;
+                        
+                    case optional_argument:
+                        s.append(2, ':');
+                        break;
+                    case required_argument:
+                        s.append(1, ':');
+                        break;
+                }
+            }
+            ++i;
+        }
+    }
+    return s;
+}

Modified: lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp?rev=195541&r1=195540&r2=195541&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp Fri Nov 22 19:58:15 2013
@@ -253,7 +253,6 @@ PlatformRemoteGDBServer::ConnectRemote (
             {
                 if (m_gdb_client.HandshakeWithServer(&error))
                 {
-                    m_gdb_client.QueryNoAckModeSupported();
                     m_gdb_client.GetHostInfo();
                     // If a working directory was set prior to connecting, send it down now
                     if (m_working_dir)
@@ -265,6 +264,8 @@ PlatformRemoteGDBServer::ConnectRemote (
                 else
                 {
                     m_gdb_client.Disconnect();
+                    if (error.Success())
+                        error.SetErrorString("handshake failed");
                 }
             }
         }
@@ -273,11 +274,6 @@ PlatformRemoteGDBServer::ConnectRemote (
             error.SetErrorString ("\"platform connect\" takes a single argument: <connect-url>");
         }
     }
-    
-    if (error.Success())
-    {
-        
-    }
 
     return error;
 }

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=195541&r1=195540&r2=195541&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Fri Nov 22 19:58:15 2013
@@ -111,17 +111,35 @@ GDBRemoteCommunicationClient::~GDBRemote
 bool
 GDBRemoteCommunicationClient::HandshakeWithServer (Error *error_ptr)
 {
+    ResetDiscoverableSettings();
+
     // Start the read thread after we send the handshake ack since if we
     // fail to send the handshake ack, there is no reason to continue...
     if (SendAck())
-        return true;
-    
-    if (error_ptr)
-        error_ptr->SetErrorString("failed to send the handshake ack");
+    {
+        // The return value from QueryNoAckModeSupported() is true if the packet
+        // was sent and _any_ response (including UNIMPLEMENTED) was received),
+        // or false if no response was received. This quickly tells us if we have
+        // a live connection to a remote GDB server...
+        if (QueryNoAckModeSupported())
+        {
+            return true;
+        }
+        else
+        {
+            if (error_ptr)
+                error_ptr->SetErrorString("failed to get reply to handshake packet");
+        }
+    }
+    else
+    {
+        if (error_ptr)
+            error_ptr->SetErrorString("failed to send the handshake ack");
+    }
     return false;
 }
 
-void
+bool
 GDBRemoteCommunicationClient::QueryNoAckModeSupported ()
 {
     if (m_supports_not_sending_acks == eLazyBoolCalculate)
@@ -137,8 +155,10 @@ GDBRemoteCommunicationClient::QueryNoAck
                 m_send_acks = false;
                 m_supports_not_sending_acks = eLazyBoolYes;
             }
+            return true;
         }
     }
+    return false;
 }
 
 void

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h?rev=195541&r1=195540&r2=195541&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h Fri Nov 22 19:58:15 2013
@@ -67,7 +67,13 @@ public:
     bool
     GetThreadSuffixSupported ();
 
-    void
+    // This packet is usually sent first and the boolean return value
+    // indicates if the packet was send and any response was received
+    // even in the response is UNIMPLEMENTED. If the packet failed to
+    // get a response, then false is returned. This quickly tells us
+    // if we were able to connect and communicte with the remote GDB
+    // server
+    bool
     QueryNoAckModeSupported ();
 
     void

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=195541&r1=195540&r2=195541&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Nov 22 19:58:15 2013
@@ -926,15 +926,13 @@ ProcessGDBRemote::ConnectToDebugserver (
     // then we aren't actually connected to anything, so try and do the
     // handshake with the remote GDB server and make sure that goes 
     // alright.
-    if (!m_gdb_comm.HandshakeWithServer (NULL))
+    if (!m_gdb_comm.HandshakeWithServer (&error))
     {
         m_gdb_comm.Disconnect();
         if (error.Success())
             error.SetErrorString("not connected to remote gdb server");
         return error;
     }
-    m_gdb_comm.ResetDiscoverableSettings();
-    m_gdb_comm.QueryNoAckModeSupported ();
     m_gdb_comm.GetThreadSuffixSupported ();
     m_gdb_comm.GetListThreadsInStopReplySupported ();
     m_gdb_comm.GetHostInfo ();

Modified: lldb/trunk/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=195541&r1=195540&r2=195541&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Fri Nov 22 19:58:15 2013
@@ -20,15 +20,16 @@ Type:
 for available options.
 """
 
+import commands
 import os
 import platform
+import progress
 import signal
 import subprocess
 import sys
 import textwrap
 import time
 import unittest2
-import progress
 
 if sys.version_info >= (2, 7):
     argparse = __import__('argparse')
@@ -171,9 +172,6 @@ compilers = None    # Must be initialize
 # just that.
 cflags_extras = ''
 
-# Delay startup in order for the debugger to attach.
-delay = False
-
 # Dump the Python sys.path variable.  Use '-D' to dump sys.path.
 dumpSysPath = False
 
@@ -256,6 +254,11 @@ separator = '-' * 70
 
 failed = False
 
+# LLDB Remote platform setting
+lldb_platform_name = None
+lldb_platform_url = None
+lldb_platform_working_dir = None
+
 def usage(parser):
     parser.print_help()
     if verbose > 0:
@@ -396,7 +399,6 @@ def parseOptionsAndInitTestdirs():
     global archs
     global compilers
     global count
-    global delay
     global dumpSysPath
     global bmExecutable
     global bmBreakpointSpec
@@ -417,6 +419,9 @@ def parseOptionsAndInitTestdirs():
     global svn_silent
     global verbose
     global testdirs
+    global lldb_platform_name
+    global lldb_platform_url
+    global lldb_platform_working_dir
 
     do_help = False
 
@@ -468,9 +473,15 @@ def parseOptionsAndInitTestdirs():
     group.add_argument('-y', type=int, metavar='count', help="Specify the iteration count used to collect our benchmarks. An example is the number of times to do 'thread step-over' to measure stepping speed.")
     group.add_argument('-#', type=int, metavar='sharp', dest='sharp', help='Repeat the test suite for a specified number of times')
 
+    # Configuration options
+    group = parser.add_argument_group('Remote platform options')
+    group.add_argument('--platform-name', dest='lldb_platform_name', metavar='platform-name', help='The name of a remote platform to use')
+    group.add_argument('--platform-url', dest='lldb_platform_url', metavar='platform-url', help='A LLDB platform URL to use when connecting to a remote platform to run the test suite')
+    group.add_argument('--platform-working-dir', dest='lldb_platform_working_dir', metavar='platform-working-dir', help='The directory to use on the remote platform.')
+
     # Test-suite behaviour
     group = parser.add_argument_group('Runtime behaviour options')
-    X('-d', 'Delay startup for 10 seconds (in order for the debugger to attach)')
+    X('-d', 'Suspend the process after launch to wait indefinitely for a debugger to attach')
     X('-F', 'Fail fast. Stop the test suite on the first error/failure')
     X('-i', "Ignore (don't bailout) if 'lldb.py' module cannot be located in the build tree relative to this script; use PYTHONPATH to locate the module")
     X('-n', "Don't print the headers like build dir, lldb version, and svn info at all")
@@ -515,6 +526,9 @@ def parseOptionsAndInitTestdirs():
 
     if args.archs:
         archs = args.archs
+        for arch in archs:
+            if arch.startswith('arm') and platform_system == 'Darwin':
+                os.environ['SDKROOT'] = commands.getoutput('xcodebuild -version -sdk iphoneos.internal Path')
     else:
         if (platform_system == 'Darwin' or (platform_system == 'Linux' and compilers == ['clang'])) and platform_machine == 'x86_64':
             archs = ['x86_64', 'i386']
@@ -575,7 +589,9 @@ def parseOptionsAndInitTestdirs():
             usage(parser)
 
     if args.d:
-        delay = True
+        sys.stdout.write("Suspending the process %d to wait for debugger to attach...\n" % os.getpid())
+        sys.stdout.flush()    
+        os.kill(os.getpid(), signal.SIGSTOP)
 
     if args.e:
         if args.e.startswith('-'):
@@ -691,6 +707,12 @@ def parseOptionsAndInitTestdirs():
     if dont_do_python_api_test and just_do_python_api_test:
         usage(parser)
 
+    if args.lldb_platform_name:
+        lldb_platform_name = args.lldb_platform_name
+    if args.lldb_platform_url:
+        lldb_platform_url = args.lldb_platform_url
+    if args.lldb_platform_working_dir:
+        lldb_platform_working_dir = args.lldb_platform_working_dir
     # Gather all the dirs passed on the command line.
     if len(args.args) > 0:
         testdirs = map(os.path.abspath, args.args)
@@ -994,27 +1016,6 @@ def setupSysPath():
     if dumpSysPath:
         print "sys.path:", sys.path
 
-
-def doDelay(delta):
-    """Delaying startup for delta-seconds to facilitate debugger attachment."""
-    def alarm_handler(*args):
-        raise Exception("timeout")
-
-    signal.signal(signal.SIGALRM, alarm_handler)
-    signal.alarm(delta)
-    sys.stdout.write("pid=%d\n" % os.getpid())
-    sys.stdout.write("Enter RET to proceed (or timeout after %d seconds):" %
-                     delta)
-    sys.stdout.flush()
-    try:
-        text = sys.stdin.readline()
-    except:
-        text = ""
-    signal.alarm(0)
-    sys.stdout.write("proceeding...\n")
-    pass
-
-
 def visit(prefix, dir, names):
     """Visitor function for os.path.walk(path, visit, arg)."""
 
@@ -1169,12 +1170,6 @@ parseOptionsAndInitTestdirs()
 setupSysPath()
 
 #
-# If '-d' is specified, do a delay of 10 seconds for the debugger to attach.
-#
-if delay:
-    doDelay(10)
-
-#
 # If '-l' is specified, do not skip the long running tests.
 if not skip_long_running_test:
     os.environ["LLDB_SKIP_LONG_RUNNING_TEST"] = "NO"
@@ -1200,6 +1195,32 @@ atexit.register(lambda: lldb.SBDebugger.
 # Create a singleton SBDebugger in the lldb namespace.
 lldb.DBG = lldb.SBDebugger.Create()
 
+if lldb_platform_name:
+    print "Setting up remote platform '%s'" % (lldb_platform_name)
+    lldb.remote_platform = lldb.SBPlatform(lldb_platform_name)
+    if not lldb.remote_platform.IsValid():
+        print "error: unable to create the LLDB platform named '%s'." % (lldb_platform_name)
+        sys.exit(1)
+    if lldb_platform_url:
+        # We must connect to a remote platform if a LLDB platform URL was specified
+        print "Connecting to remote platform '%s' at '%s'..." % (lldb_platform_name, lldb_platform_url)
+        platform_connect_options = lldb.SBPlatformConnectOptions(lldb_platform_url); 
+        err = lldb.remote_platform.ConnectRemote(platform_connect_options)
+        if err.Success():
+            print "Connected."
+        else:
+            print "error: failed to connect to remote platform using URL '%s': %s" % (lldb_platform_url, err)
+            sys.exit(1)
+    
+    if lldb_platform_working_dir:
+        print "Setting remote platform working directory to '%s'..." % (lldb_platform_working_dir)
+        lldb.remote_platform.SetWorkingDirectory(lldb_platform_working_dir)
+    
+    lldb.remote_platform_working_dir = lldb_platform_working_dir
+    lldb.DBG.SetSelectedPlatform(lldb.remote_platform)
+else:
+    lldb.remote_platform = None
+    lldb.remote_platform_working_dir = None
 # Put the blacklist in the lldb namespace, to be used by lldb.TestBase.
 lldb.blacklist = blacklist
 
@@ -1538,6 +1559,7 @@ for ia in range(len(archs) if iterArchs
                 if self.shouldSkipBecauseOfCategories(test):
                     self.hardMarkAsSkipped(test)
                 self.counter += 1
+                test.test_number = self.counter
                 if self.showAll:
                     self.stream.write(self.fmt % self.counter)
                 super(LLDBTestResult, self).startTest(test)

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=195541&r1=195540&r2=195541&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Fri Nov 22 19:58:15 2013
@@ -1684,6 +1684,16 @@ class TestBase(Base):
         if lldb.pre_flight:
             lldb.pre_flight(self)
 
+        if lldb.remote_platform:
+            #remote_test_dir = os.path.join(lldb.remote_platform_working_dir, self.mydir)
+            remote_test_dir = os.path.join(lldb.remote_platform_working_dir, str(self.test_number), self.mydir)
+            error = lldb.remote_platform.MakeDirectory(remote_test_dir, 0700)
+            if error.Success():
+                print "successfully made remote directory '%s'" % (remote_test_dir)
+                lldb.remote_platform.SetWorkingDirectory(remote_test_dir)
+            else:
+                print "error: making remote directory '%s': %s" % (remote_test_dir, error)
+    
     # utility methods that tests can use to access the current objects
     def target(self):
         if not self.dbg:

Modified: lldb/trunk/tools/lldb-gdbserver/lldb-gdbserver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-gdbserver/lldb-gdbserver.cpp?rev=195541&r1=195540&r2=195541&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-gdbserver/lldb-gdbserver.cpp (original)
+++ lldb/trunk/tools/lldb-gdbserver/lldb-gdbserver.cpp Fri Nov 22 19:58:15 2013
@@ -27,6 +27,7 @@
 #include "lldb/Core/ConnectionMachPort.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/StreamFile.h"
+#include "lldb/Host/OptionParser.h"
 #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h"
 #include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
 using namespace lldb;
@@ -108,7 +109,10 @@ main (int argc, char *argv[])
     optind = 1;
 #endif
     
-    while ((ch = getopt_long_only(argc, argv, "l:f:h", g_long_options, &long_option_index)) != -1)
+    std::string short_options(OptionParser::GetShortOptionString(g_long_options));
+
+    
+    while ((ch = getopt_long_only(argc, argv, short_options.c_str(), g_long_options, &long_option_index)) != -1)
     {
 //        DNBLogDebug("option: ch == %c (0x%2.2x) --%s%c%s\n",
 //                    ch, (uint8_t)ch,

Modified: lldb/trunk/tools/lldb-platform/lldb-platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-platform/lldb-platform.cpp?rev=195541&r1=195540&r2=195541&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-platform/lldb-platform.cpp (original)
+++ lldb/trunk/tools/lldb-platform/lldb-platform.cpp Fri Nov 22 19:58:15 2013
@@ -27,6 +27,7 @@
 #include "lldb/Core/ConnectionMachPort.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/StreamFile.h"
+#include "lldb/Host/OptionParser.h"
 #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h"
 #include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
 using namespace lldb;
@@ -67,15 +68,11 @@ static struct option g_long_options[] =
 //----------------------------------------------------------------------
 // Watch for signals
 //----------------------------------------------------------------------
-int g_sigpipe_received = 0;
 void
 signal_handler(int signo)
 {
     switch (signo)
     {
-    case SIGPIPE:
-        g_sigpipe_received = 1;
-        break;
     case SIGHUP:
         // Use SIGINT first, if that does not work, use SIGHUP as a last resort.
         // And we should not call exit() here because it results in the global destructors
@@ -100,7 +97,7 @@ int
 main (int argc, char *argv[])
 {
     const char *progname = argv[0];
-    signal (SIGPIPE, signal_handler);
+    signal (SIGPIPE, SIG_IGN);
     signal (SIGHUP, signal_handler);
     int long_option_index = 0;
     StreamSP log_stream_sp;
@@ -122,6 +119,8 @@ main (int argc, char *argv[])
     const char *log_channels[] = { "platform", "host", "process", NULL };
     EnableLog (stream_sp, 0, log_channels, NULL);
     
+    std::string short_options(OptionParser::GetShortOptionString(g_long_options));
+                            
 #if __GLIBC__
     optind = 0;
 #else
@@ -129,7 +128,7 @@ main (int argc, char *argv[])
     optind = 1;
 #endif
 
-    while ((ch = getopt_long_only(argc, argv, "l:f:L:p:m:M:", g_long_options, &long_option_index)) != -1)
+    while ((ch = getopt_long_only(argc, argv, short_options.c_str(), g_long_options, &long_option_index)) != -1)
     {
 //        DNBLogDebug("option: ch == %c (0x%2.2x) --%s%c%s\n",
 //                    ch, (uint8_t)ch,





More information about the lldb-commits mailing list