Visual Studio 在断点打印消息(跟踪点)中插入制表符/换行符?

发布于 2024-08-23 00:22:46 字数 189 浏览 9 评论 0原文

有人知道如何将制表符或换行符放入断点的打印消息中并使其正确显示吗?

到目前为止,我已经尝试过 '\t' 和 '\n',它们在调试输出中给出了相同的结果。我也尝试过只输入 4 个空格,但在“命中断点时”对话框中单击“确定”后,它们被删除。

我将 VS.NET 2008 与本机代码一起使用(如果这有影响的话)。

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

君勿笑 2024-08-30 00:22:46

您可以通过将其包含在花括号中来指定消息中的任何字符。例如,这将在消息中插入新行:{'\n'}。问题是字符的值和单引号也会被打印。我尝试使用各种表达式格式禁用字符值的输出,但没有任何帮助。

这是一个有点笨拙的解决方案,但如果您需要将长语句分成几行,它就可以工作。其他角色也都OK。但不要输入字符串 ({"\r\n"})。 VS 调试器似乎只能打印单个字符,但可以打印字符串文字。

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.

萌辣 2024-08-30 00:22:46

在 VS2010 中,您可以将复制的选项卡粘贴到“打印消息”编辑框中。

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

简单 2024-08-30 00:22:46

我能够在跟踪点输出中创建换行符的唯一方法如下:

  1. 使用换行符的占位符标记创建跟踪点,例如 BREAKME;
  2. 将断点导出为 XML(另请参阅 MSDN 如何:导入导出断点);
  3. 手动编辑 XML 并将 BREAKME 替换为 CDATA 转义符,并使用您想要的换行符而不是标记:

    <前><代码>

  4. 从断点中删除跟踪点并重新导入 XML。 p>

OTOH,如果您将结果用于后续文本处理,您可以在后续阶段自动替换标记,并节省步骤 2-4...

免责声明/披露:我使用 Visual Studio在 Microsoft,但我不开发 Visual Studio 本身;我在这里写的内容没有得到微软的认可,仅表达我的个人观点等。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文