Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/debugger/variables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ static HRESULT FetchFieldsAndProperties(Evaluator *pEvaluator, ICorDebugValue *p
return S_OK;
}

static HRESULT GetMemoryReference(ICorDebugValue* pInputValue, uint64_t& memoryReference) {
HRESULT Status;

ToRelease<ICorDebugReferenceValue> pReferenceValue;
if (FAILED(pInputValue->QueryInterface(IID_ICorDebugReferenceValue, (void**)&pReferenceValue)))
IfFailRet(pInputValue->GetAddress(&memoryReference));
else
IfFailRet(pReferenceValue->GetValue(&memoryReference));

return S_OK;
}

int Variables::GetNamedVariables(uint32_t variablesReference)
{
std::lock_guard<std::recursive_mutex> lock(m_referencesMutex);
Expand Down Expand Up @@ -219,6 +231,7 @@ HRESULT Variables::GetExceptionVariable(FrameId frameId, ICorDebugThread *pThrea
HRESULT Status;
IfFailRet(PrintValue(pExceptionValue, var.value));
IfFailRet(TypePrinter::GetTypeOfValue(pExceptionValue, var.type));
IfFailRet(GetMemoryReference(pExceptionValue, var.memoryReference));

return AddVariableReference(var, frameId, pExceptionValue, ValueIsVariable);
}
Expand Down Expand Up @@ -259,6 +272,7 @@ HRESULT Variables::GetStackVariables(
IfFailRet(getValue(&iCorValue, var.evalFlags));
IfFailRet(TypePrinter::GetTypeOfValue(iCorValue, var.type));
IfFailRet(PrintValue(iCorValue, var.value));
IfFailRet(GetMemoryReference(iCorValue, var.memoryReference));

IfFailRet(AddVariableReference(var, frameId, iCorValue, ValueIsVariable));
variables.push_back(var);
Expand Down Expand Up @@ -355,6 +369,7 @@ HRESULT Variables::GetChildren(
if (var.name.find('(') == std::string::npos) // expression evaluator does not support typecasts
var.evaluateName = ref.evaluateName + (isIndex ? "" : ".") + var.name;
IfFailRet(FillValueAndType(it, var));
IfFailRet(GetMemoryReference(it.value, var.memoryReference));
IfFailRet(AddVariableReference(var, ref.frameId, it.value, ValueIsVariable));
variables.push_back(var);
}
Expand Down Expand Up @@ -405,6 +420,7 @@ HRESULT Variables::Evaluate(
variable.evaluateName = expression;
IfFailRet(TypePrinter::GetTypeOfValue(pResultValue, variable.type));
IfFailRet(PrintValue(pResultValue, variable.value));
IfFailRet(GetMemoryReference(pResultValue, variable.memoryReference));

return AddVariableReference(variable, frameId, pResultValue, ValueIsVariable);
}
Expand Down
3 changes: 2 additions & 1 deletion src/interfaces/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,14 @@ struct Variable
std::string type;
VariablePresentationHint presentationHint;
std::string evaluateName;
uint64_t memoryReference;
uint32_t variablesReference;
int namedVariables;
int indexedVariables;
int evalFlags;
bool editable;

Variable(int flags = defaultEvalFlags) : variablesReference(0), namedVariables(0), indexedVariables(0), evalFlags(flags), editable(false) {}
Variable(int flags = defaultEvalFlags) : memoryReference(0), variablesReference(0), namedVariables(0), indexedVariables(0), evalFlags(flags), editable(false) {}
};

enum VariablesFilter
Expand Down
4 changes: 4 additions & 0 deletions src/protocols/vscodeprotocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,15 @@ void to_json(json &j, const Scope &s) {
}

void to_json(json &j, const Variable &v) {
char memoryReference[19] = "0x0000000000000000";
snprintf(memoryReference, 19, "0x%016llx", v.memoryReference);

j = json{
{"name", v.name},
{"value", v.value},
{"type", v.type},
{"evaluateName", v.evaluateName},
{"memoryReference", memoryReference},
{"variablesReference", v.variablesReference}};

if (v.variablesReference > 0)
Expand Down