本文整理汇总了C++中StackTrace::stackFrames方法的典型用法代码示例。如果您正苦于以下问题:C++ StackTrace::stackFrames方法的具体用法?C++ StackTrace::stackFrames怎么用?C++ StackTrace::stackFrames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StackTrace
的用法示例。
在下文中一共展示了StackTrace::stackFrames方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: segfault
void RequestError::segfault(Request* request, Exceptions::Segfault& e)
{
std::cerr << std::endl
<< " \033[31;1m******** SEGMENTATION FAULT ********\033[0m"
<< std::endl << std::endl
<< "WebCpp received a SIGSEGV signal: segmentation fault."
<< std::endl << std::endl
<< "This should never happen. Please file a bug to the WebCpp's "
<< std::endl << "developers on <http://bugs.webcpp.org/>."
<< std::endl << std::endl
<< "\033[33;1m*** STACK TRACE ***\033[0m" << std::endl << std::endl;
StackTrace* trace = new StackTrace(2);
List<StackTrace::Frame> frames = trace->stackFrames();
int i = 0, iLen = std::ceil(std::log10(frames.count()));
for (const StackTrace::Frame& frame : frames)
{
std::cerr << " " << std::setw(iLen) << i++ << ". "
<< "\033[34;1m" << frame.function << "\033[0m"
<< " + 0x" << String::fromNumber(frame.functionOffset, 16)
<< " @ 0x" << String::fromNumber(frame.address, 16)
<< std::endl << std::setw(iLen + 6) << " "
<< "Sources/System.cpp line 112"
<< " (from " << frame.object.absolutePath() << ")" << std::endl;
}
delete trace;
std::cerr << std::endl;
try
{
View tpl = new Template("Sys::Segfault.html", nullptr, request);
tpl["webcppVersion"] = System::get()->version();
tpl["serverName"] = request->env("SERVER_NAME", "");
loadStackTrace(e, dynamic_cast<Template*>(*tpl));
if (!request->headersSent())
request->setStatus(500);
tpl->render();
}
catch (const Exception& e2)
{ fallbackErrorPage(request, e, e2.type()); }
catch (const std::exception& e2)
{ fallbackErrorPage(request, e2, typeid(e2).name()); }
}