本文整理汇总了C++中SymCleanup函数的典型用法代码示例。如果您正苦于以下问题:C++ SymCleanup函数的具体用法?C++ SymCleanup怎么用?C++ SymCleanup使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SymCleanup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ADM_backTrack
void ADM_backTrack(const char *info,int lineno,const char *file)
{
fflush(stderr);
fflush(stdout);
if (mysaveFunction)
mysaveFunction();
if (myFatalFunction)
myFatalFunction("Crash", "Press OK to build crash info");
void* currentProcessId = GetCurrentProcess();
SymInitialize(currentProcessId, NULL, TRUE);
dumpBackTrace(currentProcessId);
SymCleanup(currentProcessId);
printf("Assert failed at file %s, line %d\n\n",file,lineno);
exit(-1);
}
示例2: Initialize
// Load and initialize dbghelp.dll. Returns false if failed.
// To simplify callers, it can be called multiple times - it only does the
// work the first time, unless force is true, in which case we re-initialize
// the library (needed in crash dump where we re-initialize dbghelp.dll after
// downloading symbols)
bool Initialize(const WCHAR *symPathW, bool force)
{
if (gSymInitializeOk && !force)
return true;
bool needsCleanup = gSymInitializeOk;
if (!Load())
return false;
if (!_SymInitializeW && !_SymInitialize) {
plog("dbghelp::Initialize(): SymInitializeW() and SymInitialize() not present in dbghelp.dll");
return false;
}
if (needsCleanup)
SymCleanup();
if (_SymInitializeW) {
gSymInitializeOk = _SymInitializeW(GetCurrentProcess(), symPathW, TRUE);
} else {
// SymInitializeW() is not present on some XP systems
char symPathA[MAX_PATH];
if (0 != str::conv::ToCodePageBuf(symPathA, dimof(symPathA), symPathW, CP_ACP))
gSymInitializeOk = _SymInitialize(GetCurrentProcess(), symPathA, TRUE);
}
if (!gSymInitializeOk) {
plog("dbghelp::Initialize(): _SymInitialize() failed");
return false;
}
DWORD symOptions = _SymGetOptions();
symOptions = (SYMOPT_LOAD_LINES | SYMOPT_DEFERRED_LOADS | SYMOPT_UNDNAME);
symOptions |= SYMOPT_FAIL_CRITICAL_ERRORS; // don't show system msg box on errors
_SymSetOptions(symOptions);
//SetupSymbolPath();
return true;
}
示例3: windows_print_stacktrace
void windows_print_stacktrace(CONTEXT* context)
{
SymInitialize(GetCurrentProcess(), 0, true);
STACKFRAME frame = { 0 };
/* setup initial stack frame */
#ifdef AMD64
frame.AddrPC.Offset = context->Rip;
frame.AddrStack.Offset = context->Rsp;
frame.AddrFrame.Offset = context->Rsp;
#else
frame.AddrPC.Offset = context->Eip;
frame.AddrStack.Offset = context->Esp;
frame.AddrFrame.Offset = context->Ebp;
#endif
frame.AddrPC.Mode = AddrModeFlat;
frame.AddrStack.Mode = AddrModeFlat;
frame.AddrFrame.Mode = AddrModeFlat;
#ifdef AMD64
while (StackWalk64(IMAGE_FILE_MACHINE_AMD64,
#else
while (StackWalk(IMAGE_FILE_MACHINE_I386,
#endif
GetCurrentProcess(),
GetCurrentThread(),
&frame,
context,
0,
SymFunctionTableAccess,
SymGetModuleBase,
0 ) )
{
addr2line(icky_global_program_name, (void*)frame.AddrPC.Offset);
}
SymCleanup( GetCurrentProcess() );
}
示例4: exceptionFilter
LONG WINAPI exceptionFilter(LPEXCEPTION_POINTERS info)
{
if (g_output == NULL)
{
g_output = (char*) malloc(BUFFER_MAX);
}
struct output_buffer ob;
output_init(&ob, g_output, BUFFER_MAX);
if (!SymInitialize(GetCurrentProcess(), 0, TRUE))
{
output_print(&ob,"Failed to init symbol context\n");
}
else
{
bfd_init();
struct bfd_set *set = (bfd_set*)calloc(1,sizeof(*set));
_backtrace(&ob , set , 128 , info->ContextRecord);
release_set(set);
SymCleanup(GetCurrentProcess());
}
// Dump a stack trace to a file.
QFile stackTraceFile;
stackTraceFile.setFileName(QString("%1/openmodelica.stacktrace.%2").arg(OpenModelica::tempDirectory()).arg(Helper::OMCServerName));
if (stackTraceFile.open(QIODevice::WriteOnly | QIODevice::Text))
{
QTextStream out(&stackTraceFile);
out.setCodec(Helper::utf8.toStdString().data());
out.setGenerateByteOrderMark(false);
out << g_output;
out.flush();
stackTraceFile.close();
}
CrashReportDialog *pCrashReportDialog = new CrashReportDialog;
pCrashReportDialog->exec();
exit(1);
}
示例5: UnmapViewOfFile
void CMiniDumpReader::Close()
{
UnmapViewOfFile(m_pMiniDumpStartPtr);
if(m_hFileMapping!=NULL)
{
CloseHandle(m_hFileMapping);
}
if(m_hFileMiniDump!=INVALID_HANDLE_VALUE)
{
CloseHandle(m_hFileMiniDump);
m_hFileMiniDump = INVALID_HANDLE_VALUE;
}
m_pMiniDumpStartPtr = NULL;
if(m_DumpData.m_hProcess!=NULL)
{
SymCleanup(m_DumpData.m_hProcess);
}
}
示例6: LOG_FUNC_ENTRY
bool CATDbgHelper::Close( void )
{
LOG_FUNC_ENTRY("CATDbgHelper::Close");
if ( ! SymUnloadModule64( GetCurrentProcess(), m_BaseAddress ) )
{
LOG_STRING("Dbghelp:Module unload failed.");
}
CDBGHELPER_CLIENTS--;
if ( CDBGHELPER_OPEN && CDBGHELPER_CLIENTS == 0)
{
// Cleanup dbghelper.
if ( ! SymCleanup( GetCurrentProcess() ) )
{
LOG_STRING("dbghelper cleanup failed.");
return false;
}
LOG_STRING("dbghelper closed.");
// Set state not opened.
CDBGHELPER_OPEN = false;
}
return true;
}
示例7: ctrl_handler_w32
static LONG CALLBACK ctrl_handler_w32(LPEXCEPTION_POINTERS info)
{
switch (info->ExceptionRecord->ExceptionCode) {
case EXCEPTION_ACCESS_VIOLATION:
switch (info->ExceptionRecord->ExceptionInformation[0])
{
case 0:
LbErrorLog("Attempt to read from inaccessible memory address.\n");
break;
case 1:
LbErrorLog("Attempt to write to inaccessible memory address.\n");
break;
case 8:
LbErrorLog("User-mode data execution prevention (DEP) violation.\n");
break;
default:
LbErrorLog("Memory access voilation, code %d.\n",(int)info->ExceptionRecord->ExceptionInformation[0]);
break;
}
break;
case EXCEPTION_INT_DIVIDE_BY_ZERO:
LbErrorLog("Attempt of integer division by zero.\n");
break;
default:
LbErrorLog("Failure code %x received.\n",info->ExceptionRecord->ExceptionCode);
break;
}
if (!SymInitialize(GetCurrentProcess(), 0, TRUE)) {
LbErrorLog("Failed to init symbol context\n");
}
else {
_backtrace(16 , info->ContextRecord);
SymCleanup(GetCurrentProcess());
}
LbScreenReset();
LbErrorLogClose();
return EXCEPTION_EXECUTE_HANDLER;
}
示例8: OsDestroy
void OsDestroy(OsContext* aContext)
{
if (aContext == NULL) {
return;
}
(void)SymCleanup(aContext->iDebugSymbolHandle);
if (NULL != aContext->iInterfaceChangeObserver) {
aContext->iInterfaceChangeObserver->iShutdown = 1;
(void)WSASetEvent(aContext->iInterfaceChangeObserver->iShutdownEvent);
(void)WaitForSingleObject(aContext->iInterfaceChangeObserver->iSem, INFINITE);
CloseHandle(aContext->iInterfaceChangeObserver->iSem);
WSACloseEvent(aContext->iInterfaceChangeObserver->iEvent);
WSACloseEvent(aContext->iInterfaceChangeObserver->iShutdownEvent);
(void)closesocket(aContext->iInterfaceChangeObserver->iSocket);
free(aContext->iInterfaceChangeObserver);
aContext->iInterfaceChangeObserver = NULL;
}
(void)WSACleanup();
OsMutexDestroy(aContext->iMutex);
aContext->iMutex = kHandleNull;
TlsFree(aContext->iTlsIndex);
free(aContext);
}
示例9: exception_filter
static LONG WINAPI
exception_filter(LPEXCEPTION_POINTERS info)
{
struct output_buffer ob;
output_init(&ob, g_output, BUFFER_MAX);
if (!SymInitialize(GetCurrentProcess(), 0, TRUE)) {
output_print(&ob,"Failed to init symbol context\n");
}
else {
struct bfd_ctx bc;
_backtrace(&ob , &bc , 128 , info->ContextRecord);
close_bfd_ctx(&bc);
SymCleanup(GetCurrentProcess());
}
fputs(g_output , stderr);
exit(1);
return 0;
}
示例10: MspAcquireContext
BOOLEAN
MspAcquireContext(
IN PMSP_STACKTRACE_OBJECT Object,
IN ULONG ProcessId
)
{
PMSP_STACKTRACE_CONTEXT Old;
PMSP_STACKTRACE_CONTEXT New;
WCHAR SymbolPath[MAX_PATH * 2];
Old = Object->Context;
if (Old != NULL) {
if (Old->ProcessId == ProcessId) {
return TRUE;
}
else {
SymCleanup(Old->ProcessHandle);
}
}
New = MspLookupStackTraceContext(Object, ProcessId, TRUE);
if (!New) {
__debugbreak();
return FALSE;
}
ASSERT(New->ProcessHandle != NULL);
MdbGetSymbolPath(SymbolPath, MAX_PATH * 2);
SymInitializeW(New->ProcessHandle, SymbolPath, TRUE);
SymSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_UNDNAME |
SYMOPT_INCLUDE_32BIT_MODULES | SYMOPT_LOAD_LINES |
SYMOPT_OMAP_FIND_NEAREST);
Object->Context = New;
return TRUE;
}
示例11: SymGetOptions
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// const char* USER_SYMBOL_SEARCH_PATH = "http://msdl.microsoft.com/download/symbols";
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SymEngine::Init()
{
if (!isInitialized)
{
previousOptions = SymGetOptions();
memset(previousSearchPath, 0, MAX_SEARCH_PATH_LENGTH);
SymGetSearchPath(hProcess, previousSearchPath, MAX_SEARCH_PATH_LENGTH);
SymSetOptions(SymGetOptions() | SYMOPT_LOAD_LINES | SYMOPT_DEFERRED_LOADS | SYMOPT_UNDNAME | SYMOPT_INCLUDE_32BIT_MODULES | SYMOPT_LOAD_ANYTHING);
if (!SymInitialize(hProcess, NULL, TRUE))
{
needRestorePreviousSettings = true;
SymCleanup(hProcess);
if (SymInitialize(hProcess, NULL, TRUE))
isInitialized = true;
}
else
{
isInitialized = true;
}
}
}
示例12: exception_filter
static LONG WINAPI
exception_filter(LPEXCEPTION_POINTERS info)
{
struct output_buffer ob;
output_init(&ob, g_output, BUFFER_MAX);
if (!SymInitialize(GetCurrentProcess(), 0, TRUE)) {
output_print(&ob,"Failed to init symbol context\n");
}
else {
bfd_init();
struct bfd_set *set = calloc(1,sizeof(*set));
_backtrace(&ob , set , 128 , info->ContextRecord);
release_set(set);
SymCleanup(GetCurrentProcess());
}
fputs(g_output , stderr);
exit(1);
return 0;
}
示例13: getCtrlRoutine
LPVOID getCtrlRoutine() {
LPVOID ctrlRoutine;
// CtrlRoutine --> MyHandle --> getCtrlRoutine
// set the CaptureStackBackTrace's first param to 2 to ingore the MyHandler and getCtrlRoutine calls.
// should disable complier optimization on Release version.
USHORT count = CaptureStackBackTrace((ULONG) 2, (ULONG) 1, &ctrlRoutine, NULL);
if (count != 1) {
_tprintf(__T("CaptureStackBackTrace error\n"));
goto error;
}
HANDLE hProcess = GetCurrentProcess();
if (!SymInitialize(hProcess, NULL, TRUE)) {
RETVAL rv; _HandleLastError(rv, __T("SymInitialize"));
}
ULONG64 buffer[(sizeof(SYMBOL_INFO) + MAX_SYM_NAME*sizeof(TCHAR) + sizeof(ULONG64)-1)/sizeof(ULONG64)];
PSYMBOL_INFO pSymbol = (PSYMBOL_INFO) buffer;
pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO);
pSymbol->MaxNameLen = MAX_SYM_NAME;
LPVOID funcCtrlRoutine = NULL;
DWORD64 dwDisplacement = 0;
if(!SymFromAddr(hProcess, (DWORD64) ctrlRoutine, &dwDisplacement, pSymbol)) {
RETVAL rv; _HandleLastError(rv, __T("SymFromAddr"));
}
funcCtrlRoutine = reinterpret_cast<LPVOID>(pSymbol->Address);
SymCleanup(hProcess);
return funcCtrlRoutine;
error:
return NULL;
}
示例14: GetSystemDirectory
BOOL CShadowSSDTMgr::GetShadowSSDTNativeAddrBySymbol()
{
BOOL boRetn;
PDWORD pW32pServiceTable = 0;
DWORD dwload = 0;
PLOADED_IMAGE ploadImage = {0};
char imgPath[MAX_PATH];
// 初始化
if ( !InitSymbolsHandler() )
{
return FALSE;
}
// 获取系统目录"C:\WINDOWS\system32"
GetSystemDirectory( imgPath, MAX_PATH );
// 加载模块
ploadImage = ImageLoad( "win32k.sys", imgPath );
// 加载符号"C:\WINDOWS\system32\win32k.sys"
strcat( imgPath, "\\win32k.sys" );
dwload=SymLoadModule ( g_ixerhProc, ploadImage->hFile,
imgPath, "win32k.pdb",
0, ploadImage->SizeOfImage );
boRetn=SymEnumSymbols( g_ixerhProc, dwload, NULL, (PSYM_ENUMERATESYMBOLS_CALLBACK)EnumSymRoutine, NULL );
if (g_W32pServiceTable)
{
pW32pServiceTable = (PDWORD)( g_W32pServiceTable - dwload + (DWORD)ploadImage->MappedAddress );
boRetn=SymEnumSymbols( g_ixerhProc, dwload, NULL, (PSYM_ENUMERATESYMBOLS_CALLBACK)EnumSymRoutine, pW32pServiceTable );
}
ImageUnload(ploadImage);
SymCleanup(g_ixerhProc);
return boRetn;
}
示例15: MyExceptionFilter
LONG WINAPI MyExceptionFilter ( EXCEPTION_POINTERS * lpep) {
BOOL rVal;
STACKFRAME StackFrame;
CONTEXT Context;
IMAGEHLP_SYMBOL *pImagehlpSymbol;
ULONG Displacement;
BOOL fReturn;
CHAR szUndecoratedName[MAXSYMBOLNAMELENGTH];
FILE * flog;
SymSetOptions(0);
SymInitialize(SYM_HANDLE, NULL, TRUE);
flog = fopen("c:\\Except.log","a");
if (!flog)
return EXCEPTION_CONTINUE_SEARCH;
printf("\ndumping stack trace\n");
ZeroMemory(&StackFrame, sizeof(StackFrame));
Context = *lpep->ContextRecord;
#if defined(_M_IX86)
StackFrame.AddrPC.Offset = Context.Eip;
StackFrame.AddrPC.Mode = AddrModeFlat;
StackFrame.AddrFrame.Offset = Context.Ebp;
StackFrame.AddrFrame.Mode = AddrModeFlat;
StackFrame.AddrStack.Offset = Context.Esp;
StackFrame.AddrStack.Mode = AddrModeFlat;
#endif
pImagehlpSymbol = (IMAGEHLP_SYMBOL *) xmalloc(sizeof(IMAGEHLP_SYMBOL) +
MAXSYMBOLNAMELENGTH - 1);
ZeroMemory(pImagehlpSymbol, sizeof(IMAGEHLP_SYMBOL) + MAXSYMBOLNAMELENGTH -
1);
pImagehlpSymbol->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL);
pImagehlpSymbol->MaxNameLength = MAXSYMBOLNAMELENGTH;
do {
rVal = StackWalk ( MACHINE_TYPE,
SYM_HANDLE,
0,
&StackFrame,
&Context,
ReadProcessMemory,
SymFunctionTableAccess,
SymGetModuleBase,
NULL);
if (rVal) {
pImagehlpSymbol->Address = StackFrame.AddrPC.Offset;
fReturn = SymGetSymFromAddr ( SYM_HANDLE,
StackFrame.AddrPC.Offset,
&Displacement,
pImagehlpSymbol
);
fprintf(flog,"%08x %08x ", StackFrame.AddrFrame.Offset,
StackFrame.AddrReturn.Offset);
printf("%08x %08x ", StackFrame.AddrFrame.Offset,
StackFrame.AddrReturn.Offset);
if (fReturn) {
fReturn = SymUnDName ( pImagehlpSymbol, szUndecoratedName,
MAXSYMBOLNAMELENGTH);
if (fReturn) {
fprintf(flog,"%s", szUndecoratedName);
printf("%s", szUndecoratedName);
if (Displacement){
fprintf(flog,"+%x", Displacement);
printf("+%x", Displacement);
}
}
} else{
fprintf(flog,"0x%08x", StackFrame.AddrPC.Offset);
printf("0x%08x", StackFrame.AddrPC.Offset);
}
fprintf(flog,"\n");
printf("\n");
}
}
while (rVal);
SymCleanup(SYM_HANDLE);
fprintf(flog,"----Hit ^c to exit----\n");
fclose(flog);
ExitProcess((DWORD)-1);
return EXCEPTION_CONTINUE_SEARCH;//EXCEPTION_EXECUTE_HANDLER;
}