perf symbols: Store the ELF symbol type in the symbol struct
There is code that needs to see if a resolved address is a function, so,
since we're going to ditch the MAP__{FUNCTION,VARIABLE} split, store
that info in the per symbol struct.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-9ugwxz0i8ryg5702rx8u5q6z@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
@@ -138,7 +138,7 @@ struct machine *setup_fake_machine(struct machines *machines)
|
|||||||
struct fake_sym *fsym = &fake_symbols[i].syms[k];
|
struct fake_sym *fsym = &fake_symbols[i].syms[k];
|
||||||
|
|
||||||
sym = symbol__new(fsym->start, fsym->length,
|
sym = symbol__new(fsym->start, fsym->length,
|
||||||
STB_GLOBAL, fsym->name);
|
STB_GLOBAL, STT_FUNC, fsym->name);
|
||||||
if (sym == NULL) {
|
if (sym == NULL) {
|
||||||
dso__put(dso);
|
dso__put(dso);
|
||||||
goto out;
|
goto out;
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ static int db_ids_from_al(struct db_export *dbe, struct addr_location *al,
|
|||||||
*dso_db_id = dso->db_id;
|
*dso_db_id = dso->db_id;
|
||||||
|
|
||||||
if (!al->sym) {
|
if (!al->sym) {
|
||||||
al->sym = symbol__new(al->addr, 0, 0, "unknown");
|
al->sym = symbol__new(al->addr, 0, 0, 0, "unknown");
|
||||||
if (al->sym)
|
if (al->sym)
|
||||||
dso__insert_symbol(dso, al->map->type, al->sym);
|
dso__insert_symbol(dso, al->map->type, al->sym);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ static struct symbol *new_inline_sym(struct dso *dso,
|
|||||||
inline_sym = symbol__new(base_sym ? base_sym->start : 0,
|
inline_sym = symbol__new(base_sym ? base_sym->start : 0,
|
||||||
base_sym ? base_sym->end : 0,
|
base_sym ? base_sym->end : 0,
|
||||||
base_sym ? base_sym->binding : 0,
|
base_sym ? base_sym->binding : 0,
|
||||||
|
base_sym ? base_sym->type : 0,
|
||||||
funcname);
|
funcname);
|
||||||
if (inline_sym)
|
if (inline_sym)
|
||||||
inline_sym->inlined = 1;
|
inline_sym->inlined = 1;
|
||||||
|
|||||||
@@ -364,7 +364,7 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss, struct map *
|
|||||||
free(demangled);
|
free(demangled);
|
||||||
|
|
||||||
f = symbol__new(plt_offset, plt_entry_size,
|
f = symbol__new(plt_offset, plt_entry_size,
|
||||||
STB_GLOBAL, sympltname);
|
STB_GLOBAL, STT_FUNC, sympltname);
|
||||||
if (!f)
|
if (!f)
|
||||||
goto out_elf_end;
|
goto out_elf_end;
|
||||||
|
|
||||||
@@ -390,7 +390,7 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss, struct map *
|
|||||||
free(demangled);
|
free(demangled);
|
||||||
|
|
||||||
f = symbol__new(plt_offset, plt_entry_size,
|
f = symbol__new(plt_offset, plt_entry_size,
|
||||||
STB_GLOBAL, sympltname);
|
STB_GLOBAL, STT_FUNC, sympltname);
|
||||||
if (!f)
|
if (!f)
|
||||||
goto out_elf_end;
|
goto out_elf_end;
|
||||||
|
|
||||||
@@ -1102,7 +1102,8 @@ new_symbol:
|
|||||||
elf_name = demangled;
|
elf_name = demangled;
|
||||||
|
|
||||||
f = symbol__new(sym.st_value, sym.st_size,
|
f = symbol__new(sym.st_value, sym.st_size,
|
||||||
GELF_ST_BIND(sym.st_info), elf_name);
|
GELF_ST_BIND(sym.st_info),
|
||||||
|
GELF_ST_TYPE(sym.st_info), elf_name);
|
||||||
free(demangled);
|
free(demangled);
|
||||||
if (!f)
|
if (!f)
|
||||||
goto out_elf_end;
|
goto out_elf_end;
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ out_unlock:
|
|||||||
up_write(&maps->lock);
|
up_write(&maps->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name)
|
struct symbol *symbol__new(u64 start, u64 len, u8 binding, u8 type, const char *name)
|
||||||
{
|
{
|
||||||
size_t namelen = strlen(name) + 1;
|
size_t namelen = strlen(name) + 1;
|
||||||
struct symbol *sym = calloc(1, (symbol_conf.priv_size +
|
struct symbol *sym = calloc(1, (symbol_conf.priv_size +
|
||||||
@@ -274,6 +274,7 @@ struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name)
|
|||||||
|
|
||||||
sym->start = start;
|
sym->start = start;
|
||||||
sym->end = len ? start + len : start;
|
sym->end = len ? start + len : start;
|
||||||
|
sym->type = type;
|
||||||
sym->binding = binding;
|
sym->binding = binding;
|
||||||
sym->namelen = namelen - 1;
|
sym->namelen = namelen - 1;
|
||||||
|
|
||||||
@@ -682,7 +683,7 @@ static int map__process_kallsym_symbol(void *arg, const char *name,
|
|||||||
* symbols, setting length to 0, and rely on
|
* symbols, setting length to 0, and rely on
|
||||||
* symbols__fixup_end() to fix it up.
|
* symbols__fixup_end() to fix it up.
|
||||||
*/
|
*/
|
||||||
sym = symbol__new(start, 0, kallsyms2elf_binding(type), name);
|
sym = symbol__new(start, 0, kallsyms2elf_binding(type), kallsyms2elf_type(type), name);
|
||||||
if (sym == NULL)
|
if (sym == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
/*
|
/*
|
||||||
@@ -1395,7 +1396,7 @@ static int dso__load_perf_map(const char *map_path, struct dso *dso,
|
|||||||
if (len + 2 >= line_len)
|
if (len + 2 >= line_len)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
sym = symbol__new(start, size, STB_GLOBAL, line + len);
|
sym = symbol__new(start, size, STB_GLOBAL, STT_FUNC, line + len);
|
||||||
|
|
||||||
if (sym == NULL)
|
if (sym == NULL)
|
||||||
goto out_delete_line;
|
goto out_delete_line;
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ struct symbol {
|
|||||||
u64 start;
|
u64 start;
|
||||||
u64 end;
|
u64 end;
|
||||||
u16 namelen;
|
u16 namelen;
|
||||||
u8 binding;
|
u8 type:4;
|
||||||
|
u8 binding:4;
|
||||||
u8 idle:1;
|
u8 idle:1;
|
||||||
u8 ignore:1;
|
u8 ignore:1;
|
||||||
u8 inlined:1;
|
u8 inlined:1;
|
||||||
@@ -292,7 +293,7 @@ void symbol__exit(void);
|
|||||||
void symbol__elf_init(void);
|
void symbol__elf_init(void);
|
||||||
int symbol__annotation_init(void);
|
int symbol__annotation_init(void);
|
||||||
|
|
||||||
struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name);
|
struct symbol *symbol__new(u64 start, u64 len, u8 binding, u8 type, const char *name);
|
||||||
size_t __symbol__fprintf_symname_offs(const struct symbol *sym,
|
size_t __symbol__fprintf_symname_offs(const struct symbol *sym,
|
||||||
const struct addr_location *al,
|
const struct addr_location *al,
|
||||||
bool unknown_as_addr,
|
bool unknown_as_addr,
|
||||||
|
|||||||
Reference in New Issue
Block a user