From: Roland McGrath Date: Tue, 4 May 2010 23:31:43 +0000 (-0700) Subject: Fix dwfl_core_file_report return value when link_map failed after sniffing succeeded. X-Git-Tag: elfutils-0.148~61 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=77cda9d7b60f698faf83a046739cccb9d4e56150;p=thirdparty%2Felfutils.git Fix dwfl_core_file_report return value when link_map failed after sniffing succeeded. --- diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index a9f36d96d..9f4a745db 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,9 @@ +2010-05-04 Roland McGrath + + * core-file.c (dwfl_core_file_report): Return any nonzero count of + modules reported, even if link_map grovelling failed and only sniffing + found anything. + 2010-04-26 Roland McGrath * relocate.c (relocate_section): Treat R_*_NONE reloc as no reloc. diff --git a/libdwfl/core-file.c b/libdwfl/core-file.c index 2f0ca8a6a..1b556dde6 100644 --- a/libdwfl/core-file.c +++ b/libdwfl/core-file.c @@ -419,6 +419,7 @@ dwfl_core_file_report (Dwfl *dwfl, Elf *elf) return ndx; /* Now sniff segment contents for modules. */ + int sniffed = 0; ndx = 0; do { @@ -427,7 +428,13 @@ dwfl_core_file_report (Dwfl *dwfl, Elf *elf) core_file_read_eagerly, elf); if (unlikely (seg < 0)) return seg; - ndx = seg > ndx ? seg : ndx + 1; + if (seg > ndx) + { + ndx = seg; + ++sniffed; + } + else + ++ndx; } while (ndx < (int) phnum); @@ -465,7 +472,13 @@ dwfl_core_file_report (Dwfl *dwfl, Elf *elf) /* Now we have NT_AUXV contents. From here on this processing could be used for a live process with auxv read from /proc. */ - return dwfl_link_map_report (dwfl, auxv, auxv_size, - dwfl_elf_phdr_memory_callback, elf); + int listed = dwfl_link_map_report (dwfl, auxv, auxv_size, + dwfl_elf_phdr_memory_callback, elf); + + /* We return the number of modules we found if we found any. + If we found none, we return -1 instead of 0 if there was an + error rather than just nothing found. If link_map handling + failed, we still have the sniffed modules. */ + return sniffed == 0 || listed > sniffed ? listed : sniffed; } INTDEF (dwfl_core_file_report)