From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Masami Hiramatsu <mhiramat@kernel.org>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Krister Johansen <kjlx@templeofstupid.com>
Subject: [PATCH 4.9 15/25] perf probe: Add error checks to offline probe post-processing
Date: Thu, 13 Jul 2017 17:40:29 +0200 [thread overview]
Message-ID: <20170713154002.545529776@linuxfoundation.org> (raw)
In-Reply-To: <20170713154001.535209166@linuxfoundation.org>
4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu <mhiramat@kernel.org>
commit 3e96dac7c956089d3f23aca98c4dfca57b6aaf8a upstream.
Add error check codes on post processing and improve it for offline
probe events as:
- post processing fails if no matched symbol found in map(-ENOENT)
or strdup() failed(-ENOMEM).
- Even if the symbol name is the same, it updates symbol address
and offset.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/148411443738.9978.4617979132625405545.stgit@devbox
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Krister Johansen <kjlx@templeofstupid.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
tools/perf/util/probe-event.c | 50 +++++++++++++++++++++++++++---------------
1 file changed, 33 insertions(+), 17 deletions(-)
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -618,6 +618,33 @@ error:
return ret ? : -ENOENT;
}
+/* Adjust symbol name and address */
+static int post_process_probe_trace_point(struct probe_trace_point *tp,
+ struct map *map, unsigned long offs)
+{
+ struct symbol *sym;
+ u64 addr = tp->address + tp->offset - offs;
+
+ sym = map__find_symbol(map, addr);
+ if (!sym)
+ return -ENOENT;
+
+ if (strcmp(sym->name, tp->symbol)) {
+ /* If we have no realname, use symbol for it */
+ if (!tp->realname)
+ tp->realname = tp->symbol;
+ else
+ free(tp->symbol);
+ tp->symbol = strdup(sym->name);
+ if (!tp->symbol)
+ return -ENOMEM;
+ }
+ tp->offset = addr - sym->start;
+ tp->address -= offs;
+
+ return 0;
+}
+
/*
* Rename DWARF symbols to ELF symbols -- gcc sometimes optimizes functions
* and generate new symbols with suffixes such as .constprop.N or .isra.N
@@ -630,11 +657,9 @@ static int
post_process_offline_probe_trace_events(struct probe_trace_event *tevs,
int ntevs, const char *pathname)
{
- struct symbol *sym;
struct map *map;
unsigned long stext = 0;
- u64 addr;
- int i;
+ int i, ret = 0;
/* Prepare a map for offline binary */
map = dso__new_map(pathname);
@@ -644,23 +669,14 @@ post_process_offline_probe_trace_events(
}
for (i = 0; i < ntevs; i++) {
- addr = tevs[i].point.address + tevs[i].point.offset - stext;
- sym = map__find_symbol(map, addr);
- if (!sym)
- continue;
- if (!strcmp(sym->name, tevs[i].point.symbol))
- continue;
- /* If we have no realname, use symbol for it */
- if (!tevs[i].point.realname)
- tevs[i].point.realname = tevs[i].point.symbol;
- else
- free(tevs[i].point.symbol);
- tevs[i].point.symbol = strdup(sym->name);
- tevs[i].point.offset = addr - sym->start;
+ ret = post_process_probe_trace_point(&tevs[i].point,
+ map, stext);
+ if (ret < 0)
+ break;
}
map__put(map);
- return 0;
+ return ret;
}
static int add_exec_to_probe_trace_events(struct probe_trace_event *tevs,
next prev parent reply other threads:[~2017-07-13 15:41 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-13 15:40 [PATCH 4.9 00/25] 4.9.38-stable review Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 01/25] mqueue: fix a use-after-free in sys_mq_notify() Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 02/25] Add "shutdown" to "struct class" Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 03/25] tpm: Issue a TPM2_Shutdown for TPM2 devices Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 04/25] tools include: Add a __fallthrough statement Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 05/25] tools string: Use __fallthrough in perf_atoll() Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 06/25] tools strfilter: Use __fallthrough Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 07/25] perf top: " Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 08/25] perf thread_map: Correctly size buffer used with dirent->dt_name Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 09/25] perf intel-pt: Use __fallthrough Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 10/25] perf tests: Avoid possible truncation with dirent->d_name + snprintf Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 11/25] perf bench numa: Avoid possible truncation when using snprintf() Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 12/25] perf header: Fix handling of PERF_EVENT_UPDATE__SCALE Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 13/25] perf scripting perl: Fix compile error with some perl5 versions Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 14/25] perf probe: Fix to probe on gcc generated symbols for offline kernel Greg Kroah-Hartman
2017-07-13 15:40 ` Greg Kroah-Hartman [this message]
2017-07-13 15:40 ` [PATCH 4.9 16/25] md: fix incorrect use of lexx_to_cpu in does_sb_need_changing Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 17/25] md: fix super_offset endianness in super_1_rdev_size_change Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 18/25] locking/rwsem-spinlock: Fix EINTR branch in __down_write_common() Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 19/25] staging: vt6556: vnt_start Fix missing call to vnt_key_init_table Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 20/25] staging: comedi: fix clean-up of comedi_class in comedi_init() Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 23/25] ext4: check return value of kstrtoull correctly in reserved_clusters_store Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 24/25] x86/mm/pat: Dont report PAT on CPUs that dont support it Greg Kroah-Hartman
2017-07-13 15:40 ` [PATCH 4.9 25/25] [media] saa7134: fix warm Medion 7134 EEPROM read Greg Kroah-Hartman
2017-07-13 16:47 ` [PATCH 4.9 00/25] 4.9.38-stable review Sumit Semwal
2017-07-14 1:34 ` Guenter Roeck
[not found] ` <5967dc72.7187df0a.f1fb5.37a1@mx.google.com>
2017-07-14 9:52 ` Greg Kroah-Hartman
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=20170713154002.545529776@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=acme@redhat.com \
--cc=jolsa@redhat.com \
--cc=kjlx@templeofstupid.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=stable@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox