aboutsummaryrefslogtreecommitdiff
path: root/include/valgrind.h
diff options
context:
space:
mode:
authorfitzhardinge <fitzhardinge@a5019735-40e9-0310-863c-91ae7b9d1cf9>2003-10-31 07:12:21 +0000
committerfitzhardinge <fitzhardinge@a5019735-40e9-0310-863c-91ae7b9d1cf9>2003-10-31 07:12:21 +0000
commit39de4b473801ab10a48e356cddc863212dd28cd1 (patch)
treeadd2fe2b2aebdf427f90bdc19a5c79bf298b03c5 /include/valgrind.h
parentece14bd9aea868e552d3365df0e6bd6083d70561 (diff)
downloadvalgrind-39de4b473801ab10a48e356cddc863212dd28cd1.tar.gz
Patch from Robert Walsh <rjwalsh@durables.org>. Adds some new client
requests to allow client code to print messages through Valgrind's logging mechanism. The new requests are: VALGRIND_PRINTF - do a normal printf (prefixed with **PID**) VALGRIND_PRINTF_BACKTRACE - do a printf with stack trace VALGRIND_INTERNAL_PRINTF - printf, but for internal use (prefixed with ==PID==) VALGRIND_INTERNAL_PRINTF_BACKTRACE - as above, with backtrace git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1974 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'include/valgrind.h')
-rw-r--r--include/valgrind.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/include/valgrind.h b/include/valgrind.h
index a1711fd28..047d6fc60 100644
--- a/include/valgrind.h
+++ b/include/valgrind.h
@@ -59,6 +59,8 @@
#ifndef __VALGRIND_H
#define __VALGRIND_H
+#include <stdarg.h>
+
/* This file is for inclusion into client (your!) code.
@@ -162,6 +164,9 @@ typedef
VG_USERREQ__MALLOCLIKE_BLOCK = 0x1301,
VG_USERREQ__FREELIKE_BLOCK = 0x1302,
+ /* Allow printfs to valgrind log. */
+ VG_USERREQ__PRINTF = 0x1401,
+ VG_USERREQ__PRINTF_BACKTRACE = 0x1402,
} Vg_ClientRequest;
@@ -187,6 +192,40 @@ typedef
_qzz_addr, _qzz_len, 0, 0); \
}
+#ifndef NVALGRIND
+
+__attribute__((weak))
+int
+VALGRIND_PRINTF(char *format, ...)
+{
+ unsigned int _qzz_res;
+ va_list vargs;
+ va_start(vargs, format);
+ VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, VG_USERREQ__PRINTF,
+ (unsigned int)format, (unsigned int)vargs, 0, 0);
+ va_end(vargs);
+ return _qzz_res;
+}
+
+__attribute__((weak))
+int
+VALGRIND_PRINTF_BACKTRACE(char *format, ...)
+{
+ unsigned int _qzz_res;
+ va_list vargs;
+ va_start(vargs, format);
+ VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, VG_USERREQ__PRINTF_BACKTRACE,
+ (unsigned int)format, (unsigned int)vargs, 0, 0);
+ va_end(vargs);
+ return _qzz_res;
+}
+
+#else /* NVALGRIND */
+
+#define VALGRIND_PRINTF(...)
+#define VALGRIND_PRINTF_BACKTRACE(...)
+
+#endif /* NVALGRIND */
/* These requests allow control to move from the simulated CPU to the
real CPU, calling an arbitary function */