Adjusting `VariableReferenceStorage` to only need to track permanent vs temporary storage by making `VariableStore` the common base class. Moved the subclasses of `VariableStore` into the Variables.cpp file, since they're no long referenced externally. Expanding on the tests by adding an updated core dump with variables in the argument scope we can use to validate variable storage.
49 lines
1.7 KiB
C++
49 lines
1.7 KiB
C++
//===-- VariablesRequestHandler.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 "DAPError.h"
|
|
#include "EventHelper.h"
|
|
#include "Handler/RequestHandler.h"
|
|
#include "Protocol/DAPTypes.h"
|
|
#include "Protocol/ProtocolRequests.h"
|
|
#include "Variables.h"
|
|
|
|
using namespace llvm;
|
|
using namespace lldb_dap::protocol;
|
|
|
|
namespace lldb_dap {
|
|
|
|
/// Retrieves all child variables for the given variable reference.
|
|
///
|
|
/// A filter can be used to limit the fetched children to either named or
|
|
/// indexed children.
|
|
Expected<VariablesResponseBody>
|
|
VariablesRequestHandler::Run(const VariablesArguments &arguments) const {
|
|
const var_ref_t var_ref = arguments.variablesReference;
|
|
if (var_ref.Kind() == eReferenceKindInvalid)
|
|
return llvm::make_error<DAPError>(
|
|
llvm::formatv("invalid variablesReference: {}.", var_ref.AsUInt32()),
|
|
/*error_code=*/llvm::inconvertibleErrorCode(), /*show_user=*/false);
|
|
|
|
VariableStore *store = dap.reference_storage.GetVariableStore(var_ref);
|
|
if (!store)
|
|
return llvm::make_error<DAPError>(
|
|
llvm::formatv("invalid variablesReference: {}.", var_ref.AsUInt32()),
|
|
/*error_code=*/llvm::inconvertibleErrorCode(), /*show_user=*/false);
|
|
|
|
Expected<std::vector<Variable>> variables =
|
|
store->GetVariables(dap.reference_storage, dap.configuration, arguments);
|
|
if (llvm::Error err = variables.takeError())
|
|
return err;
|
|
|
|
return VariablesResponseBody{*variables};
|
|
}
|
|
|
|
} // namespace lldb_dap
|