Skip to content

Commit

Permalink
Improve Windows crash log (#2736)
Browse files Browse the repository at this point in the history
* Show RVA of each call stack so we can locate the symbol with pdb file

* CI upload pdb file
  • Loading branch information
Noisyfox authored Nov 15, 2023
1 parent 3f3bd08 commit 016d3a7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build_orca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ jobs:
with:
name: OrcaSlicer_Windows_V${{ env.ver }}
path: ${{ github.workspace }}/build/OrcaSlicer*.exe

- name: Upload artifacts Win PDB
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v3
with:
name: OrcaSlicer_Windows_V${{ env.ver }}_pdb
path: ${{ github.workspace }}/build/src/Release/*.pdb
# Ubuntu

- name: Install dependencies
Expand Down
22 changes: 20 additions & 2 deletions src/BaseException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,26 @@ void CBaseException::ShowLoadModules()

void CBaseException::ShowCallstack(HANDLE hThread, const CONTEXT* context)
{
OutputString(_T("Show CallStack:\r\n"));
LPSTACKINFO phead = StackWalker(hThread, context);
OutputString(_T("Show CallStack:\n"));
LPSTACKINFO phead = StackWalker(hThread, context);

// Show RVA of each call stack, so we can locate the symbol using pdb file
// To show the symbol, load the <szFaultingModule> in WinDBG with pdb file, then type the following commands:
// > lm which gives you the start address of each module, as well as module names
// > !dh <module name> list all module headers. Find the <virtual address> of the section given by
// the <section> output in the crash log
// > ln <module start address> + <section virtual address> + <offset> reveals the debug symbol
OutputString(_T("\nLogical Address:\n"));
TCHAR szFaultingModule[MAX_PATH];
DWORD section, offset;
for (LPSTACKINFO ps = phead; ps != nullptr; ps = ps->pNext) {
if (GetLogicalAddress((PVOID) ps->szFncAddr, szFaultingModule, sizeof(szFaultingModule), section, offset)) {
OutputString(_T("0x%X 0x%X:0x%X %s\n"), ps->szFncAddr, section, offset, szFaultingModule);
} else {
OutputString(_T("0x%X Unknown\n"), ps->szFncAddr);
}
}

FreeStackInformations(phead);
}

Expand Down
6 changes: 3 additions & 3 deletions src/StackWalker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ LPSTACKINFO CStackWalker::StackWalker(HANDLE hThread, const CONTEXT* context)
}else
{
//调用错误一般是487(地址无效或者没有访问的权限、在符号表中未找到指定地址的相关信息)
this->OutputString(_T("Call SymGetSymFromAddr64 ,Address %08x Error:%08x\r\n"), sf.AddrPC.Offset, GetLastError());
//this->OutputString(_T("Call SymGetSymFromAddr64 ,Address %08x Error:%08x\n"), sf.AddrPC.Offset, GetLastError());

StringCchCopy(pCallStack->undFullName, STACKWALK_MAX_NAMELEN, textconv_helper::A2T_("Unknown"));
}
Expand All @@ -502,14 +502,14 @@ LPSTACKINFO CStackWalker::StackWalker(HANDLE hThread, const CONTEXT* context)
pCallStack->uFileNum = pLine->LineNumber;
}else
{
this->OutputString(_T("Call SymGetLineFromAddr64 ,Address %08x Error:%08x\r\n"), sf.AddrPC.Offset, GetLastError());
//this->OutputString(_T("Call SymGetLineFromAddr64 ,Address %08x Error:%08x\n"), sf.AddrPC.Offset, GetLastError());

StringCchCopy(pCallStack->szFileName, MAX_PATH, textconv_helper::A2T_("Unknown file"));
pCallStack->uFileNum = -1;
}

//这里为了将获取函数信息失败的情况与正常的情况一起输出,防止用户在查看时出现误解
this->OutputString(_T("%08llx:%s [%s][%ld]\r\n"), pCallStack->szFncAddr, pCallStack->undFullName, pCallStack->szFileName, pCallStack->uFileNum);
this->OutputString(_T("%08llx:%s [%s][%ld]\n"), pCallStack->szFncAddr, pCallStack->undFullName, pCallStack->szFileName, pCallStack->uFileNum);
if (NULL == pHead)
{
pHead = pCallStack;
Expand Down

0 comments on commit 016d3a7

Please sign in to comment.