|
From: <sv...@va...> - 2005-06-18 02:18:08
|
Author: njn
Date: 2005-06-18 03:18:04 +0100 (Sat, 18 Jun 2005)
New Revision: 3927
Log:
Created coregrind.h, a counterpart to valgrind.h containing the internal
client requests.
Added:
trunk/coregrind/coregrind.h
Modified:
trunk/coregrind/Makefile.am
trunk/coregrind/core.h
trunk/coregrind/m_replacemalloc/vg_replace_malloc.c
trunk/coregrind/m_scheduler/scheduler.c
trunk/coregrind/vg_preloaded.c
Modified: trunk/coregrind/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/Makefile.am 2005-06-18 01:42:21 UTC (rev 3926)
+++ trunk/coregrind/Makefile.am 2005-06-18 02:18:04 UTC (rev 3927)
@@ -37,6 +37,7 @@
noinst_HEADERS =3D \
core.h \
core_asm.h \
+ coregrind.h \
pub_core_aspacemgr.h \
pub_core_debuginfo.h \
pub_core_debuglog.h \
Modified: trunk/coregrind/core.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/core.h 2005-06-18 01:42:21 UTC (rev 3926)
+++ trunk/coregrind/core.h 2005-06-18 02:18:04 UTC (rev 3927)
@@ -49,20 +49,6 @@
=20
#include "pub_core_scheduler.h" // for types 'ThreadArchState'
=20
-/* These are the internal client request codes. The publically-visible
- request codes are also defined in valgrind.h, and similar headers for
- some tools. */
-
-/* Get the tool's malloc-wrapping functions */
-#define VG_USERREQ__GET_MALLOCFUNCS 0x3030
-
-/* Internal equivalent of VALGRIND_PRINTF . */
-#define VG_USERREQ__INTERNAL_PRINTF 0x3103
-
-/* Denote the finish of __libc_freeres_wrapper().=20
- A synonym for exit. */
-#define VG_USERREQ__LIBC_FREERES_DONE 0x3029
-
/* ---------------------------------------------------------------------
Exports of vg_helpers.S
------------------------------------------------------------------ */
Added: trunk/coregrind/coregrind.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/coregrind.h 2005-06-18 01:42:21 UTC (rev 3926)
+++ trunk/coregrind/coregrind.h 2005-06-18 02:18:04 UTC (rev 3927)
@@ -0,0 +1,80 @@
+
+/*--------------------------------------------------------------------*/
+/*--- Internal client requests. coregrind.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2005 Julian Seward
+ js...@ac...
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307, USA.
+
+ The GNU General Public License is contained in the file COPYING.
+*/
+
+#ifndef __COREGRIND_H
+#define __COREGRIND_H
+
+//--------------------------------------------------------------------
+// PURPOSE: This file is the counterpart to valgrind.h. It contains
+// the client requests that are internal to Valgrind, and not to be seen
+// by client programs.
+//--------------------------------------------------------------------
+
+#include <stdarg.h>
+
+// The strange choice of values here is due to historical reasons -- the=
re
+// used to be many more internal client requests.
+typedef
+ enum {=20
+ /* Denote the finish of __libc_freeres_wrapper(). Also causes exi=
t. */
+ VG_USERREQ__LIBC_FREERES_DONE =3D 0x3029,
+
+ /* Get the tool's malloc-wrapping functions */
+ VG_USERREQ__GET_MALLOCFUNCS =3D 0x3030,
+
+ /* Internal equivalent of VALGRIND_PRINTF . */
+ VG_USERREQ__INTERNAL_PRINTF =3D 0x3103,
+
+ } Vg_InternalClientRequest;
+
+// Function for printing from code within Valgrind, but which runs on th=
e
+// sim'd CPU. Must be a function rather than macros so that va_list can
+// be used.
+
+int VALGRIND_INTERNAL_PRINTF(char *format, ...);
+__attribute__((format(__printf__, 1, 2)))
+__attribute__((weak))
+int VALGRIND_INTERNAL_PRINTF(char *format, ...)
+{
+ unsigned long _qzz_res =3D 0;
+ va_list vargs;
+ va_start(vargs, format);
+ VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, VG_USERREQ__INTERNAL_PRINTF,
+ (unsigned long)format, (unsigned long)vargs, =
0, 0);
+ va_end(vargs);
+ return _qzz_res;
+}
+
+
+#endif // __COREGRIND_H
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
Modified: trunk/coregrind/m_replacemalloc/vg_replace_malloc.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_replacemalloc/vg_replace_malloc.c 2005-06-18 01:42:=
21 UTC (rev 3926)
+++ trunk/coregrind/m_replacemalloc/vg_replace_malloc.c 2005-06-18 02:18:=
04 UTC (rev 3927)
@@ -45,6 +45,8 @@
------------------------------------------------------------------ */
=20
#include "valgrind.h" // for VALGRIND_NON_SIMD_CALL[12]
+#include "coregrind.h" // for VALGRIND_INTERNAL_PRINTF
+
#include "core.h"
#include "pub_core_debuginfo.h" // needed for pub_core_redir.h :(
#include "pub_core_mallocfree.h" // for VG_MIN_MALLOC_SZB, VG_AR_CLIE=
NT
@@ -81,29 +83,9 @@
/* Startup hook - called as init section */
static void init(void) __attribute__((constructor));
=20
-// Functions for printing from code within Valgrind, but which runs on t=
he
-// sim'd CPU. They must be functions rather than macros so that va_list=
can
-// be used.
-// Nb: at one point, these were used by multiple files that run on the s=
im'd
-// CPU, and so were *defined* in core.h with the 'weak' attribute. That=
was
-// pretty ugly. It's much better if this is the only file that needs th=
em.
-
-__attribute__((format(__printf__, 1, 2)))
-static int
-internal_printf(char *format, ...)
-{
- UWord _qzz_res =3D 0;
- va_list vargs;
- va_start(vargs, format);
- VALGRIND_MAGIC_SEQUENCE(_qzz_res, 0, VG_USERREQ__INTERNAL_PRINTF,
- (UWord)format, (UWord)vargs, 0, 0);
- va_end(vargs);
- return _qzz_res;
-}
-
#define MALLOC_TRACE(format, args...) \
if (info.clo_trace_malloc) \
- internal_printf(format, ## args )
+ VALGRIND_INTERNAL_PRINTF(format, ## args )
=20
/* Below are new versions of malloc, __builtin_new, free,=20
__builtin_delete, calloc, realloc, memalign, and friends.
@@ -312,8 +294,7 @@
return VG_REPLACE_FUNCTION(libcZdsoZd6,malloc) (new_size); \
if (new_size <=3D 0) { \
VG_REPLACE_FUNCTION(libcZdsoZd6,free)(ptrV); \
- if (info.clo_trace_malloc) \
- internal_printf(" =3D 0" ); \
+ MALLOC_TRACE(" =3D 0"); \
return NULL; \
} \
if (!init_done) init(); \
Modified: trunk/coregrind/m_scheduler/scheduler.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_scheduler/scheduler.c 2005-06-18 01:42:21 UTC (rev =
3926)
+++ trunk/coregrind/m_scheduler/scheduler.c 2005-06-18 02:18:04 UTC (rev =
3927)
@@ -53,13 +53,14 @@
=20
This file is almost entirely OS-independent. The details of how
the OS handles threading and signalling are abstracted away and
- implemented elsewhere.
+ implemented elsewhere. [Some of the functions have worked their
+ way back for the moment, until we do an OS port in earnest...]
*/
=20
-#include "valgrind.h" /* for VG_USERREQ__RUNNING_ON_VALGRIND and
- VG_USERREQ__DISCARD_TRANSLATIONS, and other=
s */
+#include "valgrind.h" // for VG_USERREQ__*
+#include "coregrind.h" // for VG_USERREQ__*
+
#include "core.h"
-
#include "pub_core_aspacemgr.h"
#include "pub_core_dispatch.h"
#include "pub_core_errormgr.h"
Modified: trunk/coregrind/vg_preloaded.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/vg_preloaded.c 2005-06-18 01:42:21 UTC (rev 3926)
+++ trunk/coregrind/vg_preloaded.c 2005-06-18 02:18:04 UTC (rev 3927)
@@ -43,6 +43,8 @@
------------------------------------------------------------------ */
=20
#include "valgrind.h"
+#include "coregrind.h"
+
#include "core.h"
#include "pub_core_debuginfo.h" // needed for pub_core_redir.h :(
#include "pub_core_redir.h"
|