diff options
author | Todd Fiala <tfiala@google.com> | 2014-01-23 22:05:44 +0000 |
---|---|---|
committer | Todd Fiala <tfiala@google.com> | 2014-01-23 22:05:44 +0000 |
commit | 403edc5c57b608585b94c93a648333231a9c68c7 (patch) | |
tree | a3e7f3f652ab7e5822046300a579766f6e3f1602 /lldb/tools/lldb-gdbserver/lldb-gdbserver.cpp | |
parent | a786e53903c08e0d0f04c92b0f32e83005e252ce (diff) | |
download | bcm5719-llvm-403edc5c57b608585b94c93a648333231a9c68c7.tar.gz bcm5719-llvm-403edc5c57b608585b94c93a648333231a9c68c7.zip |
Move process launching into GDBRemoteCommunicationServer.
lldb-gdbserver was launching the commandline-specified launch process
directly, without GDBRemoteCommunicationServer knowing anything about
it. As GDBRemoteCommunicationServer is the piece that manages and
knows about processes that the gdb remote protocol discusses with
the client end, it is important that it know about launched processes.
This change also implements the k gdb remote protocol message, having it
kill all known spawned processes when it is received.
(Note: in lldb-gdbserver, the spawned processes are not properly
monitored yet. The response to the k packet will complain that
spawned processes do not really appear to be getting killed even if
they are. This will get addressed soon.)
llvm-svn: 199945
Diffstat (limited to 'lldb/tools/lldb-gdbserver/lldb-gdbserver.cpp')
-rw-r--r-- | lldb/tools/lldb-gdbserver/lldb-gdbserver.cpp | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/lldb/tools/lldb-gdbserver/lldb-gdbserver.cpp b/lldb/tools/lldb-gdbserver/lldb-gdbserver.cpp index 61548e6041b..e0cc6d742cf 100644 --- a/lldb/tools/lldb-gdbserver/lldb-gdbserver.cpp +++ b/lldb/tools/lldb-gdbserver/lldb-gdbserver.cpp @@ -105,7 +105,7 @@ main (int argc, char *argv[]) debugger_sp->SetOutputFileHandle(stdout, false); debugger_sp->SetErrorFileHandle(stderr, false); - ProcessLaunchInfo launch_info; + // ProcessLaunchInfo launch_info; ProcessAttachInfo attach_info; bool show_usage = false; @@ -210,6 +210,9 @@ main (int argc, char *argv[]) puts (output); } + const bool is_platform = false; + GDBRemoteCommunicationServer gdb_server (is_platform); + const char *host_and_port = argv[0]; argc -= 1; argv += 1; @@ -218,31 +221,19 @@ main (int argc, char *argv[]) // 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); - unsigned int launch_flags = eLaunchFlagStopAtEntry; #if !defined(__linux__) // linux doesn't yet handle eLaunchFlagDebug launch_flags |= eLaunchFlagDebug; #endif - launch_info.GetFlags ().Set (launch_flags); - error = Host::LaunchProcess (launch_info); - - if (error.Success()) - { - printf ("Launched '%s' as process %" PRIu64 "...\n", argv[0], launch_info.GetProcessID()); - } - else + error = gdb_server.LaunchProcess (argv, argc, launch_flags); + if (error.Fail ()) { fprintf (stderr, "error: failed to launch '%s': %s\n", argv[0], error.AsCString()); exit(1); } } - - const bool is_platform = false; - GDBRemoteCommunicationServer gdb_server (is_platform); - + if (host_and_port && host_and_port[0]) { std::unique_ptr<ConnectionFileDescriptor> conn_ap(new ConnectionFileDescriptor()); @@ -271,7 +262,7 @@ main (int argc, char *argv[]) if (!gdb_server.GetPacketAndSendResponse (UINT32_MAX, error, interrupt, done)) break; } - + if (error.Fail()) { fprintf(stderr, "error: %s\n", error.AsCString()); |