diff --git a/alib2common/src/debug/sigHandler.cpp b/alib2common/src/debug/sigHandler.cpp index e6c0658ac0b25538406f70140f530356e6b6bcc2..a3cfbb3ce4d60a4b53c6cc7dde54e7f1b043d345 100644 --- a/alib2common/src/debug/sigHandler.cpp +++ b/alib2common/src/debug/sigHandler.cpp @@ -9,7 +9,7 @@ #include "simpleStacktrace.h" #include <iostream> -namespace std { +namespace ext { void SigHandler::handler(int signal) { switch(signal) { @@ -24,7 +24,7 @@ void SigHandler::handler(int signal) { break; } #ifdef DEBUG - std::cout << std::simpleStacktrace() << std::endl; + std::cout << ext::simpleStacktrace() << std::endl; #endif exit(1); } @@ -36,4 +36,4 @@ SigHandler::SigHandler() { SigHandler SigHandler::HANDLER; -} /* namespace std */ +} /* namespace ext */ diff --git a/alib2common/src/debug/sigHandler.h b/alib2common/src/debug/sigHandler.h index 4de86c251b704f3812d5018039ddfa92ad234c90..0d304c3afc2a98422e85b590e44096a0e4ab9d89 100644 --- a/alib2common/src/debug/sigHandler.h +++ b/alib2common/src/debug/sigHandler.h @@ -3,7 +3,7 @@ #include <string> -namespace std { +namespace ext { class SigHandler { static void handler(int); @@ -16,6 +16,6 @@ protected: }; -} /* namespace std */ +} /* namespace ext */ #endif /* SIG_HANDLER_H_ */ diff --git a/alib2common/src/debug/simpleStacktrace.cpp b/alib2common/src/debug/simpleStacktrace.cpp index 88766b99046f50d426ebfa9ceb7bc5e330888420..794a41e69060df334c54f29a254aca66c26dcd62 100644 --- a/alib2common/src/debug/simpleStacktrace.cpp +++ b/alib2common/src/debug/simpleStacktrace.cpp @@ -15,7 +15,7 @@ #include <string> #include <map> -namespace std { +namespace ext { int callback(struct dl_phdr_info *info, size_t, void * data) { ext::map<std::string, long>& dlToBaseAddress = *(reinterpret_cast<ext::map<std::string, long>*>(data)); @@ -26,7 +26,7 @@ int callback(struct dl_phdr_info *info, size_t, void * data) { } /** Print a demangled stack backtrace of the caller function to FILE* out. */ -string simpleStacktrace(unsigned int max_frames) { +std::string simpleStacktrace(unsigned int max_frames) { char linkname[512]; /* /proc/exe */ char buf[512]; pid_t pid; @@ -40,8 +40,8 @@ string simpleStacktrace(unsigned int max_frames) { ret = readlink(linkname, buf, 512); buf[ret] = 0; - stringstream ss; - ss << "stack trace for process " << buf << " (PID:" << pid << "):"<< endl; + std::stringstream ss; + ss << "stack trace for process " << buf << " (PID:" << pid << "):"<< std::endl; // storage array for stack trace address data void** addrlist = (void**) malloc( (max_frames + 1 ) * sizeof(void*) ); @@ -50,7 +50,7 @@ string simpleStacktrace(unsigned int max_frames) { int addrlen = backtrace(addrlist, max_frames); if (addrlen == 0) { - ss << " <empty, possibly corrupt>" << endl; + ss << " <empty, possibly corrupt>" << std::endl; free(addrlist); return std::move(ss).str(); } @@ -114,15 +114,15 @@ string simpleStacktrace(unsigned int max_frames) { char* demangled = abi::__cxa_demangle(begin_name, funcname, &funcnamesize, &status); if (status == 0) { funcname = demangled; // use possibly realloc()-ed string - ss << " " << symbollist[i] << " : " << funcname << "+" << begin_offset << " " << begin_name << " [0x" << addr_offset_by_dl.c_str() << "; @ " << addr_offset << "]" << endl; + ss << " " << symbollist[i] << " : " << funcname << "+" << begin_offset << " " << begin_name << " [0x" << addr_offset_by_dl.c_str() << "; @ " << addr_offset << "]" << std::endl; } else { // demangling failed. Output function name as a C function with // no arguments. - ss << " " << symbollist[i] << " : " << begin_name << "()+" << begin_offset << " " << " [0x" << addr_offset_by_dl.c_str() << "; @ " << addr_offset << "]" << endl; + ss << " " << symbollist[i] << " : " << begin_name << "()+" << begin_offset << " " << " [0x" << addr_offset_by_dl.c_str() << "; @ " << addr_offset << "]" << std::endl; } } else { // couldn't parse the line? print the whole line. - ss << " " << symbollist[i] << endl; + ss << " " << symbollist[i] << std::endl; } } free(funcname); @@ -131,4 +131,4 @@ string simpleStacktrace(unsigned int max_frames) { return std::move(ss).str(); } -} /* namespace std */ +} /* namespace ext */ diff --git a/alib2common/src/debug/simpleStacktrace.h b/alib2common/src/debug/simpleStacktrace.h index 3bab18f1e66cba5e0df4c33c675c796cfb16f9ba..4c5ffaf396b272191ccfecb357e68e1f4c9ad939 100644 --- a/alib2common/src/debug/simpleStacktrace.h +++ b/alib2common/src/debug/simpleStacktrace.h @@ -6,11 +6,11 @@ #include <string> -namespace std { +namespace ext { /** Print a demangled stack backtrace of the caller function to FILE* out. */ -string simpleStacktrace(unsigned int max_frames = 1000); +std::string simpleStacktrace(unsigned int max_frames = 1000); -} /* namespace std */ +} /* namespace ext */ #endif // _SIMPLE_STACKTRACE_H_ diff --git a/alib2common/src/exception/CommonException.cpp b/alib2common/src/exception/CommonException.cpp index f44cef33726cd5ad98f6dc808ad74cdd016d8a24..54513c789aae6d41e6647aee5b870832591005e0 100644 --- a/alib2common/src/exception/CommonException.cpp +++ b/alib2common/src/exception/CommonException.cpp @@ -23,7 +23,7 @@ namespace exception { CommonException::CommonException ( std::string cause ) : m_cause(std::move(cause)) { #ifdef DEBUG - this->m_backtrace = std::simpleStacktrace(); + this->m_backtrace = ext::simpleStacktrace(); #else this->m_backtrace = ""; #endif