how to compose an expression to display character array


  • I have a non-\0 terminated dynamic character array stored in a custom (legacy company) datastructure that looks like this

    struct Str {
       char* buf;
       int size;

    I am trying to compose a natvis display for this:

    <Type Name="Str">
       <DisplayString> {XXX} </DisplayString>

    It looks quite straightforward, however, I wasn't able to get a clean expression for XXX.  I tried the following:

    {buf,sb} - does not work, as buf is not zero-terminated.
    {buf,size} - does not work since apparently size can not be dynamic
    {(wchar(*)[size])buf} - does not work for the same reason, and also [] produces array visualization (not string)

    Any ideas how to produce a clean string expression out of this stuct?


    • Edited by slymz Friday, April 24, 2015 7:00 PM removed wchar, it is not related to the question
    Friday, April 24, 2015 6:47 PM

All replies