You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(122) |
Nov
(152) |
Dec
(69) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(6) |
Feb
(25) |
Mar
(73) |
Apr
(82) |
May
(24) |
Jun
(25) |
Jul
(10) |
Aug
(11) |
Sep
(10) |
Oct
(54) |
Nov
(203) |
Dec
(182) |
| 2004 |
Jan
(307) |
Feb
(305) |
Mar
(430) |
Apr
(312) |
May
(187) |
Jun
(342) |
Jul
(487) |
Aug
(637) |
Sep
(336) |
Oct
(373) |
Nov
(441) |
Dec
(210) |
| 2005 |
Jan
(385) |
Feb
(480) |
Mar
(636) |
Apr
(544) |
May
(679) |
Jun
(625) |
Jul
(810) |
Aug
(838) |
Sep
(634) |
Oct
(521) |
Nov
(965) |
Dec
(543) |
| 2006 |
Jan
(494) |
Feb
(431) |
Mar
(546) |
Apr
(411) |
May
(406) |
Jun
(322) |
Jul
(256) |
Aug
(401) |
Sep
(345) |
Oct
(542) |
Nov
(308) |
Dec
(481) |
| 2007 |
Jan
(427) |
Feb
(326) |
Mar
(367) |
Apr
(255) |
May
(244) |
Jun
(204) |
Jul
(223) |
Aug
(231) |
Sep
(354) |
Oct
(374) |
Nov
(497) |
Dec
(362) |
| 2008 |
Jan
(322) |
Feb
(482) |
Mar
(658) |
Apr
(422) |
May
(476) |
Jun
(396) |
Jul
(455) |
Aug
(267) |
Sep
(280) |
Oct
(253) |
Nov
(232) |
Dec
(304) |
| 2009 |
Jan
(486) |
Feb
(470) |
Mar
(458) |
Apr
(423) |
May
(696) |
Jun
(461) |
Jul
(551) |
Aug
(575) |
Sep
(134) |
Oct
(110) |
Nov
(157) |
Dec
(102) |
| 2010 |
Jan
(226) |
Feb
(86) |
Mar
(147) |
Apr
(117) |
May
(107) |
Jun
(203) |
Jul
(193) |
Aug
(238) |
Sep
(300) |
Oct
(246) |
Nov
(23) |
Dec
(75) |
| 2011 |
Jan
(133) |
Feb
(195) |
Mar
(315) |
Apr
(200) |
May
(267) |
Jun
(293) |
Jul
(353) |
Aug
(237) |
Sep
(278) |
Oct
(611) |
Nov
(274) |
Dec
(260) |
| 2012 |
Jan
(303) |
Feb
(391) |
Mar
(417) |
Apr
(441) |
May
(488) |
Jun
(655) |
Jul
(590) |
Aug
(610) |
Sep
(526) |
Oct
(478) |
Nov
(359) |
Dec
(372) |
| 2013 |
Jan
(467) |
Feb
(226) |
Mar
(391) |
Apr
(281) |
May
(299) |
Jun
(252) |
Jul
(311) |
Aug
(352) |
Sep
(481) |
Oct
(571) |
Nov
(222) |
Dec
(231) |
| 2014 |
Jan
(185) |
Feb
(329) |
Mar
(245) |
Apr
(238) |
May
(281) |
Jun
(399) |
Jul
(382) |
Aug
(500) |
Sep
(579) |
Oct
(435) |
Nov
(487) |
Dec
(256) |
| 2015 |
Jan
(338) |
Feb
(357) |
Mar
(330) |
Apr
(294) |
May
(191) |
Jun
(108) |
Jul
(142) |
Aug
(261) |
Sep
(190) |
Oct
(54) |
Nov
(83) |
Dec
(22) |
| 2016 |
Jan
(49) |
Feb
(89) |
Mar
(33) |
Apr
(50) |
May
(27) |
Jun
(34) |
Jul
(53) |
Aug
(53) |
Sep
(98) |
Oct
(206) |
Nov
(93) |
Dec
(53) |
| 2017 |
Jan
(65) |
Feb
(82) |
Mar
(102) |
Apr
(86) |
May
(187) |
Jun
(67) |
Jul
(23) |
Aug
(93) |
Sep
(65) |
Oct
(45) |
Nov
(35) |
Dec
(17) |
| 2018 |
Jan
(26) |
Feb
(35) |
Mar
(38) |
Apr
(32) |
May
(8) |
Jun
(43) |
Jul
(27) |
Aug
(30) |
Sep
(43) |
Oct
(42) |
Nov
(38) |
Dec
(67) |
| 2019 |
Jan
(32) |
Feb
(37) |
Mar
(53) |
Apr
(64) |
May
(49) |
Jun
(18) |
Jul
(14) |
Aug
(53) |
Sep
(25) |
Oct
(30) |
Nov
(49) |
Dec
(31) |
| 2020 |
Jan
(87) |
Feb
(45) |
Mar
(37) |
Apr
(51) |
May
(99) |
Jun
(36) |
Jul
(11) |
Aug
(14) |
Sep
(20) |
Oct
(24) |
Nov
(40) |
Dec
(23) |
| 2021 |
Jan
(14) |
Feb
(53) |
Mar
(85) |
Apr
(15) |
May
(19) |
Jun
(3) |
Jul
(14) |
Aug
(1) |
Sep
(57) |
Oct
(73) |
Nov
(56) |
Dec
(22) |
| 2022 |
Jan
(3) |
Feb
(22) |
Mar
(6) |
Apr
(55) |
May
(46) |
Jun
(39) |
Jul
(15) |
Aug
(9) |
Sep
(11) |
Oct
(34) |
Nov
(20) |
Dec
(36) |
| 2023 |
Jan
(79) |
Feb
(41) |
Mar
(99) |
Apr
(169) |
May
(48) |
Jun
(16) |
Jul
(16) |
Aug
(57) |
Sep
(19) |
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
1
(1) |
2
|
3
(2) |
4
(2) |
5
|
6
|
|
7
(1) |
8
|
9
|
10
(1) |
11
(1) |
12
(2) |
13
|
|
14
|
15
|
16
(1) |
17
(1) |
18
|
19
|
20
(13) |
|
21
(3) |
22
(2) |
23
(6) |
24
(2) |
25
(5) |
26
(2) |
27
(2) |
|
28
(6) |
|
|
|
|
|
|
|
From: Mark W. <ma...@so...> - 2021-02-26 01:40:38
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=9c9b909cbfbc36156c366b4829be09f015a63474 commit 9c9b909cbfbc36156c366b4829be09f015a63474 Author: Mark Wielaard <ma...@kl...> Date: Fri Feb 26 02:34:32 2021 +0100 Make the dwarf3 reader more robust and less chatty when things go wrong Skip some stuff when seeing an unknown language, be less chatty about parser issues. All the issues seem to come from the multi-file, that is the shared (supplementary or alt) file containing debuginfo shared by all the gcc/runtime libraries. There are a couple of issues that this patch works around: - The multifile contains entries for the 'D' language, which has some constructs we don't expect. - We don't read partial units correctly, which means we often don't know the language we are looking at. - The parser is very chatty about issues it didn't expect (even if they are ignored, it will still output something) It only shows up with --read-var-info=yes which some tests enable, but which is disabled by default. Also increate the timeout of drd/tests/pth_cleanup_handler.c because DWARF reading is so slow. https://bugs.kde.org/show_bug.cgi?id=433500 Diff: --- NEWS | 3 ++- coregrind/m_debuginfo/readdwarf3.c | 16 ++++++++++++++-- coregrind/m_debuginfo/storage.c | 2 +- drd/tests/pth_cleanup_handler.c | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 3a34269869..adcb852486 100644 --- a/NEWS +++ b/NEWS @@ -118,6 +118,7 @@ where XXXXXX is the bug number as listed below. 428648 s390_emit_load_mem panics due to 20-bit offset for vector load 428716 cppcheck detects potential leak in VEX/useful/smchash.c 428909 helgrind: need to intercept duplicate libc definitions for Fedora 33 +429352 PPC ISA 3.1 support is missing, part 7 429692 unhandled ppc64le-linux syscall: 147 (getsid) 429864 s390x: C++ atomic test_and_set yields false-positive memcheck diagnostics @@ -132,8 +133,8 @@ where XXXXXX is the bug number as listed below. 432809 VEX should support REX.W + POPF 432861 PPC modsw and modsd give incorrect results for 1 mod 12 432215 Add debuginfod functionality +433500 DRD regtest faulures when libstdc++ and libgcc debuginfo are installed n-i-bz helgrind: If hg_cli__realloc fails, return NULL. -429352 PPC ISA 3.1 support is missing, part 7 Release 3.16.1 (22 June 2020) diff --git a/coregrind/m_debuginfo/readdwarf3.c b/coregrind/m_debuginfo/readdwarf3.c index 60fc402447..52c27d4bb4 100644 --- a/coregrind/m_debuginfo/readdwarf3.c +++ b/coregrind/m_debuginfo/readdwarf3.c @@ -3416,6 +3416,9 @@ static void typestack_push ( const CUConst* cc, static Bool subrange_type_denotes_array_bounds ( const D3TypeParser* parser, DW_TAG dtag ) { vg_assert(dtag == DW_TAG_subrange_type); + /* If we don't know the language, assume false. */ + if (parser->language == '?') + return False; /* For most languages, a subrange_type dtag always gives the bounds of an array. For Ada, there are additional conditions as a subrange_type @@ -3916,6 +3919,7 @@ static void parse_type_DIE ( /*MOD*/XArray* /* of TyEnt */ tyents, members must have a DW_AT_data_member_location expression whereas union members must not. */ Bool parent_is_struct; + Bool is_artificial = False; VG_(memset)( &fieldE, 0, sizeof(fieldE) ); fieldE.cuOff = posn; fieldE.tag = Te_Field; @@ -3952,7 +3956,12 @@ static void parse_type_DIE ( /*MOD*/XArray* /* of TyEnt */ tyents, (SizeT)fieldE.Te.Field.nLoc, "di.readdwarf3.ptD.member.2" ); } + if (attr == DW_AT_artificial && cts.u.val == 1) + is_artificial = True; } + /* Skip artificial members, they might not behave as expected. */ + if (is_artificial) + goto no_location; /* Do we have a plausible parent? */ if (typestack_is_empty(parser)) goto_bad_DIE; vg_assert(ML_(TyEnt__is_type)(&parser->qparentE[parser->sp])); @@ -3995,6 +4004,7 @@ static void parse_type_DIE ( /*MOD*/XArray* /* of TyEnt */ tyents, const members in C++ code which are compile time constants that do no exist in the class. They're not of any interest to us so we ignore them. */ + no_location: ML_(TyEnt__make_EMPTY)(&fieldE); } } @@ -4132,7 +4142,8 @@ static void parse_type_DIE ( /*MOD*/XArray* /* of TyEnt */ tyents, || (dtag == DW_TAG_subrange_type && !subrange_type_denotes_array_bounds(parser, dtag))) { /* subrange_type other than array bound is only for Ada. */ - vg_assert (dtag == DW_TAG_typedef || parser->language == 'A'); + vg_assert (dtag == DW_TAG_typedef || (parser->language == 'A' + || parser->language == '?')); /* We can pick up a new typedef/subrange_type any time. */ VG_(memset)(&typeE, 0, sizeof(typeE)); typeE.cuOff = D3_INVALID_CUOFF; @@ -4300,7 +4311,8 @@ static UWord chase_cuOff ( Bool* changed, ent = ML_(TyEnts__index_by_cuOff)( ents, ents_cache, cuOff ); if (!ent) { - VG_(printf)("chase_cuOff: no entry for 0x%05lx\n", cuOff); + if (VG_(clo_verbosity) > 1) + VG_(printf)("chase_cuOff: no entry for 0x%05lx\n", cuOff); *changed = False; return cuOff; } diff --git a/coregrind/m_debuginfo/storage.c b/coregrind/m_debuginfo/storage.c index 2a975dccc3..8667d123ff 100644 --- a/coregrind/m_debuginfo/storage.c +++ b/coregrind/m_debuginfo/storage.c @@ -1299,7 +1299,7 @@ void ML_(addVar)( struct _DebugInfo* di, ML_(read_elf_debug_info). */ vg_assert(di->fsm.have_rx_map && di->fsm.have_rw_map); if (level > 0 && ML_(find_rx_mapping)(di, aMin, aMax) == NULL) { - if (VG_(clo_verbosity) >= 0) { + if (VG_(clo_verbosity) > 1) { VG_(message)(Vg_DebugMsg, "warning: addVar: in range %#lx .. %#lx outside " "all rx mapped areas (%s)\n", diff --git a/drd/tests/pth_cleanup_handler.c b/drd/tests/pth_cleanup_handler.c index 0fb3d073d6..e441fa3a41 100644 --- a/drd/tests/pth_cleanup_handler.c +++ b/drd/tests/pth_cleanup_handler.c @@ -39,7 +39,7 @@ int main() pthread_t pt1, pt2; // Make sure the program exits in case a deadlock has been triggered. - alarm(20); + alarm(60); if (pthread_mutex_init(&s_mutex, NULL) != 0) { |
|
From: Mark W. <ma...@so...> - 2021-02-26 00:40:32
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=fd4e3fb0ffa3f751f0e7f2e7f4639d4c3773305d commit fd4e3fb0ffa3f751f0e7f2e7f4639d4c3773305d Author: Aaron Merey <am...@re...> Date: Thu Feb 18 22:58:25 2021 -0500 PR432215 Add debuginfod functionality debuginfod is an HTTP server for distributing ELF/DWARF debugging information. When a debuginfo file cannot be found locally, Valgrind is able to query debuginfod servers for the file using its build-id. readelf.c: Add debuginfod_find_debug_file(). Spawns a child process to exec `debuginfod-find` in order to query servers for the debuginfo file. Also add helper debuginfod_find_path(). pub_core_pathscan.h: Moved from priv_initimg_pathscan.h in order to use VG_(find_executable)() in readelf.c. docs: Add information regarding debuginfod to valgrind.1 memcheck/tests/linux: Add new test debuginfod-check. tests/vg_regtest.in: Clear $DEBUGINFOD_URLS before running any tests. https://bugs.kde.org/show_bug.cgi?id=432215 Diff: --- .gitignore | 3 + NEWS | 7 ++ configure.ac | 1 + coregrind/Makefile.am | 4 +- coregrind/m_debuginfo/readelf.c | 137 +++++++++++++++++++++ coregrind/m_initimg/initimg-darwin.c | 4 +- coregrind/m_initimg/initimg-linux.c | 4 +- coregrind/m_initimg/initimg-solaris.c | 4 +- .../{m_initimg/initimg-pathscan.c => m_pathscan.c} | 8 +- ...priv_initimg_pathscan.h => pub_core_pathscan.h} | 12 +- docs/xml/manual-core.xml | 28 +++++ docs/xml/valgrind-manpage.xml | 13 ++ memcheck/tests/linux/Makefile.am | 2 + memcheck/tests/linux/debuginfod-check.c | 7 ++ memcheck/tests/linux/debuginfod-check.pl | 116 +++++++++++++++++ memcheck/tests/linux/debuginfod-check.stderr.exp | 6 + memcheck/tests/linux/debuginfod-check.vgtest.in | 4 + tests/vg_regtest.in | 2 + 18 files changed, 343 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 3afc37f4cd..c22c0315a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1065,6 +1065,9 @@ /memcheck/tests/linux/sys-execveat /memcheck/tests/linux/check_execveat /memcheck/tests/linux/enomem +/memcheck/tests/linux/debuginfod-check +/memcheck/tests/linux/debuginfod-check.vgtest +/memcheck/tests/linux/.debuginfod/ # /memcheck/tests/mips32/ /memcheck/tests/mips32/*.stderr.diff diff --git a/NEWS b/NEWS index a20f96f0c6..3a34269869 100644 --- a/NEWS +++ b/NEWS @@ -35,6 +35,12 @@ support for X86/macOS 10.13, AMD64/macOS 10.13 and nanoMIPS/Linux. Valgrind. The vector-packed-decimal facility is currently not exploited by the standard toolchain and libraries. +* Valgrind now supports debuginfod, an HTTP server for distributing + ELF/DWARF debugging information. When a debuginfo file cannot be + found locally, Valgrind is able to query debuginfod servers for the + file using its build-id. See the user manual for more information + about debuginfod support. + * ==================== TOOL CHANGES ==================== * DHAT: @@ -125,6 +131,7 @@ where XXXXXX is the bug number as listed below. 432672 vg_regtest: test-specific environment variables not reset between tests 432809 VEX should support REX.W + POPF 432861 PPC modsw and modsd give incorrect results for 1 mod 12 +432215 Add debuginfod functionality n-i-bz helgrind: If hg_cli__realloc fails, return NULL. 429352 PPC ISA 3.1 support is missing, part 7 diff --git a/configure.ac b/configure.ac index 4648450fe3..595003b46d 100755 --- a/configure.ac +++ b/configure.ac @@ -4903,6 +4903,7 @@ AC_CONFIG_FILES([ memcheck/tests/amd64/Makefile memcheck/tests/x86/Makefile memcheck/tests/linux/Makefile + memcheck/tests/linux/debuginfod-check.vgtest memcheck/tests/darwin/Makefile memcheck/tests/solaris/Makefile memcheck/tests/amd64-linux/Makefile diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am index 1753fb633c..be097f44f5 100644 --- a/coregrind/Makefile.am +++ b/coregrind/Makefile.am @@ -212,6 +212,7 @@ noinst_HEADERS = \ pub_core_mallocfree.h \ pub_core_options.h \ pub_core_oset.h \ + pub_core_pathscan.h \ pub_core_poolalloc.h \ pub_core_rangemap.h \ pub_core_redir.h \ @@ -267,7 +268,6 @@ noinst_HEADERS = \ m_gdbserver/target.h \ m_gdbserver/valgrind_low.h \ m_gdbserver/gdb/signals.h \ - m_initimg/priv_initimg_pathscan.h \ m_scheduler/priv_sema.h \ m_scheduler/priv_sched-lock.h \ m_scheduler/priv_sched-lock-impl.h \ @@ -317,6 +317,7 @@ COREGRIND_SOURCES_COMMON = \ m_mallocfree.c \ m_options.c \ m_oset.c \ + m_pathscan.c \ m_poolalloc.c \ m_rangemap.c \ m_redir.c \ @@ -403,7 +404,6 @@ COREGRIND_SOURCES_COMMON = \ m_initimg/initimg-linux.c \ m_initimg/initimg-darwin.c \ m_initimg/initimg-solaris.c \ - m_initimg/initimg-pathscan.c \ m_mach/mach_basics.c \ m_mach/mach_msg.c \ m_mach/mach_traps-x86-darwin.S \ diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c index 404034df06..3f5f48c703 100644 --- a/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c @@ -36,9 +36,12 @@ #include "pub_core_libcbase.h" #include "pub_core_libcprint.h" #include "pub_core_libcassert.h" +#include "pub_core_libcfile.h" +#include "pub_core_libcproc.h" #include "pub_core_machine.h" /* VG_ELF_CLASS */ #include "pub_core_options.h" #include "pub_core_oset.h" +#include "pub_core_pathscan.h" /* find_executable */ #include "pub_core_syscall.h" #include "pub_core_tooliface.h" /* VG_(needs) */ #include "pub_core_xarray.h" @@ -1281,6 +1284,135 @@ DiImage* open_debug_file( const HChar* name, const HChar* buildid, UInt crc, return dimg; } +#if defined(VGO_linux) +/* Return the path of the debuginfod-find executable. */ +static +const HChar* debuginfod_find_path( void ) +{ + static const HChar* path = (const HChar*) -1; + + if (path == (const HChar*) -1) { + if (VG_(getenv)("DEBUGINFOD_URLS") == NULL + || VG_(strcmp)("", VG_(getenv("DEBUGINFOD_URLS"))) == 0) + path = NULL; + else + path = VG_(find_executable)("debuginfod-find"); + } + + return path; +} + +/* Try to find a separate debug file with |buildid| via debuginfod. If found, + return its DiImage. Searches for a local debuginfod-find executable and + runs it in a child process in order to download the debug file. */ +static +DiImage* find_debug_file_debuginfod( const HChar* objpath, + HChar** debugpath, + const HChar* buildid, + const UInt crc, Bool rel_ok ) +{ +# define BUF_SIZE 4096 + Int out_fds[2], err_fds[2]; /* pipe fds */ + DiImage* dimg = NULL; /* the img we found */ + HChar buf[BUF_SIZE]; /* executable output buffer */ + const HChar* path; /* executable path */ + SizeT len; /* number of bytes read int buf */ + Int ret; /* result of read call */ + + if (buildid == NULL) + return NULL; + + if ((path = debuginfod_find_path()) == NULL) + return NULL; + + if (VG_(pipe)(out_fds) != 0 + || VG_(pipe)(err_fds) != 0) + return NULL; + + if (VG_(clo_verbosity) > 1) + VG_(umsg)("Downloading debug info for %s...\n", objpath); + + /* Run debuginfod-find to query servers for the debuginfo. */ + Int pid = VG_(fork)(); + if (pid == 0) { + const HChar *argv[4] = { path, "debuginfo", buildid, (HChar*)0 }; + + /* Redirect stdout and stderr */ + SysRes res = VG_(dup2)(out_fds[1], 1); + if (sr_Res(res) < 0) + VG_(exit)(1); + + res = VG_(dup2)(err_fds[1], 2); + if (sr_Res(res) < 0) + VG_(exit)(1); + + /* Disable extra stderr output since it does not play well with umesg */ + VG_(env_unsetenv)(VG_(client_envp), "DEBUGINFOD_VERBOSE", NULL); + VG_(env_unsetenv)(VG_(client_envp), "DEBUGINFOD_PROGRESS", NULL); + + VG_(close)(out_fds[0]); + VG_(close)(err_fds[0]); + VG_(execv)(argv[0], argv); + + /* If we are still alive here, execv failed. */ + VG_(exit)(1); + } + + VG_(close)(out_fds[1]); + VG_(close)(err_fds[1]); + + if (pid < 0) { + if (VG_(clo_verbosity) > 1) + VG_(umsg)("Server Error\n"); + goto out; + } + VG_(waitpid)(pid, NULL, 0); + + /* Set dimg if download was successful. */ + len = 0; + ret = -1; + while (len >= 0 && len < BUF_SIZE) { + ret = VG_(read)(out_fds[0], buf + len, BUF_SIZE - len); + if (ret <= 0) + break; + len += ret; + } + if (ret >= 0 && len > 0 + && buf[0] == '/' && buf[len-1] == '\n') { + + /* Remove newline from filename before trying to open debug file */ + buf[len-1] = '\0'; + dimg = open_debug_file(buf, buildid, crc, rel_ok, NULL); + if (dimg != NULL) { + /* Success */ + if (*debugpath) + ML_(dinfo_free)(*debugpath); + + *debugpath = ML_(dinfo_strdup)("di.fdfd.1", buf); + if (VG_(clo_verbosity) > 1) + VG_(umsg)("Successfully downloaded debug file for %s\n", + objpath); + goto out; + } + } + + /* Download failed so try to print error message. */ + HChar* nl; + if (VG_(read)(err_fds[0], buf, BUF_SIZE) > 0 + && (nl = VG_(strchr)(buf, '\n'))) { + *nl = '\0'; + if (VG_(clo_verbosity) > 1) + VG_(umsg)("%s\n", buf); + } else + if (VG_(clo_verbosity) > 1) + VG_(umsg)("Server Error\n"); + +out: + VG_(close)(out_fds[0]); + VG_(close)(err_fds[0]); + return dimg; +} +#endif /* Try to find a separate debug file for a given object file. If found, return its DiImage, which should be freed by the caller. If @@ -1381,6 +1513,11 @@ DiImage* find_debug_file( struct _DebugInfo* di, ML_(dinfo_free)(objdir); } +# if defined(VGO_linux) + if (dimg == NULL) + dimg = find_debug_file_debuginfod(objpath, &debugpath, buildid, crc, rel_ok); +# endif + if (dimg != NULL) { vg_assert(debugpath); TRACE_SYMTAB("\n"); diff --git a/coregrind/m_initimg/initimg-darwin.c b/coregrind/m_initimg/initimg-darwin.c index e2662476ad..564d2fdaa7 100644 --- a/coregrind/m_initimg/initimg-darwin.c +++ b/coregrind/m_initimg/initimg-darwin.c @@ -46,7 +46,7 @@ #include "pub_core_options.h" #include "pub_core_tooliface.h" /* VG_TRACK */ #include "pub_core_threadstate.h" /* ThreadArchState */ -#include "priv_initimg_pathscan.h" +#include "pub_core_pathscan.h" /* find_executable */ #include "pub_core_initimg.h" /* self */ @@ -64,7 +64,7 @@ static void load_client ( /*OUT*/ExeInfo* info, SysRes res; vg_assert( VG_(args_the_exename) != NULL); - exe_name = ML_(find_executable)( VG_(args_the_exename) ); + exe_name = VG_(find_executable)( VG_(args_the_exename) ); if (!exe_name) { VG_(printf)("valgrind: %s: command not found\n", VG_(args_the_exename)); diff --git a/coregrind/m_initimg/initimg-linux.c b/coregrind/m_initimg/initimg-linux.c index cb7902446a..73dab34363 100644 --- a/coregrind/m_initimg/initimg-linux.c +++ b/coregrind/m_initimg/initimg-linux.c @@ -47,7 +47,7 @@ #include "pub_core_syscall.h" #include "pub_core_tooliface.h" /* VG_TRACK */ #include "pub_core_threadstate.h" /* ThreadArchState */ -#include "priv_initimg_pathscan.h" +#include "pub_core_pathscan.h" /* find_executable */ #include "pub_core_initimg.h" /* self */ /* --- !!! --- EXTERNAL HEADERS start --- !!! --- */ @@ -73,7 +73,7 @@ static void load_client ( /*MOD*/ExeInfo* info, SysRes res; vg_assert( VG_(args_the_exename) != NULL); - exe_name = ML_(find_executable)( VG_(args_the_exename) ); + exe_name = VG_(find_executable)( VG_(args_the_exename) ); if (!exe_name) { VG_(printf)("valgrind: %s: command not found\n", VG_(args_the_exename)); diff --git a/coregrind/m_initimg/initimg-solaris.c b/coregrind/m_initimg/initimg-solaris.c index 0a6c385b76..3e473c8803 100644 --- a/coregrind/m_initimg/initimg-solaris.c +++ b/coregrind/m_initimg/initimg-solaris.c @@ -51,7 +51,7 @@ #include "pub_core_syswrap.h" #include "pub_core_tooliface.h" /* VG_TRACK */ #include "pub_core_threadstate.h" /* ThreadArchState */ -#include "priv_initimg_pathscan.h" +#include "pub_core_pathscan.h" /* find_executable */ #include "pub_core_initimg.h" /* self */ @@ -68,7 +68,7 @@ static void load_client(/*OUT*/ExeInfo *info, SysRes res; vg_assert(VG_(args_the_exename)); - exe_name = ML_(find_executable)(VG_(args_the_exename)); + exe_name = VG_(find_executable)(VG_(args_the_exename)); if (!exe_name) { VG_(printf)("valgrind: %s: command not found\n", VG_(args_the_exename)); diff --git a/coregrind/m_initimg/initimg-pathscan.c b/coregrind/m_pathscan.c similarity index 95% rename from coregrind/m_initimg/initimg-pathscan.c rename to coregrind/m_pathscan.c index f5f825f3b1..02b371486e 100644 --- a/coregrind/m_initimg/initimg-pathscan.c +++ b/coregrind/m_pathscan.c @@ -1,6 +1,6 @@ /*--------------------------------------------------------------------*/ -/*--- Startup: search PATH for an executable initimg-pathscan.c ---*/ +/*--- search PATH for an executable m_pathscan.c ---*/ /*--------------------------------------------------------------------*/ /* @@ -33,9 +33,7 @@ #include "pub_core_libcproc.h" #include "pub_core_libcprint.h" #include "pub_core_mallocfree.h" -#include "pub_core_initimg.h" /* self */ - -#include "priv_initimg_pathscan.h" +#include "pub_core_pathscan.h" /* self */ /*====================================================================*/ @@ -117,7 +115,7 @@ static Bool match_executable(const HChar *entry) } // Returns NULL if it wasn't found. -const HChar* ML_(find_executable) ( const HChar* exec ) +const HChar* VG_(find_executable) ( const HChar* exec ) { vg_assert(NULL != exec); diff --git a/coregrind/m_initimg/priv_initimg_pathscan.h b/coregrind/pub_core_pathscan.h similarity index 78% rename from coregrind/m_initimg/priv_initimg_pathscan.h rename to coregrind/pub_core_pathscan.h index e6ffb4a8b0..d84953ab21 100644 --- a/coregrind/m_initimg/priv_initimg_pathscan.h +++ b/coregrind/pub_core_pathscan.h @@ -1,7 +1,7 @@ /*--------------------------------------------------------------------*/ -/*--- Startup: search PATH for an executable ---*/ -/*--- priv_initimg-pathscan.h ---*/ +/*--- Search PATH for an executable ---*/ +/*--- m_pathscan.h ---*/ /*--------------------------------------------------------------------*/ /* @@ -27,11 +27,11 @@ The GNU General Public License is contained in the file COPYING. */ -#ifndef __PRIV_INITIMG_PATHSCAN_H -#define __PRIV_INITIMG_PATHSCAN_H +#ifndef __PUB_CORE_PATHSCAN_H +#define __PUB_CORE_PATHSCAN_H #include "pub_core_basics.h" // HChar -extern const HChar* ML_(find_executable) ( const HChar* exec ); +extern const HChar* VG_(find_executable) ( const HChar* exec ); -#endif // ndef __PRIV_INITIMG_PATHSCAN_H +#endif // ndef __PUB_CORE_PATHSCAN_H diff --git a/docs/xml/manual-core.xml b/docs/xml/manual-core.xml index 5d52d2e3be..dc33e12696 100644 --- a/docs/xml/manual-core.xml +++ b/docs/xml/manual-core.xml @@ -592,6 +592,30 @@ to <computeroutput>malloc.</computeroutput>.</para> </sect1> +<sect1 id="manual-core.debuginfod" + xreflabel="Debuginfod"> +<title>Debuginfod</title> + +<para id="debuginfod.para.1">Valgrind supports the downloading of debuginfo +files via debuginfod, an HTTP server for distributing ELF/DWARF debugging +information. When a debuginfo file cannot be found locally, Valgrind is able +to query debuginfod servers for the file using its build-id.</para> + +<para id="debuginfod.para.2">In order to use this feature +<computeroutput>debuginfod-find</computeroutput> must be installed and +<computeroutput>$DEBUGINFOD_URLS</computeroutput> must contain URLs of +debuginfod servers. Valgrind does not support +<computeroutput>debuginfod-find</computeroutput> verbose output that is +normally enabled with <computeroutput>$DEBUGINFOD_PROGRESS</computeroutput> +and <computeroutput>$DEBUGINFOD_VERBOSE</computeroutput>. These environment +variables will be ignored.</para> + +<para id="debuginfod.para.3">For more information regarding debuginfod, see +https://sourceware.org/elfutils/Debuginfod.html</para> + +</sect1> + + <sect1 id="manual-core.options" xreflabel="Core Command-line Options"> <title>Core Command-line Options</title> @@ -1462,6 +1486,10 @@ that can report errors, e.g. Memcheck, but not Cachegrind.</para> you want to use it, you will have to recompile it by hand using the command shown at the top of <computeroutput>auxprogs/valgrind-di-server.c</computeroutput>.</para> + + <para>Valgrind can also download debuginfo via debuginfod. See the + DEBUGINFOD section for more information.</para> + </listitem> </varlistentry> diff --git a/docs/xml/valgrind-manpage.xml b/docs/xml/valgrind-manpage.xml index 3c893c680e..5c16c6eb35 100644 --- a/docs/xml/valgrind-manpage.xml +++ b/docs/xml/valgrind-manpage.xml @@ -221,6 +221,19 @@ system: <filename>&vg-docs-path;</filename>, or online: </refsect1> +<refsect1 id="debuginfod"> +<title>Debuginfod</title> + +<xi:include href="manual-core.xml" + xpointer="debuginfod.para.1" + xmlns:xi="http://www.w3.org/2001/XInclude" /> +<xi:include href="manual-core.xml" + xpointer="debuginfod.para.2" + xmlns:xi="http://www.w3.org/2001/XInclude" /> +<xi:include href="manual-core.xml" + xpointer="debuginfod.para.3" + xmlns:xi="http://www.w3.org/2001/XInclude" /> +</refsect1> <refsect1 id="see_also"> <title>See Also</title> diff --git a/memcheck/tests/linux/Makefile.am b/memcheck/tests/linux/Makefile.am index 7e796aa7fa..90a24e4abe 100644 --- a/memcheck/tests/linux/Makefile.am +++ b/memcheck/tests/linux/Makefile.am @@ -6,6 +6,7 @@ dist_noinst_SCRIPTS = filter_stderr EXTRA_DIST = \ brk.stderr.exp brk.vgtest \ capget.vgtest capget.stderr.exp capget.stderr.exp2 capget.stderr.exp3 \ + debuginfod-check.stderr.exp debuginfod-check.vgtest.in \ dlclose_leak-no-keep.stderr.exp dlclose_leak-no-keep.stdout.exp \ dlclose_leak-no-keep.vgtest \ dlclose_leak.stderr.exp dlclose_leak.stdout.exp \ @@ -37,6 +38,7 @@ check_PROGRAMS = \ brk \ capget \ check_preadv2_pwritev2 \ + debuginfod-check \ dlclose_leak dlclose_leak_so.so \ ioctl-tiocsig \ getregset \ diff --git a/memcheck/tests/linux/debuginfod-check.c b/memcheck/tests/linux/debuginfod-check.c new file mode 100644 index 0000000000..185139a8d8 --- /dev/null +++ b/memcheck/tests/linux/debuginfod-check.c @@ -0,0 +1,7 @@ +#include <stdlib.h> + +int main() { + char *p = malloc(1); + p[-1] = 0; + return 0; +} diff --git a/memcheck/tests/linux/debuginfod-check.pl b/memcheck/tests/linux/debuginfod-check.pl new file mode 100755 index 0000000000..4a2c1c1e1d --- /dev/null +++ b/memcheck/tests/linux/debuginfod-check.pl @@ -0,0 +1,116 @@ +#! /usr/bin/perl +use warnings; +use strict; +use Cwd; +use IPC::Open3; + +our $dir = Cwd::realpath("./.debuginfod"); +our $pid = 0; + +# Kill the server and remove temporary files. +sub cleanup_and_exit($) { + my $exit_code = $_[0]; + mysystem("rm -rf $dir"); + if ($pid != 0) { + kill "INT", $pid; + } + exit $exit_code; +} + +# Propagate Ctrl-C and exit if command results in an error. +sub mysystem($) +{ + my $exit_code = system($_[0]); + ($exit_code == 2) and cleanup_and_exit(1); # Exit if SIGINT + if ($exit_code != 0) { + #warn "Error while executing: $_[0]"; + cleanup_and_exit(1); + } + return $exit_code; +} + +# Check that debuginfod and debuginfod-find can be found +mysystem("debuginfod --help > /dev/null"); +mysystem("debuginfod-find --help > /dev/null"); + +$SIG{'INT'} = sub { cleanup_and_exit(1) }; + +my $testname = "debuginfod-check"; +my $tmp = "$dir/debuginfod_test.tmp"; +my $dbg = "$dir/dbg"; +mysystem("rm -rf $dir"); +mysystem("mkdir -p $dbg"); + +# Compile the test executable, strip its debuginfo and store it so +# that valgrind cannot find it without debuginfod. +mysystem("gcc -O0 -g -o $testname $testname.c"); +mysystem("objcopy --only-keep-debug $testname $testname.debug"); +mysystem("objcopy --strip-unneeded $testname"); +mysystem("objcopy --add-gnu-debuglink=$testname.debug $testname"); +mysystem("mv $testname.debug $dbg"); +mysystem("readelf -n $testname > $tmp 2>&1"); + +my $buildid = ""; +open(TMP, '<', $tmp); +while (my $out = <TMP>) { + if ($out =~ /Build ID: ([0-9a-f]*)/) { + $buildid = $1; + } +} + +if ($buildid eq "") { + warn "can't find $testname build-id"; + cleanup_and_exit(1); +} + +my $found_port = 0; +my $port = 7999; + +# Find an unused port +while ($found_port == 0 and $port < 65536) { + $port++; + $pid = open3(undef, "TMP", undef, + "debuginfod", "-d", "$dir/db", '-F', "$dbg", "--port=$port"); + for (my $i = 0; $i < 5 and $found_port == 0; $i++) { + while (my $got = <TMP>) { + if ($got =~ /Failed to bind/) { + last; + } elsif ($got =~ /started http server/) { + $found_port = 1; + last; + } + } + } +} + +if ($port == 65536) { + warn "No available ports"; + cleanup_and_exit(1); +} + +my $server_ready = 0; + +# Confirm that the server is ready to be queried +for (my $i = 0; $i < 10 and $server_ready == 0; $i++) { + sleep 1; + my $got = `curl -s http://localhost:$port/metrics`; + if ($got =~ /ready 1/ + and $got =~ /thread_work_total\{role=\"traverse\"\} 1/ + and $got =~ /thread_work_pending\{role=\"scan\"\} 0/ + and $got =~ /thread_busy\{role=\"scan\"\} 0/) { + $server_ready = 1; + } +} + +if ($server_ready == 0) { + warn "Can't start debuginfod server"; + cleanup_and_exit(1); +} + +# Query the server and store the debuginfo in the client cache for valgrind to find. +my $myres = mysystem("DEBUGINFOD_CACHE_PATH=$dir DEBUGINFOD_URLS=http://localhost:$port debuginfod-find debuginfo $buildid > /dev/null 2>&1"); +if ($myres != 0) { + cleanup_and_exit(1); +} +kill "INT", $pid; +exit 0; diff --git a/memcheck/tests/linux/debuginfod-check.stderr.exp b/memcheck/tests/linux/debuginfod-check.stderr.exp new file mode 100644 index 0000000000..98236beeb3 --- /dev/null +++ b/memcheck/tests/linux/debuginfod-check.stderr.exp @@ -0,0 +1,6 @@ +Invalid write of size 1 + at 0x........: main (debuginfod-check.c:5) + Address 0x........ is 1 bytes before a block of size 1 alloc'd + at 0x........: malloc (vg_replace_malloc.c:...) + by 0x........: main (debuginfod-check.c:4) + diff --git a/memcheck/tests/linux/debuginfod-check.vgtest.in b/memcheck/tests/linux/debuginfod-check.vgtest.in new file mode 100644 index 0000000000..308e16ca9b --- /dev/null +++ b/memcheck/tests/linux/debuginfod-check.vgtest.in @@ -0,0 +1,4 @@ +prereq: ./debuginfod-check.pl +prog: debuginfod-check +vgopts: -q +env: DEBUGINFOD_URLS=localhost DEBUGINFOD_CACHE_PATH=@abs_top_builddir@/memcheck/tests/linux/.debuginfod diff --git a/tests/vg_regtest.in b/tests/vg_regtest.in index c7cc60124b..0fe63411a1 100755 --- a/tests/vg_regtest.in +++ b/tests/vg_regtest.in @@ -699,6 +699,8 @@ sub warn_about_EXTRA_REGTEST_OPTS() # nuke VALGRIND_OPTS $ENV{"VALGRIND_OPTS"} = ""; +# nuke DEBUGINFOD_URLS +$ENV{"DEBUGINFOD_URLS"} = ""; if ($ENV{"EXTRA_REGTEST_OPTS"}) { print "\n"; |