From 524deefc88d3de78596862541fd650031b2f51de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Tue, 11 Feb 2020 11:12:37 -0800 Subject: [PATCH] improve logging in case of bpf load failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (we don't want to truncate this output, since it can be very useful for debugging failures) Test: builds, more useful ebpf load failure logs Signed-off-by: Maciej Żenczykowski Change-Id: I817853f33b7f59296a041fb0d26ca3ae502b29da --- libbpf_android/Loader.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libbpf_android/Loader.cpp b/libbpf_android/Loader.cpp index 3a25fbd..18dabba 100644 --- a/libbpf_android/Loader.cpp +++ b/libbpf_android/Loader.cpp @@ -520,8 +520,13 @@ static int loadCodeSections(const char* elfPath, vector& cs, const ALOGD("bpf_prog_load lib call for %s (%s) returned fd: %d (%s)\n", elfPath, cs[i].name.c_str(), fd, (fd < 0 ? std::strerror(errno) : "no error")); - if (fd <= 0) - ALOGE("bpf_prog_load: log_buf contents: %s\n", (char *)log_buf.data()); + if (fd < 0) { + std::vector lines = android::base::Split(log_buf.data(), "\n"); + + ALOGE("bpf_prog_load - BEGIN log_buf contents:"); + for (const auto& line : lines) ALOGE("%s", line.c_str()); + ALOGE("bpf_prog_load - END log_buf contents."); + } } if (fd < 0) return fd;