|
From: <sv...@va...> - 2005-09-08 09:30:38
|
Author: sewardj
Date: 2005-09-08 10:30:35 +0100 (Thu, 08 Sep 2005)
New Revision: 4611
Log:
- fix wraparound problem in add_segment
- improve segment printing
Modified:
branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c
Modified: branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c 2005-09-08 00:51:0=
3 UTC (rev 4610)
+++ branches/ASPACEM/coregrind/m_aspacemgr/aspacemgr.c 2005-09-08 09:30:3=
5 UTC (rev 4611)
@@ -1318,6 +1318,42 @@
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
=20
+static void add_to_aspacem_sprintf_buf ( HChar c, void *p )
+{
+ HChar** aspacem_sprintf_ptr =3D p;
+ *(*aspacem_sprintf_ptr)++ =3D c;
+}
+
+static
+UInt aspacem_vsprintf ( HChar* buf, const HChar *format, va_list vargs )
+{
+ Int ret;
+ Char *aspacem_sprintf_ptr =3D buf;
+
+ ret =3D VG_(debugLog_vprintf)
+ ( add_to_aspacem_sprintf_buf,=20
+ &aspacem_sprintf_ptr, format, vargs );
+ add_to_aspacem_sprintf_buf('\0', &aspacem_sprintf_ptr);
+
+ return ret;
+}
+
+static
+UInt aspacem_sprintf ( HChar* buf, const HChar *format, ... )
+{
+ UInt ret;
+ va_list vargs;
+
+ va_start(vargs,format);
+ ret =3D aspacem_vsprintf(buf, format, vargs);
+ va_end(vargs);
+
+ return ret;
+}
+
+
+/////////////////////////////////////////////////////////////////
+
static void aspacem_barf_toolow ( HChar* what )
{
VG_(debugLog)(0, "aspacem", "Valgrind: FATAL: %s is too low.\n", what)=
;
@@ -1623,26 +1659,35 @@
}
}
=20
+static void show_Addr_concisely ( /*OUT*/HChar* buf, Addr aA )
+{
+ HChar* fmt;
+ ULong a =3D (ULong)aA;
+ if (a >=3D 10000000ULL) {
+ fmt =3D "%6llum";
+a /=3D 1024*1024ULL;
+ } else {
+ fmt =3D "%7llu";
+ }
+ aspacem_sprintf(buf, fmt, a);
+}
+
static void show_nsegment ( Int logLevel, Int segNo, NSegment* seg )
{
+ HChar len_buf[20];
+ ULong len =3D ((ULong)seg->end) - ((ULong)seg->start) + 1;
+ show_Addr_concisely(len_buf, len);
+
switch (seg->kind) {
case SkFree: {
- ULong len =3D ((ULong)seg->end) - ((ULong)seg->start) + 1;
- HChar* fmt;
- if (len >=3D 1024*1024ULL) {
- len /=3D 1024*1024ULL;
- fmt =3D "%3d: %s 0x%08llx-0x%08llx %6llum\n";
- } else {
- fmt =3D "%3d: %s 0x%08llx-0x%08llx %7llu\n";
- }
VG_(debugLog)(
logLevel, "aspacem",
- fmt,
+ "%3d: %s 0x%08llx-0x%08llx %s\n",
segNo,
show_seg_kind(seg),
(ULong)seg->start,
(ULong)seg->end,
- len
+ len_buf
);
break;
}
@@ -1650,12 +1695,12 @@
case SkAnon:
VG_(debugLog)(
logLevel, "aspacem",
- "%3d: %s 0x%08llx-0x%08llx %7llu %c%c%c%c d=3D0x%03x i=3D%-7d o=3D%=
-7lld (%d)\n",
+ "%3d: %s 0x%08llx-0x%08llx %s %c%c%c%c d=3D0x%03x i=3D%-7d o=3D%-7l=
ld (%d)\n",
segNo,
show_seg_kind(seg),
(ULong)seg->start,
(ULong)seg->end,
- ((ULong)seg->end) - ((ULong)seg->start) + 1,
+ len_buf,
seg->hasR ? 'r' : '-',=20
seg->hasW ? 'w' : '-',=20
seg->hasX ? 'x' : '-',=20
@@ -1669,12 +1714,12 @@
case SkFile:
VG_(debugLog)(
logLevel, "aspacem",
- "%3d: %s 0x%08llx-0x%08llx %7llu %c%c%c%c d=3D0x%03x i=3D%-7d o=3D%=
-7lld (%d)\n",
+ "%3d: %s 0x%08llx-0x%08llx %s %c%c%c%c d=3D0x%03x i=3D%-7d o=3D%-7l=
ld (%d)\n",
segNo,
show_seg_kind(seg),
(ULong)seg->start,
(ULong)seg->end,
- ((ULong)seg->end) - ((ULong)seg->start) + 1,
+ len_buf,
seg->hasR ? 'r' : '-',=20
seg->hasW ? 'w' : '-',=20
seg->hasX ? 'x' : '-',=20
@@ -1688,20 +1733,16 @@
case SkResvn:
VG_(debugLog)(
logLevel, "aspacem",
- "%3d: %s 0x%08llx-0x%08llx %7llu %c%c%c%c d=3D0x%03x i=3D%-7d o=3D%=
-7lld (%d) (%s,%s,%llu)\n",
+ "%3d: %s 0x%08llx-0x%08llx %s %c%c%c%c (%s,%s,%llu)\n",
segNo,
show_seg_kind(seg),
(ULong)seg->start,
(ULong)seg->end,
- ((ULong)seg->end) - ((ULong)seg->start) + 1,
+ len_buf,
seg->hasR ? 'r' : '-',=20
seg->hasW ? 'w' : '-',=20
seg->hasX ? 'x' : '-',=20
seg->anyTranslated ? 'T' : '-',=20
- seg->dev,
- seg->ino,
- (Long)seg->offset,
- seg->fnIdx,
showMovable(seg->moveLo),
showMovable(seg->moveHi),
(ULong)seg->maxlen
@@ -1744,7 +1785,7 @@
=20
Addr dStart =3D seg->start;
Addr dEnd =3D seg->end;
- =20
+
aspacem_assert(dStart <=3D dEnd);
=20
nDeld =3D 0;
@@ -1823,7 +1864,8 @@
k =3D 0;
} else {
for (i =3D 0; i < nsegments_used; i++)
- if (nsegments[i].start =3D=3D dEnd+1)
+ if (dEnd+1 =3D=3D nsegments[i].start=20
+ && /*guard against wraparound*/dEnd+1 > dEnd)
break;
k =3D i;
}
@@ -1900,7 +1942,6 @@
init_resvn(&seg, Addr_MIN, aspacem_cStart-1);
add_segment(&seg);
}
-
if (aspacem_maxAddr < Addr_MAX) {
init_resvn(&seg, aspacem_maxAddr+1, Addr_MAX);
add_segment(&seg);
|