sewardj | 1cf558c | 2005-04-25 01:36:56 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- Debug (not-for-user) logging. pub_core_debuglog.h ---*/ |
| 4 | /*--------------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
| 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
| 9 | |
Elliott Hughes | ed39800 | 2017-06-21 14:41:24 -0700 | [diff] [blame^] | 10 | Copyright (C) 2000-2017 Julian Seward |
sewardj | 1cf558c | 2005-04-25 01:36:56 +0000 | [diff] [blame] | 11 | jseward@acm.org |
| 12 | |
| 13 | This program is free software; you can redistribute it and/or |
| 14 | modify it under the terms of the GNU General Public License as |
| 15 | published by the Free Software Foundation; either version 2 of the |
| 16 | License, or (at your option) any later version. |
| 17 | |
| 18 | This program is distributed in the hope that it will be useful, but |
| 19 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | General Public License for more details. |
| 22 | |
| 23 | You should have received a copy of the GNU General Public License |
| 24 | along with this program; if not, write to the Free Software |
| 25 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 26 | 02111-1307, USA. |
| 27 | |
| 28 | The GNU General Public License is contained in the file COPYING. |
| 29 | */ |
| 30 | |
| 31 | #ifndef __PUB_CORE_DEBUGLOG_H |
| 32 | #define __PUB_CORE_DEBUGLOG_H |
| 33 | |
| 34 | //-------------------------------------------------------------------- |
| 35 | // PURPOSE: This module provides a low-level debug logging facility |
| 36 | // that works through all the twists and turns of program startup. Is |
| 37 | // is completely independent of everything, including all memory |
| 38 | // facilities, and emits the debug log on file descriptor 2 (stderr). |
| 39 | // This module is the first to be initialised at system startup. |
| 40 | // |
| 41 | // Because VG_(debugLog) does printf-style formatting, and because |
| 42 | // this module depends on NO OTHERS, this module contains Valgrind's |
| 43 | // vfprintf implementation too. |
| 44 | //-------------------------------------------------------------------- |
| 45 | |
| 46 | /* Gaaah! We don't want glibc dependencies, but there is no easy, |
| 47 | portable way to avoid using stdarg.h. */ |
| 48 | #include <stdarg.h> |
| 49 | |
florian | c91f584 | 2013-09-15 10:42:26 +0000 | [diff] [blame] | 50 | #include "pub_core_basics.h" /* For definition of VG_ macro */ |
sewardj | 1cf558c | 2005-04-25 01:36:56 +0000 | [diff] [blame] | 51 | |
| 52 | /* There are no tool-visible exports from m_debuglog, hence no header |
| 53 | file for it. */ |
| 54 | /* #include "pub_tool_debuglog.h" */ |
| 55 | |
| 56 | |
| 57 | /* Module startup. */ |
| 58 | extern |
florian | dbb3584 | 2012-10-27 18:39:11 +0000 | [diff] [blame] | 59 | void VG_(debugLog_startup) ( Int level, const HChar* who ); |
sewardj | 1cf558c | 2005-04-25 01:36:56 +0000 | [diff] [blame] | 60 | |
sewardj | 1075931 | 2005-05-30 23:52:47 +0000 | [diff] [blame] | 61 | |
bart | db4384e | 2011-10-11 18:49:35 +0000 | [diff] [blame] | 62 | /* Whether %ps should escape XML metacharacters. */ |
| 63 | extern void VG_(debugLog_setXml)(Bool xml); |
| 64 | |
| 65 | |
sewardj | 1075931 | 2005-05-30 23:52:47 +0000 | [diff] [blame] | 66 | /* Get the logging threshold level, as set by the most recent call to |
| 67 | VG_(debugLog_startup), or zero if there have been no such calls so |
| 68 | far. */ |
| 69 | extern |
| 70 | Int VG_(debugLog_getLevel) ( void ); |
| 71 | |
| 72 | |
sewardj | 1cf558c | 2005-04-25 01:36:56 +0000 | [diff] [blame] | 73 | /* Send debugging output. Nothing happens unless 'level' |
| 74 | does not exceed the logging threshold level. */ |
| 75 | extern |
sewardj | 1cf558c | 2005-04-25 01:36:56 +0000 | [diff] [blame] | 76 | void VG_(debugLog) ( Int level, const HChar* modulename, |
bart | 355bc9f | 2009-08-23 11:11:36 +0000 | [diff] [blame] | 77 | const HChar* format, ... ) |
| 78 | __attribute__((format(__printf__, 3, 4))); |
sewardj | 1cf558c | 2005-04-25 01:36:56 +0000 | [diff] [blame] | 79 | |
sewardj | 1075931 | 2005-05-30 23:52:47 +0000 | [diff] [blame] | 80 | |
njn | 48d04bd | 2009-05-20 07:36:18 +0000 | [diff] [blame] | 81 | /* A simple vprintf(). For each emitted byte, (*send_fn) is called with |
sewardj | 1cf558c | 2005-04-25 01:36:56 +0000 | [diff] [blame] | 82 | that byte, and 'send_arg2' as its second param. */ |
| 83 | extern |
| 84 | UInt VG_(debugLog_vprintf) ( |
njn | 48d04bd | 2009-05-20 07:36:18 +0000 | [diff] [blame] | 85 | void (*send_fn)(HChar,void*),/* byte sink */ |
sewardj | 1cf558c | 2005-04-25 01:36:56 +0000 | [diff] [blame] | 86 | void* send_arg2, /* 2nd arg for byte sink */ |
| 87 | const HChar *format, |
| 88 | va_list vargs |
| 89 | ); |
| 90 | |
| 91 | |
| 92 | #endif // __PUB_CORE_DEBUGLOG_H |
| 93 | |
| 94 | /*--------------------------------------------------------------------*/ |
| 95 | /*--- end pub_core_debuglog.h ---*/ |
| 96 | /*--------------------------------------------------------------------*/ |