开发者

Visual Studio insert tabs/newlines in breakpoint print message (tracepoint)?

开发者 https://www.devze.com 2022-12-20 23:18 出处:网络
Anyone know how to place a tab or newline into the print message of a breakpoint and have it show up correctly?

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:

  1. Create the tracepoint with a placeholder marker for the newline, e.g. BREAKME;
  2. Export the breakpoint into XML (see also MSDN How to: Import and Export Breakpoints);
  3. Manually edit the XML and replace BREAKME with a CDATA escape, with newline(s) you wanted instead of the marker:

    <![CDATA[
    
    ]]>
    
  4. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消