|
From: <sv...@va...> - 2005-08-11 02:47:03
|
Author: njn
Date: 2005-08-11 03:46:54 +0100 (Thu, 11 Aug 2005)
New Revision: 4382
Log:
Tighten up update_extra() for Memcheck.
Modified:
trunk/memcheck/mac_shared.c
Modified: trunk/memcheck/mac_shared.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
--- trunk/memcheck/mac_shared.c 2005-08-11 02:17:07 UTC (rev 4381)
+++ trunk/memcheck/mac_shared.c 2005-08-11 02:46:54 UTC (rev 4382)
@@ -475,19 +475,6 @@
return;
}
=20
-/* Describe an address as best you can, for FreeMismatch error messages.
- By the time this is called 'ai' is already setup with all the relevan=
t
- info. So the only thing this can do is change that to UserG if 'a' i=
s in
- a user block, otherwise change it from 'Mallocd' to 'Freed'.
-*/
-static void describe_addr_FreeMismatch ( Addr a, AddrInfo* ai )
-{
- /* Perhaps it's a user-def'd block ? (only check if requested, thoug=
h) */
- if (NULL !=3D MAC_(describe_addr_supp)) {
- (void)MAC_(describe_addr_supp)( a, ai );
- }
-}
-
/* Is this address within some small distance below %ESP? Used only
for the --workaround-gcc296-bugs kludge. */
static Bool is_just_below_ESP( Addr esp, Addr aa )
@@ -611,31 +598,56 @@
UInt MAC_(update_extra)( Error* err )
{
switch (VG_(get_error_kind)(err)) {
- case ValueErr:
+ // These two don't have addresses associated with them, and so don't
+ // need any updating.
case CoreMemErr:
+ case ValueErr: {
+ MAC_Error* extra =3D VG_(get_error_extra)(err);
+ tl_assert(Unknown =3D=3D extra->addrinfo.akind);
+ return sizeof(MAC_Error);
+ }
+
+ // ParamErrs sometimes involve a memory address; call describe_addr()=
in
+ // this case.
+ case ParamErr: {
+ MAC_Error* extra =3D VG_(get_error_extra)(err);
+ tl_assert(Undescribed =3D=3D extra->addrinfo.akind ||
+ Register =3D=3D extra->addrinfo.akind);
+ if (Undescribed =3D=3D extra->addrinfo.akind)
+ describe_addr ( VG_(get_error_address)(err), &(extra->addrinfo)=
);
+ return sizeof(MAC_Error);
+ }
+
+ // These four always involve a memory address.
case AddrErr:=20
- case ParamErr:
case UserErr:
case FreeErr:
case IllegalMempoolErr: {
MAC_Error* extra =3D VG_(get_error_extra)(err);
- if (extra !=3D NULL && Undescribed =3D=3D extra->addrinfo.akind) {
- describe_addr ( VG_(get_error_address)(err), &(extra->addrinfo)=
);
- }
+ tl_assert(Undescribed =3D=3D extra->addrinfo.akind);
+ describe_addr ( VG_(get_error_address)(err), &(extra->addrinfo) );
return sizeof(MAC_Error);
}
=20
+ // FreeMismatchErrs have already had their address described; this i=
s
+ // possible because we have the MAC_Chunk on hand when the error is
+ // detected. However, the address may be part of a user block, and i=
f so
+ // we override the pre-determined description with a user block one.
case FreeMismatchErr: {
MAC_Error* extra =3D VG_(get_error_extra)(err);
tl_assert(extra && Mallocd =3D=3D extra->addrinfo.akind);
- describe_addr_FreeMismatch ( VG_(get_error_address)(err), &(extra-=
>addrinfo) );
+ if (NULL !=3D MAC_(describe_addr_supp))
+ (void)MAC_(describe_addr_supp)( VG_(get_error_address)(err),=20
+ &(extra->addrinfo) );
return sizeof(MAC_Error);
}
=20
- /* Don't need to return the correct size -- LeakErrs are always shown=
with
- VG_(unique_error)() so they're not copied anyway. */
+ // No memory address involved with these ones. Nb: for LeakErrs the
+ // returned size does not matter -- LeakErrs are always shown with
+ // VG_(unique_error)() so they're not copied.
case LeakErr: return 0;
case OverlapErr: return sizeof(OverlapExtra);
+
default: VG_(tool_panic)("update_extra: bad errkind");
}
}
|