Merge coregrind/ changes from branches/MESSAGING_TIDYUP r10464.
This commit tidies up and rationalises what could be called the
"messaging" system -- that part of V to do with presenting output to
the user. In particular it brings significant improvements to XML
output.
Changes are:
* XML and normal text output now have separate file descriptors,
which solves longstanding problems for XML consumers caused by
the XML output getting polluted by unexpected non-XML output.
* This also means that we no longer have to hardwire all manner
of output settings (verbosity, etc) when XML is requested.
* The XML output format has been revised, cleaned up, and made
more suitable for use by error detecting tools in general
(various Memcheck-specific features have been removed). XML
output is enabled for Ptrcheck and Helgrind, and Memcheck is
updated to the new format.
* One side effect is that the behaviour of VG_(message) has been
made to be consistent with printf: it no longer automatically
adds a newline at the end of the output. This means multiple
calls to it can be used to build up a single line message; or a
single call can write a multi-line message. The ==pid==
preamble is automatically inserted at each newline.
* VG_(message)(Vg_UserMsg, ..args..) now has the abbreviated form
VG_(UMSG)(..args..); ditto VG_(DMSG) for Vg_DebugMsg and
VG_(EMSG) for Vg_DebugExtraMsg. A couple of other useful
printf derivatives have been added to pub_tool_libcprint.h,
most particularly VG_(vcbprintf).
* There's a small change in the core-tool interface to do with
error handling: VG_(needs_tool_errors) has a new method
void (*before_pp_Error)(Error* err) which, if non-NULL, is
called just before void (*pp_Error)(Error* err). This is to
give tools the chance to look at errors before any part of them
is printed, so they can print any XML preamble they like.
* coregrind/m_errormgr.c has been overhauled and cleaned up, and
is a bit simpler and more commented. In particular pp_Error
and VG_(maybe_record_error) are significantly changed.
The diff is huge, but mostly very boring. Most of the changes
are of the form
- VG_(message)(Vg_UserMsg, "this is a message %d", n);
+ VG_(message)(Vg_UserMsg, "this is a message %d\n", n);
Unfortunately as a result of this, it touches a large number
of source files.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10465 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_libcassert.c b/coregrind/m_libcassert.c
index 8e3eba2..bfab45c 100644
--- a/coregrind/m_libcassert.c
+++ b/coregrind/m_libcassert.c
@@ -146,8 +146,8 @@
}
stacktop = tst->os_state.valgrind_stack_init_SP;
-
- n_ips =
+
+ n_ips =
VG_(get_StackTrace_wrk)(
0/*tid is unknown*/,
ips, BACKTRACE_DEPTH,
@@ -155,6 +155,7 @@
NULL/*array to dump FP values in*/,
ip, sp, fp, lr, sp, stacktop
);
+ VG_(clo_xml) = False;
VG_(pp_StackTrace) (ips, n_ips);
VG_(show_sched_status)();
@@ -200,7 +201,7 @@
}
if (VG_(clo_xml))
- VG_UMSG("</valgrindoutput>\n");
+ VG_(printf_xml)("</valgrindoutput>\n");
// Treat vg_assert2(0, "foo") specially, as a panicky abort
if (VG_STREQ(expr, "0")) {
@@ -221,7 +222,7 @@
Addr ip, Addr sp, Addr fp, Addr lr )
{
if (VG_(clo_xml))
- VG_UMSG("</valgrindoutput>\n");
+ VG_(printf_xml)("</valgrindoutput>\n");
VG_(printf)("\n%s: the 'impossible' happened:\n %s\n", name, str);
report_and_quit(report, ip, sp, fp, lr);
}
@@ -245,18 +246,20 @@
void VG_(unimplemented) ( Char* msg )
{
if (VG_(clo_xml))
- VG_UMSG("</valgrindoutput>\n");
- VG_UMSG("");
- VG_UMSG("Valgrind detected that your program requires");
- VG_UMSG("the following unimplemented functionality:");
- VG_UMSG(" %s", msg);
- VG_UMSG("This may be because the functionality is hard to implement,");
- VG_UMSG("or because no reasonable program would behave this way,");
- VG_UMSG("or because nobody has yet needed it. In any case, let us know at");
- VG_UMSG("%s and/or try to work around the problem, if you can.", VG_BUGS_TO);
- VG_UMSG("");
- VG_UMSG("Valgrind has to exit now. Sorry. Bye!");
- VG_UMSG("");
+ VG_(printf_xml)("</valgrindoutput>\n");
+ VG_(umsg)("\n");
+ VG_(umsg)("Valgrind detected that your program requires\n");
+ VG_(umsg)("the following unimplemented functionality:\n");
+ VG_(umsg)(" %s\n", msg);
+ VG_(umsg)("This may be because the functionality is hard to implement,\n");
+ VG_(umsg)("or because no reasonable program would behave this way,\n");
+ VG_(umsg)("or because nobody has yet needed it. "
+ "In any case, let us know at\n");
+ VG_(umsg)("%s and/or try to work around the problem, if you can.\n",
+ VG_BUGS_TO);
+ VG_(umsg)("\n");
+ VG_(umsg)("Valgrind has to exit now. Sorry. Bye!\n");
+ VG_(umsg)("\n");
VG_(show_sched_status)();
VG_(exit)(1);
}