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);
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 )
}
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,
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),
// the following code is untested. Bad.
if (xml) {
emit( " <kind>CoreMemError</kind>\n" );
- emiN( " <what>%pS contains unaddressable byte(s)</what>\n",
+ emit( " <what>%pS contains unaddressable byte(s)</what>\n",
VG_(get_error_string)(err));
VG_(pp_ExeContext)( VG_(get_error_where)(err) );
} else {
MC_(any_value_errors) = True;
if (xml) {
emit( " <kind>SyscallParam</kind>\n" );
- emiN( " <what>Syscall param %pS contains "
+ emit( " <what>Syscall param %pS contains "
"uninitialised byte(s)</what>\n",
VG_(get_error_string)(err) );
VG_(pp_ExeContext)( VG_(get_error_where)(err) );
MC_(any_value_errors) = True;
if (xml) {
emit( " <kind>SyscallParam</kind>\n" );
- emiN( " <what>Syscall param %pS points to %s byte(s)</what>\n",
+ emit( " <what>Syscall param %pS points to %s byte(s)</what>\n",
VG_(get_error_string)(err),
extra->Err.MemParam.isAddrErr
? "unaddressable" : "uninitialised" );
if (xml) {
emit( " <kind>Overlap</kind>\n" );
if (extra->Err.Overlap.szB == 0) {
- emiN( " <what>Source and destination overlap "
+ emit( " <what>Source and destination overlap "
"in %pS(%#lx, %#lx)\n</what>\n",
VG_(get_error_string)(err),
extra->Err.Overlap.dst, extra->Err.Overlap.src );
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 {