eh_elf: fix get_mmap

This commit is contained in:
Théophile Bastian 2018-06-11 19:48:29 +02:00
parent d817dbf9d9
commit c6ae72f381

View file

@ -473,10 +473,11 @@ get_proc_name(unw_addr_space_t __maybe_unused as,
}
static void
get_mmap(unw_mmap_entry_t* entries, size_t* count, void* arg) {
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;
unw_mmap_entry_t* alloc_entries = NULL;
// == Count entries ==
*count = 0;
@ -488,8 +489,9 @@ get_mmap(unw_mmap_entry_t* entries, size_t* count, void* arg) {
}
// == Allocate ==
entries = (unw_mmap_entry_t*)
malloc(sizeof(unw_mmap_entry_t) * (*count)); // Will be free'd
alloc_entries = (unw_mmap_entry_t*)
malloc(sizeof(unw_mmap_entry_t) * (*count)); // Will be free'd by user
*entries = alloc_entries;
// == Fill entries ==
id = 0;
@ -497,11 +499,12 @@ get_mmap(unw_mmap_entry_t* entries, size_t* count, void* arg) {
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);
alloc_entries[id].beg_ip = map->start;
alloc_entries[id].end_ip = map->end;
alloc_entries[id].offset = map->start - map->map_ip(map, map->start);
alloc_entries[id].object_name =
malloc(strlen(map->dso->long_name) + 1);
strcpy(alloc_entries[id].object_name, map->dso->long_name);
}
}