Print function name and file location when caught a SIGSEGV
This commit is contained in:
@@ -7,19 +7,41 @@
|
||||
class LibelfinBinding
|
||||
{
|
||||
public:
|
||||
LibelfinBinding(int fd)
|
||||
LibelfinBinding(int fd, uintptr_t _loadoffset)
|
||||
: elf(elf::create_mmap_loader(fd)),
|
||||
dwarf(dwarf::elf::create_loader(this->elf))
|
||||
dwarf(dwarf::elf::create_loader(this->elf)),
|
||||
loadoffset(_loadoffset)
|
||||
{
|
||||
}
|
||||
|
||||
elf::elf elf;
|
||||
dwarf::dwarf dwarf;
|
||||
uintptr_t loadoffset;
|
||||
};
|
||||
|
||||
DEBUGUS_EXTERNC PLibelfinBinding libelfin_wrap_get_binding(int fd)
|
||||
DEBUGUS_EXTERNC void libelfin_wrap_get_syms(PLibelfinBinding *pbind, Symbols *syms)
|
||||
{
|
||||
return (PLibelfinBinding)new LibelfinBinding(fd);
|
||||
LibelfinBinding *bind = (LibelfinBinding *)pbind;
|
||||
for (auto §ion : bind->elf.sections()) {
|
||||
if (section.get_hdr().type == elf::sht::symtab) {
|
||||
for (auto sym : section.as_symtab()) {
|
||||
auto &d = sym.get_data();
|
||||
if (d.type() == elf::stt::func) {
|
||||
Symbol s = {
|
||||
.name = (const char *)malloc(strlen(sym.get_name().c_str())+1),
|
||||
.addr = bind->loadoffset + (uintptr_t)d.value,
|
||||
};
|
||||
strcpy((char*)s.name, sym.get_name().c_str());
|
||||
da_append(syms, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DEBUGUS_EXTERNC PLibelfinBinding libelfin_wrap_get_binding(int fd, uintptr_t loadoffset)
|
||||
{
|
||||
return (PLibelfinBinding)new LibelfinBinding(fd, loadoffset);
|
||||
}
|
||||
|
||||
DEBUGUS_EXTERNC void libelfin_wrap_free_binding(PLibelfinBinding pbind)
|
||||
|
||||
Reference in New Issue
Block a user