From: Philippe Waroquiers Date: Wed, 7 May 2014 22:03:59 +0000 (+0000) Subject: * document the %ps / %pS extensions to printf X-Git-Tag: svn/VALGRIND_3_10_0~494 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4aea515f545e4a7638d43e819cc67bd4da027440;p=thirdparty%2Fvalgrind.git * document the %ps / %pS extensions to printf * remove (from memcheck) emiN, as PRINTF_CHECK can be done properly git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13942 --- diff --git a/include/pub_tool_libcprint.h b/include/pub_tool_libcprint.h index 70cd38143f..374d8e62cf 100644 --- a/include/pub_tool_libcprint.h +++ b/include/pub_tool_libcprint.h @@ -37,6 +37,18 @@ Formatting functions ------------------------------------------------------------------ */ +/* The formatting functions supports a subset (and 2 extensions) of + the 'printf' format. + The extensions are: + %pS : print a string (like %s) but escaping chars for XML safety. + %ps : with --xml=no, synonym for %s, with --xml=yes, synonym of %pS. + + Note: these extensions do not cause the compiler to barf with PRINTF_CHECK + as for the classical printf, %p requires a pointer, which must also + be provided for the %ps and %pS extensions. The s/S following %p + are understood by PRINTF_CHECK as characters to output. +*/ + extern UInt VG_(sprintf) ( HChar* buf, const HChar* format, ... ) PRINTF_CHECK(2, 3); diff --git a/memcheck/mc_errors.c b/memcheck/mc_errors.c index 424e512972..6a03a50992 100644 --- a/memcheck/mc_errors.c +++ b/memcheck/mc_errors.c @@ -286,13 +286,6 @@ static void emit ( const HChar* format, ... ) emit_WRK(format, vargs); va_end(vargs); } -static void emiN ( const HChar* format, ... ) /* NO FORMAT CHECK */ -{ - va_list vargs; - va_start(vargs, format); - emit_WRK(format, vargs); - va_end(vargs); -} static void mc_pp_AddrInfo ( Addr a, AddrInfo* ai, Bool maybe_gcc ) @@ -371,7 +364,7 @@ static void mc_pp_AddrInfo ( Addr a, AddrInfo* ai, Bool maybe_gcc ) } case Addr_DataSym: - emiN( "%sAddress 0x%llx is %llu bytes " + emit( "%sAddress 0x%llx is %llu bytes " "inside data symbol \"%pS\"%s\n", xpre, (ULong)a, @@ -395,7 +388,7 @@ static void mc_pp_AddrInfo ( Addr a, AddrInfo* ai, Bool maybe_gcc ) break; case Addr_SectKind: - emiN( "%sAddress 0x%llx is in the %pS segment of %pS%s\n", + emit( "%sAddress 0x%llx is in the %pS segment of %pS%s\n", xpre, (ULong)a, VG_(pp_SectKind)(ai->Addr.SectKind.kind), @@ -589,7 +582,7 @@ void MC_(pp_Error) ( Error* err ) // the following code is untested. Bad. if (xml) { emit( " CoreMemError\n" ); - emiN( " %pS contains unaddressable byte(s)\n", + emit( " %pS contains unaddressable byte(s)\n", VG_(get_error_string)(err)); VG_(pp_ExeContext)( VG_(get_error_where)(err) ); } else { @@ -647,7 +640,7 @@ void MC_(pp_Error) ( Error* err ) MC_(any_value_errors) = True; if (xml) { emit( " SyscallParam\n" ); - emiN( " Syscall param %pS contains " + emit( " Syscall param %pS contains " "uninitialised byte(s)\n", VG_(get_error_string)(err) ); VG_(pp_ExeContext)( VG_(get_error_where)(err) ); @@ -669,7 +662,7 @@ void MC_(pp_Error) ( Error* err ) MC_(any_value_errors) = True; if (xml) { emit( " SyscallParam\n" ); - emiN( " Syscall param %pS points to %s byte(s)\n", + emit( " Syscall param %pS points to %s byte(s)\n", VG_(get_error_string)(err), extra->Err.MemParam.isAddrErr ? "unaddressable" : "uninitialised" ); @@ -797,7 +790,7 @@ void MC_(pp_Error) ( Error* err ) if (xml) { emit( " Overlap\n" ); if (extra->Err.Overlap.szB == 0) { - emiN( " Source and destination overlap " + emit( " Source and destination overlap " "in %pS(%#lx, %#lx)\n\n", VG_(get_error_string)(err), extra->Err.Overlap.dst, extra->Err.Overlap.src ); @@ -811,7 +804,7 @@ void MC_(pp_Error) ( Error* err ) VG_(pp_ExeContext)( VG_(get_error_where)(err) ); } else { if (extra->Err.Overlap.szB == 0) { - emiN( "Source and destination overlap in %pS(%#lx, %#lx)\n", + emit( "Source and destination overlap in %pS(%#lx, %#lx)\n", VG_(get_error_string)(err), extra->Err.Overlap.dst, extra->Err.Overlap.src ); } else {