Display strings with embedded nulls in VS2010 debugger visualizer

In Visual Studio 2010, I am trying to have strings (char* and wchar_t*) display with embedded nulls in the various native C++ Debugger Visualizer components, such as the data tip area (Watch window, preview) and expanded area accessed by the magnifying glass (stringview). For example, I want to display a BSTR (embedded in an ATL::CComBSTR) with all of its content, even if null characters are in the string. By default, setting a pointer to ,s8, ,s, or ,su will treat the string as null-terminated, which is not the desired behavior. This question specifically applies to VS2010, not 2012, 2008, or prior versions.

Any clever ideas?

Upvotes: 2

Views: 420

Answers (1)

Hendrik Wagenaar
Hendrik Wagenaar

Reputation: 11

Any clever ideas?

Assuming you know when the data changes, and you have your own structure wrapping the BSTR, you could add a second debug only vector of strings (or a single string with some separator replacing the nulls) to your structure that you keep in sync with the string containing embedded nulls, then visualize the vector instead. It's not pretty, but it allows you to debug your code.

Upvotes: 1

Related Questions