New command line option: --xml-user-comment=XMLTEXT, which allows
copying of arbitrary bits of XML text to the XML output.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4186 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_main.c b/coregrind/m_main.c
index acf024a..f9162d9 100644
--- a/coregrind/m_main.c
+++ b/coregrind/m_main.c
@@ -1270,6 +1270,7 @@
 "    --show-emwarns=no|yes     show warnings about emulation limits? [no]\n"
 "    --smc-support=none|stack|all   support for self-modifying code:\n"
 "                              none, for code found in stacks, or all [stack]\n"
+"    --xml-user-comment=STR    copy STR verbatim to XML output\n"
 "\n"
 "  user options for Valgrind tools that report errors:\n"
 "    --log-fd=<number>         log messages to file descriptor [2=stderr]\n"
@@ -1554,6 +1555,10 @@
          VG_(clo_log_name) = &arg[13];
       }
 
+      else if (VG_CLO_STREQN(19, arg, "--xml-user-comment=")) {
+         VG_(clo_xml_user_comment) = &arg[19];
+      }
+
       else if (VG_CLO_STREQN(15, arg, "--suppressions=")) {
          if (VG_(clo_n_suppressions) >= VG_CLO_MAX_SFILES) {
             VG_(message)(Vg_UserMsg, "Too many suppression files specified.");
@@ -1905,12 +1910,19 @@
                                   VG_(clo_log_file_qualifier),
                                   val ? val : "");
       }
+      if (VG_(clo_xml_user_comment)) {
+         /* Note: the user comment itself is XML and is therefore to
+            be passed through verbatim (%s) rather than escaped
+            (%t). */
+         VG_(message)(Vg_UserMsg, "<usercomment>%s</usercomment>",
+                                  VG_(clo_xml_user_comment));
+      }
       VG_(message)(Vg_UserMsg, "");
       VG_(message)(Vg_UserMsg, "<args>");
       VG_(message)(Vg_UserMsg, "  <vargv>");
       for (i = 0; i < vg_argc; i++) {
          HChar* tag = i==0 ? "exe" : "arg";
-         VG_(message)(Vg_UserMsg, "    <%s>%s</%s>", 
+         VG_(message)(Vg_UserMsg, "    <%s>%t</%s>", 
                                   tag, vg_argv[i], tag);
       }
       VG_(message)(Vg_UserMsg, "  </vargv>");
diff --git a/coregrind/m_options.c b/coregrind/m_options.c
index cf98924..caed244 100644
--- a/coregrind/m_options.c
+++ b/coregrind/m_options.c
@@ -44,6 +44,7 @@
 Int    VG_(clo_sanity_level)   = 1;
 Int    VG_(clo_verbosity)      = 1;
 Bool   VG_(clo_xml)            = False;
+HChar* VG_(clo_xml_user_comment) = NULL;
 Bool   VG_(clo_demangle)       = True;
 Bool   VG_(clo_trace_children) = False;
 Int    VG_(clo_log_fd)         = 2;
diff --git a/include/pub_tool_options.h b/include/pub_tool_options.h
index e27e158..8266a3a 100644
--- a/include/pub_tool_options.h
+++ b/include/pub_tool_options.h
@@ -71,6 +71,10 @@
    way.  See vg_main.c and mc_main.c. */
 extern Bool VG_(clo_xml);
 
+/* An arbitrary user-supplied string which is copied into the
+   XML output, in between <usercomment> tags. */
+extern HChar* VG_(clo_xml_user_comment);
+
 /* Call this if a recognised option was bad for some reason.
    Note: don't use it just because an option was unrecognised -- return 'False'
    from VG_(tdict).tool_process_cmd_line_option) to indicate that. */