![]() |
RTXI 1.3
|
00001 /* 00002 Copyright (C) 2011 Georgia Institute of Technology, University of Utah, Weill Cornell Medical College 00003 00004 This program is free software: you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation, either version 3 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 00017 */ 00018 00019 #ifndef DEBUG_H 00020 #define DEBUG_H 00021 00022 #include <execinfo.h> 00023 #include <stdio.h> 00024 00026 static inline void PRINT_BACKTRACE(void) { 00027 int buffer_size; 00028 void *buffer[256]; 00029 00030 buffer_size = backtrace(buffer,sizeof(buffer)); 00031 fprintf(stderr,"Backtrace:\n"); 00032 backtrace_symbols_fd(buffer,buffer_size,2); 00033 } 00034 00035 #define ERROR_MSG(fmt,args...) do { fprintf(stderr,"%s:%d:",__FILE__,__LINE__); fprintf(stderr,fmt,## args); } while(0) 00036 00037 #ifdef DEBUG 00038 00039 #define DEBUG_MSG(fmt,args...) do { fprintf(stderr,"%s:%d:",__FILE__,__LINE__); fprintf(stderr,fmt,## args); } while(0) 00040 00041 #else /* !DEBUG */ 00042 00044 00047 #define DEBUG_MSG(fmt,args...) do { ; } while(0) 00048 00049 #endif /* DEBUG */ 00050 00051 #endif /* DEBUG_H */