Skip to content

Commit

Permalink
added:windows core-dump support
Browse files Browse the repository at this point in the history
  • Loading branch information
xengine-qyt committed Jan 23, 2025
1 parent 3f3a41b commit 9f3918b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/macbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
matrix:
include:
- os: macos-13
- os: macos-14
runs-on: ${{ matrix.os }}

steps:
Expand Down Expand Up @@ -58,7 +57,6 @@ jobs:
./XEngine_LINEnv.sh -i 0
latest_tag=$(git ls-remote --tags --sort="v:refname" https://github.com/libxengine/libxengine.git | awk '{print $2}' | sed 's/refs\/tags\///' | tail -n 1)
wget https://github.com/libxengine/libxengine/releases/download/$latest_tag/XEngine_Mac_Arm64.zip
unzip ./XEngine_Mac_Arm64.zip -d ./XEngine_Mac_Arm64
cd XEngine_Mac_Arm64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#ifdef _MSC_BUILD
#include <Windows.h>
#include <tchar.h>
#include <minidumpapiset.h>
#else
#include <unistd.h>
#include <sys/wait.h>
Expand Down Expand Up @@ -201,4 +202,5 @@ extern FILE* pSt_AFile;
#pragma comment(lib,"XEngine_AVCodec/XEngine_AudioCodec.lib")
#pragma comment(lib,"XEngine_SystemSdk/XEngine_SystemApi.lib")
#pragma comment(lib,"Ws2_32.lib")
#pragma comment(lib,"Dbghelp.lib")
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,40 @@ static int ServiceApp_Deamon()
#endif
return 0;
}
#ifdef _MSC_BUILD
LONG WINAPI Coredump_ExceptionFilter(EXCEPTION_POINTERS* pExceptionPointers)
{
static int i = 0;
XCHAR tszFileStr[MAX_PATH] = {};
XCHAR tszTimeStr[128] = {};
BaseLib_Time_TimeToStr(tszTimeStr);
_xstprintf(tszFileStr, _X("./XEngine_Coredump/dumpfile_%s_%d.dmp"), tszTimeStr, i++);

XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_FATAL, _X("主程序:软件崩溃,写入dump:%s"), tszFileStr);

HANDLE hDumpFile = CreateFileA(tszFileStr, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (INVALID_HANDLE_VALUE != hDumpFile)
{
MINIDUMP_EXCEPTION_INFORMATION st_DumpInfo = {};
st_DumpInfo.ExceptionPointers = pExceptionPointers;
st_DumpInfo.ThreadId = GetCurrentThreadId();
st_DumpInfo.ClientPointers = TRUE;

// 写入 dump 文件
MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hDumpFile, MiniDumpNormal, &st_DumpInfo, NULL, NULL);
CloseHandle(hDumpFile);
}
return EXCEPTION_EXECUTE_HANDLER;
}
#endif

int main(int argc, char** argv)
{
#ifdef _MSC_BUILD
WSADATA st_WSAData;
WSAStartup(MAKEWORD(2, 2), &st_WSAData);

SetUnhandledExceptionFilter(Coredump_ExceptionFilter);
#ifndef _DEBUG
if (setlocale(LC_ALL, ".UTF8") == NULL)
{
Expand Down

0 comments on commit 9f3918b

Please sign in to comment.