Author: Raphael Isemann
Date: 2020-11-19T19:14:04+01:00
New Revision: 47b7138b484b8fc94633ac4750a11acad797473e

URL: 
https://github.com/llvm/llvm-project/commit/47b7138b484b8fc94633ac4750a11acad797473e
DIFF: 
https://github.com/llvm/llvm-project/commit/47b7138b484b8fc94633ac4750a11acad797473e.diff

LOG: [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

Added: 
    

Modified: 
    lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Removed: 
    


################################################################################
diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index d661423f1107..b1552a3a43ad 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<TraceTypeInfo> type =
             llvm::json::parse<TraceTypeInfo>(response.Peek()))


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to