http://blog.gdb.wiki/2020/08/04/MacOS-LLDB插件开发/
https://reverse.put.as/2019/11/19/how-to-make-lldb-a-real-debugger/
https://lldb.llvm.org/python_reference/
https://www.youtube.com/watch?v=UgfzdAr9AFg
|--------------------------------|
|SBDebugger |
| |
| |-------------------------|
| |SBTarget | --> 其中包含多个 Module
| | | --> 每个module 又包含了多个 symbol
| | |-------------------|
| | |SBProcess |
| | | |
| | | |------------|
| | | |SBThread |
| | | | \\-SBFrame |
| | | | \\-SBFrame |
| | | | \\-SBFrame |
|--------------------------------|
symbol 包含对应的 name, StartAddress, EndAddress
lldb 载入一个 python 脚本的时候 会调用这个接口
lldb 加载 python 脚本的命令
command script add {command_name} -f {python_script_name}.{function_name or class_name}
一共有两种定义命令具体内容的办法,一是通过函数,而是通过类。很明显通过类会更加的具体、完整。
被绑定的方法需要有如下的参数:
def func(debugger: lldb.SBDebugger, command: str, result, internal_dict):
pass
command 是调用自定义命令时传入的参数。
同样,需要先 import 这个 py 文件,再执行 command script add -f peda.func func
,之后就可以调用 func
命令了。