Commit d26cd12b authored by Cody P Schafer's avatar Cody P Schafer Committed by Arnaldo Carvalho de Melo

perf symbols: Factor want_symtab out of dso__load_sym()

Only one callsite of dso__load_sym() uses the want_symtab functionality,
so place the logic at the callsite instead of within dso__load_sym().

This sets us up for removal of want_symtab completely once we keep
multiple elf handles (within symsrc's) around.

Setup for the later patch

"perf symbols: Use both runtime and debug images"
Signed-off-by: default avatarCody P Schafer <cody@linux.vnet.ibm.com>
Cc: David Hansen <dave@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Matt Hellsley <matthltc@us.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/1344637382-22789-15-git-send-email-cody@linux.vnet.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent a44f605b
...@@ -525,6 +525,10 @@ static int dso__swap_init(struct dso *dso, unsigned char eidata) ...@@ -525,6 +525,10 @@ static int dso__swap_init(struct dso *dso, unsigned char eidata)
return 0; return 0;
} }
bool symsrc__has_symtab(struct symsrc *ss)
{
return ss->symtab != NULL;
}
void symsrc__destroy(struct symsrc *ss) void symsrc__destroy(struct symsrc *ss)
{ {
...@@ -616,7 +620,7 @@ int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name, ...@@ -616,7 +620,7 @@ int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name,
} }
int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *ss, int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *ss,
symbol_filter_t filter, int kmodule, int want_symtab) symbol_filter_t filter, int kmodule)
{ {
struct kmap *kmap = dso->kernel ? map__kmap(map) : NULL; struct kmap *kmap = dso->kernel ? map__kmap(map) : NULL;
struct map *curr_map = map; struct map *curr_map = map;
...@@ -636,21 +640,16 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *ss, ...@@ -636,21 +640,16 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *ss,
dso->symtab_type = ss->type; dso->symtab_type = ss->type;
if (!ss->symtab) {
ss->symtab = ss->dynsym;
ss->symshdr = ss->dynshdr;
}
elf = ss->elf; elf = ss->elf;
ehdr = ss->ehdr; ehdr = ss->ehdr;
sec = ss->symtab; sec = ss->symtab;
shdr = ss->symshdr; shdr = ss->symshdr;
if (sec == NULL) {
if (want_symtab)
goto out_elf_end;
sec = ss->dynsym;
shdr = ss->dynshdr;
if (sec == NULL)
goto out_elf_end;
}
opdsec = ss->opdsec; opdsec = ss->opdsec;
opdshdr = ss->opdshdr; opdshdr = ss->opdshdr;
opdidx = ss->opdidx; opdidx = ss->opdidx;
......
...@@ -260,6 +260,11 @@ int symsrc__init(struct symsrc *ss, struct dso *dso __used, const char *name, ...@@ -260,6 +260,11 @@ int symsrc__init(struct symsrc *ss, struct dso *dso __used, const char *name,
return -1; return -1;
} }
bool symsrc__has_symtab(struct symsrc *ss __used)
{
return false;
}
void symsrc__destroy(struct symsrc *ss) void symsrc__destroy(struct symsrc *ss)
{ {
free(ss->name); free(ss->name);
...@@ -275,8 +280,7 @@ int dso__synthesize_plt_symbols(struct dso *dso __used, ...@@ -275,8 +280,7 @@ int dso__synthesize_plt_symbols(struct dso *dso __used,
} }
int dso__load_sym(struct dso *dso, struct map *map __used, struct symsrc *ss, int dso__load_sym(struct dso *dso, struct map *map __used, struct symsrc *ss,
symbol_filter_t filter __used, int kmodule __used, symbol_filter_t filter __used, int kmodule __used)
int want_symtab __used)
{ {
unsigned char *build_id[BUILD_ID_SIZE]; unsigned char *build_id[BUILD_ID_SIZE];
......
...@@ -1089,8 +1089,12 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter) ...@@ -1089,8 +1089,12 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
if (symsrc__init(&ss, dso, name, symtab_type) < 0) if (symsrc__init(&ss, dso, name, symtab_type) < 0)
continue; continue;
ret = dso__load_sym(dso, map, &ss, filter, 0, if (want_symtab && !symsrc__has_symtab(&ss)) {
want_symtab); symsrc__destroy(&ss);
continue;
}
ret = dso__load_sym(dso, map, &ss, filter, 0);
/* /*
* Some people seem to have debuginfo files _WITHOUT_ debug * Some people seem to have debuginfo files _WITHOUT_ debug
...@@ -1376,7 +1380,7 @@ int dso__load_vmlinux(struct dso *dso, struct map *map, ...@@ -1376,7 +1380,7 @@ int dso__load_vmlinux(struct dso *dso, struct map *map,
if (symsrc__init(&ss, dso, symfs_vmlinux, symtab_type)) if (symsrc__init(&ss, dso, symfs_vmlinux, symtab_type))
return -1; return -1;
err = dso__load_sym(dso, map, &ss, filter, 0, 0); err = dso__load_sym(dso, map, &ss, filter, 0);
symsrc__destroy(&ss); symsrc__destroy(&ss);
if (err > 0) { if (err > 0) {
......
...@@ -252,6 +252,7 @@ struct symsrc { ...@@ -252,6 +252,7 @@ struct symsrc {
void symsrc__destroy(struct symsrc *ss); void symsrc__destroy(struct symsrc *ss);
int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name, int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name,
enum dso_binary_type type); enum dso_binary_type type);
bool symsrc__has_symtab(struct symsrc *ss);
#define DSO__SWAP(dso, type, val) \ #define DSO__SWAP(dso, type, val) \
({ \ ({ \
...@@ -369,7 +370,7 @@ ssize_t dso__data_read_addr(struct dso *dso, struct map *map, ...@@ -369,7 +370,7 @@ ssize_t dso__data_read_addr(struct dso *dso, struct map *map,
u8 *data, ssize_t size); u8 *data, ssize_t size);
int dso__test_data(void); int dso__test_data(void);
int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *ss, int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *ss,
symbol_filter_t filter, int kmodule, int want_symtab); symbol_filter_t filter, int kmodule);
int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss, int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss,
struct map *map, symbol_filter_t filter); struct map *map, symbol_filter_t filter);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment