From 59f09a62404b5cedec058f8d85b67b2dd603bc88 Mon Sep 17 00:00:00 2001 From: Mial Lewis Date: Tue, 14 Oct 2025 09:32:06 +0000 Subject: [PATCH 1/2] add error number to file open error messages --- src/pystack/_pystack/elf_common.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pystack/_pystack/elf_common.cpp b/src/pystack/_pystack/elf_common.cpp index 972624e5..2733494d 100644 --- a/src/pystack/_pystack/elf_common.cpp +++ b/src/pystack/_pystack/elf_common.cpp @@ -401,7 +401,7 @@ getSectionInfo(const std::string& filename, const std::string& section_name, Sec LOG(DEBUG) << "Trying to locate .PyRuntime data offset from program headers"; file_unique_ptr file(fopen(filename.c_str(), "r"), fclose); if (!file || fileno(file.get()) == -1) { - LOG(ERROR) << "Cannot open ELF file " << filename; + LOG(ERROR) << "Cannot open ELF file " << filename << " (" << std::strerror(errno) << ")"; return false; } const int fd = fileno(file.get()); @@ -559,9 +559,10 @@ getBuildId(const std::string& filename) LOG(DEBUG) << "Trying to locate .PyRuntime data offset from program headers"; file_unique_ptr file(fopen(filename.c_str(), "r"), fclose); if (!file || fileno(file.get()) == -1) { - LOG(ERROR) << "Cannot open ELF file " << filename; + LOG(ERROR) << "Cannot open ELF file " << filename << " (" << std::strerror(errno) << ")"; return ""; } + const int fd = fileno(file.get()); elf_unique_ptr elf = elf_unique_ptr(elf_begin(fd, ELF_C_READ_MMAP, nullptr), elf_end); From b42042ff0a07ad56923c73e12de2e9ad685586d7 Mon Sep 17 00:00:00 2001 From: Mial Lewis Date: Tue, 14 Oct 2025 09:59:11 +0000 Subject: [PATCH 2/2] remove unnecessary whitespace --- src/pystack/_pystack/elf_common.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pystack/_pystack/elf_common.cpp b/src/pystack/_pystack/elf_common.cpp index 2733494d..96e43f25 100644 --- a/src/pystack/_pystack/elf_common.cpp +++ b/src/pystack/_pystack/elf_common.cpp @@ -562,7 +562,6 @@ getBuildId(const std::string& filename) LOG(ERROR) << "Cannot open ELF file " << filename << " (" << std::strerror(errno) << ")"; return ""; } - const int fd = fileno(file.get()); elf_unique_ptr elf = elf_unique_ptr(elf_begin(fd, ELF_C_READ_MMAP, nullptr), elf_end);