This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
[patch] Fix a regression of dwfl_core_file_report retval
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Fri, 01 Nov 2013 16:41:40 +0100
- Subject: [patch] Fix a regression of dwfl_core_file_report retval
Hi Mark,
the patch
commit 596d430f23f85f3cd019bd0ac560ecd5371fc7e0
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Tue Jul 23 16:30:01 2013 +0200
Fix false match of non-build-id disk library to build-id memory library.
regressed the return value of dwfl_core_file_report as now some modules may be
successfully reported by the function will still return 0.
Moreover the sniffed vs. listed logic no longer applies as all the modules are
reported reliably, if reported at all.
The problem occurs during jankratochvil/unwindx86 make check if there is no
vDSO to report - other modules did not count and the function returned 0.
But I have not provided a specific testcase for it.
Thanks,
Jan
libdwf/
2013-11-01 Jan Kratochvil <jan.kratochvil@redhat.com>
* core-file.c (dwfl_core_file_report): Replaced variable sniffed by
retval. Fix one forgotten LISTED increase.
diff --git a/libdwfl/core-file.c b/libdwfl/core-file.c
index 37613b8..b8087dd 100644
--- a/libdwfl/core-file.c
+++ b/libdwfl/core-file.c
@@ -462,14 +462,14 @@ dwfl_core_file_report (Dwfl *dwfl, Elf *elf, const char *executable)
struct r_debug_info r_debug_info;
memset (&r_debug_info, 0, sizeof r_debug_info);
- int listed = dwfl_link_map_report (dwfl, auxv, auxv_size,
+ int retval = dwfl_link_map_report (dwfl, auxv, auxv_size,
dwfl_elf_phdr_memory_callback, elf,
&r_debug_info);
+ int listed = MAX (0, retval);
/* Now sniff segment contents for modules hinted by information gathered
from DT_DEBUG. */
- int sniffed = 0;
ndx = 0;
do
{
@@ -485,7 +485,7 @@ dwfl_core_file_report (Dwfl *dwfl, Elf *elf, const char *executable)
if (seg > ndx)
{
ndx = seg;
- ++sniffed;
+ ++listed;
}
else
++ndx;
@@ -508,6 +508,7 @@ dwfl_core_file_report (Dwfl *dwfl, Elf *elf, const char *executable)
true, true);
if (mod == NULL)
continue;
+ ++listed;
module->elf = NULL;
module->fd = -1;
/* Move this module to the end of the list, so that we end
@@ -534,7 +535,7 @@ dwfl_core_file_report (Dwfl *dwfl, Elf *elf, const char *executable)
/* 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. */
- return sniffed || listed >= 0 ? listed + sniffed : listed;
+ return listed > 0 ? listed : retval;
}
INTDEF (dwfl_core_file_report)
NEW_VERSION (dwfl_core_file_report, ELFUTILS_0.158)