llvm-project/lldb/tools/lldb-dap/Handler/DisconnectRequestHandler.cpp
John Harrison fbb8929c9d
[lldb-dap] Updating RequestHandler to encode/decode arguments and response. (#130090)
This is a work in progress refactor to add explicit types instead of
generic 'llvm::json::Value' types to the DAP protocol.

This updates RequestHandler to have take the type of the arguments and
response body for serialization for requests.

The 'source' and 'disconnect' request is updated to show how the new
flow
works and includes serialization handling for optional arguments and
'void'
responses.

This is built on top of #130026

---------

Co-authored-by: Adrian Vogelsgesang <adrian.vogelsgesang@tum.de>
2025-03-17 10:13:11 -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'.
Expected<DisconnectResponse> DisconnectRequestHandler::Run(
const std::optional<DisconnectArguments> &arguments) const {
bool terminateDebuggee = dap.is_attach ? false : true;
if (arguments && arguments->terminateDebuggee)
terminateDebuggee = *arguments->terminateDebuggee;
if (Error error = dap.Disconnect(terminateDebuggee))
return error;
return DisconnectResponse();
}
} // namespace lldb_dap