Expressions in the Debugger - Visual Studio (Windows) (2023)

  • article

Applies to: Expressions in the Debugger - Visual Studio (Windows) (1)visual studyExpressions in the Debugger - Visual Studio (Windows) (2)Visual Studio for MacExpressions in the Debugger - Visual Studio (Windows) (3)visual study code

The Visual Studio debugger includes an expression evaluator when you're insidefast guarddialog box,I'm watchingwindows ordirectwindow. The expression evaluator also worksbreaking pointwindows and many other places in the debugger.

The following sections describe expression evaluation restrictions for languages ​​supported by Visual Studio.

F# expressions are not supported

The F# expression is not recognized. If you are debugging F# code, you must convert the expression to C# syntax before entering the expression into a debug window or dialog. When translating expressions from F# to C#, it is important to remember that C# uses==operator to check for equality, while F# uses a unique=.

C++ expression

For information about using contextual operators with expressions in C++, seeEnvironment Operators (C++).

Expressions are not supported in C++

Constructors, destructors and conversions

You cannot explicitly or implicitly call an object's constructor or destructor. For example, the following expression explicitly calls the constructor and results in an error message:

my_date (2, 3, 1985)

The conversion function cannot be called if the target of the conversion is a class. This conversion includes the construction of the item. For example ifminimum scoreis an examplegrade C, which defines the conversion function operatoralmost point, the following expression results in an error:

(fixed point) my rating

You cannot call new or delete operators. For example, the following expressions are not supported:

date (2.3.1985)

preprocessor macros

The debugger does not support preprocessor macros. For example, if a constantvaluedeclared as:#define value 3, you cannot usevalueindeI'm watchingwindow. To avoid this limitation, you should replace#definitionUse numbers and functions whenever possible.

Using namespace declarations

you cannot useuse namespaceannouncement. To access a type name or variable outside the current namespace, the fully qualified name must be used.

anonymous namespace

Anonymous namespaces are not supported. Unable to add if you have the following codetry itfor the protective window:

namespace mars { namespace { int test = 0; }}int main(){ // Adding a clock to a test has no effect. March::test++; return 0; }

Use debug properties to maintain state

Debug properties give you a way to call certain C/C++ functions in expressions without changing the state of your application.

Debug properties:

  • Guaranteed Safety: Running the debugger will not inherently destroy the debugging process.

  • allowed under all conditions, even when side effects and functional evaluation are not allowed.

  • It works in scenarios where normal function calls are not possible, such as debugging minidumps.

    Debugging properties can also make evaluating expressions more convenient. E.g,strncmp (str, "asd")Write in breakpoint mode fromstr[0] == 'a' && str[1] == 's' && str[2] == 'd')

areainternal function
string lengthstrlen, wcslen,strnlen, wcsnlen
strict comparisonstrcmp, wcscmp,strip, wcsicmp,_stricmp、_strcmpi、_wcsicmp、_wcscmpi,strncmp, wcsncmp,strnicmp, wcsnicmp,_strnicmp, _wcsnicmp
string searchstrchr, wcschr,memchr, wmemchr,strstr, wcssstr
Win32decoding factor,decoding indicator,get the latest error,gain value
windows 8RoInspectCapturedStackBackTrace,Windows compares string words,Windows are of string length,WindowsGetStringRawBuffer

These features require that the debugging process run on Windows 8. Debugging a dump file generated by a Windows 8 device also requires Visual Studio running on Windows 8. However, if you are debugging remotely on a device Windows 8, Visual The Studio engine runs Windows 7.
Windows are of string lengthandWindowsGetStringRawBufferUsed only by the execution engine (EE) at the source level.

Different kinds__log2- Returns the base 2 logarithm of the specified integer, rounded to the nearest smaller integer.

__findNonNull- Searches the index array and returns the index of the first non-zero element.
- Parameters: (1) pointer to the first element of the array (void*), (2) array size (unsigned int).
- Return value: (1) The 0-based index of the first non-zero element in the array, or -1 if not found.

Decode HString- Helper functions for formatting HSTRING values. Pop the HSTRING value off the stack, push bytes of the StringInfo structure that EE can use to tell where the string is. This is for internal EE use only. cannot be called directly by the user.

Decode WinRTRestrictedException- Decode limited WinRT exceptions for limited descriptors.
- Parameters: (1) A character representing the null-terminated string of the quoted string.
- Return value: character in a null-terminated string containing the actual error message to display.

dynamic casting- Implementer dynamic_cast.
- Parameters: (1) Pointer to the object to throw.
- Data item: A CDynamicCastData object must be associated as a data item with the corresponding ExecuteIntrinsic() command. The data element encodes the type we're converting to and whether we're evaluating a nightly expression (diagnostics are needed to escape infinite recursion).
- Return value: (1) A pointer to an object, cast to the correct type, or NULL if the cast object is not an instance of the correct type.

dynamic member posting- Helper function to dynamically get class member values

Get the length of the context block- Helper function to get the length of the context block in characters. for $env.

Stdext_HashMap_Int_OperatorBracket_idx- operator[] for stdext::hash_map. Assume the default hash function key is "int". return value. The native [] operator only supports retrieving existing elements from a hash table - it does not support inserting new elements into the table, as this can involve unnecessary complications such as memory allocation. However, the[] operator can be used to change the value associated with an existing key in the array.
- Stack parameters: (1) the address of the stdext::hash_map object, (2) the key (int) of the array, (3) a HashMapPdb structure that specifies the member field offset lookup that the function implementation should perform. This is required because the remote side does not have direct access to the symbols.
- Return value: (1) If the key is in the array, return the address of the value corresponding to the key. Otherwise NULL.

Std_UorderedMap_Int_OperatorBracket_idx- std::unordered_map works the same as stdext::hash_map except for the hash function.

ConcurrencyArray_OperatorBracket_idx// both ::array<>::operator[index<>] and operator(index<>)

ConcurrencyArray_OperatorBracket_int// samtidig ::array<>::operator(int, int, ...)

ConcurrencyArray_OperatorBracket_tidx// simultaneously :: array<>::operator[tiled_index<>] and operator(tiled_index<>)

ConcurrencyArrayView_OperatorBracket_idx// both ::array_view<>::operator[index<>] and operator(index<>)

ConcurrencyArrayView_OperatorBracket_int// samtidig ::array_view<>::operator(int, int, ...)

ConcurrencyArrayView_OperatorBracket_tidx// samtidig ::array_view<>::operator[tiled_index<>] og operator(tiled_index<>)

traversal_initialization tree- Start a new tree traversal.
- Stack parameters: (1) the address of the root node, (2) a hint about the maximum depth to use. Items that exceed this depth will be moved to the queue for later processing.
- Subroutine Parameters: (1) Node Validity (optional).
- Return value: (1) An opaque byte sequence encoding the tree traversal status.

traversal_next tree- Retrieve a node from a pending tree traversal.
- stack parameters: (1) an opaque byte array representing the state of the tree traversal, (2) the number of nodes to retrieve.
- Subroutine arguments (must match the call to TreeTraverse_Init()): (1) left child, (2) right child, (3) node validity (optional).
- Return value: (1) The number of nodes retrieved (note: pushed after the node itself so it can be popped first). If less nodes than requested are received, it means the end of the tree. (2) For each node received, the address of the node. (3) New function for opaque tree encoding byte sequence

traversal_skip tree- Skipping nodes in a pending tree traversal.
- stack parameters: (1) an opaque byte array representing the state of the tree traversal, (2) the number of nodes to skip.
- Subroutine arguments (must match in successive calls to Next() on the same counter: (1) left child, (2) right child, (3) node validity (optional).
- Return value: (1) the actual number of elements skipped (may be less than requested), (2) an opaque byte sequence encoding the new state of the tree traversal

C++/CLI - unsupported expression

  • Broadcasts that include pointers or custom broadcasts are not supported.

  • Comparing and assigning objects is not supported.

  • Overloaded operators and overloaded functions are not supported.

  • Encapsulation and decoding are not supported.

  • SizeThe operator is not supported.

C# - Unsupported expression

dynamic object

You can use statically typed dynamic variables in debug expressions. when the object implementsIDynamicMetaObjectProvider dynamic meta object providerAfter evaluation in the watch window, a dynamic view node is added. Dynamic view nodes display object members but do not allow editing of member values.

The following features on dynamic objects are not supported:

  • compound operator+=,-=,%=,/=, and*=

  • Many versions, including numerical models and parameter types

  • Method calls with more than two parameters

  • Property getters with more than two parameters

  • property setter with parameters

  • is assigned to the indexer

  • boolean operator&&and||

anonymous method

Creating new anonymous methods is not supported.

Visual Basic - Unsupported expression

dynamic object

You can use statically typed dynamic variables in debug expressions. when the object implementsIDynamicMetaObjectProvider dynamic meta object providerAfter evaluation in the watch window, a dynamic view node is added. Dynamic view nodes display object members but do not allow editing of member values.

The following features on dynamic objects are not supported:

  • compound operator+=,-=,%=,/=, and*=

  • Many versions, including numerical models and parameter types

  • Method calls with more than two parameters

  • Property getters with more than two parameters

  • property setter with parameters

  • is assigned to the indexer

  • boolean operator&&and||

local constant

Local constants are not supported.

input alias

Entering aliases is not supported.

variable declaration

You cannot declare explicit new variables in the debugger window. However, you can assign new implicit variables insidedirectwindow. These implicit variables are covered only by the debugger session and cannot be accessed outside the debugger. For example stateØ = 5implicitly creates a new variableOhand assign the value 5 to it. Such implicit variables are of typePurposeUnless the debugger can infer the type.

unsupported keyword

  • address

  • end

  • error

  • Exit

  • I am going

  • When something goes wrong

  • restore

  • RETURN

  • Election/Case

  • I am waiting

  • sync lock

  • Shot

  • try/catch/finally

  • and

  • Names or module level keywords likefinally belowthemeasurement unit.

See also

  • Format specifications in C++
  • Environment Operators (C++)
  • Format Specifiers in C#
  • dummy variable

References

Top Articles
Latest Posts
Article information

Author: Tyson Zemlak

Last Updated: 08/12/2023

Views: 5971

Rating: 4.2 / 5 (43 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Tyson Zemlak

Birthday: 1992-03-17

Address: Apt. 662 96191 Quigley Dam, Kubview, MA 42013

Phone: +441678032891

Job: Community-Services Orchestrator

Hobby: Coffee roasting, Calligraphy, Metalworking, Fashion, Vehicle restoration, Shopping, Photography

Introduction: My name is Tyson Zemlak, I am a excited, light, sparkling, super, open, fair, magnificent person who loves writing and wants to share my knowledge and understanding with you.