microsoft / ConcordExtensibilitySamples

Visual Studio Debug Engine Extensibility Samples
Other
122 stars 50 forks source link

Support for Tree like variables in IDkmClrExpressionCompiler.GetClrLocalVariableQuery #31

Closed onor13 closed 7 years ago

onor13 commented 7 years ago

Hello, the language I am trying to implement has a tree like structure variables, where only leaves has actual values, any other node value is the concatenation of his children (=sub nodes) and each leave may contain a different type of data. When composing the list of locals variables (type DkmClrLocalVariableInfo) in the IDkmClrExpressionCompiler.GetClrLocalVariableQuery, I got a dilemma with 2 possible choices: 1) Each tree structure variable will be contained in 1 DkmClrLocalVariableInfo. In this case the tree like variables can be nicely displayed (by constructing a MSIL class for each tree like variable) but I didn’t find any way to obtain the Type information for each leaf in my IDkmClrFormatter.GetTypeName implementation. When displaying simple variable, the type information can be stored in DkmClrCustomTypeInfo class when building the DkmClrLocalVariableInfo and then retrieved from the parameters of the IDkmClrFormatter.GetTypeName function. With the tree structure variables, for each node we will pass by IDkmClrFormatter.GetTypeName function and only for the root node I can retrieve the DkmClrCustomTypeInfo, for all the sub nodes of this tree the value will be null. Well, even if it was not null it would not help because the order in which nodes are visited is unpredictable, so no way to store the information for all the nodes in one instance of the DkmClrCustomTypeInfo. vars 2) The second possibility: for each leave or node of the tree like variable create a different DkmClrLocalVariableInfo, so we have 1 to 1 relation between DkmClrLocalVariableInfo and IDkmClrFormatter. But in the case I lose the tree structure representation.

Also, due to the complexity of data types there is no way create 1 to 1 relation between my custom language and MSIL, which of course would have solved the problem.

Any suggestions? Maybe instead of IDkmClrFormatter there is a different interface that I can implement that offers more flexibility?

Thank you in advance, Vladimir

plnelson commented 7 years ago

Hello Vladimir, There is a way you can control the tree expansion in your expression evaluator. We haven't documented it yet because the API is incomplete and at this time doesn't play well with the C# implementation if you want to have it take over expansion of children. We have plans for fixing this in a future version of Visual Studio and will update the sample and documentation when it's available.

In the meantime, if you want to experiment with the existing API, take a look at IDkmClrResultProvider. If you implement this interface - and configure Concord to use it via your vsdconfig file, you can take over creation of DkmSuccessEvaluationResults and DkmFailureEvaluationResults. These are the underlying data structures Concord uses for nodes in the evaluation windows. You can see the Roslyn implementation of this interface here. Good luck! -Patrick

onor13 commented 7 years ago

Hello, I tried to add the support for IDkmClrResultProvider, but I am having trouble with the registration of this component. Actually, lately I am having trouble with the registration of others components too. For example I moved my implementation of IDkmClrFormatter to another folder (and updating .vsdconfig) and IDkmClrFormatter is not recognized correctly anymore. I tried to move it back, still doesn't work. The error isn't very clrear, it just says: "Internal error retrieving local value." for each local variable. And yes, I checked the Path in the Class Name like 10 times to be sure, it's not it. Maybe Visual Studio keeps some old info in the cache somewhere? Is there a way to reset it? I am testing with Visual Studio 14 Experimental instance, I did reset the configuration with CreateExpInstance.exe /Reset /VSInstance=14.0 /RootSuffix=Exp but it did not help. Vladimir.

gregg-miskelly commented 7 years ago

Are you seeing your dll get loaded at all? (you can check the modules/output window) If you turn off Just My Code, do you see any exceptions in your scenario?

onor13 commented 7 years ago

The dll is loaded, and the IDkmClrExpressionCompiler is triggered and executed correctly. The Just My Code is already turned off. The only message I am seeing is

"Internal error retrieving local value."
for the variable I am trying to get the value. If I disable the IDkmClrFormatter, everything works fine. There is one (maybe) relevant message is the Debug window log: Exception thrown: 'System.ArgumentException' in vsdebugeng.manimpl.dll But the same exception is shown even when IDkmClrFormatter is disabled.

plnelson commented 7 years ago

?? Looks like there are now 3 different problems you are running into that we are tracking with the same GitHub issue. Perhaps IM/email is a better forum than GitHub issues related to the sample?