-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved out of process crash handler #5543
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
INCLUDE_DIRECTORIES(SYSTEM | ||
${CMAKE_CURRENT_BINARY_DIR} | ||
) | ||
|
||
QT5_WRAP_UI(CRASH_UIS_H qgscrashdialog.ui) | ||
QT5_WRAP_CPP(CRASH_HDR_MOC qgscrashdialog.h) | ||
|
||
SET(IMAGE_RCCS ../../images/images.qrc) | ||
QT5_ADD_RESOURCES(IMAGE_RCC_SRCS ${IMAGE_RCCS}) | ||
|
||
# -wd4091 Avoid 'typedef' ignored on left of '' when no variable is declared warning in DbgHelp.h | ||
SET_SOURCE_FILES_PROPERTIES(qgsstacktrace.cpp PROPERTIES COMPILE_FLAGS -wd4091) | ||
|
||
ADD_EXECUTABLE(qgiscrashhandler WIN32 | ||
main.cpp | ||
${CRASH_UIS_H} | ||
${CRASH_HDR_MOC} | ||
${IMAGE_RCC_SRCS} | ||
qgscrashdialog.cpp | ||
qgsstacktrace.cpp | ||
qgscrashreport.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/../app/qgis_win32.rc | ||
) | ||
|
||
TARGET_LINK_LIBRARIES(qgiscrashhandler | ||
${QT_QTCORE_LIBRARY} | ||
${QT_QTGUI_LIBRARY} | ||
DbgHelp | ||
) | ||
|
||
INSTALL(CODE "MESSAGE(\"Installing crashhandler ...\")") | ||
INSTALL(TARGETS qgiscrashhandler RUNTIME DESTINATION ${QGIS_LIBEXEC_DIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/*************************************************************************** | ||
crssync.cpp | ||
------------------- | ||
begin : October 2017 | ||
copyright : (C) 2017 by Nathan Woodrow | ||
email : woodrow.nathan@gmail.com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
#include <memory> | ||
#include <iostream> | ||
|
||
#define _NO_CVCONST_H | ||
#define _CRT_STDIO_ISO_WIDE_SPECIFIERS | ||
|
||
#include <QApplication> | ||
#include <QMainWindow> | ||
#include "qgscrashdialog.h" | ||
#include "qgsstacktrace.h" | ||
#include "qgscrashreport.h" | ||
|
||
|
||
int main( int argc, char *argv[] ) | ||
{ | ||
if ( argc < 2 ) | ||
{ | ||
std::cout << "QGIS Crash Handler Usage: \n" | ||
<< "qgscrashhandler {infofile}" << std::endl; | ||
return -1; | ||
} | ||
|
||
QApplication app( argc, argv ); | ||
app.setQuitOnLastWindowClosed( true ); | ||
QCoreApplication::setOrganizationName( "QGIS" ); | ||
QCoreApplication::setApplicationName( "QGIS3" ); | ||
|
||
QString extraInfoFile = QString( argv[1] ); | ||
std::cout << "Extra Info File: " << extraInfoFile.toUtf8().data() << std::endl; | ||
|
||
QFile file( extraInfoFile ); | ||
QString processIdString; | ||
QString threadIdString; | ||
QString exceptionPointersString; | ||
QString symbolPaths; | ||
QString reloadArgs; | ||
QStringList versionInfo; | ||
|
||
if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) ) | ||
{ | ||
processIdString = file.readLine(); | ||
threadIdString = file.readLine(); | ||
exceptionPointersString = file.readLine(); | ||
symbolPaths = file.readLine(); | ||
reloadArgs = file.readLine(); | ||
// The version info is the last stuff to be in the file until the end | ||
// bit gross but :) | ||
QString info = file.readAll(); | ||
versionInfo = info.split( "\n" ); | ||
} | ||
|
||
DWORD processId; | ||
DWORD threadId; | ||
LPEXCEPTION_POINTERS exception; | ||
processId = processIdString.toULong(); | ||
threadId = threadIdString.toULong(); | ||
sscanf_s( exceptionPointersString.toLocal8Bit().constData(), "%p", &exception ); | ||
|
||
std::cout << "Process ID: " << processIdString.toLocal8Bit().constData() << std::endl; | ||
std::cout << "Trhead ID:" << threadIdString.toLocal8Bit().constData() << std::endl; | ||
std::cout << "Exception Pointer: " << exceptionPointersString.toLocal8Bit().constData() << std::endl; | ||
std::cout << "Symbol Path :" << symbolPaths.toUtf8().data() << std::endl; | ||
|
||
std::unique_ptr<QgsStackTrace> stackTrace( QgsStackTrace::trace( processId, threadId, exception, symbolPaths ) ); | ||
|
||
QgsCrashReport report; | ||
report.setVersionInfo( versionInfo ); | ||
report.setStackTrace( stackTrace.get() ); | ||
report.exportToCrashFolder(); | ||
|
||
QgsCrashDialog dlg; | ||
dlg.setReloadArgs( reloadArgs ); | ||
dlg.setBugReport( report.toHtml() ); | ||
dlg.setModal( true ); | ||
dlg.show(); | ||
app.exec(); | ||
|
||
ResumeThread( stackTrace->thread ); | ||
CloseHandle( stackTrace->thread ); | ||
CloseHandle( stackTrace->process ); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bomb out if this doesn't exist?