3.13.0-12 - Use upstream version of valgrind-3.13.0-debug-alt-file.patch.

This commit is contained in:
Mark Wielaard 2017-12-13 00:27:33 +01:00
parent dcdfabdf76
commit 14e6c2a500
2 changed files with 42 additions and 25 deletions

View File

@ -1,16 +1,17 @@
From f3521f1d69312eb476c53eea06ee1187844efe18 Mon Sep 17 00:00:00 2001 commit be82bb5f9dfecd854c53eda321d1914f28f19790
From: Mark Wielaard <mark@klomp.org> Author: Mark Wielaard <mark@klomp.org>
Date: Sat, 9 Dec 2017 23:01:29 +0100 Date: Sat Dec 9 23:01:29 2017 +0100
Subject: [PATCH] Fix gnu debug alt file resolving.
The path to the alt file is relative to the actual debug file. Fix gnu debug alt file resolving.
Make sure that we got the real file, not a (build-id) symlink.
--- https://bugs.kde.org/show_bug.cgi?id=387773
coregrind/m_debuginfo/readelf.c | 57 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 55 insertions(+), 2 deletions(-) The path to the alt file is relative to the actual debug file.
Make sure that we got the real file, not a (build-id) symlink.
Also handle the case where a debug or alt file is an absolute path.
diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c
index e612250..2d52322 100644 index e612250..c19ff21 100644
--- a/coregrind/m_debuginfo/readelf.c --- a/coregrind/m_debuginfo/readelf.c
+++ b/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c
@@ -33,6 +33,7 @@ @@ -33,6 +33,7 @@
@ -29,18 +30,32 @@ index e612250..2d52322 100644
#include "pub_core_tooliface.h" /* VG_(needs) */ #include "pub_core_tooliface.h" /* VG_(needs) */
#include "pub_core_xarray.h" #include "pub_core_xarray.h"
#include "priv_misc.h" /* dinfo_zalloc/free/strdup */ #include "priv_misc.h" /* dinfo_zalloc/free/strdup */
@@ -1527,6 +1529,51 @@ static Bool check_compression(ElfXX_Shdr* h, DiSlice* s) { @@ -1323,6 +1325,12 @@ DiImage* find_debug_file( struct _DebugInfo* di,
+ (extrapath ? VG_(strlen)(extrapath) : 0)
+ (serverpath ? VG_(strlen)(serverpath) : 0));
+ if (debugname[0] == '/') {
+ VG_(sprintf)(debugpath, "%s", debugname);
+ dimg = open_debug_file(debugpath, buildid, crc, rel_ok, NULL);
+ if (dimg != NULL) goto dimg_ok;
+ }
+
VG_(sprintf)(debugpath, "%s/%s", objdir, debugname);
dimg = open_debug_file(debugpath, buildid, crc, rel_ok, NULL);
if (dimg != NULL) goto dimg_ok;
@@ -1527,6 +1535,56 @@ static Bool check_compression(ElfXX_Shdr* h, DiSlice* s) {
return True; return True;
} }
+/* Helper function to get the readlink path. Returns NULL on error. +/* Helper function to get the readlink path. Returns a copy of path if the
+ Otherwise the result needs to be released with dinfo_free. + file wasn't a symbolic link. Returns NULL on error. Unless NULL is
+ returned the result needs to be released with dinfo_free.
+*/ +*/
+static HChar* readlink_path (const HChar *path) +static HChar* readlink_path (const HChar *path)
+{ +{
+ SizeT bufsiz = VG_(strlen)(path); + SizeT bufsiz = VG_(strlen)(path);
+ HChar *buf = ML_(dinfo_strdup)("readlink_path.strdup", path); + HChar *buf = ML_(dinfo_strdup)("readlink_path.strdup", path);
+ UInt tries = 8; + UInt tries = 6;
+ +
+ while (tries > 0) { + while (tries > 0) {
+ SysRes res; + SysRes res;
@ -55,11 +70,15 @@ index e612250..2d52322 100644
+#else +#else
+# error Unknown OS +# error Unknown OS
+#endif +#endif
+ if (sr_isError(res)) + if (sr_isError(res)) {
+ return NULL; + if (sr_Err(res) == VKI_EINVAL)
+ return buf; // It wasn't a symbolic link, return the strdup result.
+ ML_(dinfo_free)(buf);
+ return NULL;
+ }
+ +
+ SSizeT r = sr_Res(res); + SSizeT r = sr_Res(res);
+ if (r < 0) break; + if (r < 0) break;
+ if (r == bufsiz) { // buffer too small; increase and retry + if (r == bufsiz) { // buffer too small; increase and retry
+ bufsiz *= 2 + 16; + bufsiz *= 2 + 16;
+ buf = ML_(dinfo_realloc)("readlink_path.realloc", buf, bufsiz); + buf = ML_(dinfo_realloc)("readlink_path.realloc", buf, bufsiz);
@ -81,7 +100,7 @@ index e612250..2d52322 100644
/* The central function for reading ELF debug info. For the /* The central function for reading ELF debug info. For the
object/exe specified by the DebugInfo, find ELF sections, then read object/exe specified by the DebugInfo, find ELF sections, then read
the symbols, line number info, file name info, CFA (stack-unwind the symbols, line number info, file name info, CFA (stack-unwind
@@ -2926,8 +2973,12 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) @@ -2926,8 +2984,12 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
(debugaltlink_escn.szB - buildid_offset) (debugaltlink_escn.szB - buildid_offset)
* 2 + 1); * 2 + 1);
@ -95,7 +114,7 @@ index e612250..2d52322 100644
for (j = 0; j < debugaltlink_escn.szB - buildid_offset; j++) for (j = 0; j < debugaltlink_escn.szB - buildid_offset; j++)
VG_(sprintf)( VG_(sprintf)(
@@ -2937,9 +2988,11 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di ) @@ -2937,9 +2999,11 @@ Bool ML_(read_elf_debug_info) ( struct _DebugInfo* di )
+ buildid_offset + j)); + buildid_offset + j));
/* See if we can find a matching debug file */ /* See if we can find a matching debug file */
@ -108,6 +127,3 @@ index e612250..2d52322 100644
if (altfile_str_m) if (altfile_str_m)
ML_(dinfo_free)(altfile_str_m); ML_(dinfo_free)(altfile_str_m);
ML_(dinfo_free)(altbuildid); ML_(dinfo_free)(altbuildid);
--
1.8.3.1

View File

@ -3,7 +3,7 @@
Summary: Tool for finding memory management bugs in programs Summary: Tool for finding memory management bugs in programs
Name: %{?scl_prefix}valgrind Name: %{?scl_prefix}valgrind
Version: 3.13.0 Version: 3.13.0
Release: 11%{?dist} Release: 12%{?dist}
Epoch: 1 Epoch: 1
License: GPLv2+ License: GPLv2+
URL: http://www.valgrind.org/ URL: http://www.valgrind.org/
@ -488,8 +488,9 @@ echo ===============END TESTING===============
%endif %endif
%changelog %changelog
* Tue Dec 12 2017 Mark Wielaard <mjw@fedoraproject.org> * Tue Dec 12 2017 Mark Wielaard <mjw@fedoraproject.org> - 3.13.0-12
- Add valgrind-3.13.0-s390-cgijnl.patch. - Add valgrind-3.13.0-s390-cgijnl.patch.
- Use upstream version of valgrind-3.13.0-debug-alt-file.patch.
* Sun Dec 10 2017 Mark Wielaard <mjw@fedoraproject.org> - 3.13.0-11 * Sun Dec 10 2017 Mark Wielaard <mjw@fedoraproject.org> - 3.13.0-11
- Add valgrind-3.13.0-debug-alt-file.patch. - Add valgrind-3.13.0-debug-alt-file.patch.