All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kui-Feng Lee <kuifeng@fb.com>
To: <bpf@vger.kernel.org>, <ast@kernel.org>, <daniel@iogearbox.net>,
	<andrii@kernel.org>
Cc: Kui-Feng Lee <kuifeng@fb.com>
Subject: [PATCH v4 bpf-next 3/4] tools/perf: Stop using bpf_object__find_program_by_title API.
Date: Mon, 10 Jan 2022 14:34:45 -0800	[thread overview]
Message-ID: <20220110223446.345531-4-kuifeng@fb.com> (raw)
In-Reply-To: <20220110223446.345531-1-kuifeng@fb.com>

bpf_obj__find_program_by_title() in libbpf is going to be deprecated.
Call bpf_object_for_each_program to find a program in the section with
a given name instead.

Signed-off-by: Kui-Feng Lee <kuifeng@fb.com>
---
 tools/perf/builtin-trace.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 624ea12ce5ca..7c7278e434a0 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -3253,10 +3253,21 @@ static void trace__set_bpf_map_syscalls(struct trace *trace)
 
 static struct bpf_program *trace__find_bpf_program_by_title(struct trace *trace, const char *name)
 {
+	struct bpf_program *pos, *prog = NULL;
+	const char *sec_name;
+
 	if (trace->bpf_obj == NULL)
 		return NULL;
 
-	return bpf_object__find_program_by_title(trace->bpf_obj, name);
+	bpf_object__for_each_program(pos, trace->bpf_obj) {
+		sec_name = bpf_program__section_name(pos);
+		if (sec_name && !strcmp(sec_name, name)) {
+			prog = pos;
+			break;
+		}
+	}
+
+	return prog;
 }
 
 static struct bpf_program *trace__find_syscall_bpf_prog(struct trace *trace, struct syscall *sc,
-- 
2.30.2


  parent reply	other threads:[~2022-01-10 22:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-10 22:34 [PATCH v4 bpf-next 0/4] Stop using bpf_object__find_program_by_title API Kui-Feng Lee
2022-01-10 22:34 ` [PATCH v4 bpf-next 1/4] selftests/bpf: " Kui-Feng Lee
2022-01-10 22:34 ` [PATCH v4 bpf-next 2/4] samples/bpf: " Kui-Feng Lee
2022-01-10 22:34 ` Kui-Feng Lee [this message]
2022-01-10 22:45 ` [PATCH v4 bpf-next 0/4] " Kui-Feng Lee
  -- strict thread matches above, loose matches on Subject: below --
2021-12-14  3:59 Kui-Feng Lee
2021-12-14  3:59 ` [PATCH v4 bpf-next 3/4] tools/perf: " Kui-Feng Lee

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=20220110223446.345531-4-kuifeng@fb.com \
    --to=kuifeng@fb.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    /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.