|
From: <sv...@va...> - 2005-05-17 04:00:26
|
Author: njn
Date: 2005-05-17 05:00:11 +0100 (Tue, 17 May 2005)
New Revision: 3754
Modified:
trunk/include/pub_tool_errormgr.h
trunk/memcheck/mac_leakcheck.c
trunk/memcheck/mac_shared.c
trunk/memcheck/mac_shared.h
Log:
Undo the awful Leak Error type-abuse.
Modified: trunk/include/pub_tool_errormgr.h
=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/include/pub_tool_errormgr.h 2005-05-17 03:22:38 UTC (rev 3753)
+++ trunk/include/pub_tool_errormgr.h 2005-05-17 04:00:11 UTC (rev 3754)
@@ -78,9 +78,9 @@
/* Similar to VG_(maybe_record_error)(), except this one doesn't record =
the
error -- useful for errors that can only happen once. The errors can=
be
suppressed, though. Return value is True if it was suppressed.
- `print_error' dictates whether to print the error, which is a bit of =
a
+ 'print_error' dictates whether to print the error, which is a bit of =
a
hack that's useful sometimes if you just want to know if the error wo=
uld
- be suppressed without possibly printing it. `count_error' dictates
+ be suppressed without possibly printing it. 'count_error' dictates
whether to add the error in the error total count (another mild hack)=
. */
extern Bool VG_(unique_error) ( ThreadId tid, ErrorKind ekind,
Addr a, Char* s, void* extra,
Modified: trunk/memcheck/mac_leakcheck.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_leakcheck.c 2005-05-17 03:22:38 UTC (rev 3753)
+++ trunk/memcheck/mac_leakcheck.c 2005-05-17 04:00:11 UTC (rev 3754)
@@ -99,6 +99,12 @@
}
LossRecord;
=20
+/* The 'extra' struct for leak errors. */
+typedef struct {
+ UInt n_this_record;
+ UInt n_total_records;
+ LossRecord* lossRecord;
+} LeakExtra;
=20
/* Find the i such that ptr points at or inside the block described by
shadows[i]. Return -1 if none found. This assumes that shadows[]
@@ -178,7 +184,7 @@
static Bool (*lc_is_within_valid_secondary) (Addr addr);
static Bool (*lc_is_valid_aligned_word) (Addr addr);
=20
-static const Char *pp_lossmode(Reachedness lossmode)
+static const Char *str_lossmode(Reachedness lossmode)
{
const Char *loss =3D "?";
=20
@@ -194,10 +200,11 @@
=20
/* Used for printing leak errors, avoids exposing the LossRecord type (w=
hich
comes in as void*, requiring a cast. */
-void MAC_(pp_LeakError)(void* vl, UInt n_this_record, UInt n_total_recor=
ds)
+void MAC_(pp_LeakError)(void* vextra)
{
- LossRecord* l =3D (LossRecord*)vl;
- const Char *loss =3D pp_lossmode(l->loss_mode);
+ LeakExtra* extra =3D (LeakExtra*)vextra;
+ LossRecord* l =3D extra->lossRecord;
+ const Char *loss =3D str_lossmode(l->loss_mode);
=20
VG_(message)(Vg_UserMsg, "");
if (l->indirect_bytes) {
@@ -205,12 +212,12 @@
"%d (%d direct, %d indirect) bytes in %d blocks are %s in loss reco=
rd %d of %d",
l->total_bytes + l->indirect_bytes,=20
l->total_bytes, l->indirect_bytes, l->num_blocks,
- loss, n_this_record, n_total_records);
+ loss, extra->n_this_record, extra->n_total_records);
} else {
VG_(message)(Vg_UserMsg,=20
"%d bytes in %d blocks are %s in loss record %d of %d",
l->total_bytes, l->num_blocks,
- loss, n_this_record, n_total_records);
+ loss, extra->n_this_record, extra->n_total_records);
}
VG_(pp_ExeContext)(l->allocated_at);
}
@@ -409,6 +416,7 @@
LossRecord* errlist;
LossRecord* p;
Bool is_suppressed;
+ LeakExtra leak_extra;
=20
/* Go through and group lost structures into cliques. For each
Unreached block, push it onto the mark stack, and find all the
@@ -419,7 +427,7 @@
for (i =3D 0; i < lc_n_shadows; i++) {
if (VG_DEBUG_CLIQUE)
VG_(printf)("cliques: %d at %p -> %s\n",
- i, lc_shadows[i]->data, pp_lossmode(lc_markstack[i].state));
+ i, lc_shadows[i]->data, str_lossmode(lc_markstack[i].state));
if (lc_markstack[i].state !=3D Unreached)
continue;
=20
@@ -487,18 +495,23 @@
/* Ok to have tst=3D=3DNULL; it's only used if --gdb-attach=3Dyes=
, and
we disallow that when --leak-check=3Dyes. =20
=20
- Prints the error if not suppressed, unless it's reachable (Prop=
er or IndirectLeak)
- and --show-reachable=3Dno */
+ Prints the error if not suppressed, unless it's reachable (Prop=
er
+ or IndirectLeak) and --show-reachable=3Dno */
=20
print_record =3D ( MAC_(clo_show_reachable) ||=20
- Unreached =3D=3D p_min->loss_mode || Interior =3D=3D p_min->los=
s_mode );
+ Unreached =3D=3D p_min->loss_mode ||=20
+ Interior =3D=3D p_min->loss_mode );
+
+ // Nb: because VG_(unique_error) does all the error processing
+ // immediately, and doesn't save the error, leakExtra can be
+ // stack-allocated.
+ leak_extra.n_this_record =3D i+1;
+ leak_extra.n_total_records =3D n_lossrecords;
+ leak_extra.lossRecord =3D p_min;
is_suppressed =3D=20
- VG_(unique_error) ( tid, LeakErr, (UInt)i+1,
- /* HACK ALERT */
- ULong_to_Ptr((ULong)(UInt)n_lossrecords),=20
- /* end HACK ALERT */
- (void*) p_min,
- p_min->allocated_at, print_record,
+ VG_(unique_error) ( tid, LeakErr, /*Addr*/0, /*s*/NULL,
+ /*extra*/&leak_extra,=20
+ /*where*/p_min->allocated_at, print_record,
/*allow_GDB_attach*/False, /*count_error*/F=
alse );
=20
if (is_suppressed) {
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-05-17 03:22:38 UTC (rev 3753)
+++ trunk/memcheck/mac_shared.c 2005-05-17 04:00:11 UTC (rev 3754)
@@ -337,11 +337,7 @@
break;
}
case LeakErr: {
- /* Totally abusing the types of these spare fields... oh well. =
*/
- UInt n_this_record =3D (UWord)VG_(get_error_address)(err);
- UInt n_total_records =3D (UWord)VG_(get_error_string) (err);
-
- MAC_(pp_LeakError)(err_extra, n_this_record, n_total_records);
+ MAC_(pp_LeakError)(err_extra);
break;
}
=20
Modified: trunk/memcheck/mac_shared.h
=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.h 2005-05-17 03:22:38 UTC (rev 3753)
+++ trunk/memcheck/mac_shared.h 2005-05-17 04:00:11 UTC (rev 3754)
@@ -418,8 +418,7 @@
UWord* arg_block, UWor=
d* ret );
=20
/* For leak checking */
-extern void MAC_(pp_LeakError)(void* vl, UInt n_this_record,=20
- UInt n_total_records);=20
+extern void MAC_(pp_LeakError)(void* extra);
=20
extern void MAC_(print_malloc_stats) ( void );
=20
|