From: Mark Wielaard Date: Fri, 5 Sep 2014 22:50:51 +0000 (+0000) Subject: Always check crc in open_debug_file for now. Bug #338791 followup. X-Git-Tag: svn/VALGRIND_3_10_0~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13e43db4830e9673db6cd4e5dbf9684c10720c73;p=thirdparty%2Fvalgrind.git Always check crc in open_debug_file for now. Bug #338791 followup. Revision r14464 made it so that debug alt files could be found by their build-id or their (relative) file path. Debug alt files are matched using the given build-id, but by crc. Calculating the full CRC is costly, but currently still needed to avoid misidentifying the main file as debug file. Slightly more efficient would be to use fstat to check we aren't actually opening the main file under any other name (but that only works for local DiImages). Or we could check that the file being opened actually has at least one .debug* section. But this change was the minimal patch to make things work as before. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14474 --- diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c index 86186d3b42..75fa469714 100644 --- a/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c @@ -1180,7 +1180,12 @@ DiImage* open_debug_file( const HChar* name, const HChar* buildid, UInt crc, VG_(message)(Vg_DebugMsg, " Considering %s ..\n", name); } - if (buildid) { + /* We will always check the crc if we have one (altfiles don't have one) + for now because we might be opening the main file again by any other + name, and that obviously also has the same buildid. More efficient + would be an fstat bases check or a check that the file actually + contains .debug* sections. */ + if (buildid && crc == 0) { HChar* debug_buildid = find_buildid(dimg, rel_ok, True); if (debug_buildid == NULL || VG_(strcmp)(buildid, debug_buildid) != 0) { ML_(img_done)(dimg);