#include "tool.h"
#include "cg_arch.h"
#include "pub_tool_libcbase.h"
+#include "pub_tool_libcprint.h"
// All CPUID info taken from sandpile.org/a32/cpuid.htm */
// Probably only works for Intel and AMD chips, and probably only for some of
#include "tool.h"
#include "cg_arch.h"
-#include "pub_tool_libcbase.h"
void VGA_(configure_caches)(cache_t* I1c, cache_t* D1c, cache_t* L2c,
Bool all_caches_clo_defined)
#include "pub_tool_debuginfo.h"
#include "pub_tool_hashtable.h"
#include "pub_tool_libcbase.h"
+#include "pub_tool_libcprint.h"
#include "pub_tool_mallocfree.h"
#include "pub_tool_options.h"
#include "pub_tool_profile.h"
#include "tool.h"
#include "pub_tool_libcbase.h"
+#include "pub_tool_libcprint.h"
#include "cg_arch.h"
// All CPUID info taken from sandpile.org/a32/cpuid.htm */
pub_core_execontext.h \
pub_core_hashtable.h \
pub_core_libcbase.h \
+ pub_core_libcprint.h \
pub_core_main.h \
pub_core_mallocfree.h \
pub_core_options.h \
m_execontext.c \
m_hashtable.c \
m_libcbase.c \
+ m_libcprint.c \
m_main.c \
m_mallocfree.c \
m_options.c \
m_transtab.c \
\
ume.c \
- vg_messages.c \
vg_mylibc.c \
vg_threadmodel.c \
vg_pthreadmodel.c
extern void VG_(unimplemented) ( Char* msg )
__attribute__((__noreturn__));
-/* Tell the logging mechanism whether we are logging to a file
- descriptor or a socket descriptor. */
-extern Bool VG_(logging_to_socket);
-
/* Tools use VG_(strdup)() which doesn't expose ArenaId */
extern Char* VG_(arena_strdup) ( ArenaId aid, const Char* s);
#include "core.h"
#include "pub_core_debuglog.h"
+#include "pub_core_libcprint.h"
#include "pub_core_options.h"
#include "pub_core_signals.h"
#include "pub_core_tooliface.h"
#include "core.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "pub_core_options.h"
#include "pub_core_syscalls.h"
#include "pub_core_tooliface.h"
#include "core.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
/* Size of a smallish table used to read /proc/self/map entries. */
#define M_PROCMAP_BUF 50000
#include "core.h"
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "pub_core_options.h"
#include "priv_symtab.h"
#include "core.h"
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "priv_symtab.h"
#include <a.out.h> /* stabs defns */
#include "pub_core_aspacemgr.h"
#include "pub_core_demangle.h"
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "pub_core_options.h"
#include "pub_core_profile.h"
#include "pub_core_redir.h"
#include "pub_core_debuginfo.h"
#include "pub_core_debuglog.h" /* VG_(debugLog_vprintf) */
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "pub_core_tooliface.h"
#include "priv_symtypes.h"
#include "safe-ctype.h"
#include "core.h"
#include "pub_core_libcbase.h"
+#include "pub_tool_libcprint.h"
/*#include <sys/types.h>
#include <string.h>
#include "pub_core_errormgr.h"
#include "pub_core_execontext.h"
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "pub_core_main.h" // for VG_(start_debugger)()
#include "pub_core_options.h"
#include "pub_core_stacktrace.h"
#include "core.h"
#include "pub_core_execontext.h"
+#include "pub_core_libcprint.h"
#include "pub_core_options.h"
#include "pub_core_profile.h"
The GNU General Public License is contained in the file COPYING.
*/
-#include "tool.h" // XXX: temporary, for NULL, VG_(), Char, etc
+#include "core.h" // XXX: temporary, for NULL, VG_(), Char, etc
#include "pub_core_libcbase.h"
/* ---------------------------------------------------------------------
#include "pub_core_errormgr.h"
#include "pub_core_execontext.h"
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "pub_core_main.h"
#include "pub_core_options.h"
#include "pub_core_profile.h"
#include "core.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "pub_core_options.h"
#include "pub_core_profile.h"
#include "valgrind.h"
*/
#include "core.h"
+#include "pub_core_libcprint.h"
#include "pub_core_profile.h"
/* get rid of these, if possible */
#include "pub_core_aspacemgr.h"
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "pub_core_skiplist.h"
#include "pub_core_options.h"
#include "pub_core_redir.h"
#include "core.h"
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "pub_core_options.h"
#include "pub_core_replacemalloc.h"
#include "pub_core_dispatch.h"
#include "pub_core_errormgr.h"
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "pub_core_main.h"
#include "pub_core_options.h"
#include "pub_core_profile.h"
#include "core.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "pub_core_options.h"
#include "pub_core_sigframe.h"
#include "pub_core_signals.h"
#include "core.h"
#include "pub_core_aspacemgr.h" /* find_segment */
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "pub_core_options.h"
#include "pub_core_sigframe.h"
#include "pub_core_signals.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_errormgr.h"
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "pub_core_main.h"
#include "pub_core_options.h"
#include "pub_core_signals.h"
#include "core.h"
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "pub_core_skiplist.h"
#include <stdlib.h>
#include "core.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "pub_core_options.h"
#include "pub_core_profile.h"
#include "pub_core_stacktrace.h"
#include "ume.h" /* for jmp_with_stack */
#include "pub_core_debuglog.h"
#include "pub_core_aspacemgr.h"
+#include "pub_core_libcprint.h"
#include "pub_core_sigframe.h"
#include "pub_core_syscalls.h"
#include "pub_core_tooliface.h"
#include "core.h"
#include "pub_core_aspacemgr.h"
+#include "pub_core_libcprint.h"
#include "pub_core_tooliface.h"
#include "priv_syscalls.h"
#include "ume.h" /* for jmp_with_stack */
#include "pub_core_debuglog.h"
#include "pub_core_aspacemgr.h"
+#include "pub_core_libcprint.h"
#include "pub_core_sigframe.h"
#include "pub_core_syscalls.h"
#include "pub_core_tooliface.h"
#include "pub_core_debuglog.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "pub_core_main.h"
#include "pub_core_profile.h"
#include "pub_core_stacktrace.h"
#include "core.h"
#include "pub_core_tooliface.h"
+#include "pub_core_libcprint.h"
// The core/tool dictionary of functions (initially zeroed, as we want it)
VgToolInterface VG_(tdict);
#include "core.h"
#include "pub_core_aspacemgr.h"
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "pub_core_main.h" // for VG_(bbs_done)
#include "pub_core_options.h"
#include "pub_core_profile.h"
#include "core.h"
#include "pub_core_debuginfo.h"
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "pub_core_options.h"
#include "pub_core_tooliface.h"
// XXX: this module should not depend on m_translate!
--- /dev/null
+
+/*--------------------------------------------------------------------*/
+/*--- Printing libc stuff. pub_core_libcprint.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2005 Julian Seward
+ jseward@acm.org
+
+ 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 __PUB_CORE_LIBCPRINT_H
+#define __PUB_CORE_LIBCPRINT_H
+
+//--------------------------------------------------------------------
+// PURPOSE: This module contains all the libc code that is related to
+// higher-level (ie. higher than DebugLog) printing, eg. VG_(printf)().
+//--------------------------------------------------------------------
+
+#include "pub_tool_libcprint.h"
+
+/* Tell the logging mechanism whether we are logging to a file
+ descriptor or a socket descriptor. */
+extern Bool VG_(logging_to_socket);
+
+#endif // __PUB_CORE_LIBCPRINT_H
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
+++ /dev/null
-
-/*--------------------------------------------------------------------*/
-/*--- For sending error/informative messages. ---*/
-/*--- vg_messages.c ---*/
-/*--------------------------------------------------------------------*/
-
-/*
- This file is part of Valgrind, a dynamic binary instrumentation
- framework.
-
- Copyright (C) 2000-2005 Julian Seward
- jseward@acm.org
-
- 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.
-*/
-
-#include "core.h"
-#include "valgrind.h"
-
-#include "pub_core_options.h"
-
-#include <time.h>
-#include <sys/time.h>
-
-UInt VG_(vmessage) ( VgMsgKind kind, const HChar* format, va_list vargs )
-{
- UInt count = 0;
- Char c;
- const Char* pfx_s;
- static const Char pfx[] = ">>>>>>>>>>>>>>>>";
-
- switch (kind) {
- case Vg_UserMsg: c = '='; break;
- case Vg_DebugMsg: c = '-'; break;
- case Vg_DebugExtraMsg: c = '+'; break;
- case Vg_ClientMsg: c = '*'; break;
- default: c = '?'; break;
- }
-
- // The pfx trick prints one or more '>' characters in front of the
- // messages when running Valgrind under Valgrind, one per level of
- // self-hosting.
- pfx_s = &pfx[sizeof(pfx)-1-RUNNING_ON_VALGRIND],
-
- // Print the message
- count = 0;
-
- if (!VG_(clo_xml))
- count += VG_(printf) ("%s%c%c", pfx_s, c,c);
-
- if (VG_(clo_time_stamp)) {
- struct timeval tv;
- struct tm tm;
-
- if ( gettimeofday( &tv, NULL ) == 0 &&
- localtime_r( &tv.tv_sec, &tm ) == &tm )
- {
- count +=
- VG_(printf)( "%04d-%02d-%02d %02d:%02d:%02d.%03d ",
- tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
- tm.tm_hour, tm.tm_min, tm.tm_sec, tv.tv_usec / 1000 );
- }
- }
-
- if (!VG_(clo_xml))
- count += VG_(printf) ("%d%c%c ", VG_(getpid)(), c,c);
-
- count += VG_(vprintf)(format, vargs);
- count += VG_(printf) ("\n");
- return count;
-}
-
-/* Send a simple single-part message. */
-UInt VG_(message) ( VgMsgKind kind, const HChar* format, ... )
-{
- UInt count;
- va_list vargs;
- va_start(vargs,format);
- count = VG_(vmessage) ( kind, format, vargs );
- va_end(vargs);
- return count;
-}
-
-/*--------------------------------------------------------------------*/
-/*--- end ---*/
-/*--------------------------------------------------------------------*/
#include "pub_core_aspacemgr.h"
#include "pub_core_debuglog.h" /* VG_(debugLog_vprintf) */
#include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
#include "pub_core_main.h"
#include "pub_core_options.h"
#include "pub_core_stacktrace.h"
}
-/* Tell the logging mechanism whether we are logging to a file
- descriptor or a socket descriptor. */
-Bool VG_(logging_to_socket) = False;
-
-/* Do the low-level send of a message to the logging sink. */
-static void send_bytes_to_logging_sink ( Char* msg, Int nbytes )
-{
- if (!VG_(logging_to_socket)) {
- VG_(write)( VG_(clo_log_fd), msg, nbytes );
- } else {
- Int rc = VG_(write_socket)( VG_(clo_log_fd), msg, nbytes );
- if (rc == -1) {
- // For example, the listener process died. Switch back to stderr.
- VG_(logging_to_socket) = False;
- VG_(clo_log_fd) = 2;
- VG_(write)( VG_(clo_log_fd), msg, nbytes );
- }
- }
-}
-
-typedef struct {
- char buf[100];
- int n;
-} printf_buf;
-
-// Adds a single char to the buffer. When the buffer gets sufficiently
-// full, we write its contents to the logging sink.
-static void add_to_myprintf_buf ( HChar c, void *p )
-{
- printf_buf *myprintf_buf = (printf_buf *)p;
-
- if (myprintf_buf->n >= 100-10 /*paranoia*/ ) {
- send_bytes_to_logging_sink( myprintf_buf->buf, myprintf_buf->n );
- myprintf_buf->n = 0;
- }
- myprintf_buf->buf[myprintf_buf->n++] = c;
- myprintf_buf->buf[myprintf_buf->n] = 0;
-}
-
-UInt VG_(vprintf) ( const HChar *format, va_list vargs )
-{
- UInt ret = 0;
- printf_buf myprintf_buf = {"",0};
-
- if (VG_(clo_log_fd) >= 0) {
- ret = VG_(debugLog_vprintf)
- ( add_to_myprintf_buf, &myprintf_buf, format, vargs );
-
- // Write out any chars left in the buffer.
- if (myprintf_buf.n > 0) {
- send_bytes_to_logging_sink( myprintf_buf.buf, myprintf_buf.n );
- }
- }
- return ret;
-}
-
-UInt VG_(printf) ( const HChar *format, ... )
-{
- UInt ret;
- va_list vargs;
-
- va_start(vargs, format);
- ret = VG_(vprintf)(format, vargs);
- va_end(vargs);
-
- return ret;
-}
-
-/* A general replacement for sprintf(). */
-static void add_to_vg_sprintf_buf ( HChar c, void *p )
-{
- char **vg_sprintf_ptr = p;
- *(*vg_sprintf_ptr)++ = c;
-}
-
-UInt VG_(vsprintf) ( Char* buf, const HChar *format, va_list vargs )
-{
- Int ret;
- Char *vg_sprintf_ptr = buf;
-
- ret = VG_(debugLog_vprintf)
- ( add_to_vg_sprintf_buf, &vg_sprintf_ptr, format, vargs );
- add_to_vg_sprintf_buf('\0', &vg_sprintf_ptr);
-
- vg_assert(VG_(strlen)(buf) == ret);
-
- return ret;
-}
-
-UInt VG_(sprintf) ( Char* buf, const HChar *format, ... )
-{
- UInt ret;
- va_list vargs;
-
- va_start(vargs,format);
- ret = VG_(vsprintf)(buf, format, vargs);
- va_end(vargs);
-
- return ret;
-}
-
/* ---------------------------------------------------------------------
strdup()
------------------------------------------------------------------ */
#include "pub_tool_debuginfo.h"
#include "pub_tool_hashtable.h"
#include "pub_tool_libcbase.h"
+#include "pub_tool_libcprint.h"
#include "pub_tool_mallocfree.h"
#include "pub_tool_options.h"
#include "pub_tool_profile.h"
pub_tool_execontext.h \
pub_tool_hashtable.h \
pub_tool_libcbase.h \
+ pub_tool_libcprint.h \
pub_tool_mallocfree.h \
pub_tool_options.h \
pub_tool_profile.h \
--- /dev/null
+
+/*--------------------------------------------------------------------*/
+/*--- Printing libc stuff. pub_tool_libcprint.h ---*/
+/*--------------------------------------------------------------------*/
+
+/*
+ This file is part of Valgrind, a dynamic binary instrumentation
+ framework.
+
+ Copyright (C) 2000-2005 Julian Seward
+ jseward@acm.org
+
+ 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 __PUB_TOOL_LIBCPRINT_H
+#define __PUB_TOOL_LIBCPRINT_H
+
+/* ---------------------------------------------------------------------
+ Basic printing
+ ------------------------------------------------------------------ */
+
+/* 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, ... );
+extern UInt VG_(vprintf) ( const HChar *format, va_list vargs );
+/* too noisy ... __attribute__ ((format (printf, 1, 2))) ; */
+extern UInt VG_(sprintf) ( Char* buf, const HChar* format, ... );
+extern UInt VG_(vsprintf)( Char* buf, const HChar* format, va_list vargs );
+
+/* ---------------------------------------------------------------------
+ Messages for the user
+ ------------------------------------------------------------------ */
+
+/* Print a message prefixed by "??<pid>?? "; '?' depends on the VgMsgKind.
+ Should be used for all user output. */
+
+typedef
+ enum { Vg_UserMsg, /* '?' == '=' */
+ Vg_DebugMsg, /* '?' == '-' */
+ Vg_DebugExtraMsg, /* '?' == '+' */
+ Vg_ClientMsg /* '?' == '*' */
+ }
+ VgMsgKind;
+
+/* Send a single-part message. Appends a newline. */
+extern UInt VG_(message) ( VgMsgKind kind, const HChar* format, ... );
+extern UInt VG_(vmessage) ( VgMsgKind kind, const HChar* format, va_list vargs );
+
+#endif // __PUB_TOOL_LIBCPRINT_H
+
+/*--------------------------------------------------------------------*/
+/*--- end ---*/
+/*--------------------------------------------------------------------*/
extern Char** VG_(client_envp);
-/*====================================================================*/
-/*=== Printing messages for the user ===*/
-/*====================================================================*/
-
-/* Print a message prefixed by "??<pid>?? "; '?' depends on the VgMsgKind.
- Should be used for all user output. */
-
-typedef
- enum { Vg_UserMsg, /* '?' == '=' */
- Vg_DebugMsg, /* '?' == '-' */
- Vg_DebugExtraMsg, /* '?' == '+' */
- Vg_ClientMsg /* '?' == '*' */
- }
- VgMsgKind;
-
-/* Send a single-part message. Appends a newline. */
-extern UInt VG_(message) ( VgMsgKind kind, const HChar* format, ... );
-extern UInt VG_(vmessage) ( VgMsgKind kind, const HChar* format, va_list vargs );
-
-
/*====================================================================*/
/*=== Useful stuff to call from generated code ===*/
/*====================================================================*/
#endif
/* ------------------------------------------------------------------ */
-/* stdio.h
- *
- * 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, ... );
-extern UInt VG_(vprintf) ( const HChar *format, va_list vargs );
-/* too noisy ... __attribute__ ((format (printf, 1, 2))) ; */
-extern UInt VG_(sprintf) ( Char* buf, const HChar* format, ... );
-extern UInt VG_(vsprintf)( Char* buf, const HChar* format, va_list vargs );
+/* stdio.h */
extern Int VG_(rename) ( Char* old_name, Char* new_name );
#include "tool.h"
#include "pub_tool_tooliface.h"
+#include "pub_tool_libcprint.h"
/* Nb: use ULongs because the numbers can get very big */
static ULong n_dlrr_calls = 0;
#include "pub_tool_debuginfo.h"
#include "pub_tool_hashtable.h"
#include "pub_tool_libcbase.h"
+#include "pub_tool_libcprint.h"
#include "pub_tool_mallocfree.h"
#include "pub_tool_options.h"
#include "pub_tool_profile.h"
#include <setjmp.h>
#include "mac_shared.h"
#include "pub_tool_libcbase.h"
+#include "pub_tool_libcprint.h"
/* Define to debug the memory-leak-detector. */
#define VG_DEBUG_LEAKCHECK 0
#include "mac_shared.h"
#include "pub_tool_libcbase.h"
+#include "pub_tool_libcprint.h"
/*------------------------------------------------------------*/
/*--- Defns ---*/
#include "mac_shared.h"
#include "pub_tool_libcbase.h"
+#include "pub_tool_libcprint.h"
#include "memcheck.h" /* for VG_USERREQ__* */
/*------------------------------------------------------------*/
#include "mc_include.h"
#include "memcheck.h" /* for client requests */
#include "pub_tool_libcbase.h"
+#include "pub_tool_libcprint.h"
#define EXPECTED_TAKEN(cond) __builtin_expect((cond),1)
*/
#include "mc_include.h"
+#include "pub_tool_libcprint.h"
/*------------------------------------------------------------*/