Remove tool-specific code (which says which tools allow XML) from the core
by introducing a new "need":  VG_(needs_xml_output)().


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5854 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_main.c b/coregrind/m_main.c
index bc0b591..8b5a1d3 100644
--- a/coregrind/m_main.c
+++ b/coregrind/m_main.c
@@ -912,7 +912,7 @@
 "                              handle non-standard kernel variants\n"
 "\n"
 "  user options for Valgrind tools that report errors:\n"
-"    --xml=yes                 all output is in XML (Memcheck/Nulgrind only)\n"
+"    --xml=yes                 all output is in XML (some tools only)\n"
 "    --xml-user-comment=STR    copy STR verbatim to XML output\n"
 "    --demangle=no|yes         automatically demangle C++ names? [yes]\n"
 "    --num-callers=<number>    show <number> callers in stack traces [12]\n"
@@ -1457,11 +1457,10 @@
 
 
    /* Check that the requested tool actually supports XML output. */
-   if (VG_(clo_xml) && !VG_STREQ(toolname, "memcheck")
-                    && !VG_STREQ(toolname, "none")) {
+   if (VG_(clo_xml) && !VG_(needs).xml_output) {
       VG_(clo_xml) = False;
       VG_(message)(Vg_UserMsg, 
-         "Currently only Memcheck|None supports XML output."); 
+         "%s does not support XML output.", VG_(details).name); 
       VG_(bad_option)("--xml=yes");
       /*NOTREACHED*/
    }
diff --git a/coregrind/m_tooliface.c b/coregrind/m_tooliface.c
index 359408b..dd941ef 100644
--- a/coregrind/m_tooliface.c
+++ b/coregrind/m_tooliface.c
@@ -93,6 +93,7 @@
    .sanity_checks        = False,
    .data_syms	         = False,
    .malloc_replacement   = False,
+   .xml_output           = False,
 };
 
 /* static */
@@ -161,6 +162,7 @@
 NEEDS(libc_freeres)
 NEEDS(core_errors)
 NEEDS(data_syms)
+NEEDS(xml_output)
 
 void VG_(needs_basic_block_discards)(
    void (*discard)(Addr64, VexGuestExtents)
diff --git a/coregrind/pub_core_tooliface.h b/coregrind/pub_core_tooliface.h
index 5866628..7746fee 100644
--- a/coregrind/pub_core_tooliface.h
+++ b/coregrind/pub_core_tooliface.h
@@ -90,6 +90,7 @@
       Bool sanity_checks;
       Bool data_syms;
       Bool malloc_replacement;
+      Bool xml_output;
    } 
    VgNeeds;
 
diff --git a/docs/xml/manual-core.xml b/docs/xml/manual-core.xml
index b059ae1..f333756 100644
--- a/docs/xml/manual-core.xml
+++ b/docs/xml/manual-core.xml
@@ -766,7 +766,7 @@
       <para>When enabled, output will be in XML format.  This is aimed
       at making life easier for tools that consume Valgrind's output as
       input, such as GUI front ends.  Currently this option only works
-      with Memcheck and Nulgrind.</para>
+      with Memcheck.</para>
     </listitem>
   </varlistentry>
 
diff --git a/include/pub_tool_tooliface.h b/include/pub_tool_tooliface.h
index 7ae35d1..6f70836 100644
--- a/include/pub_tool_tooliface.h
+++ b/include/pub_tool_tooliface.h
@@ -138,9 +138,6 @@
 /* ------------------------------------------------------------------ */
 /* Needs */
 
-/* Booleans that decide core behaviour, but don't require extra
-   operations to be defined if `True' */
-
 /* Should __libc_freeres() be run?  Bugs in it can crash the tool. */
 extern void VG_(needs_libc_freeres) ( void );
 
@@ -299,6 +296,11 @@
    SizeT client_malloc_redzone_szB
 );
 
+/* Can the tool do XML output?  This is a slight misnomer, because the tool
+ * is not requesting the core to do anything, rather saying "I can handle
+ * it". */
+extern void VG_(needs_xml_output)( void );
+
 /* ------------------------------------------------------------------ */
 /* Core events to track */
 
diff --git a/memcheck/mc_main.c b/memcheck/mc_main.c
index 6286dbd..0ee073b 100644
--- a/memcheck/mc_main.c
+++ b/memcheck/mc_main.c
@@ -4330,7 +4330,6 @@
    VG_(needs_client_requests)     (mc_handle_client_request);
    VG_(needs_sanity_checks)       (mc_cheap_sanity_check,
                                    mc_expensive_sanity_check);
-
    VG_(needs_malloc_replacement)  (MC_(malloc),
                                    MC_(__builtin_new),
                                    MC_(__builtin_vec_new),
@@ -4341,6 +4340,7 @@
                                    MC_(__builtin_vec_delete),
                                    MC_(realloc),
                                    MC_MALLOC_REDZONE_SZB );
+   VG_(needs_xml_output)          ();
 
    VG_(track_new_mem_startup)     ( mc_new_mem_startup );
    VG_(track_new_mem_stack_signal)( MC_(make_mem_undefined) );
diff --git a/none/tests/cmdline1.stdout.exp b/none/tests/cmdline1.stdout.exp
index 6ceb817..1338d91 100644
--- a/none/tests/cmdline1.stdout.exp
+++ b/none/tests/cmdline1.stdout.exp
@@ -27,7 +27,7 @@
                               handle non-standard kernel variants
 
   user options for Valgrind tools that report errors:
-    --xml=yes                 all output is in XML (Memcheck/Nulgrind only)
+    --xml=yes                 all output is in XML (some tools only)
     --xml-user-comment=STR    copy STR verbatim to XML output
     --demangle=no|yes         automatically demangle C++ names? [yes]
     --num-callers=<number>    show <number> callers in stack traces [12]
diff --git a/none/tests/cmdline2.stdout.exp b/none/tests/cmdline2.stdout.exp
index 69a4e27..f1fc904 100644
--- a/none/tests/cmdline2.stdout.exp
+++ b/none/tests/cmdline2.stdout.exp
@@ -27,7 +27,7 @@
                               handle non-standard kernel variants
 
   user options for Valgrind tools that report errors:
-    --xml=yes                 all output is in XML (Memcheck/Nulgrind only)
+    --xml=yes                 all output is in XML (some tools only)
     --xml-user-comment=STR    copy STR verbatim to XML output
     --demangle=no|yes         automatically demangle C++ names? [yes]
     --num-callers=<number>    show <number> callers in stack traces [12]