From: tip-bot for Cody P Schafer <cody@linux.vnet.ibm.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, linux-kernel@vger.kernel.org, paulus@samba.org,
mingo@redhat.com, hpa@zytor.com, mingo@kernel.org,
cody@linux.vnet.ibm.com, a.p.zijlstra@chello.nl,
matthltc@us.ibm.com, dave@linux.vnet.ibm.com,
namhyung@kernel.org, sukadev@linux.vnet.ibm.com,
tglx@linutronix.de
Subject: [tip:perf/core] perf symbols: Use both runtime and debug images
Date: Tue, 21 Aug 2012 09:10:44 -0700 [thread overview]
Message-ID: <tip-3aafe5ae08f2aed378e06d78b207883879d25cbe@git.kernel.org> (raw)
In-Reply-To: <1344637382-22789-17-git-send-email-cody@linux.vnet.ibm.com>
Commit-ID: 3aafe5ae08f2aed378e06d78b207883879d25cbe
Gitweb: http://git.kernel.org/tip/3aafe5ae08f2aed378e06d78b207883879d25cbe
Author: Cody P Schafer <cody@linux.vnet.ibm.com>
AuthorDate: Fri, 10 Aug 2012 15:23:02 -0700
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 13 Aug 2012 14:46:55 -0300
perf symbols: Use both runtime and debug images
We keep both a 'runtime' elf image as well as a 'debug' elf image around
and generate symbols by looking at both of these.
This eliminates the need for the want_symtab/goto restart mechanism
combined with iterating over and reopening the elf images a second time.
Also give dso__synthsize_plt_symbols() the runtime image (which has
dynsyms) instead of the symbol image (which may only have a symtab and
no dynsyms).
Previously if a debug image was found all runtime images were ignored.
This fixes 2 issues:
- Symbol resolution to failure on PowerPC systems with debug symbols
installed, as the debug images lack a '.opd' section which contains
function descriptors.
- On all archs, plt synthesis failed when a debug image was loaded and
that debug image lacks a dynsym section while a runtime image has a
dynsym section.
Assumptions:
- If a .opd section exists, it is contained in the highest priority
image with a dynsym section.
- This generally implies that the debug image lacks a dynsym section
(ie: it is marked as NO_BITS).
Signed-off-by: Cody 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-17-git-send-email-cody@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/symbol-elf.c | 5 ++
tools/perf/util/symbol-minimal.c | 6 +++
tools/perf/util/symbol.c | 77 +++++++++++++++++++++----------------
tools/perf/util/symbol.h | 1 +
4 files changed, 56 insertions(+), 33 deletions(-)
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 36e4a45..5b37e13 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -525,6 +525,11 @@ static int dso__swap_init(struct dso *dso, unsigned char eidata)
return 0;
}
+bool symsrc__possibly_runtime(struct symsrc *ss)
+{
+ return ss->dynsym || ss->opdsec;
+}
+
bool symsrc__has_symtab(struct symsrc *ss)
{
return ss->symtab != NULL;
diff --git a/tools/perf/util/symbol-minimal.c b/tools/perf/util/symbol-minimal.c
index 7747ea6..6738ea1 100644
--- a/tools/perf/util/symbol-minimal.c
+++ b/tools/perf/util/symbol-minimal.c
@@ -260,6 +260,12 @@ out_close:
return -1;
}
+bool symsrc__possibly_runtime(struct symsrc *ss __used)
+{
+ /* Assume all sym sources could be a runtime image. */
+ return true;
+}
+
bool symsrc__has_symtab(struct symsrc *ss __used)
{
return false;
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 739e5a3..2293a4a 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1026,11 +1026,12 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
{
char *name;
int ret = -1;
- struct symsrc ss;
u_int i;
struct machine *machine;
char *root_dir = (char *) "";
- int want_symtab;
+ int ss_pos = 0;
+ struct symsrc ss_[2];
+ struct symsrc *syms_ss = NULL, *runtime_ss = NULL;
dso__set_loaded(dso, map->type);
@@ -1072,12 +1073,12 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
root_dir = machine->root_dir;
/* Iterate over candidate debug images.
- * On the first pass, only load images if they have a full symtab.
- * Failing that, do a second pass where we accept .dynsym also
+ * Keep track of "interesting" ones (those which have a symtab, dynsym,
+ * and/or opd section) for processing.
*/
- want_symtab = 1;
-restart:
for (i = 0; i < DSO_BINARY_TYPE__SYMTAB_CNT; i++) {
+ struct symsrc *ss = &ss_[ss_pos];
+ bool next_slot = false;
enum dso_binary_type symtab_type = binary_type_symtab[i];
@@ -1086,45 +1087,55 @@ restart:
continue;
/* Name is now the name of the next image to try */
- if (symsrc__init(&ss, dso, name, symtab_type) < 0)
+ if (symsrc__init(ss, dso, name, symtab_type) < 0)
continue;
- if (want_symtab && !symsrc__has_symtab(&ss)) {
- symsrc__destroy(&ss);
- continue;
+ if (!syms_ss && symsrc__has_symtab(ss)) {
+ syms_ss = ss;
+ next_slot = true;
}
- ret = dso__load_sym(dso, map, &ss, &ss, filter, 0);
-
- /*
- * Some people seem to have debuginfo files _WITHOUT_ debug
- * info!?!?
- */
- if (!ret) {
- symsrc__destroy(&ss);
- continue;
+ if (!runtime_ss && symsrc__possibly_runtime(ss)) {
+ runtime_ss = ss;
+ next_slot = true;
}
- if (ret > 0) {
- int nr_plt;
+ if (next_slot) {
+ ss_pos++;
- nr_plt = dso__synthesize_plt_symbols(dso, &ss, map, filter);
- if (nr_plt > 0)
- ret += nr_plt;
- symsrc__destroy(&ss);
- break;
+ if (syms_ss && runtime_ss)
+ break;
}
+
}
- /*
- * If we wanted a full symtab but no image had one,
- * relax our requirements and repeat the search.
- */
- if (ret <= 0 && want_symtab) {
- want_symtab = 0;
- goto restart;
+ if (!runtime_ss && !syms_ss)
+ goto out_free;
+
+ if (runtime_ss && !syms_ss) {
+ syms_ss = runtime_ss;
+ }
+
+ /* We'll have to hope for the best */
+ if (!runtime_ss && syms_ss)
+ runtime_ss = syms_ss;
+
+ if (syms_ss)
+ ret = dso__load_sym(dso, map, syms_ss, runtime_ss, filter, 0);
+ else
+ ret = -1;
+
+ if (ret > 0 && runtime_ss->dynsym) {
+ int nr_plt;
+
+ nr_plt = dso__synthesize_plt_symbols(dso, runtime_ss, map, filter);
+ if (nr_plt > 0)
+ ret += nr_plt;
}
+ for (; ss_pos > 0; ss_pos--)
+ symsrc__destroy(&ss_[ss_pos - 1]);
+out_free:
free(name);
if (ret < 0 && strstr(dso->name, " (deleted)") != NULL)
return 0;
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 1f3eed2..fc4b1e6 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -253,6 +253,7 @@ void symsrc__destroy(struct symsrc *ss);
int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name,
enum dso_binary_type type);
bool symsrc__has_symtab(struct symsrc *ss);
+bool symsrc__possibly_runtime(struct symsrc *ss);
#define DSO__SWAP(dso, type, val) \
({ \
prev parent reply other threads:[~2012-08-21 16:11 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-10 22:22 [PATCH v2 00/16] perf: various symbol resolution fixes, including .opd section use Cody P Schafer
2012-08-10 22:22 ` [PATCH 01/16] perf symbol: correct comment wrt kallsyms loading Cody P Schafer
2012-08-11 13:14 ` Namhyung Kim
2012-08-21 16:00 ` [tip:perf/core] perf symbols: Correct " tip-bot for Cody P Schafer
2012-08-10 22:22 ` [PATCH 02/16] perf symbol: remove unused 'end' arg in kallsyms parse cb Cody P Schafer
2012-08-21 16:01 ` [tip:perf/core] perf symbols: Remove " tip-bot for Cody P Schafer
2012-08-10 22:22 ` [PATCH 03/16] perf symbol: only un-prelink non-zero symbols Cody P Schafer
2012-08-21 15:56 ` [tip:perf/core] perf symbols: Only " tip-bot for Cody P Schafer
2012-08-10 22:22 ` [PATCH 04/16] perf utils: remove unused function map__objdump_2ip Cody P Schafer
2012-08-21 15:57 ` [tip:perf/core] perf symbols: Remove " tip-bot for Cody P Schafer
2012-08-10 22:22 ` [PATCH 05/16] perf symbol: don't try to synthesize plt without dynstr Cody P Schafer
2012-08-21 15:58 ` [tip:perf/core] perf symbols: Don' t " tip-bot for Cody P Schafer
2012-08-10 22:22 ` [PATCH 06/16] perf symbol: remove unneeded call to dso__set_long_name() Cody P Schafer
2012-08-21 15:59 ` [tip:perf/core] perf symbols: Remove " tip-bot for Cody P Schafer
2012-08-10 22:22 ` [PATCH 07/16] perf symbol: simplify out_fixup in kernel syms loading Cody P Schafer
2012-08-21 16:02 ` [tip:perf/core] perf symbols: Simplify " tip-bot for Cody P Schafer
2012-08-10 22:22 ` [PATCH 08/16] perf symbol: only set vmlinux longname & mark loaded if really loaded Cody P Schafer
2012-08-21 16:03 ` [tip:perf/core] perf symbols: " tip-bot for Cody P Schafer
2012-08-10 22:22 ` [PATCH 09/16] perf symbol: avoid segfault in elf_strptr Cody P Schafer
2012-08-21 16:04 ` [tip:perf/core] perf symbols: Avoid " tip-bot for Cody P Schafer
2012-08-10 22:22 ` [PATCH 10/16] perf symbol: track symtab_type of vmlinux Cody P Schafer
2012-08-21 16:05 ` [tip:perf/core] perf symbols: Track " tip-bot for Cody P Schafer
2012-08-10 22:22 ` [PATCH 11/16] perf symbol: introduce symsrc structure Cody P Schafer
2012-08-11 13:28 ` Namhyung Kim
2012-08-13 17:36 ` Arnaldo Carvalho de Melo
2012-08-21 16:06 ` [tip:perf/core] perf symbols: Introduce " tip-bot for Cody P Schafer
2012-08-10 22:22 ` [PATCH 12/16] perf symbol: set symtab_type in dso__load_sym Cody P Schafer
2012-08-21 16:07 ` [tip:perf/core] perf symbols: Set " tip-bot for Cody P Schafer
2012-08-10 22:22 ` [PATCH 13/16] perf symbol: switch dso__synthesize_plt_symbols() to use symsrc Cody P Schafer
2012-08-21 16:07 ` [tip:perf/core] perf symbols: Switch " tip-bot for Cody P Schafer
2012-08-10 22:23 ` [PATCH 14/16] perf symbol: factor want_symtab out of dso__load_sym() Cody P Schafer
2012-08-21 16:08 ` [tip:perf/core] perf symbols: Factor " tip-bot for Cody P Schafer
2012-08-10 22:23 ` [PATCH 15/16] perf symbol: convert dso__load_syms to take 2 symsrc's Cody P Schafer
2012-08-21 16:09 ` [tip:perf/core] perf symbols: Convert " tip-bot for Cody P Schafer
2012-08-10 22:23 ` [PATCH 16/16] perf symbol: use both runtime and debug images Cody P Schafer
2012-08-21 16:10 ` tip-bot for Cody P Schafer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-3aafe5ae08f2aed378e06d78b207883879d25cbe@git.kernel.org \
--to=cody@linux.vnet.ibm.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=dave@linux.vnet.ibm.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=matthltc@us.ibm.com \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=paulus@samba.org \
--cc=sukadev@linux.vnet.ibm.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.