|
From: <sv...@va...> - 2011-10-11 18:54:20
|
Author: bart
Date: 2011-10-11 19:49:35 +0100 (Tue, 11 Oct 2011)
New Revision: 12135
Log:
Add format specifier %ps: only escape XML-metacharacters for --xml=yes
Modified:
trunk/coregrind/m_debuglog.c
trunk/coregrind/m_main.c
trunk/coregrind/pub_core_debuglog.h
Modified: trunk/coregrind/m_debuglog.c
===================================================================
--- trunk/coregrind/m_debuglog.c 2011-10-11 18:17:48 UTC (rev 12134)
+++ trunk/coregrind/m_debuglog.c 2011-10-11 18:49:35 UTC (rev 12135)
@@ -56,6 +56,13 @@
#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 @@
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;
Modified: trunk/coregrind/m_main.c
===================================================================
--- trunk/coregrind/m_main.c 2011-10-11 18:17:48 UTC (rev 12134)
+++ trunk/coregrind/m_main.c 2011-10-11 18:49:35 UTC (rev 12135)
@@ -462,7 +462,9 @@
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) {}
Modified: trunk/coregrind/pub_core_debuglog.h
===================================================================
--- trunk/coregrind/pub_core_debuglog.h 2011-10-11 18:17:48 UTC (rev 12134)
+++ trunk/coregrind/pub_core_debuglog.h 2011-10-11 18:49:35 UTC (rev 12135)
@@ -59,6 +59,10 @@
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. */
|