summaryrefslogtreecommitdiff
path: root/tools/perf/util/genelf.c
diff options
context:
space:
mode:
authorStephane Eranian <eranian@google.com>2015-11-30 10:02:23 +0100
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-02-05 12:33:09 -0300
commit598b7c6919c7bbcc1243009721a01bc12275ff3e (patch)
treea774366184bc50f78d124bdb597965b378ec9a9d /tools/perf/util/genelf.c
parent209045adc2bbdb2b315fa5539cec54d01cd3e7db (diff)
perf jit: add source line info support
This patch adds source line information support to perf for jitted code. The source line info must be emitted by the runtime, such as JVMTI. Perf injects extract the source line info from the jitdump file and adds the corresponding .debug_lines section in the ELF image generated for each jitted function. The source line enables matching any address in the profile with a source file and line number. The improvement is visible in perf annotate with the source code displayed alongside the assembly code. The dwarf code leverages the support from OProfile which is also released under GPLv2. Copyright 2007 OProfile authors. Signed-off-by: Stephane Eranian <eranian@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Carl Love <cel@us.ibm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: John McCutchan <johnmccutchan@google.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Pawel Moll <pawel.moll@arm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Sonny Rao <sonnyrao@chromium.org> Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> Link: http://lkml.kernel.org/r/1448874143-7269-5-git-send-email-eranian@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/genelf.c')
-rw-r--r--tools/perf/util/genelf.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/perf/util/genelf.c b/tools/perf/util/genelf.c
index 145f8116ef56..c1ef805c6a8f 100644
--- a/tools/perf/util/genelf.c
+++ b/tools/perf/util/genelf.c
@@ -156,7 +156,8 @@ gen_build_id(struct buildid_note *note, unsigned long load_addr, const void *cod
*/
int
jit_write_elf(int fd, uint64_t load_addr, const char *sym,
- const void *code, int csize)
+ const void *code, int csize,
+ void *debug, int nr_debug_entries)
{
Elf *e;
Elf_Data *d;
@@ -385,9 +386,15 @@ jit_write_elf(int fd, uint64_t load_addr, const char *sym,
shdr->sh_size = sizeof(bnote);
shdr->sh_entsize = 0;
- if (elf_update(e, ELF_C_WRITE) < 0) {
- warnx("elf_update 4 failed");
- goto error;
+ if (debug && nr_debug_entries) {
+ retval = jit_add_debug_info(e, load_addr, debug, nr_debug_entries);
+ if (retval)
+ goto error;
+ } else {
+ if (elf_update(e, ELF_C_WRITE) < 0) {
+ warnx("elf_update 4 failed");
+ goto error;
+ }
}
retval = 0;