Fixed debugserver to properly attach to a process by name with the
"vAttachName;<PROCNAME>" packet, and wait for a new process by name to launch
with the "vAttachWait;<PROCNAME>".
Fixed a few issues with attaching where if DoAttach() returned no error, yet
there was no valid process ID, we would deadlock waiting for an event that
would never happen.
Added a new "process launch" option "--tty" that will launch the process
in a new terminal if the Host layer supports the "Host::LaunchInNewTerminal(...)"
function. This currently works on MacOSX and will allow the debugging of
terminal applications that do complex operations with the terminal.
Cleaned up the output when the process resumes, stops and halts to be
consistent with the output format.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@116693 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 3da1d59..4b45bd4 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -366,7 +366,6 @@
return error;
}
-//#define LAUNCH_WITH_LAUNCH_SERVICES 1
//----------------------------------------------------------------------
// Process Control
//----------------------------------------------------------------------
@@ -383,30 +382,6 @@
)
{
Error error;
-#if defined (LAUNCH_WITH_LAUNCH_SERVICES)
- ArchSpec inferior_arch(module->GetArchitecture());
-
- //FileSpec app_file_spec (argv[0]);
- pid_t pid = Host::LaunchInNewTerminal (argv,
- envp,
- &inferior_arch,
- true, // stop at entry
- (launch_flags & eLaunchFlagDisableASLR) != 0);
-
- // Let the app get launched and stopped...
- sleep (1);
-
- if (pid != LLDB_INVALID_PROCESS_ID)
- {
- FileSpec program(argv[0]);
- error = DoAttachToProcessWithName (program.GetFilename().AsCString(), false);
- //error = DoAttachToProcessWithID (pid);
- }
- else
- {
- error.SetErrorString("Host::LaunchApplication(() failed to launch process");
- }
-#else
// ::LogSetBitMask (GDBR_LOG_DEFAULT);
// ::LogSetOptions (LLDB_LOG_OPTION_THREADSAFE | LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD);
// ::LogSetLogFile ("/dev/stdout");
@@ -522,7 +497,6 @@
SetID(LLDB_INVALID_PROCESS_ID);
error.SetErrorStringWithFormat("Failed to get object file from '%s' for arch %s.\n", module->GetFileSpec().GetFilename().AsCString(), module->GetArchitecture().AsCString());
}
-#endif
return error;
}
@@ -646,13 +620,9 @@
void
ProcessGDBRemote::DidLaunch ()
{
-#if defined (LAUNCH_WITH_LAUNCH_SERVICES)
- DidAttach ();
-#else
DidLaunchOrAttach ();
if (m_dynamic_loader_ap.get())
m_dynamic_loader_ap->DidLaunch();
-#endif
}
Error
@@ -795,9 +765,10 @@
{
StreamString packet;
- packet.PutCString("vAttach");
if (wait_for_launch)
- packet.PutCString("Wait");
+ packet.PutCString("vAttachWait");
+ else
+ packet.PutCString("vAttachName");
packet.PutChar(';');
packet.PutBytesAsRawHex8(process_name, strlen(process_name), eByteOrderHost, eByteOrderHost);
StringExtractorGDBRemote response;
@@ -835,7 +806,11 @@
if (pid == LLDB_INVALID_PROCESS_ID)
{
KillDebugserverProcess();
+
+ if (error.Success())
+ error.SetErrorStringWithFormat("unable to attach to process named '%s'", process_name);
}
+
return error;
}