microsoft / microsoft/ConcordExtensibilitySamples

Difficulties changing names on DkmEvaluationResults

Open
#79 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
135
Forks
54
Avg merge
5h 58m
Merged PRs (30d)
3

Description

This is not really an issue per se, more of a question of how to use the API.

I have a modified CCppCustomVisualizer class I'm working on, for a complex object(the object is actually a collection of structs residing in different memory locations, so the object can have 0-N "members"). So far so good, I've gotten it to work and when resolving the complex object, it has a dynamic amount of children.

The problem I'm encountering is when I try to rename the children by recreating a DkmSuccessEvaluationResult, is that the little "+" next to the object stops working in Visual Studios 'Watch' window, i.e. we cannot expand the child components. However, dragging the child member so it creates a new entry in the 'Watch' window, allows expansion. Also, not renaming/recreating DkmSuccessEvaluationResult also works.

HRESULT STDMETHODCALLTYPE CCppCustomVisualizerService::GetItems(
   _In_ Evaluation::DkmVisualizedExpression *pVisualizedExpression,
   _In_ Evaluation::DkmEvaluationResultEnumContext *pEnumContext,
   _In_ UINT32 StartIndex, _In_ UINT32 Count,
   _Out_ DkmArray<Evaluation::DkmChildVisualizedExpression *> *pItems) {
 HRESULT hr;
 hr = DkmAllocArray(Count, pItems);
 if (FAILED(hr)) {
   return hr;
 }

 Evaluation::DkmPointerValueHome *pPointerValueHome =
     Evaluation::DkmPointerValueHome::TryCast(
         pVisualizedExpression->ValueHome());

 vector<name_and_expr> comps;
 hr = evaluate_entity(pVisualizedExpression, pPointerValueHome, comps);
 if (FAILED(hr)) {
   return hr;
 }

 for (UINT32 i = StartIndex; i < StartIndex + Count; ++i) {
   const name_and_expr &expr = comps[i];
   DkmChildVisualizedExpression **children = pItems->Members;
   DkmChildVisualizedExpression **pChild = &children[i];

   CComPtr<DkmEvaluationResult> pEEEvaluationResultOther;
   hr =
       EvaluateOtherExpression(pVisualizedExpression, DkmEvaluationFlags::None,
                               expr._expr.c_str(), &pEEEvaluationResultOther);
   CComPtr<DkmString> pName;
   hr = DkmString::Create(DkmSourceString(expr._name.c_str()), &pName);
   if (FAILED(hr)) {
     return hr;
   }

   if (pEEEvaluationResultOther->TagValue() ==
           DkmEvaluationResult::Tag::SuccessResult &&
       !expr._name.empty()) {
     DkmSuccessEvaluationResult *success =
         DkmSuccessEvaluationResult::TryCast(pEEEvaluationResultOther);

     CComPtr<DkmSuccessEvaluationResult> pNamedEEEvaluationResultOther;

     // NOTE: HERE IS THE PROBLEM CODE
     // Createa success result, but with a custom name
     // Either using 'success->Name()' or 'pName' here leads to a child member which cannot be expanded
     hr = DkmSuccessEvaluationResult::Create(
         success->InspectionContext(), success->StackFrame(), success->Name(),
         success->FullName(), success->Flags(), success->Value(),
         success->EditableValue(), success->Type(), success->Category(),
         success->Access(), success->StorageType(),
         success->TypeModifierFlags(), success->Address(),
         success->CustomUIVisualizers(), success->ExternalModules(),
         DkmDataItem::Null(), &pNamedEEEvaluationResultOther);

     pEEEvaluationResultOther = pNamedEEEvaluationResultOther.Detach();
     // NOTE: PROBLEM CODE END
   }

   DkmChildVisualizedExpression::Create(
       pVisualizedExpression->InspectionContext(),
       pVisualizedExpression->VisualizerId(),
       pVisualizedExpression->SourceId(), pVisualizedExpression->StackFrame(),
       pPointerValueHome, pEEEvaluationResultOther.Detach(),
       pVisualizedExpression, i, DkmDataItem::Null(), pChild);
 }

 return S_OK;
}

Image of the result, where the selected row cannot be expanded, but as you can see, the row at the end containing the same expression can be.
image

Do you have any idea what could cause such a behavior? Is it possible to change the 'Name' of a DkmEvaluationResult in some other way? Or clone it somehow? I have used the same approach in another part of the code, and there it works. You can check the fork with modified CppCustomVisualizer/dll and CppCustomVisualizer/TargetApp here: https://github.com/fredrikz/ConcordExtensibilitySamples

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in CCppCustomVisualizerService::GetItems in the CppCustomVisualizer code and compare the child-creation path with and without recreating DkmSuccessEvaluationResult. Reproduce the Watch-window behavior using the linked CppCustomVisualizer/dll and TargetApp fork; done means renamed child results remain expandable.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.