Visual Studio 在断点打印消息(跟踪点)中插入制表符/换行符?
有人知道如何将制表符或换行符放入断点的打印消息中并使其正确显示吗?
到目前为止,我已经尝试过 '\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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以通过将其包含在花括号中来指定消息中的任何字符。例如,这将在消息中插入新行:
{'\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.在 VS2010 中,您可以将复制的选项卡粘贴到“打印消息”编辑框中。
In VS2010 you can paste in a tab you have copied into the "Print a message" edit box.
我能够在跟踪点输出中创建换行符的唯一方法如下:
手动编辑 XML 并将 BREAKME 替换为 CDATA 转义符,并使用您想要的换行符而不是标记:
<前><代码>
从断点中删除跟踪点并重新导入 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:
Manually edit the XML and replace BREAKME with a CDATA escape, with newline(s) you wanted instead of the marker:
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.