microsoft / ConcordExtensibilitySamples

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

$CALLSTACK and $CALLER in Debugger Trace points #98

Closed RobertvanderHulst closed 1 year ago

RobertvanderHulst commented 1 year ago

If you set a debugger tracepoint and include the $CALLSTACK token, then the output windows shows the current callstack. For our language, the assembly name and member names are shown, but not the class name. For example

for a member Foo in the class MyNs.Bar in the assembly MyAsm the output window shows: MyAsm.dll!Foo where I expected to see MyAsm.dll!MyNs.Bar.Foo

I see the same problem for the $CALLER token. This gets shown as Foo and not MyNs.Bar.Foo. The $FUNCTION token however does include the namespace, classname, member name and parameter list.

Where does the debugger get the name from for the $CALLER and $CALLSTACK tokens? I have implemented IVsLanguageDebugInfo in our language service and the GetNameOfLocation() of method, but that does not seem to get called.

gregg-miskelly commented 1 year ago

Have you implemented an expression evaluator? If not, those strings will be coming from the default expression evaluator. I am guessing you have a .NET-based language? If so, the default is the C# expression evaluator and I believe will obtain the class/method names from metadata.

IVsLanguageDebugInfo is not used for all that much. From what I recall, GetNameOfLocation is used get the names of methods to display in the breakpoints window when a breakpoint isn't bound yet. There may be a few other uses that I am not thinking of, but 98% of the information that the debugger shows about the target program are going to come from the debugger rather than the language service.

RobertvanderHulst commented 1 year ago

@gregg-miskelly Yes, we have implemented an expression evaluator (also based on the Roslyn expression evaluator). Do you have any idea which method / property is called to retrieve these values ? I see that GetNameOfLocation is called and also GetProximityExpressions. We have implemented both and they work. We see the names of the methods and the autos window is also filled.

gregg-miskelly commented 1 year ago

I would expect it to call IDkmLanguageInstructionDecoder.GetFrameName with DkmFrameFormatOptions.ArgumentFlags=DkmVariableInfoFlags.None and DkmFrameFormatOptions.FrameNameFormat=DkmFrameNameFormatOptions.Module

RobertvanderHulst commented 1 year ago

Thanks, that helped.

Robert