feat: add breakpad crash support

This commit is contained in:
xiaoyifang 2023-05-01 16:01:48 +08:00
parent 5aee6e4627
commit c969418497
5 changed files with 72 additions and 4 deletions

View file

@ -31,6 +31,10 @@ function Main() {
# 拷贝exe
Copy-Item release\$targetName $archiveName\
Write-Host "copy item finished..."
#拷贝pdb
Copy-Item release\*.pdb $archiveName\
Write-Host "copy pdb finished..."
# 拷贝依赖
windeployqt --qmldir . --plugindir $archiveName\plugins --compiler-runtime $archiveName\$targetName
# 删除不必要的文件

View file

@ -82,6 +82,19 @@ jobs:
echo "$previousTag">version.txt
cat version.txt
- name: vcpkg install
shell: powershell
run: |
git clone --depth 1 https://github.com/microsoft/vcpkg.git
.\vcpkg\bootstrap-vcpkg.bat
# .\vcpkg\vcpkg.exe install ffmpeg[core,avcodec,avformat,mp3lame,opus,speex,swresample,vorbis,fdk-aac,gpl] --triplet=x64-windows-release
.\vcpkg\vcpkg.exe install breakpad --triplet=x64-windows-release
- name: copy vcpkg packages into winlibs
shell: bash
run: |
cp -R vcpkg/packages/breakpad_x64-windows-release/* thirdparty/breakpad
ls -al thirdparty/breakpad
# # msvc编译
- uses: ilammy/msvc-dev-cmd@v1
# with:
@ -90,7 +103,7 @@ jobs:
id: build
shell: cmd
run: |
qmake "CONFIG+=zim_support" CONFIG+=release CONFIG+=use_xapian CONFIG+=use_iconv
qmake "CONFIG+=zim_support" CONFIG+=release CONFIG+=use_xapian CONFIG+=use_iconv CONFIG+=use_breakpad
nmake
echo winSdkDir=%WindowsSdkDir% >> %GITHUB_ENV%

View file

@ -79,6 +79,22 @@ CONFIG( use_xapian ) {
LIBS+= -lxapian
}
CONFIG( use_breakpad ) {
DEFINES += USE_BREAKPAD
win32: LIBS += -L$$PWD/thirdparty/breakpad/lib/ -llibbreakpad -llibbreakpad_client
else:unix: LIBS += -L$$PWD/thirdparty/breakpad/lib/ -llibbreakpa
INCLUDEPATH += $$PWD/thirdparty/breakpad/include
DEPENDPATH += $$PWD/thirdparty/breakpad/include
CONFIG( release, debug|release ) {
# create debug symbols for release builds
CONFIG*=force_debug_info
QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO -= -O2
}
}
CONFIG( use_iconv ) {
DEFINES += USE_ICONV
unix:!mac{

View file

@ -30,6 +30,24 @@
#include "gddebug.hh"
#if defined(USE_BREAKPAD)
#include "client/windows/handler/exception_handler.h"
#endif
#if defined(USE_BREAKPAD)
bool callback(const wchar_t* dump_path, const wchar_t* id,
void* context, EXCEPTION_POINTERS* exinfo,
MDRawAssertionInfo* assertion,
bool succeeded) {
if (succeeded) {
qDebug() << "Create dump file success";
} else {
qDebug() << "Create dump file failed";
}
return succeeded;
}
#endif
void gdMessageHandler( QtMsgType type, const QMessageLogContext &context, const QString &mess )
{
Q_UNUSED( context );
@ -228,8 +246,7 @@ int main( int argc, char ** argv )
char ARG_DISABLE_WEB_SECURITY[] = "--disable-web-security";
int newArgc = argc + 1 + 1;
char ** newArgv = new char *[ newArgc ];
for( int i = 0; i < argc; i++ )
{
for ( int i = 0; i < argc; i++ ) {
newArgv[ i ] = argv[ i ];
}
newArgv[ argc ] = ARG_DISABLE_WEB_SECURITY;
@ -238,11 +255,27 @@ int main( int argc, char ** argv )
QHotkeyApplication app( "GoldenDict", newArgc, newArgv );
app.setApplicationName( "GoldenDict" );
app.setOrganizationDomain( "https://github.com/xiaoyifang/goldendict" );
app.setOrganizationDomain( "https://github.com/xiaoyifang/goldendict-ng" );
#ifndef Q_OS_MAC
app.setWindowIcon( QIcon( ":/icons/programicon.png" ) );
#endif
#if defined(USE_BREAKPAD)
QString appDirPath = QCoreApplication::applicationDirPath() + "/crash";
QDir dir;
if (!dir.exists(appDirPath)) {
bool res = dir.mkpath(appDirPath);
qDebug() << "New mkdir " << appDirPath << " " << res;
}
google_breakpad::ExceptionHandler eh(
appDirPath.toStdWString(), NULL, callback, NULL,
google_breakpad::ExceptionHandler::HANDLER_ALL);
#endif
GDOptions gdcl{};
if ( argc > 1 ) {

2
thirdparty/breakpad/Readme.md vendored Normal file
View file

@ -0,0 +1,2 @@
This is is a placeholder for breakpad.
the lib and include files will be copied here with vcpkg.