]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Improve line info tracing, in particular when using lto.
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Tue, 18 Feb 2020 20:35:44 +0000 (21:35 +0100)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Tue, 3 Mar 2020 19:02:33 +0000 (20:02 +0100)
With gcc 9 and --enable-lto, we now have spurious warnings telling
that the line information in the debug info has huge line numbers,
greater than the (valgrind) maximum of 2^20.

These spurious warnings make that all tests are failing.

This change modifies the tracing/debugging of the line info to:
  * disable by default the warning for line info greater than 2^20.
    When using -d, such warnings are however still shown (once).
  * allow to see all such warnings, when using at least -d -d -d -d

coregrind/m_debuginfo/storage.c

index 011d012b18fb6fa45f2ce79750737445392c0d8b..2a975dccc3e86ab5a5ee9517674cf0ee08e74b2c 100644 (file)
@@ -527,18 +527,22 @@ static void shrinkLocTab ( struct _DebugInfo* di )
    di->loctab_size = new_sz;
 }
 
-#define COMPLAIN_ONCE(what, limit, limit_op)                   \
+// Complain once, unless VG_(debugLog_getLevel)() > 3
+// showinfo is called if VG_(debugLog_getLevel)() >= 1
+#define COMPLAIN_ONCE(what, limit, limit_op, showinfo)         \
    {                                                           \
    static Bool complained = False;                             \
    if (!complained) {                                          \
-      complained = True;                                       \
+      complained = VG_(debugLog_getLevel)() <= 3;              \
       VG_(message)(Vg_UserMsg,                                 \
                    "warning: Can't handle " what " with "      \
                    "line number %d " limit_op " than %d\n",    \
                    lineno, limit);                             \
-      VG_(message)(Vg_UserMsg,                                 \
-                   "(Nb: this message is only shown once)\n"); \
-   } \
+      if (VG_(debugLog_getLevel)() >= 1) showinfo;             \
+      if (complained)                                          \
+         VG_(message)(Vg_UserMsg,                              \
+                      "(Nb: this message is only shown once)\n");       \
+   }                                                                    \
 }
 
 
@@ -556,6 +560,11 @@ void ML_(addLineInfo) ( struct _DebugInfo* di,
    DiLoc loc;
    UWord size = next - this;
 
+#  define SHOWLINEINFO                                                  \
+   VG_(message)(Vg_DebugMsg,                                            \
+                "addLoc: addr %#lx, size %lu, line %d, fndn_ix %u\n",   \
+                this,size,lineno,fndn_ix)
+
    /* Ignore zero-sized locs */
    if (this == next) return;
 
@@ -615,11 +624,14 @@ void ML_(addLineInfo) ( struct _DebugInfo* di,
    }
 
    if (lineno < 0) {
-      COMPLAIN_ONCE("line info entry", 0, "smaller");
+      COMPLAIN_ONCE("line info entry", 0, "smaller", SHOWLINEINFO);
       return;
    }
    if (lineno > MAX_LINENO) {
-      COMPLAIN_ONCE("line info entry", MAX_LINENO, "greater");
+      /* With --enable-lto, gcc 9 creates huge line numbers e.g. in the tool
+         => only complain with some debug level. */
+      if (VG_(debugLog_getLevel)() >= 1)
+         COMPLAIN_ONCE("line info entry", MAX_LINENO, "greater", SHOWLINEINFO);
       return;
    }
 
@@ -627,11 +639,10 @@ void ML_(addLineInfo) ( struct _DebugInfo* di,
    loc.size      = (UShort)size;
    loc.lineno    = lineno;
 
-   if (0) VG_(message)(Vg_DebugMsg, 
-                      "addLoc: addr %#lx, size %lu, line %d, fndn_ix %u\n",
-                      this,size,lineno,fndn_ix);
+   if (0) SHOWLINEINFO;
 
    addLoc ( di, &loc, fndn_ix );
+#  undef SHOWLINEINFO
 }
 
 /* Add an inlined call info to the inlined call table. 
@@ -687,22 +698,34 @@ void ML_(addInlInfo) ( struct _DebugInfo* di,
 {
    DiInlLoc inl;
 
+#  define SHOWLINEINFO                                                  \
+   VG_(message) (Vg_DebugMsg,                                           \
+                 "addInlInfo: fn %s inlined as addr_lo %#lx,addr_hi %#lx," \
+                 "caller fndn_ix %u %s:%d\n",                           \
+                 inlinedfn, addr_lo, addr_hi, fndn_ix,                  \
+                 ML_(fndn_ix2filename) (di, fndn_ix), lineno)
+
    /* Similar paranoia as in ML_(addLineInfo). Unclear if needed. */
    if (addr_lo >= addr_hi) {
        if (VG_(clo_verbosity) > 2) {
            VG_(message)(Vg_DebugMsg, 
                         "warning: inlined info addresses out of order "
                         "at: 0x%lx 0x%lx\n", addr_lo, addr_hi);
+           SHOWLINEINFO;
        }
        addr_hi = addr_lo + 1;
    }
 
    if (lineno < 0) {
-      COMPLAIN_ONCE ("inlined call info entry", 0, "smaller");
+      COMPLAIN_ONCE ("inlined call info entry", 0, "smaller", SHOWLINEINFO);
       return;
    }
    if (lineno > MAX_LINENO) {
-      COMPLAIN_ONCE ("inlined call info entry", MAX_LINENO, "greater");
+      /* With --enable-lto, gcc 9 creates huge line numbers e.g. in the tool
+         => only complain with some debug level. */
+      if (VG_(debugLog_getLevel)() >= 1)
+         COMPLAIN_ONCE ("inlined call info entry", MAX_LINENO, "greater",
+                        SHOWLINEINFO);
       return;
    }
 
@@ -715,14 +738,10 @@ void ML_(addInlInfo) ( struct _DebugInfo* di,
    inl.lineno    = lineno;
    inl.level     = level;
 
-   if (0) VG_(message)
-             (Vg_DebugMsg, 
-              "addInlInfo: fn %s inlined as addr_lo %#lx,addr_hi %#lx,"
-              "caller fndn_ix %u %s:%d\n",
-              inlinedfn, addr_lo, addr_hi, fndn_ix,
-              ML_(fndn_ix2filename) (di, fndn_ix), lineno);
+   if (0) SHOWLINEINFO;
 
    addInl ( di, &inl );
+#  undef SHOWLINEINFO
 }
 
 DiCfSI_m* ML_(get_cfsi_m) (const DebugInfo* di, UInt pos)