Anyone know how to place a tab or newline into the print message of a breakpoint and have it show up correctly?
Thus far I've tried '\t' and '\n' which give the same thing in the debug output. I've also tried just putting in 4 spaces, but they get removed after I click OK in the 'When Breakpoint is Hit' dialog.
I'm using VS.NET 20开发者_如何学Go08 with native code if that makes a difference.
Thanks.
You can specify any character in the message by including it in curly braces. For example, this will insert new line in the message: {'\n'}
. The problem is that character's value and single quotes will be printed, too. I tried to disable output of the character's value with all kinds of expression formatting, but nothing helps.
It is a bit clumsy solution, but it works if you need to break long statement into several lines. Other character are OK, as well. But don't put strings ({"\r\n"}
). It seems that VS debugger is able to print only single characters, but string literals.
In VS2010 you can paste in a tab you have copied into the "Print a message" edit box.
The only way I was able to create a newline in tracepoint output was as follows:
- Create the tracepoint with a placeholder marker for the newline, e.g. BREAKME;
- Export the breakpoint into XML (see also MSDN How to: Import and Export Breakpoints);
Manually edit the XML and replace BREAKME with a CDATA escape, with newline(s) you wanted instead of the marker:
<![CDATA[ ]]>
Remove the tracepoint from your breakpoints and re-import the XML.
OTOH, if you use the result for later text processing, you can auto-replace your marker at the later stages, and save yourself the steps 2-4...
Disclaimer/disclosure: I use Visual Studio at Microsoft, but I don't develop Visual Studio itself; what I write here isn't endorsed by Microsoft and expresses my private opinions only, etc.
精彩评论