eh_elf: tentative changes to integrate

This commit is contained in:
Théophile Bastian 2018-06-11 16:15:03 +02:00
parent 16c00db4bb
commit 1ee9a2e1e1

View file

@ -472,6 +472,39 @@ get_proc_name(unw_addr_space_t __maybe_unused as,
return -UNW_EINVAL;
}
static void
get_mmap(unw_mmap_entry_t* entries, size_t* count, void* arg) {
struct unwind_info* unw_info = arg;
struct map_groups* mgroups = unw_info->thread->mg;
int id;
// == Count entries ==
*count = 0;
for(struct map* map = map_groups__first(mgroups, MAP__FUNCTION);
map;
map = map_groups__next(map))
{
++(*count);
}
// == Allocate ==
entries = (unw_mmap_entry_t*)
malloc(sizeof(unw_mmap_entry_t) * (*count)); // Will be free'd
// == Fill entries ==
id = 0;
for(struct map* map = map_groups__first(mgroups, MAP__FUNCTION);
map;
map = map_groups__next(map), ++id)
{
entries[id].beg_ip = map->start;
entries[id].end_ip = map->end;
entries[id].offset = map->start - map->map_ip(map, map->start);
entries[id].object_name = malloc(strlen(map->dso->long_name) + 1);
strcpy(entries[id].object_name, map->dso->long_name);
}
}
static int access_dso_mem(struct unwind_info *ui, unw_word_t addr,
unw_word_t *data)
{
@ -627,6 +660,12 @@ static unw_accessors_t accessors = {
.access_fpreg = access_fpreg,
.resume = resume,
.get_proc_name = get_proc_name,
.eh_elf_init = {
.init_mode = UNW_EH_ELF_INIT_MMAP,
.init_data = {
.get_mmap = get_mmap,
}
}
};
static int _unwind__prepare_access(struct thread *thread)