mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00:00
Improving the logging, got fed up with color so optionally disable.
Backtrace macro used everwhere
This commit is contained in:
parent
a5f683d124
commit
2cfa20cc4e
@ -294,6 +294,7 @@ void Grid_sa_signal_handler(int sig,siginfo_t *si,void * ptr)
|
|||||||
ucontext_t * uc= (ucontext_t *)ptr;
|
ucontext_t * uc= (ucontext_t *)ptr;
|
||||||
struct sigcontext *sc = (struct sigcontext *)&uc->uc_mcontext;
|
struct sigcontext *sc = (struct sigcontext *)&uc->uc_mcontext;
|
||||||
printf(" instruction %llx\n",(unsigned long long)sc->rip);
|
printf(" instruction %llx\n",(unsigned long long)sc->rip);
|
||||||
|
|
||||||
#define REG(A) printf(" %s %lx\n",#A,sc-> A);
|
#define REG(A) printf(" %s %lx\n",#A,sc-> A);
|
||||||
|
|
||||||
REG(rdi);
|
REG(rdi);
|
||||||
@ -316,13 +317,7 @@ void Grid_sa_signal_handler(int sig,siginfo_t *si,void * ptr)
|
|||||||
REG(r14);
|
REG(r14);
|
||||||
REG(r15);
|
REG(r15);
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_EXECINFO_H
|
BACKTRACE();
|
||||||
int symbols = backtrace (Grid_backtrace_buffer,_NBACKTRACE);
|
|
||||||
char **strings = backtrace_symbols(Grid_backtrace_buffer,symbols);
|
|
||||||
for (int i = 0; i < symbols; i++){
|
|
||||||
printf ("%s\n", strings[i]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
exit(0);
|
exit(0);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
13
lib/Log.cc
13
lib/Log.cc
@ -62,6 +62,19 @@ void GridLogConfigure(std::vector<std::string> &logstreams)
|
|||||||
GridLogPerformance.Active(0);
|
GridLogPerformance.Active(0);
|
||||||
GridLogIntegrator.Active(0);
|
GridLogIntegrator.Active(0);
|
||||||
|
|
||||||
|
int blackAndWhite = 1;
|
||||||
|
if(blackAndWhite){
|
||||||
|
Logger::BLACK = std::string("");
|
||||||
|
Logger::RED =Logger::BLACK;
|
||||||
|
Logger::GREEN =Logger::BLACK;
|
||||||
|
Logger::YELLOW =Logger::BLACK;
|
||||||
|
Logger::BLUE =Logger::BLACK;
|
||||||
|
Logger::PURPLE =Logger::BLACK;
|
||||||
|
Logger::CYAN =Logger::BLACK;
|
||||||
|
Logger::WHITE =Logger::BLACK;
|
||||||
|
Logger::NORMAL =Logger::BLACK;
|
||||||
|
}
|
||||||
|
|
||||||
for(int i=0;i<logstreams.size();i++){
|
for(int i=0;i<logstreams.size();i++){
|
||||||
if ( logstreams[i]== std::string("Error") ) GridLogError.Active(1);
|
if ( logstreams[i]== std::string("Error") ) GridLogError.Active(1);
|
||||||
if ( logstreams[i]== std::string("Warning") ) GridLogWarning.Active(1);
|
if ( logstreams[i]== std::string("Warning") ) GridLogWarning.Active(1);
|
||||||
|
16
lib/Log.h
16
lib/Log.h
@ -99,7 +99,6 @@ extern GridLogger GridLogIntegrator ;
|
|||||||
#define _NBACKTRACE (256)
|
#define _NBACKTRACE (256)
|
||||||
extern void * Grid_backtrace_buffer[_NBACKTRACE];
|
extern void * Grid_backtrace_buffer[_NBACKTRACE];
|
||||||
|
|
||||||
#ifdef HAVE_EXECINFO_H
|
|
||||||
#define BACKTRACEFILE() {\
|
#define BACKTRACEFILE() {\
|
||||||
char string[20]; \
|
char string[20]; \
|
||||||
std::sprintf(string,"backtrace.%d",Rank()); \
|
std::sprintf(string,"backtrace.%d",Rank()); \
|
||||||
@ -107,7 +106,9 @@ extern void * Grid_backtrace_buffer[_NBACKTRACE];
|
|||||||
BACKTRACEFP(fp)\
|
BACKTRACEFP(fp)\
|
||||||
std::fclose(fp); \
|
std::fclose(fp); \
|
||||||
}
|
}
|
||||||
#define BACKTRACE() BACKTRACE(std::stdout)
|
|
||||||
|
|
||||||
|
#ifdef HAVE_EXECINFO_H
|
||||||
#define BACKTRACEFP(fp) { \
|
#define BACKTRACEFP(fp) { \
|
||||||
int symbols = backtrace (Grid_backtrace_buffer,_NBACKTRACE);\
|
int symbols = backtrace (Grid_backtrace_buffer,_NBACKTRACE);\
|
||||||
char **strings = backtrace_symbols(Grid_backtrace_buffer,symbols);\
|
char **strings = backtrace_symbols(Grid_backtrace_buffer,symbols);\
|
||||||
@ -116,14 +117,15 @@ extern void * Grid_backtrace_buffer[_NBACKTRACE];
|
|||||||
}\
|
}\
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define BACKTRACE() BACKTRACE(std::stdout);
|
|
||||||
|
|
||||||
#define BACKTRACEFP(fp) { \
|
#define BACKTRACEFP(fp) { \
|
||||||
for (int i = 0; i < 4; i++){\
|
std::fprintf (fp,"BT %d %lx\n",0, __builtin_return_address(0)); std::fflush(fp); \
|
||||||
std::fprintf (fp,"BT %d %lx\n",i, __builtin_return_address(i); std::fflush(fp); \
|
std::fprintf (fp,"BT %d %lx\n",1, __builtin_return_address(1)); std::fflush(fp); \
|
||||||
}\
|
std::fprintf (fp,"BT %d %lx\n",2, __builtin_return_address(2)); std::fflush(fp); \
|
||||||
|
std::fprintf (fp,"BT %d %lx\n",3, __builtin_return_address(3)); std::fflush(fp); \
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define BACKTRACE() BACKTRACEFP(stdout)
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user