]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Modularise printing functions in m_libcprint.
authorNicholas Nethercote <njn@valgrind.org>
Fri, 3 Jun 2005 03:08:39 +0000 (03:08 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Fri, 3 Jun 2005 03:08:39 +0000 (03:08 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3840

49 files changed:
cachegrind/amd64/cg_arch.c
cachegrind/arm/cg_arch.c
cachegrind/cg_main.c
cachegrind/x86/cg_arch.c
coregrind/Makefile.am
coregrind/core.h
coregrind/linux/core_os.c
coregrind/m_aspacemgr/aspacemgr.c
coregrind/m_aspacemgr/read_procselfmaps.c
coregrind/m_debuginfo/dwarf.c
coregrind/m_debuginfo/stabs.c
coregrind/m_debuginfo/symtab.c
coregrind/m_debuginfo/symtypes.c
coregrind/m_demangle/cplus-dem.c
coregrind/m_errormgr.c
coregrind/m_execontext.c
coregrind/m_libcbase.c
coregrind/m_main.c
coregrind/m_mallocfree.c
coregrind/m_profile.c
coregrind/m_redir.c
coregrind/m_replacemalloc/replacemalloc_core.c
coregrind/m_scheduler/scheduler.c
coregrind/m_sigframe/sigframe-amd64-linux.c
coregrind/m_sigframe/sigframe-x86-linux.c
coregrind/m_signals.c
coregrind/m_skiplist.c
coregrind/m_stacktrace.c
coregrind/m_syscalls/syscalls-amd64-linux.c
coregrind/m_syscalls/syscalls-linux.c
coregrind/m_syscalls/syscalls-x86-linux.c
coregrind/m_syscalls/syscalls.c
coregrind/m_tooliface.c
coregrind/m_translate.c
coregrind/m_transtab.c
coregrind/pub_core_libcprint.h [new file with mode: 0644]
coregrind/vg_messages.c [deleted file]
coregrind/vg_mylibc.c
helgrind/hg_main.c
include/Makefile.am
include/pub_tool_libcprint.h [new file with mode: 0644]
include/tool.h
lackey/lk_main.c
massif/ms_main.c
memcheck/mac_leakcheck.c
memcheck/mac_malloc_wrappers.c
memcheck/mac_shared.c
memcheck/mc_main.c
memcheck/mc_translate.c

index 9d6ba0169c6c366fe24e2906a48332b952633dd0..8d14da37c5cdbe1bd5e75e7caddebcddb9cda60e 100644 (file)
@@ -31,6 +31,7 @@
 #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
index f775224006f8380a135457c51239aadb3d94acd2..9800069aa3c76a49ce996c1a41630fd99b3b0395 100644 (file)
@@ -30,7 +30,6 @@
 
 #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)
index c313b7aaec486517457ce84f4d1b4efa89edc224..1c13db3b1b7818c37961267a9b2c8c04c765ecd8 100644 (file)
@@ -33,6 +33,7 @@
 #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"
index f737836c03b7b4ec891cd9b6ad64b6449f0825ff..36ab3a68dc42d5226a4fd7aa064cfd9b034a99cd 100644 (file)
@@ -30,6 +30,7 @@
 
 #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 */
index 723436c1066cdcf4b8bbad56157b3461c23f7b59..d5c2ef9010e0af36bae74e8cff4202897c92d71e 100644 (file)
@@ -47,6 +47,7 @@ noinst_HEADERS = \
        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      \
@@ -89,6 +90,7 @@ stage2_SOURCES = \
        m_execontext.c \
        m_hashtable.c \
        m_libcbase.c \
+       m_libcprint.c \
        m_main.c \
        m_mallocfree.c \
        m_options.c \
@@ -102,7 +104,6 @@ stage2_SOURCES = \
        m_transtab.c \
        \
        ume.c \
-       vg_messages.c \
        vg_mylibc.c \
        vg_threadmodel.c \
        vg_pthreadmodel.c
index 58e08f7cea2c62d904fd431ed6341065b4fa9ee4..25c8ee41af1b7527ad0ebf56658fe77b0b4e116e 100644 (file)
@@ -128,10 +128,6 @@ extern void  VG_(core_panic_at)   ( Char* str, Addr ip, Addr sp, Addr fp );
 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);
 
index 1c65a296027d67be548925ec2ce9100237b9c5f8..77ed8618e81a89387d5a365317b477195a77f104 100644 (file)
@@ -30,6 +30,7 @@
 
 #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"
index 5f4fce11e96138b06ff45fb623b75a92c413bb2b..ded33e6e0d06b0f2ad5924ae1b4f0f8b8ea3c427 100644 (file)
@@ -33,6 +33,7 @@
 #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"
index f1699c1e8f278d5b4c27b97377dbaa676ca913a3..7e20cc162403927da43e12527b772e4305a057e1 100644 (file)
@@ -33,6 +33,7 @@
 #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
index a4c7004eba351fe7c15368f58136efdaf486c0e1..2cde63765a1ff6bdddcd594389286107ae18a699 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "core.h"
 #include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
 #include "pub_core_options.h"
 #include "priv_symtab.h"
 
index 1ba467fdd8703911ee686d3928e4a3a52fd914e9..aa117a359edfe53918d5c17c15beededc103af71 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "core.h"
 #include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
 #include "priv_symtab.h"
 
 #include <a.out.h>        /* stabs defns                    */
index a259560148f14e9a532361820558769edea7c70b..94d2b323bfafeef0e200fcd7fae4065eeb5dfcf3 100644 (file)
@@ -33,6 +33,7 @@
 #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"
index 8c32d9e2097506d08fbba1a0a0813a081462a2c6..4eae1ed5eb8c21000d6d5f84cb99851f53faa2d6 100644 (file)
@@ -32,6 +32,7 @@
 #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"
 
index fe059c75e7e1202d3e3fd1a52fdc8e24147c4ec0..e854c04c8fd94c85ad6e665812dc2fed03f7e54f 100644 (file)
@@ -39,6 +39,7 @@ Boston, MA 02111-1307, USA.  */
 #include "safe-ctype.h"
 #include "core.h"
 #include "pub_core_libcbase.h"
+#include "pub_tool_libcprint.h"
 
 /*#include <sys/types.h>
 #include <string.h>
index 34a3219bb3c82ed6f29e7673c0a5286abc81cbf2..fe36d2291ebf654926d4f244b1b5100e97f9f4de 100644 (file)
@@ -33,6 +33,7 @@
 #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"
index d8a47af418e27795c2b24ed4a96b4a81db1a10ff..f53f151d7eb1a031140eb7983807c4be6720ec4d 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "core.h"
 #include "pub_core_execontext.h"
+#include "pub_core_libcprint.h"
 #include "pub_core_options.h"
 #include "pub_core_profile.h"
 
index 33608efdca9057dd31941f78715e348d855ea678..1ab10d37d8701e566de2c0a3650b976cb2596cc9 100644 (file)
@@ -28,7 +28,7 @@
    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"
 
 /* ---------------------------------------------------------------------
index 713667ccda9ab824ba3f5c65ddc196aac7d8a553..d64272bc0d4b39dc3bef74234f9d7ee366bb22b4 100644 (file)
@@ -37,6 +37,7 @@
 #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"
index b6b58a7a89ecaea5c7868951e0178903cf65f582..3c09ef92e8b29131fc68959d4c37fc030e177413 100644 (file)
@@ -33,6 +33,7 @@
 #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"
index 630fa9d29d2a47d13c0f73f7a941bc4064ba1cfe..2f72aa308d0529bb9490ac728cf880a7142f6860 100644 (file)
@@ -29,6 +29,7 @@
 */
 
 #include "core.h"
+#include "pub_core_libcprint.h"
 #include "pub_core_profile.h"
 
 /* get rid of these, if possible */
index b00645b6912aff099e4de330d54895b70d54bb36..81afc96c61f544f20ae2a1c4942b1a030698da5f 100644 (file)
@@ -33,6 +33,7 @@
 
 #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"
index 8b99757f3f52d828436701a641943b4fa87c92c7..25ef0cf65b2eeb6a0784f620f9bc3aa1a74c2fd9 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "core.h"
 #include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
 #include "pub_core_options.h"
 #include "pub_core_replacemalloc.h"
 
index 11c402c09de8ef001c58cb3c8b4d80ad19fc3f9c..5455ce7e7b6439e692283a081335cbe0ccd389ce 100644 (file)
@@ -64,6 +64,7 @@
 #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"
index b9e2d6a682a8b333ed1d3656b8c122351cb86327..33593bc96f7654060b3d1bb2d2da568bb3135bd9 100644 (file)
@@ -32,6 +32,7 @@
 #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"
index 36aa5f1ae7e03f7abe4434404d105c8368b1fcf3..f76058693543c692732825ae99a5c02b54cabcd8 100644 (file)
@@ -32,6 +32,7 @@
 #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"
index d7dcc7f818ab4192baeede9e1427989742a0c237..36d57361f61cc530f2ae1e899cae82692cdf88db 100644 (file)
@@ -84,6 +84,7 @@
 #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"
index 1de8d2df55a127004c2dd2a4fdcb92df96b268cd..17ee897c9c52476fbaa0b22022f35c6e3dc1a534 100644 (file)
@@ -88,6 +88,7 @@
 
 #include "core.h"
 #include "pub_core_libcbase.h"
+#include "pub_core_libcprint.h"
 #include "pub_core_skiplist.h"
 
 #include <stdlib.h>
index 2b87d765ba68e99f4afb9f03ff61e9067d4d152b..d9845cd2bfdeaaca289d14b675f21ebf604a02da 100644 (file)
@@ -31,6 +31,7 @@
 #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"
index fdece82ac746cd0d4a2a221ea0744d2586b9c5a5..e96bb2ea50800c2c6fd2c0c57c751da3ad0fef93 100644 (file)
@@ -32,6 +32,7 @@
 #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"
index 6895c43f9a3eb1833736fb07588fe3e354b13780..165a97f5aa77ad561cc9b6ca29d1f4187d697842 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "core.h"
 #include "pub_core_aspacemgr.h"
+#include "pub_core_libcprint.h"
 #include "pub_core_tooliface.h"
 #include "priv_syscalls.h"
 
index d7cdd576d07b34e91bdf90cdf36a8b0d3cb65d53..e4cd2675c8ec0a0ca1f966ac877ef0a7a78da4c0 100644 (file)
@@ -37,6 +37,7 @@
 #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"
index 05805e49db8e0986e6cbd8d43709c938a3bf33e3..dfc9ff6010559c11d5c30df711b84b194117e79c 100644 (file)
@@ -32,6 +32,7 @@
 #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"
index 9c343fd51d7664d33841974e158bfae6dbf30447..b9916af4711417206e88a58a4648239ea8c78001 100644 (file)
@@ -31,6 +31,7 @@
 
 #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);
index eb4d9409b8173ebdca79ef64b288665309ee26c0..9da8aaeb21a35e348e131f0d1c7df8f92cfac7b0 100644 (file)
@@ -32,6 +32,7 @@
 #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"
index 50182e3e551f19c886c9c0a96e81924ddbfff727..8cc16997d64f0c5c323c03e0f80310fdacef2a30 100644 (file)
@@ -32,6 +32,7 @@
 #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!
diff --git a/coregrind/pub_core_libcprint.h b/coregrind/pub_core_libcprint.h
new file mode 100644 (file)
index 0000000..303a430
--- /dev/null
@@ -0,0 +1,49 @@
+
+/*--------------------------------------------------------------------*/
+/*--- 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                                                          ---*/
+/*--------------------------------------------------------------------*/
diff --git a/coregrind/vg_messages.c b/coregrind/vg_messages.c
deleted file mode 100644 (file)
index fe4004c..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-
-/*--------------------------------------------------------------------*/
-/*--- 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                                                          ---*/
-/*--------------------------------------------------------------------*/
index 989bcd386fe60b39c6cf3cf12f3498842adc3d47..9486dac0e01d80b3a0a363fe2735f5060ec4b146 100644 (file)
@@ -34,6 +34,7 @@
 #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"
@@ -408,107 +409,6 @@ Int VG_(poll)( struct vki_pollfd *ufds, UInt nfds, Int timeout)
 }
 
 
-/* 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()
    ------------------------------------------------------------------ */
index 91d9be0bd17b863e4dfe13af994b5ece298e58ac..d23fe7a574f359b0e5c3c7f7907645ef9a1cd411 100644 (file)
@@ -33,6 +33,7 @@
 #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"
index 62426871c4ad86529e2f7b4a291a0838c4791dd8..aac22923e1ae0d0b33fcdb3df0277158b3dd31e7 100644 (file)
@@ -9,6 +9,7 @@ incinc_HEADERS = \
        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              \
diff --git a/include/pub_tool_libcprint.h b/include/pub_tool_libcprint.h
new file mode 100644 (file)
index 0000000..8e44d23
--- /dev/null
@@ -0,0 +1,71 @@
+
+/*--------------------------------------------------------------------*/
+/*--- 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                                                          ---*/
+/*--------------------------------------------------------------------*/
index 063b7c142603489b4b58468f37fae3fc17736f47..a781459d5903b47727e0a4d1c59c73691e70ae7d 100644 (file)
@@ -77,26 +77,6 @@ extern Char** VG_(client_argv);
 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                     ===*/
 /*====================================================================*/
@@ -132,17 +112,7 @@ extern Addr VG_(get_IP) ( ThreadId tid );
 #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 );
 
index 80a987b63a5407752c6b308c28fbf6390872f2ee..f63551aa25fd859d529c6dc10df78dcc4373a6fb 100644 (file)
@@ -31,6 +31,7 @@
 
 #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;
index ec8ebeb70424de9e0b0bae5d41aa5cc667b89baa..c25147352e8a2f8d7528012f9cb426996d219c79 100644 (file)
@@ -38,6 +38,7 @@
 #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"
index e7ed39339de85cf31853af55855c1599a9df385f..5341c0d143af6835b3269619c4f9e9ade497cc95 100644 (file)
@@ -33,6 +33,7 @@
 #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
index a35a6e77a9222abd6c8e43792fb131cf42fb775a..a888536ec7646e49d98427df58dc0b749d09388a 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "mac_shared.h"
 #include "pub_tool_libcbase.h"
+#include "pub_tool_libcprint.h"
 
 /*------------------------------------------------------------*/
 /*--- Defns                                                ---*/
index 2f9effd127f2b3094492875d0c2df8ab541618d0..83a8084a8fa1513be58ba5b5457d6228f7d7ce36 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "mac_shared.h"
 #include "pub_tool_libcbase.h"
+#include "pub_tool_libcprint.h"
 #include "memcheck.h"   /* for VG_USERREQ__* */
 
 /*------------------------------------------------------------*/
index a4df82f01eaf121f65eb271bf34f647503af001d..a2e24db51c86f1daf5981efa75521f55db43a618 100644 (file)
@@ -39,6 +39,7 @@
 #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)
index f61570b8f883ef2295e88e37c268b149e2238b09..d4a1327c782212b065d9b3452b53436df4c5be00 100644 (file)
@@ -30,6 +30,7 @@
 */
 
 #include "mc_include.h"
+#include "pub_tool_libcprint.h"
 
 
 /*------------------------------------------------------------*/