blob: 0e057cbba0f707e3c639c5701a9dfa405f9082f8 [file] [log] [blame]
njn36a20fa2005-06-03 03:08:39 +00001
2/*--------------------------------------------------------------------*/
3/*--- Printing libc stuff. pub_tool_libcprint.h ---*/
4/*--------------------------------------------------------------------*/
5
6/*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
9
njn9f207462009-03-10 22:02:09 +000010 Copyright (C) 2000-2009 Julian Seward
njn36a20fa2005-06-03 03:08:39 +000011 jseward@acm.org
12
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.
17
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.
22
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
26 02111-1307, USA.
27
28 The GNU General Public License is contained in the file COPYING.
29*/
30
31#ifndef __PUB_TOOL_LIBCPRINT_H
32#define __PUB_TOOL_LIBCPRINT_H
33
34/* ---------------------------------------------------------------------
35 Basic printing
36 ------------------------------------------------------------------ */
37
38/* Note that they all output to the file descriptor given by the
sewardj5d9dc752009-07-15 14:52:18 +000039 --log-fd/--log-file/--log-socket argument, which defaults to 2
40 (stderr). Hence no need for VG_(fprintf)().
41*/
42extern UInt VG_(printf) ( const HChar *format, ... )
43 PRINTF_CHECK(1, 2);
44
45extern UInt VG_(vprintf) ( const HChar *format, va_list vargs )
46 PRINTF_CHECK(1, 0);
47
48extern UInt VG_(sprintf) ( Char* buf, const HChar* format, ... )
49 PRINTF_CHECK(2, 3);
50
51extern UInt VG_(vsprintf) ( Char* buf, const HChar* format, va_list vargs )
52 PRINTF_CHECK(2, 0);
53
sewardj45f4e7c2005-09-27 19:20:21 +000054extern UInt VG_(snprintf) ( Char* buf, Int size,
sewardj5d9dc752009-07-15 14:52:18 +000055 const HChar *format, ... )
56 PRINTF_CHECK(3, 4);
57
sewardj45f4e7c2005-09-27 19:20:21 +000058extern UInt VG_(vsnprintf)( Char* buf, Int size,
sewardj5d9dc752009-07-15 14:52:18 +000059 const HChar *format, va_list vargs )
60 PRINTF_CHECK(3, 0);
61
62/* Yet another, totally general, version of vprintf, which hands all
63 output bytes to CHAR_SINK, passing it OPAQUE as the second arg. */
64extern void VG_(vcbprintf)( void(*char_sink)(HChar, void* opaque),
65 void* opaque,
66 const HChar* format, va_list vargs );
67
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
70 normal one.
71*/
72extern UInt VG_(printf_xml) ( const HChar *format, ... )
73 PRINTF_CHECK(1, 2);
74
75extern UInt VG_(vprintf_xml) ( const HChar *format, va_list vargs )
76 PRINTF_CHECK(1, 0);
77
78extern UInt VG_(printf_xml_no_f_c) ( const HChar *format, ... );
njn36a20fa2005-06-03 03:08:39 +000079
njn7a5915e2005-07-17 16:12:59 +000080// Percentify n/m with d decimal places. Includes the '%' symbol at the end.
njn5eaff2f2005-09-25 19:11:45 +000081// Right justifies in 'buf'.
82extern void VG_(percentify)(ULong n, ULong m, UInt d, Int n_buf, char buf[]);
njn856c54e2005-06-26 18:43:40 +000083
sewardj5d9dc752009-07-15 14:52:18 +000084
njn36a20fa2005-06-03 03:08:39 +000085/* ---------------------------------------------------------------------
86 Messages for the user
87 ------------------------------------------------------------------ */
88
njn3e114522005-06-11 03:31:09 +000089/* No, really. I _am_ that strange. */
sewardj5d9dc752009-07-15 14:52:18 +000090#define OINK(nnn) VG_(message)(Vg_DebugMsg, "OINK %d\n",nnn)
njn3e114522005-06-11 03:31:09 +000091
njn36a20fa2005-06-03 03:08:39 +000092/* Print a message prefixed by "??<pid>?? "; '?' depends on the VgMsgKind.
93 Should be used for all user output. */
94
95typedef
96 enum { Vg_UserMsg, /* '?' == '=' */
97 Vg_DebugMsg, /* '?' == '-' */
98 Vg_DebugExtraMsg, /* '?' == '+' */
99 Vg_ClientMsg /* '?' == '*' */
100 }
101 VgMsgKind;
102
sewardj5d9dc752009-07-15 14:52:18 +0000103/* 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
106 list. */
barta0b6b2c2008-07-07 06:49:24 +0000107extern UInt VG_(message_no_f_c)( VgMsgKind kind, const HChar* format, ... );
sewardj5d9dc752009-07-15 14:52:18 +0000108/* 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. */
barta0b6b2c2008-07-07 06:49:24 +0000111extern UInt VG_(message)( VgMsgKind kind, const HChar* format, ... )
112 PRINTF_CHECK(2, 3);
njn36a20fa2005-06-03 03:08:39 +0000113
barta0b6b2c2008-07-07 06:49:24 +0000114extern UInt VG_(vmessage)( VgMsgKind kind, const HChar* format, va_list vargs )
115 PRINTF_CHECK(2, 0);
116
njn6f74a7e2009-03-12 00:06:45 +0000117// Short-cuts for VG_(message)().
sewardj5d9dc752009-07-15 14:52:18 +0000118extern UInt VG_(umsg)( const HChar* format, ... ) PRINTF_CHECK(1, 2);
119extern UInt VG_(dmsg)( const HChar* format, ... ) PRINTF_CHECK(1, 2);
120extern UInt VG_(emsg)( const HChar* format, ... ) PRINTF_CHECK(1, 2);
121
122/* Flush any output cached by previous calls to VG_(message) et al. */
123extern void VG_(message_flush) ( void );
barta0b6b2c2008-07-07 06:49:24 +0000124
njn36a20fa2005-06-03 03:08:39 +0000125#endif // __PUB_TOOL_LIBCPRINT_H
126
127/*--------------------------------------------------------------------*/
128/*--- end ---*/
129/*--------------------------------------------------------------------*/