Add crash reporter using libcrashreporter-qt

This commit is contained in:
Dominik Schmidt 2014-08-26 18:07:42 +02:00
parent 17e16f5e79
commit 2b4849a2fa
11 changed files with 181 additions and 0 deletions

3
.gitmodules vendored
View file

@ -7,3 +7,6 @@
[submodule "binary"] [submodule "binary"]
path = binary path = binary
url = git://github.com/owncloud/owncloud-client-binary.git url = git://github.com/owncloud/owncloud-client-binary.git
[submodule "src/3rdparty/libcrashreporter-qt"]
path = src/3rdparty/libcrashreporter-qt
url = git://github.com/dschmidt/libcrashreporter-qt.git

View file

@ -94,6 +94,12 @@ if(OWNCLOUD_5XX_NO_BLACKLIST)
add_definitions(-DOWNCLOUD_5XX_NO_BLACKLIST=1) add_definitions(-DOWNCLOUD_5XX_NO_BLACKLIST=1)
endif() endif()
option(WITH_CRASHREPORTER "Build the crash reporter" ON)
IF( CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty/libcrashreporter-qt/CMakeLists.txt")
message(STATUS "Build of crashreporter disabled.")
SET(WITH_CRASHREPORTER OFF)
ENDIF()
#### find libs #### find libs
#find_package(Qt4 4.7.0 COMPONENTS QtCore QtGui QtXml QtNetwork QtTest QtWebkit REQUIRED ) #find_package(Qt4 4.7.0 COMPONENTS QtCore QtGui QtXml QtNetwork QtTest QtWebkit REQUIRED )
#if( UNIX AND NOT APPLE ) # Fdo notifications #if( UNIX AND NOT APPLE ) # Fdo notifications

View file

@ -3,6 +3,7 @@
#cmakedefine USE_INOTIFY 1 #cmakedefine USE_INOTIFY 1
#cmakedefine WITH_QTKEYCHAIN 1 #cmakedefine WITH_QTKEYCHAIN 1
#cmakedefine WITH_CRASHREPORTER
#cmakedefine GIT_SHA1 "@GIT_SHA1@" #cmakedefine GIT_SHA1 "@GIT_SHA1@"
#cmakedefine APPLICATION_DOMAIN @APPLICATION_DOMAIN@ #cmakedefine APPLICATION_DOMAIN @APPLICATION_DOMAIN@

1
src/3rdparty/libcrashreporter-qt vendored Submodule

@ -0,0 +1 @@
Subproject commit 9bac9c15b474ab03d0ba80d89ff126ce20a9dff8

View file

@ -7,6 +7,11 @@ add_subdirectory(libsync)
if (NOT BUILD_LIBRARIES_ONLY) if (NOT BUILD_LIBRARIES_ONLY)
add_subdirectory(gui) add_subdirectory(gui)
add_subdirectory(cmd) add_subdirectory(cmd)
if (WITH_CRASHREPORTER)
add_subdirectory(3rdparty/libcrashreporter-qt)
add_subdirectory(crashreporter)
endif()
endif(NOT BUILD_LIBRARIES_ONLY) endif(NOT BUILD_LIBRARIES_ONLY)
find_program(KRAZY2_EXECUTABLE krazy2) find_program(KRAZY2_EXECUTABLE krazy2)

View file

@ -0,0 +1,45 @@
PROJECT( CrashReporter )
cmake_policy(SET CMP0017 NEW)
list(APPEND crashreporter_SOURCES main.cpp)
list(APPEND crashreporter_RC resources.qrc)
qt_wrap_ui( crashreporter_UI_HEADERS ${crashreporter_UI} )
qt_add_resources( crashreporter_RC_RCC ${crashreporter_RC} )
# TODO: differentiate release channel
# if(BUILD_RELEASE)
# set(CRASHREPORTER_RELEASE_CHANNEL "release")
# else()
set(CRASHREPORTER_RELEASE_CHANNEL "nightly")
# endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CrashReporterConfig.h.in
${CMAKE_CURRENT_BINARY_DIR}/CrashReporterConfig.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# ../../libtomahawk
# ../../thirdparty/libcrashreporter-qt/src
#)
add_executable( owncloud_crash_reporter WIN32
${crashreporter_SOURCES}
${crashreporter_HEADERS_MOC}
${crashreporter_UI_HEADERS}
${crashreporter_RC_RCC}
)
target_link_libraries(owncloud_crash_reporter
crashreporter-gui
${QT_LIBRARIES}
)
#TODO: don't use automoc :-(
set_target_properties(owncloud_crash_reporter PROPERTIES AUTOMOC ON)
set_target_properties(owncloud_crash_reporter PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIRECTORY} )
install(TARGETS owncloud_crash_reporter RUNTIME DESTINATION ${LIBEXEC_INSTALL_DIR})
qt5_use_modules(owncloud_crash_reporter Widgets Network)

View file

@ -0,0 +1,12 @@
#ifndef CRASHREPORTERCONFIG_H
#define CRASHREPORTERCONFIG_H
#define CRASHREPORTER_BUILD_ID "@CMAKE_DATESTAMP_YEAR@@CMAKE_DATESTAMP_MONTH@@CMAKE_DATESTAMP_DAY@000000"
#define CRASHREPORTER_RELEASE_CHANNEL "@CRASHREPORTER_RELEASE_CHANNEL@"
#define CRASHREPORTER_PRODUCT_NAME "ownCloud Client"
#define CRASHREPORTER_VERSION_STRING "@MIRALL_VERSION_STRING@"
#endif // CRASHREPORTERCONFIG_H

View file

@ -0,0 +1,84 @@
/*
* Copyright (C) by Dominik Schmidt <domme@tomahawk-player.org>
*
* 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.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include "../3rdparty/libcrashreporter-qt/src/libcrashreporter-gui/CrashReporter.h"
#include "CrashReporterConfig.h"
#include <QApplication>
#include <QDebug>
int main( int argc, char* argv[] )
{
QApplication app( argc, argv );
if ( app.arguments().size() != 2 )
{
qDebug() << "You need to pass the .dmp file path as only argument";
return 1;
}
// TODO: install socorro ....
CrashReporter reporter( QUrl( "http://crash-reports.tomahawk-player.org/submit" ), app.arguments() );
reporter.setLogo(QPixmap(":/owncloud-icon.png"));
reporter.setWindowTitle(CRASHREPORTER_PRODUCT_NAME);
reporter.setText("<html><head/><body><p><span style=\" font-weight:600;\">Sorry!</span> " CRASHREPORTER_PRODUCT_NAME " crashed. Please tell us about it! " CRASHREPORTER_PRODUCT_NAME " has created an error report for you that can help improve the stability in the future. You can now send this report directly to the " CRASHREPORTER_PRODUCT_NAME " developers.</p></body></html>");
reporter.setReportData( "BuildID", CRASHREPORTER_BUILD_ID );
reporter.setReportData( "ProductName", CRASHREPORTER_PRODUCT_NAME );
reporter.setReportData( "Version", CRASHREPORTER_VERSION_STRING );
reporter.setReportData( "ReleaseChannel", CRASHREPORTER_RELEASE_CHANNEL);
//reporter.setReportData( "timestamp", QByteArray::number( QDateTime::currentDateTime().toTime_t() ) );
// add parameters
// << Pair("InstallTime", "1357622062")
// << Pair("Theme", "classic/1.0")
// << Pair("Version", "30")
// << Pair("id", "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}")
// << Pair("Vendor", "Mozilla")
// << Pair("EMCheckCompatibility", "true")
// << Pair("Throttleable", "0")
// << Pair("URL", "http://code.google.com/p/crashme/")
// << Pair("version", "20.0a1")
// << Pair("CrashTime", "1357770042")
// << Pair("submitted_timestamp", "2013-01-09T22:21:18.646733+00:00")
// << Pair("buildid", "20130107030932")
// << Pair("timestamp", "1357770078.646789")
// << Pair("Notes", "OpenGL: NVIDIA Corporation -- GeForce 8600M GT/PCIe/SSE2 -- 3.3.0 NVIDIA 313.09 -- texture_from_pixmap\r\n")
// << Pair("StartupTime", "1357769913")
// << Pair("FramePoisonSize", "4096")
// << Pair("FramePoisonBase", "7ffffffff0dea000")
// << Pair("Add-ons", "%7B972ce4c6-7e08-4474-a285-3208198ce6fd%7D:20.0a1,crashme%40ted.mielczarek.org:0.4")
// << Pair("SecondsSinceLastCrash", "1831736")
// << Pair("ProductName", "WaterWolf")
// << Pair("legacy_processing", "0")
// << Pair("ProductID", "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}")
;
// TODO:
// send log
// QFile logFile( INSERT_FILE_PATH_HERE );
// logFile.open( QFile::ReadOnly );
// reporter.setReportData( "upload_file_miralllog", qCompress( logFile.readAll() ), "application/x-gzip", QFileInfo( INSERT_FILE_PATH_HERE ).fileName().toUtf8());
// logFile.close();
reporter.show();
return app.exec();
}

View file

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file alias="owncloud-icon.png">../../theme/colored/owncloud-icon-128.png</file>
</qresource>
</RCC>

View file

@ -227,6 +227,15 @@ target_link_libraries( ${APPLICATION_EXECUTABLE} ${synclib_NAME} )
target_link_libraries( ${APPLICATION_EXECUTABLE} updater ) target_link_libraries( ${APPLICATION_EXECUTABLE} updater )
target_link_libraries( ${APPLICATION_EXECUTABLE} ${OS_SPECIFIC_LINK_LIBRARIES} ) target_link_libraries( ${APPLICATION_EXECUTABLE} ${OS_SPECIFIC_LINK_LIBRARIES} )
if(WITH_CRASHREPORTER)
target_link_libraries( ${APPLICATION_EXECUTABLE} crashreporter-handler)
if(UNIX AND NOT MAC)
find_package(Threads REQUIRED)
target_link_libraries( ${APPLICATION_EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT})
endif()
endif()
install(TARGETS ${APPLICATION_EXECUTABLE} install(TARGETS ${APPLICATION_EXECUTABLE}
RUNTIME DESTINATION bin RUNTIME DESTINATION bin
LIBRARY DESTINATION lib LIBRARY DESTINATION lib

View file

@ -28,6 +28,10 @@
#include "updater/updater.h" #include "updater/updater.h"
#ifdef WITH_CRASHREPORTER
#include "../3rdparty/libcrashreporter-qt/src/libcrashreporter-handler/Handler.h"
#endif
#include <QTimer> #include <QTimer>
#include <QMessageBox> #include <QMessageBox>
@ -51,6 +55,12 @@ int main(int argc, char **argv)
Mac::CocoaInitializer cocoaInit; // RIIA Mac::CocoaInitializer cocoaInit; // RIIA
#endif #endif
Mirall::Application app(argc, argv); Mirall::Application app(argc, argv);
#ifdef WITH_CRASHREPORTER
new CrashReporter::Handler( QDir::tempPath(), true, "owncloud_crash_reporter" );
#endif
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
#endif #endif