admin管理员组文章数量:1024727
In LLDB you can do the following during a debugging session to add missing symbols at particular addresses:
target modules load --file <symbol file> .text 0x<address>
How can you do that in with the LLDB Python scripting module? I searched through the API but I couldn't find a corresponding method.
In LLDB you can do the following during a debugging session to add missing symbols at particular addresses:
target modules load --file <symbol file> .text 0x<address>
How can you do that in with the LLDB Python scripting module? I searched through the API but I couldn't find a corresponding method.
Share Improve this question asked Nov 18, 2024 at 11:35 KotosifKotosif 3531 gold badge3 silver badges13 bronze badges2 Answers
Reset to default 0I figured it out. You can make use of the debugger.HandleCommand
to run arbitrary LLDB command. The general way I resolved this was to define and register a function that can be called during a LLDB debugging session.
For example:
def load_libraries(debugger, command, result, internal_dict):
print(f"image add some_library.so", flush=True)
debugger.HandleCommand(f"image add some_library.so")
print(f"target modules load --file some_library.so .text 0x<some address>", flush=True)
debugger.HandleCommand(f"target modules load --file some_library.so .text 0x<some address>")
The SBTarget manages the list of modules. So you would add a module to the target (but not give it load addresses) using SBTarget::AddModule
. Then to give load addresses to the module, you can either use SBTarget::SetModuleLoadAddress
- if the whole module loads rigidly like on Darwin, or go through the sections of the module using SBTarget::SetSectionLoadAddress
if the sections load at different offsets as happens on ELF systems.
You might take a look at the symbolication.py module - particularly add_module
and load_module
. It's a pretty fully worked out version of how to recreate the symbol world of a binary from a list of modules and load addresses, then looking up addresses in that context. That's at:
https://github/llvm/llvm-project/blob/main/lldb/examples/python/symbolication.py
In LLDB you can do the following during a debugging session to add missing symbols at particular addresses:
target modules load --file <symbol file> .text 0x<address>
How can you do that in with the LLDB Python scripting module? I searched through the API but I couldn't find a corresponding method.
In LLDB you can do the following during a debugging session to add missing symbols at particular addresses:
target modules load --file <symbol file> .text 0x<address>
How can you do that in with the LLDB Python scripting module? I searched through the API but I couldn't find a corresponding method.
Share Improve this question asked Nov 18, 2024 at 11:35 KotosifKotosif 3531 gold badge3 silver badges13 bronze badges2 Answers
Reset to default 0I figured it out. You can make use of the debugger.HandleCommand
to run arbitrary LLDB command. The general way I resolved this was to define and register a function that can be called during a LLDB debugging session.
For example:
def load_libraries(debugger, command, result, internal_dict):
print(f"image add some_library.so", flush=True)
debugger.HandleCommand(f"image add some_library.so")
print(f"target modules load --file some_library.so .text 0x<some address>", flush=True)
debugger.HandleCommand(f"target modules load --file some_library.so .text 0x<some address>")
The SBTarget manages the list of modules. So you would add a module to the target (but not give it load addresses) using SBTarget::AddModule
. Then to give load addresses to the module, you can either use SBTarget::SetModuleLoadAddress
- if the whole module loads rigidly like on Darwin, or go through the sections of the module using SBTarget::SetSectionLoadAddress
if the sections load at different offsets as happens on ELF systems.
You might take a look at the symbolication.py module - particularly add_module
and load_module
. It's a pretty fully worked out version of how to recreate the symbol world of a binary from a list of modules and load addresses, then looking up addresses in that context. That's at:
https://github/llvm/llvm-project/blob/main/lldb/examples/python/symbolication.py
本文标签: LLDB Python scriptinghow to add module or load symbol file at particular addressStack Overflow
版权声明:本文标题:LLDB Python scripting - how to add module or load symbol file at particular address? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745621102a2159575.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论