]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add format specifier %ps: only escape XML-metacharacters for --xml=yes
authorBart Van Assche <bvanassche@acm.org>
Tue, 11 Oct 2011 18:49:35 +0000 (18:49 +0000)
committerBart Van Assche <bvanassche@acm.org>
Tue, 11 Oct 2011 18:49:35 +0000 (18:49 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12135

coregrind/m_debuglog.c
coregrind/m_main.c
coregrind/pub_core_debuglog.h

index 7ad3f8c76b0110353e799fa01d5bf458a0b15b60..c3dcb191eed0ba7ab346bf4c12bec4cfad699eb2 100644 (file)
 #include "pub_core_debuglog.h"   /* our own iface */
 #include "valgrind.h"            /* for RUNNING_ON_VALGRIND */
 
+static Bool clo_xml;
+
+void VG_(debugLog_setXml)(Bool xml)
+{
+   clo_xml = xml;
+}
+
 /*------------------------------------------------------------*/
 /*--- Stuff to make us completely independent.             ---*/
 /*------------------------------------------------------------*/
@@ -730,6 +737,17 @@ VG_(debugLog_vprintf) (
                if (str == (char*) 0)
                   str = "(null)";
                ret += myvprintf_str_XML_simplistic(send, send_arg2, str);
+            } else if (format[i+1] == 's') {
+               i++;
+               /* %ps, synonym for %s with --xml=no / %pS with --xml=yes */
+               char *str = va_arg (vargs, char *);
+               if (str == (char*) 0)
+                  str = "(null)";
+               if (clo_xml)
+                  ret += myvprintf_str_XML_simplistic(send, send_arg2, str);
+               else
+                  ret += myvprintf_str(send, send_arg2, flags, width, str,
+                                       False);
             } else {
                /* %p */
                ret += 2;
index a8edffba5e51e979fa715f7f68a4aa9a66e3591d..1981321c88a5cf6fb5cf4ffb1d2e847c5794f6fd 100644 (file)
@@ -462,7 +462,9 @@ void main_process_cmd_line_options ( /*OUT*/Bool* logging_to_fd,
          VG_(clo_verbosity)--;
 
       else if VG_BOOL_CLO(arg, "--stats",          VG_(clo_stats)) {}
-      else if VG_BOOL_CLO(arg, "--xml",            VG_(clo_xml)) {}
+      else if VG_BOOL_CLO(arg, "--xml",            VG_(clo_xml))
+         VG_(debugLog_setXml)(VG_(clo_xml));
+
       else if VG_XACT_CLO(arg, "--vgdb=no",        VG_(clo_vgdb), Vg_VgdbNo) {}
       else if VG_XACT_CLO(arg, "--vgdb=yes",       VG_(clo_vgdb), Vg_VgdbYes) {}
       else if VG_XACT_CLO(arg, "--vgdb=full",      VG_(clo_vgdb), Vg_VgdbFull) {}
index 9cdcd613ca4077f0386b03de6929d227ec77a646..865963e0a6ff4418dbb1eff666f8e68cf7e8ebee 100644 (file)
@@ -59,6 +59,10 @@ extern
 void VG_(debugLog_startup) ( Int level, HChar* who );
 
 
+/* Whether %ps should escape XML metacharacters. */
+extern void VG_(debugLog_setXml)(Bool xml);
+
+
 /* Get the logging threshold level, as set by the most recent call to
    VG_(debugLog_startup), or zero if there have been no such calls so
    far. */