From 47b7138b484b8fc94633ac4750a11acad797473e Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Thu, 19 Nov 2020 19:13:39 +0100 Subject: [PATCH] [lldb] Fix incorrect error handling in GDBRemoteCommunicationClient::SendGetSupportedTraceType GDBRemoteCommunicationClient::SendGetSupportedTraceType is checking whether the response is `!response.IsNormalResponse()` and infers from that that it is an error response. However, it could be either "unsupported" or "error". If we get an unsupported response, the code then tries to generate an llvm::Expected from the non-error response which then asserts. Debugserver doesn't implement `jLLDBTraceSupportedType`, so we get an unsupported response whenever this function is called on macOS. This fixes the TestAproposWithProcess on macOS (where the `apropos` command will query the CommandObjectTraceStart which then sends the trace type query package). Reviewed By: wallace, shafik Differential Revision: https://reviews.llvm.org/D91801 --- .../Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index d661423..b1552a3 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -3465,8 +3465,11 @@ GDBRemoteCommunicationClient::SendGetSupportedTraceType() { if (SendPacketAndWaitForResponse(escaped_packet.GetString(), response, true) == GDBRemoteCommunication::PacketResult::Success) { - if (!response.IsNormalResponse()) + if (response.IsErrorResponse()) return response.GetStatus().ToError(); + if (response.IsUnsupportedResponse()) + return llvm::createStringError(llvm::inconvertibleErrorCode(), + "jLLDBTraceSupportedType is unsupported"); if (llvm::Expected type = llvm::json::parse(response.Peek())) -- 2.7.4