本文整理汇总了C++中StackTrace::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ StackTrace::empty方法的具体用法?C++ StackTrace::empty怎么用?C++ StackTrace::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StackTrace
的用法示例。
在下文中一共展示了StackTrace::empty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SuspendedStacktrace
/**
*
* This entry point is tailored for the Watchdog module.
* Since the thread to be traced may be running, it requires a ThreadControls object in order to suspend/resume the thread.
* @brief RemoteStacktrace
*/
void SuspendedStacktrace(Threading::ThreadControls* ctls, const std::string& threadName)
{
#if !(DEDICATED || UNIT_TEST)
Watchdog::ClearTimer();
#endif
assert(ctls != nullptr);
assert(ctls->handle != 0);
assert(threadName.size() > 0);
LOG_L(L_WARNING, "Suspended-thread Stacktrace (%s) for Spring %s:", threadName.c_str(), (SpringVersion::GetFull()).c_str());
LOG_L(L_DEBUG, "SuspendedStacktrace[1]");
StackTrace stacktrace;
// Get untranslated stacktrace symbols
{
// process and analyse the raw stack trace
void* iparray[MAX_STACKTRACE_DEPTH];
ctls->Suspend();
const int numLines = thread_unwind(&ctls->ucontext, iparray, stacktrace);
ctls->Resume();
LOG_L(L_DEBUG, "SuspendedStacktrace[2]");
if(numLines > MAX_STACKTRACE_DEPTH) {
LOG_L(L_ERROR, "thread_unwind returned more lines than we allotted space for!");
}
char** lines = backtrace_symbols(iparray, numLines); // give them meaningfull names
ExtractSymbols(lines, stacktrace);
}
if (stacktrace.empty()) {
LOG_L(L_WARNING, " Unable to create suspended stacktrace");
return;
}
LOG_L(L_DEBUG, "SuspendedStacktrace[3]");
// Translate symbols into code line numbers
TranslateStackTrace(NULL, stacktrace, LOG_LEVEL_WARNING);
LOG_L(L_DEBUG, "SuspendedStacktrace[4]");
// Print out the translated StackTrace
LogStacktrace(LOG_LEVEL_WARNING, stacktrace);
}
示例2: HaltedStacktrace
/**
* This stack trace is tailored for the SIGSEGV / SIGILL / SIGFPE etc signal handler.
* The thread to be traced is usually in a halted state, but the signal handler can provide siginfo_t and ucontext_t structures to help produce the trace using libunwind.
* @brief PrepareStacktrace
*/
void HaltedStacktrace(const std::string& errstr, siginfo_t* siginfo, ucontext_t* ucontext)
{
LOG_L(L_ERROR, "Halted Stacktrace for Spring %s using libunwind:", (SpringVersion::GetFull()).c_str());
assert(siginfo != nullptr);
assert(ucontext != nullptr);
StackTrace stacktrace;
LOG_L(L_DEBUG, "HaltedStacktrace[1]");
// Get untranslated stacktrace symbols
{
// process and analyse the raw stack trace
void* iparray[MAX_STACKTRACE_DEPTH];
const int numLines = thread_unwind(nullptr, iparray, stacktrace);
LOG_L(L_DEBUG, "HaltedStacktrace[2]");
if(numLines > MAX_STACKTRACE_DEPTH) {
LOG_L(L_ERROR, "thread_unwind returned more lines than we allotted space for!");
}
char** lines = backtrace_symbols(iparray, numLines); // give them meaningfull names
ExtractSymbols(lines, stacktrace);
}
LOG_L(L_DEBUG, "HaltedStacktrace[3]");
if (stacktrace.empty()) {
LOG_I(LOG_LEVEL_ERROR, " Unable to create stacktrace");
return;
}
// Translate it
TranslateStackTrace(NULL, stacktrace, LOG_LEVEL_ERROR);
LOG_L(L_DEBUG, "HaltedStacktrace[4]");
// Print out the translated StackTrace. Ignore the frames that occur inside the signal handler (before its line in the trace) -- they are likely some kind of padding or just garbage.
LogStacktrace(LOG_LEVEL_ERROR, stacktrace);
}
示例3: Stacktrace
static void Stacktrace(bool* aiCrash, pthread_t* hThread = NULL, const char* threadName = NULL, const int logLevel = LOG_LEVEL_ERROR)
{
#if !(DEDICATED || UNIT_TEST)
Watchdog::ClearTimer();
#endif
if (threadName != NULL) {
LOG_I(logLevel, "Stacktrace (%s) for Spring %s:", threadName, (SpringVersion::GetFull()).c_str());
} else {
LOG_I(logLevel, "Stacktrace for Spring %s:", (SpringVersion::GetFull()).c_str());
}
StackTrace stacktrace;
// Get untranslated stacktrace symbols
{
// process and analyse the raw stack trace
void* iparray[MAX_STACKTRACE_DEPTH];
int numLines = thread_unwind(nullptr, iparray, stacktrace);
if (numLines > MAX_STACKTRACE_DEPTH) {
LOG_L(L_ERROR, "thread_unwind returned more lines than we allotted space for!");
}
char** lines = backtrace_symbols(iparray, numLines); // give them meaningfull names
ExtractSymbols(lines, stacktrace);
}
if (stacktrace.empty()) {
LOG_I(logLevel, " Unable to create stacktrace");
return;
}
// Translate it
TranslateStackTrace(aiCrash, stacktrace, logLevel);
LogStacktrace(logLevel, stacktrace);
}