summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h4
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp4
-rw-r--r--lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp22
-rw-r--r--lldb/unittests/tools/lldb-server/tests/TestClient.cpp10
4 files changed, 29 insertions, 11 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
index a3535248004..880caacd641 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
@@ -57,8 +57,8 @@ protected:
bool m_exit_now; // use in asynchronous handling to indicate process should
// exit.
- bool m_send_error_strings; // If the client enables this then
- // we will send error strings as well.
+ bool m_send_error_strings = false; // If the client enables this then
+ // we will send error strings as well.
PacketResult Handle_QErrorStringEnable(StringExtractorGDBRemote &packet);
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 069720859a5..b72fd4cd9dc 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -291,7 +291,7 @@ Status GDBRemoteCommunicationServerLLGS::AttachToProcess(lldb::pid_t pid) {
// else.
if (m_debugged_process_up &&
m_debugged_process_up->GetID() != LLDB_INVALID_PROCESS_ID)
- return Status("cannot attach to a process %" PRIu64
+ return Status("cannot attach to process %" PRIu64
" when another process with pid %" PRIu64
" is being debugged.",
pid, m_debugged_process_up->GetID());
@@ -2935,7 +2935,7 @@ GDBRemoteCommunicationServerLLGS::Handle_vAttach(
log->Printf("GDBRemoteCommunicationServerLLGS::%s failed to attach to "
"pid %" PRIu64 ": %s\n",
__FUNCTION__, pid, error.AsCString());
- return SendErrorResponse(0x01);
+ return SendErrorResponse(error);
}
// Notify we attached by sending a stop packet.
diff --git a/lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp b/lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp
index 8733adefa38..fab84f7dd6b 100644
--- a/lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp
+++ b/lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp
@@ -46,3 +46,25 @@ TEST_F(TestBase, DS_TEST(DebugserverEnv)) {
HasValue(testing::Property(&StopReply::getKind,
WaitStatus{WaitStatus::Exit, 0})));
}
+
+TEST_F(TestBase, LLGS_TEST(vAttachRichError)) {
+ auto ClientOr = TestClient::launch(getLogFileName(),
+ {getInferiorPath("environment_check")});
+ ASSERT_THAT_EXPECTED(ClientOr, Succeeded());
+ auto &Client = **ClientOr;
+
+ // Until we enable error strings we should just get the error code.
+ ASSERT_THAT_ERROR(Client.SendMessage("vAttach;1"),
+ Failed<ErrorInfoBase>(testing::Property(
+ &ErrorInfoBase::message, "Error 255")));
+
+ ASSERT_THAT_ERROR(Client.SendMessage("QEnableErrorStrings"), Succeeded());
+
+ // Now, we expect the full error message.
+ ASSERT_THAT_ERROR(
+ Client.SendMessage("vAttach;1"),
+ Failed<ErrorInfoBase>(testing::Property(
+ &ErrorInfoBase::message,
+ testing::StartsWith(
+ "cannot attach to process 1 when another process with pid"))));
+}
diff --git a/lldb/unittests/tools/lldb-server/tests/TestClient.cpp b/lldb/unittests/tools/lldb-server/tests/TestClient.cpp
index 5bc60018cdb..7bd94588b2a 100644
--- a/lldb/unittests/tools/lldb-server/tests/TestClient.cpp
+++ b/lldb/unittests/tools/lldb-server/tests/TestClient.cpp
@@ -162,13 +162,9 @@ Error TestClient::SendMessage(StringRef message) {
Error TestClient::SendMessage(StringRef message, std::string &response_string) {
if (Error E = SendMessage(message, response_string, PacketResult::Success))
return E;
- if (response_string[0] == 'E') {
- return make_error<StringError>(
- formatv("Error `{0}` while sending message: {1}", response_string,
- message)
- .str(),
- inconvertibleErrorCode());
- }
+ StringExtractorGDBRemote Extractor(response_string);
+ if (Extractor.IsErrorResponse())
+ return Extractor.GetStatus().ToError();
return Error::success();
}
OpenPOWER on IntegriCloud