|
From: <sv...@va...> - 2009-05-10 22:24:04
|
Author: sewardj
Date: 2009-05-10 23:23:48 +0100 (Sun, 10 May 2009)
New Revision: 9829
Log:
Hook up Memcheck to the revised XML printing framework.
Modified:
branches/MESSAGING_TIDYUP/coregrind/m_errormgr.c
branches/MESSAGING_TIDYUP/coregrind/m_main.c
branches/MESSAGING_TIDYUP/memcheck/mc_errors.c
Modified: branches/MESSAGING_TIDYUP/coregrind/m_errormgr.c
===================================================================
--- branches/MESSAGING_TIDYUP/coregrind/m_errormgr.c 2009-05-10 22:14:40 UTC (rev 9828)
+++ branches/MESSAGING_TIDYUP/coregrind/m_errormgr.c 2009-05-10 22:23:48 UTC (rev 9829)
@@ -623,8 +623,12 @@
errors = p;
if (p->supp == NULL) {
n_errs_found++;
- if (!is_first_shown_context)
- VG_(UMSG)("\n");
+ if (!is_first_shown_context) {
+ if (VG_(clo_xml))
+ VG_(printf_xml)("\n");
+ else
+ VG_(UMSG)("\n");
+ }
pp_Error(p);
is_first_shown_context = False;
n_errs_shown++;
Modified: branches/MESSAGING_TIDYUP/coregrind/m_main.c
===================================================================
--- branches/MESSAGING_TIDYUP/coregrind/m_main.c 2009-05-10 22:14:40 UTC (rev 9828)
+++ branches/MESSAGING_TIDYUP/coregrind/m_main.c 2009-05-10 22:23:48 UTC (rev 9829)
@@ -613,23 +613,23 @@
any need for user input during the run. */
if (VG_(clo_xml)) {
/* Disable suppression generation (requires user input) */
- VG_(clo_gen_suppressions) = 0;
+ //VG_(clo_gen_suppressions) = 0;
/* Disable attaching to GDB (requires user input) */
- VG_(clo_db_attach) = False;
+ //VG_(clo_db_attach) = False;
/* Set a known verbosity level */
- VG_(clo_verbosity) = 1;
+ //VG_(clo_verbosity) = 1;
/* Disable error limits (this might be a bad idea!) */
VG_(clo_error_limit) = False;
/* Disable emulation warnings */
- VG_(clo_show_emwarns) = False;
+ //VG_(clo_show_emwarns) = False;
/* Disable waiting for GDB to debug Valgrind */
- VG_(clo_wait_for_gdb) = False;
+ //VG_(clo_wait_for_gdb) = False;
/* No file-descriptor leak checking yet */
- VG_(clo_track_fds) = False;
+ //VG_(clo_track_fds) = False;
/* Disable timestamped output */
- VG_(clo_time_stamp) = False;
+ //VG_(clo_time_stamp) = False;
/* Disable heap profiling, since that prints lots of stuff. */
- VG_(clo_profile_heap) = False;
+ //VG_(clo_profile_heap) = False;
/* Also, we want to set options for the leak checker, but that
will have to be done in Memcheck's flag-handling code, not
here. */
@@ -1038,6 +1038,8 @@
// Empty line after the preamble
if (VG_(clo_verbosity) > 0)
VG_(message)(Vg_UserMsg, "\n");
+ if (VG_(clo_xml))
+ VG_(printf_xml)("\n");
if (VG_(clo_verbosity) > 1) {
SysRes fd;
@@ -2267,9 +2269,9 @@
VG_TDICT_CALL(tool_fini, 0/*exitcode*/);
if (VG_(clo_xml)) {
- VG_(message)(Vg_UserMsg, "\n");
- VG_(message)(Vg_UserMsg, "</valgrindoutput>\n");
- VG_(message)(Vg_UserMsg, "\n");
+ VG_(printf_xml)("\n");
+ VG_(printf_xml)("</valgrindoutput>\n");
+ VG_(printf_xml)("\n");
}
VG_(sanity_check_general)( True /*include expensive checks*/ );
Modified: branches/MESSAGING_TIDYUP/memcheck/mc_errors.c
===================================================================
--- branches/MESSAGING_TIDYUP/memcheck/mc_errors.c 2009-05-10 22:14:40 UTC (rev 9828)
+++ branches/MESSAGING_TIDYUP/memcheck/mc_errors.c 2009-05-10 22:23:48 UTC (rev 9829)
@@ -258,6 +258,36 @@
/*--- Printing errors ---*/
/*------------------------------------------------------------*/
+/* Do a printf-style op (with a trailing \n) on either the XML or
+ normal output channel, depending on the setting of VG_(clo_xml).
+*/
+static void emit_WRK ( HChar* format, va_list vargs )
+{
+ if (VG_(clo_xml)) {
+ VG_(vprintf_xml)(format, vargs);
+ } else {
+ VG_(vmessage)(Vg_UserMsg, format, vargs);
+ }
+}
+
+static void emit ( HChar* format, ... ) PRINTF_CHECK(1, 2);
+static void emit ( HChar* format, ... )
+{
+ va_list vargs;
+ va_start(vargs, format);
+ emit_WRK(format, vargs);
+ va_end(vargs);
+}
+
+static void emit_no_f_c ( HChar* format, ... )
+{
+ va_list vargs;
+ va_start(vargs, format);
+ emit_WRK(format, vargs);
+ va_end(vargs);
+}
+
+
static void mc_pp_AddrInfo ( Addr a, AddrInfo* ai, Bool maybe_gcc )
{
HChar* xpre = VG_(clo_xml) ? " <auxwhat>" : " ";
@@ -266,23 +296,19 @@
switch (ai->tag) {
case Addr_Unknown:
if (maybe_gcc) {
- VG_(message)(Vg_UserMsg,
- "%sAddress 0x%llx is just below the stack ptr. "
- "To suppress, use: --workaround-gcc296-bugs=yes%s\n",
- xpre, (ULong)a, xpost
- );
+ emit( "%sAddress 0x%llx is just below the stack ptr. "
+ "To suppress, use: --workaround-gcc296-bugs=yes%s\n",
+ xpre, (ULong)a, xpost );
} else {
- VG_(message)(Vg_UserMsg,
- "%sAddress 0x%llx "
- "is not stack'd, malloc'd or (recently) free'd%s\n",
- xpre, (ULong)a, xpost);
+ emit( "%sAddress 0x%llx "
+ "is not stack'd, malloc'd or (recently) free'd%s\n",
+ xpre, (ULong)a, xpost );
}
break;
case Addr_Stack:
- VG_(message)(Vg_UserMsg,
- "%sAddress 0x%llx is on thread %d's stack%s\n",
- xpre, (ULong)a, ai->Addr.Stack.tid, xpost);
+ emit( "%sAddress 0x%llx is on thread %d's stack%s\n",
+ xpre, (ULong)a, ai->Addr.Stack.tid, xpost );
break;
case Addr_Block: {
@@ -301,7 +327,7 @@
delta = rwoffset;
relative = "inside";
}
- VG_(message)(Vg_UserMsg,
+ emit(
"%sAddress 0x%lx is %'lu bytes %s a %s of size %'lu %s%s\n",
xpre,
a, delta, relative, ai->Addr.Block.block_desc,
@@ -309,39 +335,36 @@
ai->Addr.Block.block_kind==Block_Mallocd ? "alloc'd"
: ai->Addr.Block.block_kind==Block_Freed ? "free'd"
: "client-defined",
- xpost);
+ xpost
+ );
VG_(pp_ExeContext)(ai->Addr.Block.lastchange);
break;
}
case Addr_DataSym:
- VG_(message_no_f_c)(Vg_UserMsg,
- "%sAddress 0x%llx is %llu bytes "
- "inside data symbol \"%t\"%s\n",
- xpre,
- (ULong)a,
- (ULong)ai->Addr.DataSym.offset,
- ai->Addr.DataSym.name,
- xpost);
+ emit_no_f_c( "%sAddress 0x%llx is %llu bytes "
+ "inside data symbol \"%t\"%s\n",
+ xpre,
+ (ULong)a,
+ (ULong)ai->Addr.DataSym.offset,
+ ai->Addr.DataSym.name,
+ xpost );
break;
case Addr_Variable:
if (ai->Addr.Variable.descr1[0] != '\0')
- VG_(message)(Vg_UserMsg, "%s%s%s\n",
- xpre, ai->Addr.Variable.descr1, xpost);
+ emit( "%s%s%s\n", xpre, ai->Addr.Variable.descr1, xpost);
if (ai->Addr.Variable.descr2[0] != '\0')
- VG_(message)(Vg_UserMsg, "%s%s%s\n",
- xpre, ai->Addr.Variable.descr2, xpost);
+ emit( "%s%s%s\n", xpre, ai->Addr.Variable.descr2, xpost);
break;
case Addr_SectKind:
- VG_(message_no_f_c)(Vg_UserMsg,
- "%sAddress 0x%llx is in the %t segment of %t%s\n",
- xpre,
- (ULong)a,
- VG_(pp_SectKind)(ai->Addr.SectKind.kind),
- ai->Addr.SectKind.objname,
- xpost);
+ emit_no_f_c( "%sAddress 0x%llx is in the %t segment of %t%s\n",
+ xpre,
+ (ULong)a,
+ VG_(pp_SectKind)(ai->Addr.SectKind.kind),
+ ai->Addr.SectKind.objname,
+ xpost );
break;
default:
@@ -381,11 +404,15 @@
va_list vargs;
if (VG_(clo_xml))
- VG_(message)(Vg_UserMsg, " <kind>%s</kind>\n", xml_name);
+ VG_(printf_xml)(" <kind>%s</kind>\n", xml_name);
// Stick xpre and xpost on the front and back of the format string.
VG_(snprintf)(buf, 256, "%s%s%s\n", xpre, format, xpost);
va_start(vargs, format);
- VG_(vmessage) ( Vg_UserMsg, buf, vargs );
+ if (VG_(clo_xml)) {
+ VG_(vprintf_xml) ( buf, vargs );
+ } else {
+ VG_(vmessage) ( Vg_UserMsg, buf, vargs );
+ }
va_end(vargs);
VG_(pp_ExeContext)( VG_(get_error_where)(err) );
}
@@ -405,16 +432,17 @@
}
tl_assert(src); /* guards against invalid 'okind' */
- if (VG_(clo_xml)) {
- VG_(message)(Vg_UserMsg, " <origin>\n");
+ if (VG_(clo_xml)) {
+ VG_(printf_xml)(" <origin>\n");
+ VG_(printf_xml)("%sUninitialised value was created%s%s",
+ xpre, src, xpost);
+ VG_(pp_ExeContext)( ec );
+ VG_(printf_xml)(" </origin>\n");
+ } else {
+ VG_(message)(Vg_UserMsg, "Uninitialised value was created%s\n",
+ src);
+ VG_(pp_ExeContext)( ec );
}
-
- VG_(message)(Vg_UserMsg, "%sUninitialised value was created%s%s\n",
- xpre, src, xpost);
- VG_(pp_ExeContext)( ec );
- if (VG_(clo_xml)) {
- VG_(message)(Vg_UserMsg, " </origin>\n");
- }
}
void MC_(pp_Error) ( Error* err )
|