“formats.html”页面中提到的格式不是用于表达式,而是用于在lldb打印时打印线程和框架信息的方式。举例来说,我有这样的:
settings set thread-format thread #${thread.index}: tid = ${thread.id}{, name = ${thread.name}}{, function: ${function.name}} {, stop reason = ${thread.stop-reason}}{, return = ${thread.return-value}}\n
在我.lldbinit
,这样我就可以看到线程ID &的名字时,我停下来。
如果您正在Xcode中运行,您通常不会看到在停止时打印的线程信息,因为Xcode并没有在Xcode控制台的每个停止处都回显。但你仍然可以调用一些这方面的信息与“线程信息”命令:
(lldb) thread info
thread #1: tid = 0x34ca69, name = A_Cool_Thread, function: -[SKTGraphicView alignLeftEdges:] , stop reason = breakpoint 2.1
因此,对于你的目的,你可以把一个断点命令你关心的断点,并有命令是“线程信息”。然后每一站都会告诉你身份证和姓名等。
注意,另一种方式做同样的事情将是使用Python断点命令,例如:
(lldb) breakpoint command add -s python <BPNO>
Enter your Python command(s). Type 'DONE' to end.
def function (frame, bp_loc, internal_dict):
"""frame: the lldb.SBFrame for the location at which you stopped
bp_loc: an lldb.SBBreakpointLocation for the breakpoint location information
internal_dict: an LLDB support object not to be used"""
print "Thread ID is: ", frame.thread.GetThreadID(), " and name: ", frame.thread.GetName()
DONE
(lldb)
然后每次打断点,你会看到类似这样的时间:
Thread id is: 3459689 and name: A_Cool_Thread
顺便说一句,你没有说你在哪个系统上,但是在Mac OS X上这里列出的线程ID不是p线程ID。 pthread id只能保证在程序中给定时间存在的所有线程都是唯一的,所以当给定时间的程序中的每个线程都具有不同的pthread ID时,不能保证在不同时间的两个线程将会有不同的线程ID。但是,Mac OS X具有“全局唯一的线程ID”,这在程序运行过程中是唯一的。这就是这个线程ID。
已知这些变量不适用于表达式,它完全由设计决定。如果你想在表达式中检索线程信息,你需要像在代码中那样做。 – 2014-09-29 18:01:21