在指定的模块/共享库中,使用GDB/LLDB在所有函数处设置断点。

7
lldb中,我输入了命令help breakpoint set:
       -a <address-expression> ( --address <address-expression> )
        Set the breakpoint at the specified address.  If the address maps uniquely to a particular binary, then the address will be converted to a "file" address, so that the
        breakpoint will track that binary+offset no matter where the binary eventually loads.  Alternately, if you also specify the module - with the -s option - then the
        address will be treated as a file address in that module, and resolved accordingly.  Again, this will allow lldb to track that offset on subsequent reloads.  The
        module need not have been loaded at the time you specify this breakpoint, and will get resolved when the module is loaded.

并且。
       -r <regular-expression> ( --func-regex <regular-expression> )
        Set the breakpoint by function name, evaluating a regular-expression to find the function name(s).

并且。
   -s <shlib-name> ( --shlib <shlib-name> )
        Set the breakpoint only in this shared library.  Can repeat this option multiple times to specify multiple shared libraries.

现在我想在指定的模块/ dylib 的每个函数处设置断点,您可以在命令 image list -f 的结果中找到它们。
libobjc.A.dylibMyOwn.dylib为例。我尝试了以下命令但失败了:
(lldb) breakpoint set -r libobjc.A.dylib
Breakpoint 1: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.

(lldb) b +[ThunderManager load]
Breakpoint 2: where = MyOwn.dylib`+[ThunderManager load] +16 at ThunderManager.m:20, address = 0x000000010489f274

(lldb) breakpoint set -r MyOwn.dylib`*
Breakpoint 3: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.

我希望在lldb中对模块libobjc.A.dylibMyOwn.dylib等已加载的模块/共享库中的所有函数设置断点。如何在lldb中设置断点?


旁注 - 如果你将搜索更改为单个函数,我喜欢这个命令:(lldb) breakpoint set -F access -s libsystem_kernel.dylib - rustyMagnet
1个回答

11
(lldb) break set -r . -s libobjc.A.dylib

-s选项的值是一个共享库,它将断点限制在指定的共享库中。您可以多次使用-s选项以指定要包含在断点搜索中的多个共享库。

-r选项的值是一个正则表达式;如果符号名称与该表达式匹配,则将其包括在断点中。. 匹配所有内容。

lldb教程:

http://lldb.llvm.org/tutorial.html

从描述lldb命令的结构开始,这可能会对您有所帮助。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接