(lldb) image help
Commands for accessing information for one or more target modules.
Syntax: target modules <sub-command> ...
The following subcommands are supported:
add -- Add a new module to the current target's modules.
dump -- Commands for dumping information about one or more target modules.
list -- List current executable and dependent shared library images.
load -- Set the load addresses for one or more sections in a target module.
lookup -- Look up information within executable and dependent shared library images.
search-paths -- Commands for managing module search paths for a target.
show-unwind -- Show synthesized unwind instructions for a function.
以上是有关image的命令。image主要用于搜索modules内的代码定位、执行等信息,modules主要包括“executable, frameworks, or plugins”,最主要的还是查看dynamic libraries库。
//将会在控制台中输出所有加载的modules的信息。
(lldb)image list
[ 0] 60F7CBED-F929-36C3-B25D-93843480A1E7 0x0000000103b65000 /Users/zhangguolin/Library/Developer/Xcode/DerivedData/Signals-glcoyiscddhlkrdlzqlhpctitugj/Build/Products/Debug-iphonesimulator/Signals.app/Signals
[ 1] 289AB27E-F09F-3384-A14A-100431139559 0x000000010484e000 /usr/lib/dyld
[ 2] C3514384-926E-3813-BF0C-69FFC704E283 0x0000000103b9a000 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/dyld_sim
聚焦某个特定的module
(lldb) image list Foundation
[ 0] E5391C7B-0161-33AF-A5A7-1E18DBF9041F
//表示的module的UUID
0x0000000103e99000
//表示内存中地址
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Foundation.framework/Foundation
//表示子硬盘中的地址
(lldb)
//image lookup 表示查找
// -n 精准匹配
// -rn 表示regex匹配
image lookup -n "-[UIViewController viewDidLoad]"
//表示匹配UIViewController的分类
image lookup -rn '\[UIViewController\(\w+\)\'
//获取栈内信息
(lldb) frame info
frame #0: 0x000000010bd35550 Commons`__34+[UnixSignalHandler sharedHandler]_block_invoke(.block_descriptor=0x000000010bd3b200) at UnixSignalHandler.m:72
// 查看指定模块汇总的_block_invoke
(lldb) image lookup -rn _block_invoke Commons
6 matches found in /Users/zhangguolin/Library/Developer/Xcode/DerivedData/Signals-glcoyiscddhlkrdlzqlhpctitugj/Build/Products/Debug-iphonesimulator/Signals.app/Frameworks/Commons.framework/Commons:
Address: Commons[0x0000000000001980] (Commons.__TEXT.__text + 1216)
Summary: Commons`__32-[UnixSignalHandler initPrivate]_block_invoke at UnixSignalHandler.m:82 Address: Commons[0x0000000000001bf0] (Commons.__TEXT.__text + 1840)
Summary: Commons`__32-[UnixSignalHandler initPrivate]_block_invoke.27 at UnixSignalHandler.m:109 Address: Commons[0x0000000000001540] (Commons.__TEXT.__text + 128)
Summary: Commons`__34+[UnixSignalHandler sharedHandler]_block_invoke at UnixSignalHandler.m:71 Address: Commons[0x0000000000001db0] (Commons.__TEXT.__text + 2288)
Summary: Commons`__38-[UnixSignalHandler appendSignal:sig:]_block_invoke at UnixSignalHandler.m:123 Address: Commons[0x0000000000001df0] (Commons.__TEXT.__text + 2352)
Summary: Commons`__38-[UnixSignalHandler appendSignal:sig:]_block_invoke_2 at UnixSignalHandler.m:127 Address: Commons[0x0000000000002180] (Commons.__TEXT.__text + 3264)
Summary: Commons`__38-[UnixSignalHandler appendSignal:sig:]_block_invoke_3 at UnixSignalHandler.m:139
//在此处添加断点
(lldb) rb appendSignal.*_block_invoke -s Commons
Breakpoint 2: 3 locations.
2019-04-18 16:41:12.435275+0800 Signals[2981:281824] Appending new signal: SIGWINCH
//查看当前变量信息
(lldb) frame variable
(__block_literal_6 *) .block_descriptor = 0x000000010bd3b2e0
//查看 __block_literal_6信息
(lldb) image lookup -t __block_literal_6
Best match found in /Users/zhangguolin/Library/Developer/Xcode/DerivedData/Signals-glcoyiscddhlkrdlzqlhpctitugj/Build/Products/Debug-iphonesimulator/Signals.app/Frameworks/Commons.framework/Commons:
id = {0x100000d35}, name = "__block_literal_6", byte-size = 32, decl = UnixSignalHandler.m:139, compiler_type = "struct __block_literal_6 {
void *__isa;
int __flags;
int __reserved;
void (*__FuncPtr)();
__block_descriptor *__descriptor;
}"
(lldb) po ((__block_literal_6 *)0x000000010bd3b2e0)
<__NSGlobalBlock__: 0x10bd3b2e0>
// block 下的执行体信息
(lldb) p/x ((__block_literal_6 *)0x000000010bd3b2e0)->__FuncPtr
(void (*)()) $4 = 0x000000010bd36180 (Commons`__38-[UnixSignalHandler appendSignal:sig:]_block_invoke_3 at UnixSignalHandler.m:139)
(lldb) p/x ((__block_literal_6 *)0x000000010bd3b2e0)
(__block_literal_6 *) $5 = 0x000000010bd3b2e0
(lldb) p ((__block_literal_6 *)0x000000010bd3b2e0)
(__block_literal_6 *) $6 = 0x000000010bd3b2e0
(lldb) p/x ((__block_literal_6 *)0x000000010bd3b2e0)->__isa
(void *) $7 = 0x000000010fb60470
(lldb) p $7
(void *) $7 = 0x000000010fb60470
(lldb) po 0x000000010fb60470
__NSGlobalBlock__
(lldb) p/x ((__block_literal_6 *)0x000000010bd3b2e0)->__flags
(int) $9 = 0x50000000
(lldb) po $9
0x50000000
(lldb) p *$7
(lldb) po [__NSGlobalBlock__ superclass]
__NSGlobalBlock
(lldb) po id $block = (id)0x000000010bd3b2e0
(lldb) po [$block retain]
<__NSGlobalBlock__: 0x10bd3b2e0>
(lldb) po [$block invoke]
nil
(lldb)
网友评论