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
This commit is contained in:
Maciej Żenczykowski 2020-02-11 11:12:37 -08:00
parent 06caf87004
commit 524deefc88

View file

@ -520,8 +520,13 @@ static int loadCodeSections(const char* elfPath, vector<codeSection>& 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<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;