简体   繁体   English

如何让 LLDB 打印当前行

[英]How to get LLDB to print current line

When running GDB, the debugger would print the current line it's at to give you an indication of where it's currently at.运行 GDB 时,调试器会打印它所在的当前行,以指示它当前所在的位置。

Seeing as I'm on Mavericks, GDB doesn't seem to be an option, and as such I'm forced to use LLDB.鉴于我在小牛队,GDB 似乎不是一个选择,因此我被迫使用 LLDB。 My question is: How do I get similar behaviour from LLDB?我的问题是:如何从 LLDB 获得类似的行为?

Currently all it does is print 7 or-so lines of code with an arrow pointing at the current line, rather than just printing the line it's on, which is rather cluttered to look at.目前它所做的只是打印 7 行左右的代码,箭头指向当前行,而不仅仅是打印它所在的行,这看起来很混乱。 LLDB also seems to ignore all output produced by printf LLDB 似乎也忽略了printf产生的所有输出

Is there a way to achieve the same, or similar results using LLDB?有没有办法使用 LLDB 实现相同或相似的结果?

I don't think the question you asked is exactly what you intended.我不认为你问的问题正是你想要的。 I assume you mean "How to get LLDB to print ONLY the current line" since, as you noted, it always prints the current line along with some lines of context.我假设您的意思是“如何让 LLDB 仅打印当前行”,因为正如您所指出的,它总是打印当前行以及一些上下文行。

Anyway, how many lines of source get printed when you stop is controlled by the two settings:无论如何,停止时打印多少行源代码由两个设置控制:

  stop-line-count-after    -- The number of sources lines to display that come after the current source line when displaying a stopped context.
  stop-line-count-before   -- The number of sources lines to display that come before the current source line when displaying a stopped context.

Actually these aren't quite right, since setting both to 0 shows no source lines, but setting "after" to 1 shows TWO stop lines.实际上这些并不完全正确,因为将两者都设置为 0 显示没有源代码行,但将“after”设置为 1 显示两个停止行。 Somebody apparently wanted to make it possible to show NO source lines, but didn't want to add an extra setting.显然有人想让显示 NO 源代码行成为可能,但不想添加额外的设置。

Anyway, you can't get just one line, but you can get it down to two.无论如何,你不能只得到一行,但你可以把它减少到两行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM