简体   繁体   中英

Limit display of char* in natvis file to specific length

I've got a custom data structure holding a char* buffer with two lengths associated: maximum and actual length:

struct MyData {
  char* data;
  int length;
  int capacity;
};

In the Visual Studio (2015) debugger visualizer I only want to display the first length elements of the data buffer and not the (usually uninitialized) remaining elements.

I've the following rule in my custom .natvis file for displaying my custom data structure:

<Type Name="MyData">
  <DisplayString>content="{data,su}" length={length}</DisplayString>
</Type>

Is it possible to only display data as a " su "-encoded string from data[0] to data[length-1] ?

This will limit the length of the string in the debugger:

<Type Name="MyData">
    <DisplayString>{data,[length]su}</DisplayString>
</Type>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM