Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf dso: Clean up read_symbol() error handling

Ensure errno is set and return to caller for error handling.

Unusually for perf the value isn't negated as expected by
symbol__strerror_disassemble().

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Ghiti <alexghiti@rivosinc.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.ibm.com>
Cc: Bill Wendling <morbo@google.com>
Cc: Charlie Jenkins <charlie@rivosinc.com>
Cc: Collin Funk <collin.funk1@gmail.com>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Dr. David Alan Gilbert <linux@treblig.org>
Cc: Eric Biggers <ebiggers@kernel.org>
Cc: Haibo Xu <haibo1.xu@intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Justin Stitt <justinstitt@google.com>
Cc: Li Huafei <lihuafei1@huawei.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <nick.desaulniers+lkml@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <song@kernel.org>
Cc: Stephen Brennan <stephen.s.brennan@oracle.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
bca75320 aa04707f

+16 -5
+2 -1
tools/perf/util/capstone.c
··· 11 11 #include "print_insn.h" 12 12 #include "symbol.h" 13 13 #include "thread.h" 14 + #include <errno.h> 14 15 #include <fcntl.h> 15 16 #include <string.h> 16 17 ··· 246 245 buf = dso__read_symbol(dso, filename, map, sym, 247 246 &code_buf, &buf_len, &is_64bit); 248 247 if (buf == NULL) 249 - return -1; 248 + return errno; 250 249 251 250 /* add the function address and name */ 252 251 scnprintf(disasm_buf, sizeof(disasm_buf), "%#"PRIx64" <%s>:",
+12 -3
tools/perf/util/dso.c
··· 1827 1827 .ip = start, 1828 1828 }; 1829 1829 u8 *code_buf = NULL; 1830 + int saved_errno; 1830 1831 1831 1832 nsinfo__mountns_enter(dso__nsinfo(dso), &nsc); 1832 1833 fd = open(symfs_filename, O_RDONLY); 1834 + saved_errno = errno; 1833 1835 nsinfo__mountns_exit(&nsc); 1834 - if (fd < 0) 1836 + if (fd < 0) { 1837 + errno = saved_errno; 1835 1838 return NULL; 1836 - 1837 - if (file__read_maps(fd, /*exe=*/true, find_file_offset, &data, is_64bit) == 0) { 1839 + } 1840 + if (file__read_maps(fd, /*exe=*/true, find_file_offset, &data, is_64bit) <= 0) { 1838 1841 close(fd); 1842 + errno = ENOENT; 1839 1843 return NULL; 1840 1844 } 1841 1845 code_buf = malloc(len); 1842 1846 if (code_buf == NULL) { 1843 1847 close(fd); 1848 + errno = ENOMEM; 1844 1849 return NULL; 1845 1850 } 1846 1851 count = pread(fd, code_buf, len, data.offset); 1852 + saved_errno = errno; 1847 1853 close(fd); 1848 1854 if ((u64)count != len) { 1849 1855 free(code_buf); 1856 + errno = saved_errno; 1850 1857 return NULL; 1851 1858 } 1852 1859 *out_buf = code_buf; ··· 1882 1875 * Note, there is fallback BPF image disassembly in the objdump 1883 1876 * version but it currently does nothing. 1884 1877 */ 1878 + errno = EOPNOTSUPP; 1885 1879 return NULL; 1886 1880 } 1887 1881 if (dso__binary_type(dso) == DSO_BINARY_TYPE__BPF_PROG_INFO) { ··· 1903 1895 return (const u8 *)(uintptr_t)(info_linear->info.jited_prog_insns); 1904 1896 #else 1905 1897 pr_debug("No BPF program disassembly support\n"); 1898 + errno = EOPNOTSUPP; 1906 1899 return NULL; 1907 1900 #endif 1908 1901 }
+2 -1
tools/perf/util/llvm.c
··· 7 7 #include "namespaces.h" 8 8 #include "srcline.h" 9 9 #include "symbol.h" 10 + #include <errno.h> 10 11 #include <fcntl.h> 11 12 #include <unistd.h> 12 13 #include <linux/zalloc.h> ··· 148 147 buf = dso__read_symbol(dso, filename, map, sym, 149 148 &code_buf, &buf_len, &is_64bit); 150 149 if (buf == NULL) 151 - return -1; 150 + return errno; 152 151 153 152 init_llvm(); 154 153 if (arch__is(args->arch, "x86")) {