mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-01 11:22:21 -06:00
Debugger: Correctly handle clients without supportsVariableType
Fixes: #25057
This commit is contained in:
@@ -78,15 +78,16 @@ dap::array<dap::Variable> cmDebuggerVariables::HandleVariablesRequest()
|
||||
entry.Value.empty()) {
|
||||
continue;
|
||||
}
|
||||
variables.push_back(dap::Variable{ {},
|
||||
{},
|
||||
{},
|
||||
entry.Name,
|
||||
{},
|
||||
PrivateDataHint,
|
||||
entry.Type,
|
||||
entry.Value,
|
||||
0 });
|
||||
variables.push_back(dap::Variable{
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
entry.Name,
|
||||
{},
|
||||
PrivateDataHint,
|
||||
SupportsVariableType ? entry.Type : dap::optional<dap::string>(),
|
||||
entry.Value,
|
||||
0 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,16 +107,16 @@ void cmDebuggerVariables::EnumerateSubVariablesIfAny(
|
||||
{
|
||||
dap::array<dap::Variable> ret;
|
||||
for (auto const& variables : SubVariables) {
|
||||
toBeReturned.emplace_back(
|
||||
dap::Variable{ {},
|
||||
{},
|
||||
{},
|
||||
variables->GetName(),
|
||||
{},
|
||||
PrivatePropertyHint,
|
||||
SupportsVariableType ? "collection" : nullptr,
|
||||
variables->GetValue(),
|
||||
variables->GetId() });
|
||||
toBeReturned.emplace_back(dap::Variable{
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
variables->GetName(),
|
||||
{},
|
||||
PrivatePropertyHint,
|
||||
SupportsVariableType ? "collection" : dap::optional<dap::string>(),
|
||||
variables->GetValue(),
|
||||
variables->GetId() });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,15 @@
|
||||
do { \
|
||||
ASSERT_TRUE(x.name == expectedName); \
|
||||
ASSERT_TRUE(x.value == expectedValue); \
|
||||
ASSERT_TRUE(x.type.value() == expectedType); \
|
||||
ASSERT_TRUE(x.evaluateName.has_value() == false); \
|
||||
if (std::string(expectedType) == "collection") { \
|
||||
ASSERT_TRUE(x.variablesReference != 0); \
|
||||
if (expectedType == nullptr) { \
|
||||
ASSERT_TRUE(x.type == dap::optional<dap::string>()); \
|
||||
} else { \
|
||||
ASSERT_TRUE(x.type == dap::optional<dap::string>(expectedType)); \
|
||||
if (std::string(expectedType) == "collection") { \
|
||||
ASSERT_TRUE(x.variablesReference != 0); \
|
||||
} \
|
||||
} \
|
||||
ASSERT_TRUE(x.evaluateName.has_value() == false); \
|
||||
} while (false)
|
||||
|
||||
#define ASSERT_VARIABLE_REFERENCE(x, expectedName, expectedValue, \
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include <cm3p/cppdap/optional.h>
|
||||
#include <cm3p/cppdap/protocol.h>
|
||||
#include <cm3p/cppdap/types.h>
|
||||
|
||||
@@ -174,6 +175,33 @@ static bool testSortTheResult()
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool testNoSupportsVariableType()
|
||||
{
|
||||
auto variablesManager =
|
||||
std::make_shared<cmDebugger::cmDebuggerVariablesManager>();
|
||||
|
||||
auto vars = std::make_shared<cmDebugger::cmDebuggerVariables>(
|
||||
variablesManager, "Variables", false, []() {
|
||||
return std::vector<cmDebugger::cmDebuggerVariableEntry>{ { "test",
|
||||
"value" } };
|
||||
});
|
||||
|
||||
auto subvars = std::make_shared<cmDebugger::cmDebuggerVariables>(
|
||||
variablesManager, "Children", false);
|
||||
|
||||
vars->AddSubVariables(subvars);
|
||||
|
||||
dap::array<dap::Variable> variables =
|
||||
variablesManager->HandleVariablesRequest(
|
||||
CreateVariablesRequest(vars->GetId()));
|
||||
|
||||
ASSERT_TRUE(variables.size() == 2);
|
||||
ASSERT_VARIABLE(variables[0], "Children", "", nullptr);
|
||||
ASSERT_VARIABLE(variables[1], "test", "value", nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int testDebuggerVariables(int, char*[])
|
||||
{
|
||||
return runTests(std::vector<std::function<bool()>>{
|
||||
@@ -181,5 +209,6 @@ int testDebuggerVariables(int, char*[])
|
||||
testConstructors,
|
||||
testIgnoreEmptyStringEntries,
|
||||
testSortTheResult,
|
||||
testNoSupportsVariableType,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <cm3p/cppdap/optional.h>
|
||||
#include <cm3p/cppdap/protocol.h>
|
||||
#include <cm3p/cppdap/types.h>
|
||||
#include <stddef.h>
|
||||
|
||||
Reference in New Issue
Block a user