]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Make the dwarf3 reader more robust and less chatty when things go wrong
authorMark Wielaard <mark@klomp.org>
Fri, 26 Feb 2021 01:34:32 +0000 (02:34 +0100)
committerMark Wielaard <mark@klomp.org>
Fri, 26 Feb 2021 01:34:32 +0000 (02:34 +0100)
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

NEWS
coregrind/m_debuginfo/readdwarf3.c
coregrind/m_debuginfo/storage.c
drd/tests/pth_cleanup_handler.c

diff --git a/NEWS b/NEWS
index 3a34269869d0ae3157d9cfed004f7fa0b4aefb65..adcb8524864d37ccf42d8210db7de254a22d0d7a 100644 (file)
--- 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)
index 60fc4024476fb70b998e5a1bd0d0939f37763657..52c27d4bb4ede51f1666ecf442d95a48919cc243 100644 (file)
@@ -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;
    }
index 2a975dccc3e86ab5a5ee9517674cf0ee08e74b2c..8667d123ffbb896bd2ae24c5ec007ae10329b7ba 100644 (file)
@@ -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",
index 0fb3d073d66839e457505bcf1dcdace531c62f45..e441fa3a41c4f328884c07be291348ddd34b7a35 100644 (file)
@@ -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)
   {