如果我用命令设置了一个自动继续断点,那么我还可以打印出断点id,以便知道哪个断点正在显示该命令。
在下面的列表中,我需要
br命令添加"print brk-id“27
但是,要这样做的命令是什么,我没有在文档中找到它,或者在上面找到它。
Current breakpoints:
27: regex = 'coordinateReadingItemAtURL', module = Foundation, locations = 28, resolved = 28, hit count = 16 Options: enabled auto-continue
Breakpoint commands:
po $rdx
27.1: where = Foundation`-[NSFileCoordinator coordinateReadingItemAtURL:options:error:byAccessor:], address = 0x00007fff534d2642, resolved, hit count = 3
27.2: where = Foundation`-[NSFileCoordinator(NSPrivate) _coordinateReadingItemAtURL:options:error:byAccessor:], address = 0x00007fff534d2695, resolved, hit count = 3
27.3: where = Foundation`__85-[NSFileCoordinator(NSPrivate) _coordinateReadingItemAtURL:options:error:byAccessor:]_block_invoke_2, address = 0x00007fff534d4d44, resolved, hit count = 2
27.4: where = Foundation`__85-[NSFileCoordinator(NSPrivate) _coordinateReadingItemAtURL:options:error:byAccessor:]_block_invoke.404, address = 0x00007fff534d52bf, resolved, hit count = 2
27.5: where = Foundation`__73-[NSFileCoordinator coordinateReadingItemAtURL:options:error:byAccessor:]_block_invoke, address = 0x00007fff534d5330, resolved, hit count = 2
27.6: where = Foundation`__73-[NSFileCoordinator coordinateReadingItemAtURL:options:error:byAccessor:]_block_invoke_2, address = 0x00007fff534d5559, resolved, hit count = 2
27.7: where = Foundation`__85-[NSFileCoordinator(NSPrivate) _coordinateReadingItemAtURL:options:error:byAccessor:]_block_invoke_2.405, address = 0x00007fff534d60e3, resolved, hit count = 2发布于 2019-01-09 01:32:05
我不认为有命令只会打印断点id。我所知道的最接近的是thread info
br command add -o "thread info"这将打印一组数据,最后是断点id:
thread #1: tid = 0x2220c5, 0x000000010b6cc4dd SomeSDK`-[ABClass method:], queue = 'com.apple.main-thread', stop reason = breakpoint 1.1此数据由thread-format设置控制。您可以将默认值更改为更简洁,例如:
settings set thread-format "thread #${thread.index}{, stop reason = ${thread.stop-reason}}"有了这个,thread info显示:
thread #1, stop reason = breakpoint 1.1请记住,此设置在其他地方使用,更改可以显示在其他地方。
最后,您可以使用Python。此命令将打印断点id:
br command add -s python -o 'print "{}.{}".format(bp_loc.GetBreakpoint().GetID(), bp_loc.GetID())'为了解释这一点,Python断点命令实际上是一个函数,您可以运行break list来查看lldb将如何调用它。其中一个参数是bp_loc,它是一个SBBreakpointLocation。为了获得完整的断点ID,这段代码结合了两个ID值:bp_loc.GetBreakpoint().GetID()和bp_loc.GetID()。
为了便于重用,您可以将其放入某个文件中,例如helpers.py。
# helpers.py
def brk_id(frame, bp_loc, internal_dict):
bp_id = bp_loc.GetBreakpoint().GetID()
loc_id = bp_loc.GetID()
print "{}.{}".format(bp_id, loc_id)然后在您的~/.lldbinit中导入它,如下所示:
command script import path/to/helpers.py现在您可以轻松地使用助手函数:
br command add -F helpers.brk_idhttps://stackoverflow.com/questions/54096381
复制相似问题