深入探索共享库与多线程调试
1. 支持多个 ELF 文件的函数查找
在查找目标中的函数时, std::target::find_functions 函数需要遍历目标中的所有 ELF 文件。我们可以通过将代码(除了第一条和最后一条语句)封装在一个 lambda 表达式中,进行一些小的修改,并将其传递给 sdb::elf_collection::for_each 来实现:
sdb::target::find_functions_result
sdb::target::find_functions(std::string name) const {
find_functions_result result;
elves_.for_each([&](auto& elf) {
auto dwarf_found = elf.get_dwarf().find_functions(name);
if (dwarf_found.empty()) {
auto elf_found = elf.get_symbols_by_name(name);
for (auto sym : elf_found) {
result.elf_functions.push_back(std::pair{ &elf, sym });
}
}
else {
// --snip--
}
超级会员免费看
订阅专栏 解锁全文
1183

被折叠的 条评论
为什么被折叠?



