From: Bart Van Assche Date: Tue, 11 Oct 2011 18:49:35 +0000 (+0000) Subject: Add format specifier %ps: only escape XML-metacharacters for --xml=yes X-Git-Tag: svn/VALGRIND_3_7_0~104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99066365d5318374e47cfe5a0b342b2d45fc6393;p=thirdparty%2Fvalgrind.git Add format specifier %ps: only escape XML-metacharacters for --xml=yes git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12135 --- diff --git a/coregrind/m_debuglog.c b/coregrind/m_debuglog.c index 7ad3f8c76b..c3dcb191ee 100644 --- a/coregrind/m_debuglog.c +++ b/coregrind/m_debuglog.c @@ -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 @@ 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; diff --git a/coregrind/m_main.c b/coregrind/m_main.c index a8edffba5e..1981321c88 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -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) {} diff --git a/coregrind/pub_core_debuglog.h b/coregrind/pub_core_debuglog.h index 9cdcd613ca..865963e0a6 100644 --- a/coregrind/pub_core_debuglog.h +++ b/coregrind/pub_core_debuglog.h @@ -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. */