6

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 2008 with native code if that makes a difference.

Thanks.

adam
  • 861
  • 8
  • 18
  • Does this answer your question? [How to output new line in Visual Studio actions?](https://stackoverflow.com/questions/43464123/how-to-output-new-line-in-visual-studio-actions) – fkorsa May 13 '20 at 08:55
  • See this answer: https://stackoverflow.com/a/43488943/4213607 – fkorsa May 13 '20 at 08:56
  • You can do the same for tabs with {"\t",s8b} – fkorsa May 13 '20 at 08:56

3 Answers3

2

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.

Alex Blekhman
  • 3,875
  • 2
  • 19
  • 18
  • This does not work for me (using VS 2012). All that's printed is in fact the string representation of the character in single quotes (`'\n'`). I could live with the fact, that this shows up in **addition** to the desired line break. However, no line break is inserted at all. – IInspectable Dec 08 '14 at 16:27
  • @IInspectable, you're right. It seems they fixed it. I tried with VS2013 and it doesn't work anymore. – Alex Blekhman Dec 08 '14 at 23:09
0

In VS2010 you can paste in a tab you have copied into the "Print a message" edit box.

Serge
  • 1
0

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.

The Hungry Dictator
  • 3,444
  • 5
  • 37
  • 53