diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-02-24 16:14:03 +1100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-03-01 04:32:12 +0100 |
commit | 5f5ca913b7abfcf95782339fac2dc8c1541b1126 (patch) | |
tree | edd1c797f8d8692ff7d613e7ae8901b656dd6726 /source3/include | |
parent | 4acef317a0e1692afc526a3805adf87403651170 (diff) | |
download | samba-5f5ca913b7abfcf95782339fac2dc8c1541b1126.tar.gz samba-5f5ca913b7abfcf95782339fac2dc8c1541b1126.tar.bz2 samba-5f5ca913b7abfcf95782339fac2dc8c1541b1126.zip |
lib/util: new merged debug system
This is the s3 debug system, with a number of changes to tidy it up
for common use. The debug class system is simplified by the removal of the
ISSET table, the system no longer attempts to cope with assignment of
DEBUGLEVEL, and the full class table is always available (rather than
just DEBUGLEVEL_CLASS[DBCG_ALL]) from startup. It is also no longer
confusingly described as a hack, but as the initial table.
Autobuild-User: Andrew Bartlett <abartlet@samba.org>
Autobuild-Date: Tue Mar 1 04:32:12 CET 2011 on sn-devel-104
Diffstat (limited to 'source3/include')
-rw-r--r-- | source3/include/debug.h | 280 | ||||
-rw-r--r-- | source3/include/includes.h | 2 | ||||
-rw-r--r-- | source3/include/local.h | 5 | ||||
-rw-r--r-- | source3/include/smb.h | 3 |
4 files changed, 2 insertions, 288 deletions
diff --git a/source3/include/debug.h b/source3/include/debug.h deleted file mode 100644 index 328bfb63b9..0000000000 --- a/source3/include/debug.h +++ /dev/null @@ -1,280 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SMB debug stuff - Copyright (C) Andrew Tridgell 1992-1998 - Copyright (C) John H Terpstra 1996-1998 - Copyright (C) Luke Kenneth Casson Leighton 1996-1998 - Copyright (C) Paul Ashton 1998 - - 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 3 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, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef _DEBUG_H -#define _DEBUG_H - -/* -------------------------------------------------------------------------- ** - * Debugging code. See also debug.c - */ - -/* the maximum debug level to compile into the code. This assumes a good - optimising compiler that can remove unused code - for embedded or low-memory systems set this to a value like 2 to get - only important messages. This gives *much* smaller binaries -*/ -#ifndef MAX_DEBUG_LEVEL -#define MAX_DEBUG_LEVEL 1000 -#endif - -/* mkproto.awk has trouble with ifdef'd function definitions (it ignores - * the #ifdef directive and will read both definitions, thus creating two - * diffferent prototype declarations), so we must do these by hand. - */ -/* I know the __attribute__ stuff is ugly, but it does ensure we get the - arguments to DEBUG() right. We have got them wrong too often in the - past. - The PRINTFLIKE comment does the equivalent for SGI MIPSPro. - */ -/* PRINTFLIKE1 */ -int Debug1( const char *, ... ) PRINTF_ATTRIBUTE(1,2); -/* PRINTFLIKE1 */ -bool dbgtext( const char *, ... ) PRINTF_ATTRIBUTE(1,2); -bool dbghdrclass( int level, int cls, const char *location, const char *func); -bool dbghdr( int level, const char *location, const char *func); - -#if defined(sgi) && (_COMPILER_VERSION >= 730) -#pragma mips_frequency_hint NEVER Debug1 -#pragma mips_frequency_hint NEVER dbgtext -#pragma mips_frequency_hint NEVER dbghdrclass -#pragma mips_frequency_hint NEVER dbghdr -#endif - -/* If we have these macros, we can add additional info to the header. */ - -#ifdef HAVE_FUNCTION_MACRO -#define FUNCTION_MACRO (__FUNCTION__) -#else -#define FUNCTION_MACRO ("") -#endif - -/* - * Redefine DEBUGLEVEL because so we don't have to change every source file - * that *unnecessarily* references it. Source files neeed not extern reference - * DEBUGLEVEL, as it's extern in includes.h (which all source files include). - * Eventually, all these references should be removed, and all references to - * DEBUGLEVEL should be references to DEBUGLEVEL_CLASS[DBGC_ALL]. This could - * still be through a macro still called DEBUGLEVEL. This cannot be done now - * because some references would expand incorrectly. - */ -#define DEBUGLEVEL *debug_level -extern int DEBUGLEVEL; - -/* - * Define all new debug classes here. A class is represented by an entry in - * the DEBUGLEVEL_CLASS array. Index zero of this arrray is equivalent to the - * old DEBUGLEVEL. Any source file that does NOT add the following lines: - * - * #undef DBGC_CLASS - * #define DBGC_CLASS DBGC_<your class name here> - * - * at the start of the file (after #include "includes.h") will default to - * using index zero, so it will behaive just like it always has. - */ -#define DBGC_ALL 0 /* index equivalent to DEBUGLEVEL */ - -#define DBGC_TDB 1 -#define DBGC_PRINTDRIVERS 2 -#define DBGC_LANMAN 3 -#define DBGC_SMB 4 -#define DBGC_RPC_PARSE 5 -#define DBGC_RPC_SRV 6 -#define DBGC_RPC_CLI 7 -#define DBGC_PASSDB 8 -#define DBGC_SAM 9 -#define DBGC_AUTH 10 -#define DBGC_WINBIND 11 -#define DBGC_VFS 12 -#define DBGC_IDMAP 13 -#define DBGC_QUOTA 14 -#define DBGC_ACLS 15 -#define DBGC_LOCKING 16 -#define DBGC_MSDFS 17 -#define DBGC_DMAPI 18 -#define DBGC_REGISTRY 19 - -/* So you can define DBGC_CLASS before including debug.h */ -#ifndef DBGC_CLASS -#define DBGC_CLASS 0 /* override as shown above */ -#endif - -extern int *DEBUGLEVEL_CLASS; -extern bool *DEBUGLEVEL_CLASS_ISSET; - -/* Debugging macros - * - * DEBUGLVL() - * If the 'file specific' debug class level >= level OR the system-wide - * DEBUGLEVEL (synomym for DEBUGLEVEL_CLASS[ DBGC_ALL ]) >= level then - * generate a header using the default macros for file, line, and - * function name. Returns True if the debug level was <= DEBUGLEVEL. - * - * Example: if( DEBUGLVL( 2 ) ) dbgtext( "Some text.\n" ); - * - * DEBUGLVLC() - * If the 'macro specified' debug class level >= level OR the system-wide - * DEBUGLEVEL (synomym for DEBUGLEVEL_CLASS[ DBGC_ALL ]) >= level then - * generate a header using the default macros for file, line, and - * function name. Returns True if the debug level was <= DEBUGLEVEL. - * - * Example: if( DEBUGLVLC( DBGC_TDB, 2 ) ) dbgtext( "Some text.\n" ); - * - * DEBUG() - * If the 'file specific' debug class level >= level OR the system-wide - * DEBUGLEVEL (synomym for DEBUGLEVEL_CLASS[ DBGC_ALL ]) >= level then - * generate a header using the default macros for file, line, and - * function name. Each call to DEBUG() generates a new header *unless* the - * previous debug output was unterminated (i.e. no '\n'). - * See debug.c:dbghdr() for more info. - * - * Example: DEBUG( 2, ("Some text and a value %d.\n", value) ); - * - * DEBUGC() - * If the 'macro specified' debug class level >= level OR the system-wide - * DEBUGLEVEL (synomym for DEBUGLEVEL_CLASS[ DBGC_ALL ]) >= level then - * generate a header using the default macros for file, line, and - * function name. Each call to DEBUG() generates a new header *unless* the - * previous debug output was unterminated (i.e. no '\n'). - * See debug.c:dbghdr() for more info. - * - * Example: DEBUGC( DBGC_TDB, 2, ("Some text and a value %d.\n", value) ); - * - * DEBUGADD(), DEBUGADDC() - * Same as DEBUG() and DEBUGC() except the text is appended to the previous - * DEBUG(), DEBUGC(), DEBUGADD(), DEBUGADDC() with out another interviening - * header. - * - * Example: DEBUGADD( 2, ("Some text and a value %d.\n", value) ); - * DEBUGADDC( DBGC_TDB, 2, ("Some text and a value %d.\n", value) ); - * - * Note: If the debug class has not be redeined (see above) then the optimizer - * will remove the extra conditional test. - */ - -/* - * From talloc.c: - */ - -/* these macros gain us a few percent of speed on gcc */ -#if (__GNUC__ >= 3) -/* the strange !! is to ensure that __builtin_expect() takes either 0 or 1 - as its first argument */ -#ifndef likely -#define likely(x) __builtin_expect(!!(x), 1) -#endif -#ifndef unlikely -#define unlikely(x) __builtin_expect(!!(x), 0) -#endif -#else -#ifndef likely -#define likely(x) (x) -#endif -#ifndef unlikely -#define unlikely(x) (x) -#endif -#endif - -#define CHECK_DEBUGLVL( level ) \ - ( ((level) <= MAX_DEBUG_LEVEL) && \ - unlikely((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))|| \ - (!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \ - DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) ) - -#define DEBUGLVL( level ) \ - ( CHECK_DEBUGLVL(level) \ - && dbghdrclass( level, DBGC_CLASS, __location__, FUNCTION_MACRO ) ) - - -#define DEBUGLVLC( dbgc_class, level ) \ - ( ((level) <= MAX_DEBUG_LEVEL) && \ - unlikely((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))|| \ - (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \ - DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ - && dbghdrclass( level, DBGC_CLASS, __location__, FUNCTION_MACRO) ) - - -#define DEBUG( level, body ) \ - (void)( ((level) <= MAX_DEBUG_LEVEL) && \ - unlikely((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))|| \ - (!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \ - DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ - && (dbghdrclass( level, DBGC_CLASS, __location__, FUNCTION_MACRO )) \ - && (dbgtext body) ) - -#define DEBUGC( dbgc_class, level, body ) \ - (void)( ((level) <= MAX_DEBUG_LEVEL) && \ - unlikely((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))|| \ - (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \ - DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ - && (dbghdrclass( level, DBGC_CLASS, __location__, FUNCTION_MACRO)) \ - && (dbgtext body) ) - -#define DEBUGADD( level, body ) \ - (void)( ((level) <= MAX_DEBUG_LEVEL) && \ - unlikely((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))|| \ - (!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \ - DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ - && (dbgtext body) ) - -#define DEBUGADDC( dbgc_class, level, body ) \ - (void)( ((level) <= MAX_DEBUG_LEVEL) && \ - unlikely((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))|| \ - (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \ - DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \ - && (dbgtext body) ) - -/* Print a separator to the debug log. */ -#define DEBUGSEP(level)\ - DEBUG((level),("===============================================================\n")) - -/* The following definitions come from lib/debug.c */ - -/** Possible destinations for the debug log (in order of precedence - - * once set to DEBUG_FILE, it is not possible to reset to DEBUG_STDOUT - * for example. This makes it easy to override for debug to stderr on - * the command line, as the smb.conf cannot reset it back to - * file-based logging */ -enum debug_logtype {DEBUG_DEFAULT_STDERR = 0, DEBUG_STDOUT = 1, DEBUG_FILE = 2, DEBUG_STDERR = 3}; - -void setup_logging(const char *prog_name, enum debug_logtype new_logtype); - -void debug_close_dbf(void); -void gfree_debugsyms(void); -const char *debug_classname_from_index(int ndx); -int debug_add_class(const char *classname); -int debug_lookup_classname(const char *classname); -bool debug_parse_levels(const char *params_str); -void debug_message(struct messaging_context *msg_ctx, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *data); -void debug_init(void); -void debug_register_msgs(struct messaging_context *msg_ctx); -void debug_set_logfile(const char *name); -bool reopen_logs( void ); -void force_check_log_size( void ); -bool need_to_check_log_size( void ); -void check_log_size( void ); -void dbgflush( void ); -bool dbghdrclass(int level, int cls, const char *location, const char *func); -bool dbghdr(int level, const char *location, const char *func); -bool debug_get_output_is_stderr(void); - -#endif - diff --git a/source3/include/includes.h b/source3/include/includes.h index 2d6e1e7551..18b53879ad 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -739,8 +739,6 @@ enum flush_reason_enum { #endif #endif -extern int DEBUGLEVEL; - #define MAX_SEC_CTX_DEPTH 8 /* Maximum number of security contexts */ diff --git a/source3/include/local.h b/source3/include/local.h index bb73840757..680631c1c5 100644 --- a/source3/include/local.h +++ b/source3/include/local.h @@ -42,11 +42,6 @@ /* maximum number of file caches per smbd */ #define MAX_WRITE_CACHES 10 -/* define what facility to use for syslog */ -#ifndef SYSLOG_FACILITY -#define SYSLOG_FACILITY LOG_DAEMON -#endif - /* * Fudgefactor required for open tdb's, etc. */ diff --git a/source3/include/smb.h b/source3/include/smb.h index 49c653e8f3..7c9f60d2fe 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -69,7 +69,8 @@ #define SMB_SECONDARY_WAIT (60*1000) /* Debugging stuff */ -#include "debug.h" +#include "lib/util/debug.h" +#include "lib/util/debug_s3.h" /* this defines the error codes that receive_smb can put in smb_read_error */ enum smb_read_errors { |