improve logging in case of bpf load failure
(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 <maze@google.com>
Change-Id: I817853f33b7f59296a041fb0d26ca3ae502b29da
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 @@
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<std::string> 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;