diff options
author | Pavel Labath <pavel@labath.sk> | 2022-09-27 20:04:10 +0200 |
---|---|---|
committer | Pavel Labath <pavel@labath.sk> | 2022-10-06 17:18:51 +0200 |
commit | 8d1de7b34af46a089eb5433c700419ad9b2923ee (patch) | |
tree | 4ba7c2f22668cfa698f48fc3a7602b06652dbf0f /lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | |
parent | 561443818a15e7b368ddbb58207a14c60ba55c58 (diff) | |
download | llvm-8d1de7b34af46a089eb5433c700419ad9b2923ee.zip llvm-8d1de7b34af46a089eb5433c700419ad9b2923ee.tar.gz llvm-8d1de7b34af46a089eb5433c700419ad9b2923ee.tar.bz2 |
[lldb/gdb-server] Better reporting of launch errors
Use our "rich error" facility to propagate error reported by the stub to
the user. lldb-server reports rich launch errors as of D133352.
To make this easier to implement, and reduce code duplication, I have
moved the vRun/A/qLaunchSuccess handling into a single
GDBRemoteCommunicationClient function.
Differential Revision: https://reviews.llvm.org/D134754
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 09b4436..ecd9606 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -84,6 +84,7 @@ #include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/StringSwitch.h" +#include "llvm/Support/FormatAdapters.h" #include "llvm/Support/Threading.h" #include "llvm/Support/raw_ostream.h" @@ -799,17 +800,17 @@ Status ProcessGDBRemote::DoLaunch(lldb_private::Module *exe_module, GDBRemoteCommunication::ScopedTimeout timeout(m_gdb_comm, std::chrono::seconds(10)); - int arg_packet_err = m_gdb_comm.SendArgumentsPacket(launch_info); - if (arg_packet_err == 0) { - std::string error_str; - if (m_gdb_comm.GetLaunchSuccess(error_str)) { - SetID(m_gdb_comm.GetCurrentProcessID()); - } else { - error.SetErrorString(error_str.c_str()); - } + // Since we can't send argv0 separate from the executable path, we need to + // make sure to use the actual executable path found in the launch_info... + Args args = launch_info.GetArguments(); + if (FileSpec exe_file = launch_info.GetExecutableFile()) + args.ReplaceArgumentAtIndex(0, exe_file.GetPath(false)); + if (llvm::Error err = m_gdb_comm.LaunchProcess(args)) { + error.SetErrorStringWithFormatv("Cannot launch '{0}': {1}", + args.GetArgumentAtIndex(0), + llvm::fmt_consume(std::move(err))); } else { - error.SetErrorStringWithFormat("'A' packet returned an error: %i", - arg_packet_err); + SetID(m_gdb_comm.GetCurrentProcessID()); } } |