#include "print_insn.h"
#include "symbol.h"
#include "thread.h"
+#include <errno.h>
#include <fcntl.h>
#include <string.h>
buf = dso__read_symbol(dso, filename, map, sym,
&code_buf, &buf_len, &is_64bit);
if (buf == NULL)
- return -1;
+ return errno;
/* add the function address and name */
scnprintf(disasm_buf, sizeof(disasm_buf), "%#"PRIx64" <%s>:",
.ip = start,
};
u8 *code_buf = NULL;
+ int saved_errno;
nsinfo__mountns_enter(dso__nsinfo(dso), &nsc);
fd = open(symfs_filename, O_RDONLY);
+ saved_errno = errno;
nsinfo__mountns_exit(&nsc);
- if (fd < 0)
+ if (fd < 0) {
+ errno = saved_errno;
return NULL;
-
- if (file__read_maps(fd, /*exe=*/true, find_file_offset, &data, is_64bit) == 0) {
+ }
+ if (file__read_maps(fd, /*exe=*/true, find_file_offset, &data, is_64bit) <= 0) {
close(fd);
+ errno = ENOENT;
return NULL;
}
code_buf = malloc(len);
if (code_buf == NULL) {
close(fd);
+ errno = ENOMEM;
return NULL;
}
count = pread(fd, code_buf, len, data.offset);
+ saved_errno = errno;
close(fd);
if ((u64)count != len) {
free(code_buf);
+ errno = saved_errno;
return NULL;
}
*out_buf = code_buf;
* Note, there is fallback BPF image disassembly in the objdump
* version but it currently does nothing.
*/
+ errno = EOPNOTSUPP;
return NULL;
}
if (dso__binary_type(dso) == DSO_BINARY_TYPE__BPF_PROG_INFO) {
return (const u8 *)(uintptr_t)(info_linear->info.jited_prog_insns);
#else
pr_debug("No BPF program disassembly support\n");
+ errno = EOPNOTSUPP;
return NULL;
#endif
}
#include "namespaces.h"
#include "srcline.h"
#include "symbol.h"
+#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/zalloc.h>
buf = dso__read_symbol(dso, filename, map, sym,
&code_buf, &buf_len, &is_64bit);
if (buf == NULL)
- return -1;
+ return errno;
init_llvm();
if (arch__is(args->arch, "x86")) {