From: Jin Yao <yao.jin@linux.intel.com>
To: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org,
mingo@redhat.com, alexander.shishkin@linux.intel.com
Cc: Linux-kernel@vger.kernel.org, ak@linux.intel.com,
kan.liang@intel.com, yao.jin@intel.com,
Jin Yao <yao.jin@linux.intel.com>
Subject: [PATCH v2 1/3] perf script python: Move dsoname code to a new function
Date: Fri, 1 Jun 2018 17:01:01 +0800 [thread overview]
Message-ID: <1527843663-32288-2-git-send-email-yao.jin@linux.intel.com> (raw)
In-Reply-To: <1527843663-32288-1-git-send-email-yao.jin@linux.intel.com>
This patch creates a new function get_dsoname() and move the
code which gets the dsoname string to this function.
That's because in next patch, when we process LBR data, we will
also need get_dsoname() to return dsoname for branch from/to.
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
---
.../util/scripting-engines/trace-event-python.c | 23 ++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c
index 7f8afac..f863e96 100644
--- a/tools/perf/util/scripting-engines/trace-event-python.c
+++ b/tools/perf/util/scripting-engines/trace-event-python.c
@@ -372,6 +372,19 @@ static PyObject *get_field_numeric_entry(struct event_format *event,
return obj;
}
+static const char *get_dsoname(struct map *map)
+{
+ const char *dsoname = "[unknown]";
+
+ if (map && map->dso) {
+ if (symbol_conf.show_kernel_path && map->dso->long_name)
+ dsoname = map->dso->long_name;
+ else
+ dsoname = map->dso->name;
+ }
+
+ return dsoname;
+}
static PyObject *python_process_callchain(struct perf_sample *sample,
struct perf_evsel *evsel,
@@ -427,14 +440,8 @@ static PyObject *python_process_callchain(struct perf_sample *sample,
}
if (node->map) {
- struct map *map = node->map;
- const char *dsoname = "[unknown]";
- if (map && map->dso) {
- if (symbol_conf.show_kernel_path && map->dso->long_name)
- dsoname = map->dso->long_name;
- else
- dsoname = map->dso->name;
- }
+ const char *dsoname = get_dsoname(node->map);
+
pydict_set_item_string_decref(pyelem, "dso",
_PyUnicode_FromString(dsoname));
}
--
2.7.4
next prev parent reply other threads:[~2018-06-01 1:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-01 9:01 [PATCH v2 0/3] perf script python: Add more PMU fields Jin Yao
2018-06-01 1:55 ` Andi Kleen
2018-06-06 12:45 ` Arnaldo Carvalho de Melo
2018-06-01 9:01 ` Jin Yao [this message]
2018-06-07 8:25 ` [tip:perf/urgent] perf script python: Move dsoname code to a new function tip-bot for Jin Yao
2018-06-01 9:01 ` [PATCH v2 2/3] perf script python: Add more PMU fields Jin Yao
2018-06-06 18:36 ` Arnaldo Carvalho de Melo
2018-06-07 1:00 ` Jin, Yao
2018-06-07 8:25 ` [tip:perf/urgent] perf script python: Add more PMU fields to event handler dict tip-bot for Jin Yao
2018-06-01 9:01 ` [PATCH v2 3/3] perf script python: Add fields introduction to Documentation Jin Yao
2018-06-07 8:26 ` [tip:perf/urgent] perf script python: Add dict " tip-bot for Jin Yao
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=1527843663-32288-2-git-send-email-yao.jin@linux.intel.com \
--to=yao.jin@linux.intel.com \
--cc=Linux-kernel@vger.kernel.org \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@intel.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=yao.jin@intel.com \
/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