]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix debug output of aspacemgr
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Thu, 5 Feb 2015 22:30:57 +0000 (22:30 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Thu, 5 Feb 2015 22:30:57 +0000 (22:30 +0000)
The list of segnames was shown with a seq nr,
while each segment was referencing its segname with an offset.
The patch ensures that at all places, both the seq nr and the
offset is output

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14911

coregrind/m_aspacemgr/aspacemgr-linux.c

index 3e9549e8f5a7329416f9a50a0d0d2bbd56c2af46..bcdd73ac0a7cb0377cc92c4ca699a927241a0a49 100644 (file)
@@ -479,6 +479,22 @@ static void show_len_concisely ( /*OUT*/HChar* buf, Addr start, Addr end )
    ML_(am_sprintf)(buf, fmt, len);
 }
 
+/* Returns a sequence number for the fnIdx position in segnames.
+   Used in aspacemgr debug output to associate a segment with
+   the list of segments output at the beginning. */
+static Int fnIdx_seqnr(Int fnIdx)
+{
+   SizeT ix;
+   Int seqnr = -1;
+
+   for (ix = 0; ix < segnames_used; ix += VG_(strlen)(segnames + ix) + 1) {
+      seqnr++;
+      if (ix == fnIdx)
+         return seqnr;
+   }
+
+   return -1;
+}
 
 /* Show full details of an NSegment */
 
@@ -496,14 +512,15 @@ static void show_nsegment_full ( Int logLevel, Int segNo, const NSegment* seg )
    VG_(debugLog)(
       logLevel, "aspacem",
       "%3d: %s %010llx-%010llx %s %c%c%c%c%c %s "
-      "d=0x%03llx i=%-7lld o=%-7lld (%d) %s\n",
+      "d=0x%03llx i=%-7lld o=%-7lld (%d,%d) %s\n",
       segNo, show_SegKind(seg->kind),
       (ULong)seg->start, (ULong)seg->end, len_buf,
       seg->hasR ? 'r' : '-', seg->hasW ? 'w' : '-', 
       seg->hasX ? 'x' : '-', seg->hasT ? 'T' : '-',
       seg->isCH ? 'H' : '-',
       show_ShrinkMode(seg->smode),
-      seg->dev, seg->ino, seg->offset, seg->fnIdx,
+      seg->dev, seg->ino, seg->offset,
+      fnIdx_seqnr(seg->fnIdx), seg->fnIdx,
       name
    );
 }
@@ -543,13 +560,14 @@ static void show_nsegment ( Int logLevel, Int segNo, const NSegment* seg )
          VG_(debugLog)(
             logLevel, "aspacem",
             "%3d: %s %010llx-%010llx %s %c%c%c%c%c d=0x%03llx "
-            "i=%-7lld o=%-7lld (%d)\n",
+            "i=%-7lld o=%-7lld (%d,%d)\n",
             segNo, show_SegKind(seg->kind),
             (ULong)seg->start, (ULong)seg->end, len_buf,
             seg->hasR ? 'r' : '-', seg->hasW ? 'w' : '-', 
             seg->hasX ? 'x' : '-', seg->hasT ? 'T' : '-', 
             seg->isCH ? 'H' : '-',
-            seg->dev, seg->ino, seg->offset, seg->fnIdx
+            seg->dev, seg->ino, seg->offset,
+            fnIdx_seqnr(seg->fnIdx), seg->fnIdx
          );
          break;
 
@@ -587,7 +605,7 @@ void VG_(am_show_nsegments) ( Int logLevel, const HChar* who )
    i = 0;
    for (ix = 0; ix < segnames_used; ix += VG_(strlen)(segnames + ix) + 1) {
       VG_(debugLog)(logLevel, "aspacem",
-                    "(%2d) %s\n", i++, segnames + ix);
+                    "(%d,%lu) %s\n", i++, ix, segnames + ix);
    }
    for (i = 0; i < nsegments_used; i++)
      show_nsegment( logLevel, i, &nsegments[i] );