本文整理汇总了C++中Exception::StackTrace方法的典型用法代码示例。如果您正苦于以下问题:C++ Exception::StackTrace方法的具体用法?C++ Exception::StackTrace怎么用?C++ Exception::StackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exception
的用法示例。
在下文中一共展示了Exception::StackTrace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UnhandledExceptionHandler
void OpenHome::UnhandledExceptionHandler(Exception& aException)
{
Bws<5> thName;
GetThreadName(thName);
char buf[1024];
(void)snprintf(buf, sizeof(buf), "Unhandled exception %s at %s:%lu in thread %s\n", aException.Message(), aException.File(), (unsigned long)aException.Line(), thName.Ptr());
TInt len = 8*1024;
char* msg = new char[len];
if (msg != NULL) {
(void)strncpy(msg, buf, len);
len -= (TInt)strlen(buf);
(void)strncat(msg, "\n", len);
len -= 2;
THandle stackTrace = aException.StackTrace();
TUint count = Os::StackTraceNumEntries(stackTrace);
for (TUint i=0; i<count; i++) {
const char* entry = Os::StackTraceEntry(stackTrace, i);
(void)strncat(msg, entry, len);
len -= (TInt)strlen(entry) + 2;
if (len < 0) {
break;
}
(void)strncat(msg, "\n", len);
}
}
if (len > 0) {
(void)strncat(msg, "\n", len);
}
CallFatalErrorHandler((msg!=NULL? msg : buf));
delete msg;
}
示例2: OnException
//-----------------------------------------------------------------------------------------------------------------------------------------------------
VOID Application::OnException(Exception& E)
{
Trace0Enter("");
StringBuilder Message;
Message.AppendLine(TEXT("UNHANDLED EXCEPTION"));
Message.AppendFormatLine(TEXT("Exception Type: %s::%s"), E.GetType()->Namespace(), E.GetType()->Name() );
Message.AppendFormatLine(TEXT("Description: %s"), E.Description().ConstStr() );
Message.AppendLine(TEXT("\nStack Trace:"));
for( SIZE_T i=0; i<E.StackTrace().Length(); i++ )
{
#if defined(UNICODE)
if (E.StackTrace()[i].Symbol().SourceFile() != 0)
Message.AppendFormatLine(TEXT("0x%p %S() at %S:%d"), E.StackTrace()[i].InstructionPtr(), E.StackTrace()[i].Symbol().Name(), E.StackTrace()[i].Symbol().SourceFile(), E.StackTrace()[i].Symbol().SourceLine() );
else
Message.AppendFormatLine(TEXT("0x%p %S()"), E.StackTrace()[i].InstructionPtr(), E.StackTrace()[i].Symbol().Name() );
#else
if (E.StackTrace()[i].Symbol().SourceFile() != 0)
Message.AppendFormatLine(TEXT("0x%p %s()\r\n at %s:%d"), E.StackTrace()[i].InstructionPtr(), E.StackTrace()[i].Symbol().Name(), Path::Filename(E.StackTrace()[i].Symbol().SourceFile()).ConstStr(), E.StackTrace()[i].Symbol().SourceLine() );
else
Message.AppendFormatLine(TEXT("0x%p %s()"), E.StackTrace()[i].InstructionPtr(), E.StackTrace()[i].Symbol().Name() );
#endif
}
Trace(TraceLevel::ERROR, this, Message.ToString() );
Debug::GenerateCoreDump();
}