LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Leo Yan <leo.yan@linaro.org>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Leo Yan <leo.yan@linaro.org>
Subject: [PATCH bpf-next 5/5] samples/bpf: Handle NULL pointer returned by ksym_search()
Date: Thu, 19 Apr 2018 09:34:06 +0800 [thread overview]
Message-ID: <1524101646-6544-6-git-send-email-leo.yan@linaro.org> (raw)
In-Reply-To: <1524101646-6544-1-git-send-email-leo.yan@linaro.org>
This commit handles NULL pointer returned by ksym_search() to directly
print address hexadecimal value, the change is applied in 'trace_event',
'spintest' and 'offwaketime' programs.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
samples/bpf/offwaketime_user.c | 5 +++++
samples/bpf/spintest_user.c | 5 ++++-
samples/bpf/trace_event_user.c | 5 +++++
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/samples/bpf/offwaketime_user.c b/samples/bpf/offwaketime_user.c
index 512f87a..fce2113 100644
--- a/samples/bpf/offwaketime_user.c
+++ b/samples/bpf/offwaketime_user.c
@@ -27,6 +27,11 @@ static void print_ksym(__u64 addr)
if (!addr)
return;
sym = ksym_search(addr);
+ if (!sym) {
+ printf("%llx;", addr);
+ return;
+ }
+
if (PRINT_RAW_ADDR)
printf("%s/%llx;", sym->name, addr);
else
diff --git a/samples/bpf/spintest_user.c b/samples/bpf/spintest_user.c
index 3d73621..3140803 100644
--- a/samples/bpf/spintest_user.c
+++ b/samples/bpf/spintest_user.c
@@ -36,7 +36,10 @@ int main(int ac, char **argv)
bpf_map_lookup_elem(map_fd[0], &next_key, &value);
assert(next_key == value);
sym = ksym_search(value);
- printf(" %s", sym->name);
+ if (!sym)
+ printf(" %lx", value);
+ else
+ printf(" %s", sym->name);
key = next_key;
}
if (key)
diff --git a/samples/bpf/trace_event_user.c b/samples/bpf/trace_event_user.c
index 56f7a25..d2ab33e 100644
--- a/samples/bpf/trace_event_user.c
+++ b/samples/bpf/trace_event_user.c
@@ -33,6 +33,11 @@ static void print_ksym(__u64 addr)
if (!addr)
return;
sym = ksym_search(addr);
+ if (!sym) {
+ printf("%llx;", addr);
+ return;
+ }
+
printf("%s;", sym->name);
if (!strcmp(sym->name, "sys_read"))
sys_read_seen = true;
--
1.9.1
prev parent reply other threads:[~2018-04-19 1:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-19 1:34 [PATCH bpf-next 0/5] samples/bpf: Minor fixes and cleanup Leo Yan
2018-04-19 1:34 ` [PATCH bpf-next 1/5] samples/bpf: Fix typo in comment Leo Yan
2018-04-20 12:10 ` Jesper Dangaard Brouer
2018-04-20 13:21 ` Daniel Thompson
2018-04-20 13:52 ` Jesper Dangaard Brouer
2018-04-25 10:01 ` Leo Yan
2018-04-19 1:34 ` [PATCH bpf-next 2/5] samples/bpf: Dynamically allocate structure 'syms' Leo Yan
2018-04-19 1:34 ` [PATCH bpf-next 3/5] samples/bpf: Use NULL for failed to find symbol Leo Yan
2018-04-19 1:34 ` [PATCH bpf-next 4/5] samples/bpf: Refine printing symbol for sampleip Leo Yan
2018-04-19 4:47 ` Alexei Starovoitov
2018-04-19 5:12 ` Leo Yan
2018-04-19 5:21 ` Alexei Starovoitov
2018-04-19 5:33 ` Leo Yan
2018-04-19 1:34 ` Leo Yan [this message]
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=1524101646-6544-6-git-send-email-leo.yan@linaro.org \
--to=leo.yan@linaro.org \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--subject='Re: [PATCH bpf-next 5/5] samples/bpf: Handle NULL pointer returned by ksym_search()' \
/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
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).