diff options
| author | Greg Clayton <gclayton@apple.com> | 2013-11-23 01:58:15 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2013-11-23 01:58:15 +0000 |
| commit | fb90931b60c66f6cbaec24fb1be374146c008807 (patch) | |
| tree | d65f47863e7a04397b6dbad80baf9098e0b128a3 /lldb/source | |
| parent | f0c1f59d7ef7f8e33486092bb42bc9486af8f3a0 (diff) | |
| download | bcm5719-llvm-fb90931b60c66f6cbaec24fb1be374146c008807.tar.gz bcm5719-llvm-fb90931b60c66f6cbaec24fb1be374146c008807.zip | |
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.
llvm-svn: 195541
Diffstat (limited to 'lldb/source')
6 files changed, 135 insertions, 20 deletions
diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index 6e312a973f1..6ab65067dca 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -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; } diff --git a/lldb/source/Host/common/OptionParser.cpp b/lldb/source/Host/common/OptionParser.cpp index 6f2ea35a89a..ead044f53cf 100644 --- a/lldb/source/Host/common/OptionParser.cpp +++ b/lldb/source/Host/common/OptionParser.cpp @@ -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; +} diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp index 752b56c3efb..069ff0c8918 100644 --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -253,7 +253,6 @@ PlatformRemoteGDBServer::ConnectRemote (Args& args) { 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 (Args& args) else { m_gdb_client.Disconnect(); + if (error.Success()) + error.SetErrorString("handshake failed"); } } } @@ -273,11 +274,6 @@ PlatformRemoteGDBServer::ConnectRemote (Args& args) error.SetErrorString ("\"platform connect\" takes a single argument: <connect-url>"); } } - - if (error.Success()) - { - - } return error; } diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 8c23bcd73b0..2690992eeed 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -111,17 +111,35 @@ GDBRemoteCommunicationClient::~GDBRemoteCommunicationClient() 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::QueryNoAckModeSupported () m_send_acks = false; m_supports_not_sending_acks = eLazyBoolYes; } + return true; } } + return false; } void diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h index 7d4d9a29729..564afbb2911 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h @@ -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 diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 6618b071f54..7f1fbefc1b7 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -926,15 +926,13 @@ ProcessGDBRemote::ConnectToDebugserver (const char *connect_url) // 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 (); |

