While looking at the '[raw]' value of a std::vector I noticed we didn't handle the anonymous inner struct very well. The 'evaluateName' was incorrect (e.g. the evaluateName would return `<var>.` for the anonymous struct). This improves support for variables with anonymous fields and anonymous types. * Changed the name of anonymous fields from `<null>` to `(anonymous)`, which matches other tooling like clangd's representation and how types are presented if the field is not defined. * Adjusts variables to not return an 'evaluateName' for anonymous fields. * Adjusted '[raw]' values to be marked as 'internal' which deemphasizes them in the UI. While working in this area, I also consolidated some helpers that are only used within Variables.cpp. Before my changes: <img width="513" height="460" alt="before" src="https://github.com/user-attachments/assets/3da0aada-8ba3-415d-bbec-56b41a9b9415" /> After my changes: <img width="414" height="467" alt="after" src="https://github.com/user-attachments/assets/66a47108-ee44-4e01-8eab-e89edb348fde" />
48 lines
1.7 KiB
C++
48 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(arguments);
|
|
if (llvm::Error err = variables.takeError())
|
|
return err;
|
|
|
|
return VariablesResponseBody{*variables};
|
|
}
|
|
|
|
} // namespace lldb_dap
|