/*OUT*/Char* dname, Int n_dname,
/*OUT*/PtrdiffT* offset );
-/* Try to form some description of data_addr by looking at the DWARF3
+/* Try to form some description of DATA_ADDR by looking at the DWARF3
debug info we have. This considers all global variables, and all
- frames in the stacks of all threads. Result (or as much as will
- fit) is put into into dname{1,2}[0 .. n_dname-1] and is guaranteed
- to be zero terminated. */
-extern Bool VG_(get_data_description)( /*OUT*/Char* dname1,
- /*OUT*/Char* dname2,
- Int n_dname,
- Addr data_addr );
+ frames in the stacks of all threads. Result is written at the ends
+ of DNAME{1,2}V, which are XArray*s of HChar, that have been
+ initialised by the caller, and True is returned. If no description
+ is created, False is returned. Regardless of the return value,
+ DNAME{1,2}V are guaranteed to be zero terminated after the call.
+
+ Note that after the call, DNAME{1,2} may have more than one
+ trailing zero, so callers should establish the useful text length
+ using VG_(strlen) on the contents, rather than VG_(sizeXA) on the
+ XArray itself.
+*/
+Bool VG_(get_data_description)(
+ /*MOD*/ void* /* really, XArray* of HChar */ dname1v,
+ /*MOD*/ void* /* really, XArray* of HChar */ dname2v,
+ Addr data_addr
+ );
/* Succeeds if the address is within a shared object or the main executable.
It doesn't matter if debug info is present or not. */
------------------------------------------------------------------ */
/* Note that they all output to the file descriptor given by the
- * --log-fd/--log-file/--log-socket argument, which defaults to 2 (stderr).
- * Hence no need for VG_(fprintf)().
- */
-extern UInt VG_(printf) ( const HChar *format, ... ) PRINTF_CHECK(1, 2);
-extern UInt VG_(vprintf) ( const HChar *format, va_list vargs ) PRINTF_CHECK(1, 0);
-extern UInt VG_(sprintf) ( Char* buf, const HChar* format, ... ) PRINTF_CHECK(2, 3);
-extern UInt VG_(vsprintf) ( Char* buf, const HChar* format, va_list vargs ) PRINTF_CHECK(2, 0);
+ --log-fd/--log-file/--log-socket argument, which defaults to 2
+ (stderr). Hence no need for VG_(fprintf)().
+*/
+extern UInt VG_(printf) ( const HChar *format, ... )
+ PRINTF_CHECK(1, 2);
+
+extern UInt VG_(vprintf) ( const HChar *format, va_list vargs )
+ PRINTF_CHECK(1, 0);
+
+extern UInt VG_(sprintf) ( Char* buf, const HChar* format, ... )
+ PRINTF_CHECK(2, 3);
+
+extern UInt VG_(vsprintf) ( Char* buf, const HChar* format, va_list vargs )
+ PRINTF_CHECK(2, 0);
+
extern UInt VG_(snprintf) ( Char* buf, Int size,
- const HChar *format, ... ) PRINTF_CHECK(3, 4);
+ const HChar *format, ... )
+ PRINTF_CHECK(3, 4);
+
extern UInt VG_(vsnprintf)( Char* buf, Int size,
- const HChar *format, va_list vargs ) PRINTF_CHECK(3, 0);
+ const HChar *format, va_list vargs )
+ PRINTF_CHECK(3, 0);
+
+/* Yet another, totally general, version of vprintf, which hands all
+ output bytes to CHAR_SINK, passing it OPAQUE as the second arg. */
+extern void VG_(vcbprintf)( void(*char_sink)(HChar, void* opaque),
+ void* opaque,
+ const HChar* format, va_list vargs );
+
+/* These are the same as the non "_xml" versions above, except the
+ output goes on the selected XML output channel instead of the
+ normal one.
+*/
+extern UInt VG_(printf_xml) ( const HChar *format, ... )
+ PRINTF_CHECK(1, 2);
+
+extern UInt VG_(vprintf_xml) ( const HChar *format, va_list vargs )
+ PRINTF_CHECK(1, 0);
+
+extern UInt VG_(printf_xml_no_f_c) ( const HChar *format, ... );
// Percentify n/m with d decimal places. Includes the '%' symbol at the end.
// Right justifies in 'buf'.
extern void VG_(percentify)(ULong n, ULong m, UInt d, Int n_buf, char buf[]);
+
/* ---------------------------------------------------------------------
Messages for the user
------------------------------------------------------------------ */
/* No, really. I _am_ that strange. */
-#define OINK(nnn) VG_(message)(Vg_DebugMsg, "OINK %d",nnn)
+#define OINK(nnn) VG_(message)(Vg_DebugMsg, "OINK %d\n",nnn)
/* Print a message prefixed by "??<pid>?? "; '?' depends on the VgMsgKind.
Should be used for all user output. */
}
VgMsgKind;
-/* Send a single-part message. Appends a newline. The format
- specification may contain any ISO C format specifier or %t.
- No attempt is made to let the compiler verify consistency of the
- format string and the argument list. */
+/* Send a single-part message. The format specification may contain
+ any ISO C format specifier or %t. No attempt is made to let the
+ compiler verify consistency of the format string and the argument
+ list. */
extern UInt VG_(message_no_f_c)( VgMsgKind kind, const HChar* format, ... );
-/* Send a single-part message. Appends a newline. The format
- specification may contain any ISO C format specifier. The gcc compiler
- will verify consistency of the format string and the argument list. */
+/* Send a single-part message. The format specification may contain
+ any ISO C format specifier. The gcc compiler will verify
+ consistency of the format string and the argument list. */
extern UInt VG_(message)( VgMsgKind kind, const HChar* format, ... )
PRINTF_CHECK(2, 3);
PRINTF_CHECK(2, 0);
// Short-cuts for VG_(message)().
-#define VG_UMSG( format, args... ) VG_(message)(Vg_UserMsg, format, ##args)
-#define VG_DMSG( format, args... ) VG_(message)(Vg_DebugMsg, format, ##args)
-#define VG_EMSG( format, args... ) VG_(message)(Vg_DebugExtraMsg, \
- format, ##args)
+extern UInt VG_(umsg)( const HChar* format, ... ) PRINTF_CHECK(1, 2);
+extern UInt VG_(dmsg)( const HChar* format, ... ) PRINTF_CHECK(1, 2);
+extern UInt VG_(emsg)( const HChar* format, ... ) PRINTF_CHECK(1, 2);
+
+/* Flush any output cached by previous calls to VG_(message) et al. */
+extern void VG_(message_flush) ( void );
#endif // __PUB_TOOL_LIBCPRINT_H
// similar errors occurring.
Bool (*eq_Error)(VgRes res, Error* e1, Error* e2),
+ // We give tools a chance to have a look at errors
+ // just before they are printed. That is, before_pp_Error is
+ // called just before pp_Error itself. This gives the tool a
+ // chance to look at the just-about-to-be-printed error, so as to
+ // emit any arbitrary output if wants to, before the error itself
+ // is printed. This functionality was added to allow Helgrind to
+ // print thread-announcement messages immediately before the
+ // errors that refer to them.
+ void (*before_pp_Error)(Error* err),
+
// Print error context.
void (*pp_Error)(Error* err),
/* Can the tool do XML output? This is a slight misnomer, because the tool
* is not requesting the core to do anything, rather saying "I can handle
* it". */
-extern void VG_(needs_xml_output)( void );
+extern void VG_(needs_xml_output) ( void );
/* Does the tool want to have one final pass over the IR after tree
building but before instruction selection? If so specify the