From: Julian Seward Date: Wed, 15 Jul 2009 14:52:18 +0000 (+0000) Subject: Merge include/ changes from branches/MESSAGING_TIDYUP r10464. X-Git-Tag: svn/VALGRIND_3_5_0~372 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=22ec466157f7f933896bfae1f36885fee445127e;p=thirdparty%2Fvalgrind.git Merge include/ changes from branches/MESSAGING_TIDYUP r10464. See trunk r10465 commit message for details. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10476 --- diff --git a/include/pub_tool_debuginfo.h b/include/pub_tool_debuginfo.h index e5ad9f74ce..a55bca0618 100644 --- a/include/pub_tool_debuginfo.h +++ b/include/pub_tool_debuginfo.h @@ -95,15 +95,24 @@ extern Bool VG_(get_datasym_and_offset)( Addr data_addr, /*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. */ diff --git a/include/pub_tool_libcprint.h b/include/pub_tool_libcprint.h index b3386b252e..dd92feebcb 100644 --- a/include/pub_tool_libcprint.h +++ b/include/pub_tool_libcprint.h @@ -50,28 +50,58 @@ ------------------------------------------------------------------ */ /* 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 "???? "; '?' depends on the VgMsgKind. Should be used for all user output. */ @@ -84,14 +114,14 @@ typedef } 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); @@ -99,10 +129,12 @@ extern UInt VG_(vmessage)( VgMsgKind kind, const HChar* format, va_list vargs ) 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 diff --git a/include/pub_tool_options.h b/include/pub_tool_options.h index cab21015fd..ec03af3b77 100644 --- a/include/pub_tool_options.h +++ b/include/pub_tool_options.h @@ -97,7 +97,7 @@ /* Check bounds. */ \ if ((qq_var) < (qq_lo) || (qq_var) > (qq_hi)) { \ VG_(message)(Vg_UserMsg, \ - "'%s' argument must be between %lld and %lld", \ + "'%s' argument must be between %lld and %lld\n", \ (qq_option), (Long)(qq_lo), (Long)(qq_hi)); \ VG_(err_bad_option)(qq_arg); \ } \ diff --git a/include/pub_tool_tooliface.h b/include/pub_tool_tooliface.h index a006c4b645..bce2b227f8 100644 --- a/include/pub_tool_tooliface.h +++ b/include/pub_tool_tooliface.h @@ -284,6 +284,16 @@ extern void VG_(needs_tool_errors) ( // 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), @@ -434,7 +444,7 @@ extern void VG_(needs_malloc_replacement)( /* 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