Skip to content

Stack Trace and Value Formatting

Andrew Crawley edited this page Mar 21, 2018 · 4 revisions

Stack Trace and Value Formatting

Visual Studio provides options that let the user configure how stack traces and values are displayed. These settings are provided to the debug adapter via the ValueFormat and StackFrameFormat objects. The debug adapter should use the provided settings to format the value provided to Visual Studio.

Required Implementation

To support custom value formatting, a debug adapter must:

  • Return true for the supportsValueFormattingOptions field in the Capabilities object returned in response to the initialize request.
  • Use the values provided in the ValueFormat and StackTraceFormat objects to format stack traces and values as requested.

ValueFormat Object

A ValueFormat object is provided as a format argument to the evaluate, setExpression, setVariable, and variable requests, and contains the following fields:

Name Type Description
hex boolean Indicates that values should be provided in base-16.
rawValue boolean Indicates that string values should not have any formatting applied. For instance, newlines should not be replaced with a string like "\n".

StackFrameFormat Object

A StackFrameFormat object is provided as a format argument to the stackTrace request, and contains the following fields:

Name Type Description
hex boolean Indicates that values should be provided in base-16.
parameters boolean Indicates that parameters should be included.
parameterTypes boolean Indicates that parameter types should be included.
parameterNames boolean Indicates that parameter names should be included.
parameterValues boolean Indicates that parameter values should be included.
line boolean Indicates that the line number should be included.
module boolean Indicates that the module name should be included.
includeAll boolean Indicates that all stack frames should be included, even those the debug adapter might otherwise hide.

If no format argument is provided, the debug adapter should use its default formatting behavior.

Example

Assume the existance of a method called MyMethod, with an integer parameter parameter1 and a boolean parameter parameter2, defined in the module MyModule. If this method called with parameters "42" and "false", the corresponding stack frame could be formatted as follows:

hex parameters parameterTypes parameterNames parameterValues line module Example StackFrame.name value provided by adapter
false false false false false false false MyMethod
false false false false false true true MyModule!MyMethod Line 3
false true false false false true true MyModule!MyMethod() Line 3
false true true false false true true MyModule!MyMethod(int, bool) Line 3
false true true true false true true MyModule!MyMethod(int parameter1, bool parameter2) Line 3
false true true true true true true MyModule!MyMethod(int parameter1 = 42, bool parameter2 = false) Line 3
true true true true true false false MyMethod(int parameter1 = 0x2A, bool parameter2 = false)