From 5f29bb8a675e8f96452b632e7129113f7dec850e Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Tue, 20 Aug 2019 20:51:52 +0000 Subject: Vendor import of stripped lldb trunk r366426 (just before the release_90 branch point): https://llvm.org/svn/llvm-project/lldb/trunk@366426 --- .../gdb-remote/GDBRemoteCommunicationServer.cpp | 27 ++++++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp') diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp index 026f78117a0c..49cbeb023fd5 100644 --- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp +++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp @@ -1,9 +1,8 @@ //===-- GDBRemoteCommunicationServer.cpp ------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -107,12 +106,28 @@ GDBRemoteCommunicationServer::SendErrorResponse(const Status &error) { if (m_send_error_strings) { lldb_private::StreamString packet; packet.Printf("E%2.2x;", static_cast(error.GetError())); - packet.PutCStringAsRawHex8(error.AsCString()); + packet.PutStringAsRawHex8(error.AsCString()); return SendPacketNoLock(packet.GetString()); } else return SendErrorResponse(error.GetError()); } +GDBRemoteCommunication::PacketResult +GDBRemoteCommunicationServer::SendErrorResponse(llvm::Error error) { + std::unique_ptr EIB; + std::unique_ptr PUE; + llvm::handleAllErrors( + std::move(error), + [&](std::unique_ptr E) { PUE = std::move(E); }, + [&](std::unique_ptr E) { EIB = std::move(E); }); + + if (EIB) + return SendErrorResponse(Status(llvm::Error(std::move(EIB)))); + if (PUE) + return SendUnimplementedResponse(PUE->message().c_str()); + return SendErrorResponse(Status("Unknown Error")); +} + GDBRemoteCommunication::PacketResult GDBRemoteCommunicationServer::Handle_QErrorStringEnable( StringExtractorGDBRemote &packet) { @@ -139,3 +154,5 @@ GDBRemoteCommunicationServer::SendOKResponse() { bool GDBRemoteCommunicationServer::HandshakeWithClient() { return GetAck() == PacketResult::Success; } + +char PacketUnimplementedError::ID; -- cgit v1.2.3