RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
debug.h
Go to the documentation of this file.
1 /*
2  The Real-Time eXperiment Interface (RTXI)
3  Copyright (C) 2011 Georgia Institute of Technology, University of Utah, Weill Cornell Medical College
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 
20 #ifndef DEBUG_H
21 #define DEBUG_H
22 
23 #include <execinfo.h>
24 #include <stdio.h>
25 
26 #if XENOMAI
27 #include <rtdk.h>
28 #endif
29 
31 static inline void PRINT_BACKTRACE(void)
32 {
33  int buffer_size;
34  void *buffer[256];
35 
36  buffer_size = backtrace(buffer,sizeof(buffer));
37  fprintf(stderr,"Backtrace:\n");
38  backtrace_symbols_fd(buffer,buffer_size,2);
39 }
40 
41 #define ERROR_MSG(fmt,args...) do { fprintf(stderr,"%s:%d:",__FILE__,__LINE__); fprintf(stderr,fmt,## args); } while(0)
42 
43 #ifdef DEBUG
44 
45 #define DEBUG_MSG(fmt,args...) do { fprintf(stderr,"%s:%d:",__FILE__,__LINE__); fprintf(stderr,fmt,## args); } while(0)
46 
47 #else /* !DEBUG */
48 
50 
53 #define DEBUG_MSG(fmt,args...) do { ; } while(0)
54 
55 #endif /* DEBUG */
56 
57 #endif /* DEBUG_H */