Zero  0.1.0
trace.h
Go to the documentation of this file.
1 /* -*- mode:C++; c-basic-offset:4 -*-
2  Shore-kits -- Benchmark implementations for Shore-MT
3 
4  Copyright (c) 2007-2009
5  Data Intensive Applications and Systems Labaratory (DIAS)
6  Ecole Polytechnique Federale de Lausanne
7 
8  All Rights Reserved.
9 
10  Permission to use, copy, modify and distribute this software and
11  its documentation is hereby granted, provided that both the
12  copyright notice and this permission notice appear in all copies of
13  the software, derivative works or modified versions, and any
14  portions thereof, and that both notices appear in supporting
15  documentation.
16 
17  This code is distributed in the hope that it will be useful, but
18  WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS
20  DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
21  RESULTING FROM THE USE OF THIS SOFTWARE.
22 */
23 
31 #ifndef __TRACE_H
32 #define __TRACE_H
33 
34 #include <cstdarg> /* for varargs */
35 #include <cstdint> /* for uint32_t */
36 
37 #include "util/compat.h"
38 #include "trace_types.h"
39 
40 /* exported functions */
41 
42 struct tracer {
43  char const* _file;
44 
45  int _line;
46 
47  char const* _function;
48 
49  tracer(char const* file, int line, char const* function)
50  : _file(file),
51  _line(line),
52  _function(function) {}
53 
54  void operator()(unsigned int type, char const* format, ...) ATTRIBUTE(format(printf, 3, 4));
55 };
56 
57 void trace_(unsigned int trace_type,
58  const char* filename, int line_num, const char* function_name,
59  char const* format, ...);
60 
61 void trace_set(unsigned int trace_type_mask);
62 
63 unsigned int trace_get();
64 
65 
66 
67 /* exported macros */
68 
69 
91 #define TRACE tracer(__FILE__, __LINE__, __FUNCTION__)
92 
93 
94 
105 #define TRACE_SET(types) trace_set(types)
106 
107 
108 
116 #define TRACE_GET() trace_get()
117 
118 #endif // __TRACE_H
int _line
Definition: trace.h:45
Lists all TRACE types. Each of these should be a bit specified in a bit vector. We current support up...
tracer(char const *file, int line, char const *function)
Definition: trace.h:49
void trace_(unsigned int trace_type, const char *filename, int line_num, const char *function_name, char const *format,...)
void trace_set(unsigned int trace_type_mask)
Specify the set of trace types that are currently enabled.
Definition: trace.cpp:127
char const * _function
Definition: trace.h:47
#define ATTRIBUTE(x)
Definition: compat.h:33
char const * _file
Definition: trace.h:43
unsigned int trace_get()
Get the set of trace types that are currently enabled.
Definition: trace.cpp:138
void operator()(unsigned int type, char const *format,...) ATTRIBUTE(format(printf
Convert the specified message into a single string and process it.
Definition: trace.cpp:102
Definition: trace.h:42