llvm-project/lldb/tools/lldb-dap/Handler/DisconnectRequestHandler.cpp
John Harrison 4d42c8e184
[lldb-dap] Correct the disconnect helper on server shutdown. (#142508)
Previously, we incorrectly handled the disconnect operation if we signal
lldb-dap running in server mode.

Updated to correctly disconnect the attach vs launch behavior on server
shutdown.
2025-06-03 09:40:40 -07:00

34 lines
1.0 KiB
C++

//===-- DisconnectRequestHandler.cpp --------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
#include "DAP.h"
#include "Protocol/ProtocolRequests.h"
#include "RequestHandler.h"
#include "llvm/Support/Error.h"
#include <optional>
using namespace llvm;
using namespace lldb_dap::protocol;
namespace lldb_dap {
/// Disconnect request; value of command field is 'disconnect'.
Error DisconnectRequestHandler::Run(
const std::optional<DisconnectArguments> &arguments) const {
bool terminateDebuggee = !dap.is_attach;
if (arguments && arguments->terminateDebuggee)
terminateDebuggee = *arguments->terminateDebuggee;
if (Error error = dap.Disconnect(terminateDebuggee))
return error;
return Error::success();
}
} // namespace lldb_dap