diff --git a/mtelf.c b/mtelf.c index 6e0552c..3cd4e80 100644 --- a/mtelf.c +++ b/mtelf.c @@ -175,7 +175,8 @@ static int populate_this_symtab(struct mt_elf *mte, struct library *lib, Elf_Dat arch_addr_t addr = ARCH_ADDR_T(sym.st_value + mte->bias); - if (!library_find_symbol(lib, addr)) { + struct library_symbol *libsym = library_find_symbol(lib, addr); + if (!libsym) { struct library_symbol *libsym = library_symbol_new(lib, addr, func); if (!libsym) { @@ -183,6 +184,11 @@ static int populate_this_symtab(struct mt_elf *mte, struct library *lib, Elf_Dat continue; } } + else { + /* handle symbol alias */ + if (libsym->func->level > func->level) + libsym->func = func; + } } return 0; diff --git a/report.c b/report.c index 0e32a7a..4c29ee6 100644 --- a/report.c +++ b/report.c @@ -313,34 +313,33 @@ static int _report_mremap(struct task *task, struct library_symbol *libsym) } static const struct function flist[] = { - { "malloc", 2, NULL, _report_malloc }, - { "free", 3, report_free, NULL }, - { "realloc", 4, report_realloc, _report_realloc }, - { "calloc", 5, NULL, _report_calloc }, - { "posix_memalign", 6, NULL, _report_posix_memalign }, - { "mmap", 7, NULL, _report_mmap }, - { "mmap64", 8, NULL, _report_mmap64 }, - { "munmap", 9, report_munmap, _null }, - { "memalign", 10, NULL, _report_memalign }, - { "aligned_alloc", 11, NULL, _report_aligned_alloc }, - { "valloc", 12, NULL, _report_valloc }, - { "pvalloc", 13, NULL, _report_pvalloc }, - { "mremap", 14, report_mremap, _report_mremap}, - { "cfree", 15, report_free, NULL }, - { "vfree", 16, report_free, NULL }, + { "malloc", 0, 2, NULL, _report_malloc }, + { "free", 0, 3, report_free, NULL }, + { "realloc", 0, 4, report_realloc, _report_realloc }, + { "calloc", 0, 5, NULL, _report_calloc }, + { "posix_memalign", 0, 6, NULL, _report_posix_memalign }, + { "mmap", 0, 7, NULL, _report_mmap }, + { "mmap64", 1, 8, NULL, _report_mmap64 }, + { "munmap", 0, 9, report_munmap, _null }, + { "memalign", 0, 10, NULL, _report_memalign }, + { "aligned_alloc", 1, 11, NULL, _report_aligned_alloc }, + { "valloc", 1, 12, NULL, _report_valloc }, + { "pvalloc", 1, 13, NULL, _report_pvalloc }, + { "mremap", 0, 14, report_mremap, _report_mremap}, + { "cfree", 1, 15, report_free, NULL }, /* * support for Google gperftools * the c++ operators new and delete do not call malloc() and free() */ - { "tc_delete", 17, report_free, NULL }, - { "tc_deletearray", 18, report_free, NULL }, - { "tc_deletearray_nothrow", 19, report_free, NULL }, - { "tc_delete_nothrow", 20, report_free, NULL }, - { "tc_new", 21, NULL, _report_malloc }, - { "tc_newarray", 22, NULL, _report_malloc }, - { "tc_newarray_nothrow", 23, NULL, _report_malloc }, - { "tc_new_nothrow", 24, NULL, _report_malloc }, + { "tc_delete", 1, 17, report_free, NULL }, + { "tc_deletearray", 1, 18, report_free, NULL }, + { "tc_deletearray_nothrow", 1, 19, report_free, NULL }, + { "tc_delete_nothrow", 1, 20, report_free, NULL }, + { "tc_new", 1, 21, NULL, _report_malloc }, + { "tc_newarray", 1, 22, NULL, _report_malloc }, + { "tc_newarray_nothrow", 1, 23, NULL, _report_malloc }, + { "tc_new_nothrow", 1, 24, NULL, _report_malloc }, }; const struct function *flist_matches_symbol(const char *sym_name) diff --git a/report.h b/report.h index 600961f..41f9bb9 100644 --- a/report.h +++ b/report.h @@ -29,9 +29,15 @@ #define REPORT_LEAVE 2 struct function { + /* symbol name */ const char *name; + /* level for aliased symbol */ + unsigned int level; + /* minimum number of hw breakpoints for using a hw bp */ unsigned int hw_bp_min; + /* report when function is entered */ int (*report_in)(struct task *task, struct library_symbol *libsym); + /* report when function is exited */ int (*report_out)(struct task *task, struct library_symbol *libsym); };