~ubuntu-branches/ubuntu/trusty/mysql-5.6/trusty

« back to all changes in this revision

Viewing changes to plugin/innodb_memcached/innodb_memcache/include/debug.h

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-12 11:54:27 UTC
  • Revision ID: package-import@ubuntu.com-20140212115427-oq6tfsqxl1wuwehi
Tags: upstream-5.6.15
ImportĀ upstreamĀ versionĀ 5.6.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef NDBMEMCACHE_DEBUG_H
 
2
#define NDBMEMCACHE_DEBUG_H
 
3
 
 
4
 
 
5
/* DEBUG macros for NDB Memcache. 
 
6
 
 
7
   Debugging is activated by defining DEBUG_OUTPUT at compile-time.
 
8
 
 
9
   In order to use the THREAD_ variants of these macros, the caller must define
 
10
   two macros, DEBUG_THD_ID and DEBUG_THD_NAME, in the source file. 
 
11
     DEBUG_THD_ID : (int) numeric thread id
 
12
     DEBUG_THD_NAME : (const char *) thread name.
 
13
 
 
14
   DEBUG_INIT(const char * outfile) 
 
15
     Initialize debugging. If outfile is null, STDERR will be used.
 
16
 
 
17
   DEBUG_ASSERT 
 
18
     An assertion that is compiled only if debugging is enabled.
 
19
 
 
20
   DEBUG_PRINT(), THREAD_DEBUG_PRINT():
 
21
     These take printf() style parameter lists.  
 
22
   
 
23
   DEBUG_ENTER(), THREAD_DEBUG_ENTER:
 
24
     Print the name of the function being entered.
 
25
 
 
26
   ODD_DEBUG_ENTER(thread_id, thread_name, function_name)
 
27
   ODD_DEBUG_PRINT(thread_id, thread_name, fmt, ... ):
 
28
     Manual variants which allow the caller to specify the thread name and id.
 
29
*/
 
30
 
 
31
 
 
32
#include "dbmemcache_global.h"
 
33
#include "config.h"
 
34
 
 
35
#ifdef DEBUG_OUTPUT
 
36
 
 
37
extern int do_debug;
 
38
 
 
39
/* There's no if(do_debug) check on DEBUG_INIT or DEBUG_ASSERT */
 
40
#define DEBUG_INIT(OUTFILE, LEVEL) ndbmc_debug_init(OUTFILE, LEVEL)
 
41
#define DEBUG_ASSERT(X) assert(X)
 
42
 
 
43
#define DEBUG_PRINT(...) if(do_debug) ndbmc_debug_print(0, 0, __func__, __VA_ARGS__)
 
44
#define THREAD_DEBUG_PRINT(...) if(do_debug) ndbmc_debug_print(DEBUG_THD_ID, DEBUG_THD_NAME, __func__, __VA_ARGS__)
 
45
 
 
46
#define DEBUG_ENTER() if(do_debug) ndbmc_debug_enter(0, 0, __func__)
 
47
#define THREAD_DEBUG_ENTER() if(do_debug) ndbmc_debug_enter(DEBUG_THD_ID, DEBUG_THD_NAME, __func__)
 
48
 
 
49
#define ODD_DEBUG_ENTER(id, name, func) if(do_debug) ndbmc_debug_enter(id, name, func)
 
50
#define ODD_DEBUG_PRINT(id, name, ...) if(do_debug) ndbmc_debug_print(id, name, __func__, __VA_ARGS__)
 
51
 
 
52
#else
 
53
#define DEBUG_INIT(...) 
 
54
#define DEBUG_ASSERT(...)
 
55
#define DEBUG_PRINT(...) 
 
56
#define THREAD_DEBUG_PRINT(...) 
 
57
#define DEBUG_ENTER()
 
58
#define THREAD_DEBUG_ENTER()
 
59
#define ODD_DEBUG_ENTER(...) 
 
60
#define ODD_DEBUG_PRINT(...)
 
61
 
 
62
#endif
 
63
 
 
64
/* internal prototypes for debug functions */
 
65
DECLARE_FUNCTIONS_WITH_C_LINKAGE
 
66
void ndbmc_debug_init(const char *file, bool enable);
 
67
void ndbmc_debug_print(int, const char *, const char *, const char *, ...);
 
68
void ndbmc_debug_enter(int, const char *, const char *);
 
69
END_FUNCTIONS_WITH_C_LINKAGE
 
70
 
 
71
#endif