Commit 8e8258dd authored by David Calavera's avatar David Calavera Committed by Matheus Marchini

Print program ID when the verbose option is enabled.

This allows operators to use other tools, like bpftool, to
introspect a running program.
Signed-off-by: default avatarDavid Calavera <david.calavera@gmail.com>
parent 3fe276e2
......@@ -339,10 +339,18 @@ void AttachedProbe::load_prog()
if (bt_verbose)
std::cerr << std::endl << "Error log: " << std::endl << log_buf << std::endl;
throw std::runtime_error("Error loading program: " + probe_.name + (bt_verbose ? "" : " (try -v)"));
} else {
if (bt_verbose) {
std::cout << std::endl << "Bytecode: " << std::endl << log_buf << std::endl;
}
if (bt_verbose) {
struct bpf_prog_info info = {};
uint32_t info_len = sizeof(info);
int ret;
ret = bpf_obj_get_info(progfd_, &info, &info_len);
if (ret == 0) {
std::cout << std::endl << "Program ID: " << info.id << std::endl;
}
std::cout << std::endl << "Bytecode: " << std::endl << log_buf << std::endl;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment