2 /*--------------------------------------------------------------------*/
3 /*--- Printing libc stuff. pub_tool_libcprint.h ---*/
4 /*--------------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2000-2010 Julian Seward
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28 The GNU General Public License is contained in the file COPYING.
31 #ifndef __PUB_TOOL_LIBCPRINT_H
32 #define __PUB_TOOL_LIBCPRINT_H
34 /* ---------------------------------------------------------------------
36 ------------------------------------------------------------------ */
38 /* Note that they all output to the file descriptor given by the
39 --log-fd/--log-file/--log-socket argument, which defaults to 2
40 (stderr). Hence no need for VG_(fprintf)().
42 extern UInt VG_(printf) ( const HChar *format, ... )
45 extern UInt VG_(vprintf) ( const HChar *format, va_list vargs )
48 extern UInt VG_(sprintf) ( Char* buf, const HChar* format, ... )
51 extern UInt VG_(vsprintf) ( Char* buf, const HChar* format, va_list vargs )
54 extern UInt VG_(snprintf) ( Char* buf, Int size,
55 const HChar *format, ... )
58 extern UInt VG_(vsnprintf)( Char* buf, Int size,
59 const HChar *format, va_list vargs )
62 /* Yet another, totally general, version of vprintf, which hands all
63 output bytes to CHAR_SINK, passing it OPAQUE as the second arg. */
64 extern void VG_(vcbprintf)( void(*char_sink)(HChar, void* opaque),
66 const HChar* format, va_list vargs );
68 /* These are the same as the non "_xml" versions above, except the
69 output goes on the selected XML output channel instead of the
72 extern UInt VG_(printf_xml) ( const HChar *format, ... )
75 extern UInt VG_(vprintf_xml) ( const HChar *format, va_list vargs )
78 extern UInt VG_(printf_xml_no_f_c) ( const HChar *format, ... );
80 // Percentify n/m with d decimal places. Includes the '%' symbol at the end.
81 // Right justifies in 'buf'.
82 extern void VG_(percentify)(ULong n, ULong m, UInt d, Int n_buf, char buf[]);
85 /* ---------------------------------------------------------------------
87 ------------------------------------------------------------------ */
89 /* No, really. I _am_ that strange. */
90 #define OINK(nnn) VG_(message)(Vg_DebugMsg, "OINK %d\n",nnn)
92 /* Print a message prefixed by "??<pid>?? "; '?' depends on the VgMsgKind.
93 Should be used for all user output. */
96 enum { Vg_UserMsg, /* '?' == '=' */
97 Vg_DebugMsg, /* '?' == '-' */
98 Vg_DebugExtraMsg, /* '?' == '+' */
99 Vg_ClientMsg /* '?' == '*' */
103 /* Send a single-part message. The format specification may contain
104 any ISO C format specifier or %t. No attempt is made to let the
105 compiler verify consistency of the format string and the argument
107 extern UInt VG_(message_no_f_c)( VgMsgKind kind, const HChar* format, ... );
108 /* Send a single-part message. The format specification may contain
109 any ISO C format specifier. The gcc compiler will verify
110 consistency of the format string and the argument list. */
111 extern UInt VG_(message)( VgMsgKind kind, const HChar* format, ... )
114 extern UInt VG_(vmessage)( VgMsgKind kind, const HChar* format, va_list vargs )
117 // Short-cuts for VG_(message)().
118 extern UInt VG_(umsg)( const HChar* format, ... ) PRINTF_CHECK(1, 2);
119 extern UInt VG_(dmsg)( const HChar* format, ... ) PRINTF_CHECK(1, 2);
120 extern UInt VG_(emsg)( const HChar* format, ... ) PRINTF_CHECK(1, 2);
122 /* Flush any output cached by previous calls to VG_(message) et al. */
123 extern void VG_(message_flush) ( void );
125 #endif // __PUB_TOOL_LIBCPRINT_H
127 /*--------------------------------------------------------------------*/
129 /*--------------------------------------------------------------------*/