From: Ian Rogers <irogers@google.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 2/3] perf tools: Add kallsyms__get_symbol_start()
Date: Thu, 22 Jun 2023 10:23:33 -0700 [thread overview]
Message-ID: <CAP-5=fWrVh=RDEhise-gSzBfrfno8v8pyMw3QpBxio2j7QN3pA@mail.gmail.com> (raw)
In-Reply-To: <20230620201818.1670753-2-namhyung@kernel.org>
On Tue, Jun 20, 2023 at 1:18 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> The kallsyms__get_symbol_start() to get any symbol address from
> kallsyms. The existing kallsyms__get_function_start() only allows text
> symbols so create this to allow data symbols too.
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
> ---
> tools/perf/util/event.c | 30 +++++++++++++++++++++++++++---
> tools/perf/util/event.h | 2 ++
> 2 files changed, 29 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
> index 3860b0c74829..6fdda0eb3854 100644
> --- a/tools/perf/util/event.c
> +++ b/tools/perf/util/event.c
> @@ -93,8 +93,8 @@ struct process_symbol_args {
> u64 start;
> };
>
> -static int find_symbol_cb(void *arg, const char *name, char type,
> - u64 start)
> +static int find_func_symbol_cb(void *arg, const char *name, char type,
> + u64 start)
> {
> struct process_symbol_args *args = arg;
>
> @@ -110,12 +110,36 @@ static int find_symbol_cb(void *arg, const char *name, char type,
> return 1;
> }
>
> +static int find_any_symbol_cb(void *arg, const char *name,
> + char type __maybe_unused, u64 start)
> +{
> + struct process_symbol_args *args = arg;
> +
> + if (strcmp(name, args->name))
> + return 0;
> +
> + args->start = start;
> + return 1;
> +}
> +
> int kallsyms__get_function_start(const char *kallsyms_filename,
> const char *symbol_name, u64 *addr)
> {
> struct process_symbol_args args = { .name = symbol_name, };
>
> - if (kallsyms__parse(kallsyms_filename, &args, find_symbol_cb) <= 0)
> + if (kallsyms__parse(kallsyms_filename, &args, find_func_symbol_cb) <= 0)
> + return -1;
> +
> + *addr = args.start;
> + return 0;
> +}
> +
> +int kallsyms__get_symbol_start(const char *kallsyms_filename,
> + const char *symbol_name, u64 *addr)
> +{
> + struct process_symbol_args args = { .name = symbol_name, };
> +
> + if (kallsyms__parse(kallsyms_filename, &args, find_any_symbol_cb) <= 0)
> return -1;
>
> *addr = args.start;
> diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h
> index de20e01c9d72..d8bcee2e9b93 100644
> --- a/tools/perf/util/event.h
> +++ b/tools/perf/util/event.h
> @@ -360,6 +360,8 @@ size_t perf_event__fprintf(union perf_event *event, struct machine *machine, FIL
>
> int kallsyms__get_function_start(const char *kallsyms_filename,
> const char *symbol_name, u64 *addr);
> +int kallsyms__get_symbol_start(const char *kallsyms_filename,
> + const char *symbol_name, u64 *addr);
>
> void event_attr_init(struct perf_event_attr *attr);
>
> --
> 2.41.0.185.g7c58973941-goog
>
next prev parent reply other threads:[~2023-06-22 17:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-20 20:18 [PATCH 1/3] perf machine: Add machine->has_data_mmap field Namhyung Kim
2023-06-20 20:18 ` [PATCH 2/3] perf tools: Add kallsyms__get_symbol_start() Namhyung Kim
2023-06-22 17:23 ` Ian Rogers [this message]
2023-06-20 20:18 ` [PATCH 3/3] perf machine: Include data symbols in the kernel map Namhyung Kim
2023-06-22 17:27 ` Ian Rogers
2023-07-11 15:19 ` Adrian Hunter
2023-07-11 17:30 ` Namhyung Kim
2023-07-12 5:44 ` Adrian Hunter
2023-06-22 17:17 ` [PATCH 1/3] perf machine: Add machine->has_data_mmap field Ian Rogers
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='CAP-5=fWrVh=RDEhise-gSzBfrfno8v8pyMw3QpBxio2j7QN3pA@mail.gmail.com' \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.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;
as well as URLs for NNTP newsgroup(s).