diff options
| author | Greg Clayton <gclayton@apple.com> | 2011-03-23 00:09:55 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2011-03-23 00:09:55 +0000 |
| commit | d314e810a70e9104c8d30d9b0719bc5a3dc0acab (patch) | |
| tree | 0d881e5b16df61aa732dea1555adecf675db83e8 /lldb/tools/lldb-platform/lldb-platform.cpp | |
| parent | 7ca3ddc2333a05f60be578cffc93610a34638602 (diff) | |
| download | bcm5719-llvm-d314e810a70e9104c8d30d9b0719bc5a3dc0acab.tar.gz bcm5719-llvm-d314e810a70e9104c8d30d9b0719bc5a3dc0acab.zip | |
Added new platform commands:
platform connect <args>
platform disconnect
Each platform can decide the args they want to use for "platform connect". I
will need to add a function that gets the connect options for the current
platform as each one can have different options and argument counts.
Hooked up more functionality in the PlatformMacOSX and PlatformRemoteiOS.
Also started an platform agnostic PlatformRemoteGDBServer.cpp which can end
up being used by one or more actual platforms. It can also be specialized and
allow for platform specific commands.
llvm-svn: 128123
Diffstat (limited to 'lldb/tools/lldb-platform/lldb-platform.cpp')
| -rw-r--r-- | lldb/tools/lldb-platform/lldb-platform.cpp | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/lldb/tools/lldb-platform/lldb-platform.cpp b/lldb/tools/lldb-platform/lldb-platform.cpp index 3ca0f334611..736daeb4d20 100644 --- a/lldb/tools/lldb-platform/lldb-platform.cpp +++ b/lldb/tools/lldb-platform/lldb-platform.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// C Includes #include <errno.h> #include <getopt.h> #include <signal.h> @@ -15,8 +16,16 @@ #include <stdlib.h> #include <string.h> +// C++ Includes + +// Other libraries and framework includes +#include "lldb/Core/Error.h" +#include "lldb/Core/ConnectionFileDescriptor.h" #include "GDBRemoteCommunicationServer.h" +using namespace lldb; +using namespace lldb_private; + //---------------------------------------------------------------------- // option descriptors for getopt_long() //---------------------------------------------------------------------- @@ -30,6 +39,7 @@ static struct option g_long_options[] = { "verbose", no_argument, &g_verbose, 1 }, { "log-file", required_argument, NULL, 'l' }, { "log-flags", required_argument, NULL, 'f' }, + { "listen", required_argument, NULL, 'L' }, { NULL, 0, NULL, 0 } }; @@ -58,6 +68,7 @@ main (int argc, char *argv[]) int long_option_index = 0; FILE* log_file = NULL; uint32_t log_flags = 0; + std::string connect_url; char ch; while ((ch = getopt_long(argc, argv, "l:f:", g_long_options, &long_option_index)) != -1) @@ -98,6 +109,11 @@ main (int argc, char *argv[]) if (optarg && optarg[0]) log_flags = strtoul(optarg, NULL, 0); break; + + case 'L': + connect_url.assign ("connect://"); + connect_url.append (optarg); + break; } } @@ -106,7 +122,48 @@ main (int argc, char *argv[]) argv += optind; - GDBRemoteCommunicationServer gdb_comm; + GDBRemoteCommunicationServer gdb_server; + Error error; + if (!connect_url.empty()) + { + std::auto_ptr<ConnectionFileDescriptor> conn_ap(new ConnectionFileDescriptor()); + if (conn_ap.get()) + { + const uint32_t max_retry_count = 50; + uint32_t retry_count = 0; + while (!gdb_server.IsConnected()) + { + if (conn_ap->Connect(connect_url.c_str(), &error) == eConnectionStatusSuccess) + { + gdb_server.SetConnection (conn_ap.release()); + break; + } + retry_count++; + + if (retry_count >= max_retry_count) + break; + + usleep (100000); + } + } + } + + + if (gdb_server.IsConnected()) + { + if (gdb_server.StartReadThread(&error)) + { + bool interrupt = false; + bool done = false; + while (!interrupt && !done) + { + gdb_server.GetPacketAndSendResponse(NULL, interrupt, done); + } + } + else + { + } + } return 0; } |

