summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2013-11-21 18:58:35 +0000
committerGreg Clayton <gclayton@apple.com>2013-11-21 18:58:35 +0000
commitdd59dcb6d11c997a547b3c2c5bc9fa025d2f293f (patch)
treee6553155aabe16cb631c758ca741f2b8855738db
parentbe94a0405587069c0b6d33c4803db0451e008ff0 (diff)
downloadbcm5719-llvm-dd59dcb6d11c997a547b3c2c5bc9fa025d2f293f.tar.gz
bcm5719-llvm-dd59dcb6d11c997a547b3c2c5bc9fa025d2f293f.zip
Added the ability to launch the program that was specified on the command line and have it waiting for a NativeProcessProtocol to attach.
llvm-svn: 195370
-rw-r--r--lldb/tools/lldb-gdbserver/lldb-gdbserver.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/lldb/tools/lldb-gdbserver/lldb-gdbserver.cpp b/lldb/tools/lldb-gdbserver/lldb-gdbserver.cpp
index 26b9b2d19eb..dd90f05c7b5 100644
--- a/lldb/tools/lldb-gdbserver/lldb-gdbserver.cpp
+++ b/lldb/tools/lldb-gdbserver/lldb-gdbserver.cpp
@@ -93,7 +93,9 @@ main (int argc, char *argv[])
Error error;
int ch;
Debugger::Initialize();
-
+ ProcessLaunchInfo launch_info;
+ ProcessAttachInfo attach_info;
+
bool show_usage = false;
int option_error = 0;
// StreamSP stream_sp (new StreamFile(stdout, false));
@@ -183,7 +185,23 @@ main (int argc, char *argv[])
// Any arguments left over are for the the program that we need to launch. If there
// are no arguments, then the GDB server will start up and wait for an 'A' packet
// to launch a program, or a vAttach packet to attach to an existing process.
-
+ if (argc > 0)
+ {
+ // Launch the program specified on the command line
+ launch_info.SetArguments((const char **)argv, true);
+ launch_info.GetFlags().Set(eLaunchFlagDebug | eLaunchFlagStopAtEntry);
+ error = Host::LaunchProcess (launch_info);
+
+ if (error.Success())
+ {
+ printf ("Launched '%s' as process %" PRIu64 "...\n", argv[0], launch_info.GetProcessID());
+ }
+ else
+ {
+ fprintf (stderr, "error: failed to launch '%s': %s\n", argv[0], error.AsCString());
+ }
+ }
+
const bool is_platform = false;
GDBRemoteCommunicationServer gdb_server (is_platform);
OpenPOWER on IntegriCloud