diff options
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | 3rd-party/breakpad/CMakeLists.txt | 11 | ||||
m--------- | 3rd-party/breakpad/breakpad.git | 0 | ||||
-rwxr-xr-x | 3rd-party/breakpad/build.sh | 16 | ||||
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | doc/Breakpad.md | 14 | ||||
-rw-r--r-- | src/CMakeLists.txt | 14 | ||||
-rw-r--r-- | src/main.cpp | 43 |
8 files changed, 94 insertions, 13 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..17d12ff --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "3rd-party/breakpad/breakpad.git"] + path = 3rd-party/breakpad/breakpad.git + url = https://chromium.googlesource.com/breakpad/breakpad diff --git a/3rd-party/breakpad/CMakeLists.txt b/3rd-party/breakpad/CMakeLists.txt new file mode 100644 index 0000000..dd0ef8e --- /dev/null +++ b/3rd-party/breakpad/CMakeLists.txt @@ -0,0 +1,11 @@ +if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + + if (NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/install") + message(FATAL_ERROR "Could not find breakpad build, see 3rd-party/breakpad/build.sh") + endif () + + find_package(PkgConfig REQUIRED) + set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${CMAKE_CURRENT_LIST_DIR}/install/lib/pkgconfig" ) + pkg_check_modules(BREAKPAD REQUIRED IMPORTED_TARGET breakpad-client) + +endif() # linux system
\ No newline at end of file diff --git a/3rd-party/breakpad/breakpad.git b/3rd-party/breakpad/breakpad.git new file mode 160000 +Subproject 54fa71efbe50fb2b58096d871575b59e12edba6 diff --git a/3rd-party/breakpad/build.sh b/3rd-party/breakpad/build.sh new file mode 100755 index 0000000..0d8d306 --- /dev/null +++ b/3rd-party/breakpad/build.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +if [ ! -f breakpad.git/src/third_party/lss/linux_syscall_support.h ]; then + mkdir -p breakpad.git/src/third_party/lss + curl -L https://chromium.googlesource.com/linux-syscall-support/+/master/linux_syscall_support.h?format=TEXT | base64 --decode > breakpad.git/src/third_party/lss/linux_syscall_support.h +fi + +installpath=$(pwd)/install +rm -r $installpath +mkdir -p $installpath +mkdir build && cd build + +../breakpad.git/configure --prefix=$installpath +make -j 2 +make install +rm -r build diff --git a/CMakeLists.txt b/CMakeLists.txt index a966253..90aa0ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.10.0) -project(smolbote CXX) +project(smolbote) include(FeatureSummary) @@ -11,6 +11,7 @@ option(QtDeprecatedWarnings "Qt deprecated warnings" ON) option(UseLibCpp "Use libc++ over stdlibc++ (requires clang)" OFF) option(Tests "Enable/disable some basic autotests" OFF) option(Plasma "Enable some fancy effects on Plasma" OFF) +option(Breakpad "Enable breakpad crash reports" OFF) # Libraries find_package(Qt5 COMPONENTS Core Widgets Concurrent REQUIRED) @@ -40,6 +41,9 @@ endif (UseLibCpp) configure_file("${PROJECT_SOURCE_DIR}/src/version.h.in" "${PROJECT_BINARY_DIR}/src/version.h") add_subdirectory(3rd-party/SingleApplication) +if(Breakpad) + add_subdirectory(3rd-party/breakpad) +endif() add_subdirectory(lib/about) add_subdirectory(lib/addressbar) diff --git a/doc/Breakpad.md b/doc/Breakpad.md new file mode 100644 index 0000000..d1056a5 --- /dev/null +++ b/doc/Breakpad.md @@ -0,0 +1,14 @@ +## Producing symbols + +~~~sh +tools/linux/dump_syms/dump_syms ./poi > poi.sym +head -n1 poi.sym +mkdir -p ./symbols/poi/<hex> +mv poi.sym ./symbols/poi/<hex> +~~~ + +## Processing minidump + +~~~sh +processor/minidump_stackwalk minidump.dmp ./symbols +~~~ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index df2aeeb..e256ee8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -47,6 +47,10 @@ set(srclist plugin.h ) +if(Breakpad) + link_directories("${BREAKPAD_LIBRARY_DIRS}") +endif() + if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") add_executable(${poi_exe} WIN32 ${srclist} ${PROJECT_SOURCE_DIR}/data/windows.rc) else() @@ -70,6 +74,16 @@ target_link_libraries(${poi_exe} bookmarks downloads web ) +if(Breakpad) + find_package(Threads REQUIRED) + + target_link_libraries(${poi_exe} Threads::Threads ${BREAKPAD_LIBRARIES}) + target_include_directories(${poi_exe} PRIVATE ${BREAKPAD_INCLUDE_DIRS}) + target_compile_options(${poi_exe} PRIVATE ${BREAKPAD_CFLAGS_OTHER}) + + target_compile_definitions(${poi_exe} PRIVATE BreakpadEnabled) +endif() + if(Plasma) target_link_libraries(${poi_exe} KF5::WindowSystem) target_compile_definitions(${poi_exe} diff --git a/src/main.cpp b/src/main.cpp index 12961ff..f3ddeb9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,25 +7,40 @@ */ #include "browser.h" +#include "plugin.h" +#include "session.h" #include "version.h" #include <QFile> +#include <QLibraryInfo> +#include <QTranslator> #include <configuration/configuration.h> -#include <memory> #include <iostream> -#include "plugin.h" -#include "session.h" -#include <QTranslator> -#include <QLibraryInfo> +#include <memory> #ifdef _WIN32 -#include <windows.h> #include <cstdio> +#include <windows.h> +#endif + +#ifdef BreakpadEnabled +#include <client/linux/handler/exception_handler.h> + +static bool dumpCallback(const google_breakpad::MinidumpDescriptor &descriptor, void *context, bool succeeded) +{ + printf("Dump path: %s\n", descriptor.path()); + return succeeded; +} #endif int main(int argc, char **argv) { +#ifdef BreakpadEnabled + google_breakpad::MinidumpDescriptor descriptor("/tmp"); + google_breakpad::ExceptionHandler eh(descriptor, NULL, dumpCallback, NULL, true, -1); +#endif + // a beautiful hack to be able to write to stdout on Windows #ifdef _WIN32 - if (AttachConsole(ATTACH_PARENT_PROCESS)) { + if(AttachConsole(ATTACH_PARENT_PROCESS)) { freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stderr); } @@ -62,7 +77,7 @@ int main(int argc, char **argv) QVector<Plugin> plugins = loadPlugins(config->value<QString>("plugins.path").value()); QMap<QString, std::function<int()>> pluginCommands; for(const auto &plugin : plugins) { - auto *pluginInterface = qobject_cast<PluginInterface*>(plugin.instance); + auto *pluginInterface = qobject_cast<PluginInterface *>(plugin.instance); Q_CHECK_PTR(pluginInterface); QHashIterator<QString, std::function<int()>> i(pluginInterface->commands()); @@ -74,9 +89,11 @@ int main(int argc, char **argv) if(config->exists("help")) { std::cout << "smolbote " << SMOLBOTE_VERSION << ": yet another no-frills browser" << std::endl; - std::cout << "Usage: " << argv[0] << " [options] [command/URL(s)]" << std::endl << std::endl; + std::cout << "Usage: " << argv[0] << " [options] [command/URL(s)]" << std::endl + << std::endl; - std::cout << "Command-line Options: " << std::endl << config->commandlineOptions() << std::endl; + std::cout << "Command-line Options: " << std::endl + << config->commandlineOptions() << std::endl; std::cout << "Commands: " << std::endl; for(auto it = pluginCommands.constBegin(); it != pluginCommands.constEnd(); ++it) { @@ -84,10 +101,12 @@ int main(int argc, char **argv) } std::cout << std::endl; - std::cout << "Configuration Options: " << std::endl << config->configurationOptions() << std::endl; + std::cout << "Configuration Options: " << std::endl + << config->configurationOptions() << std::endl; #ifdef Q_OS_LINUX - std::cout << std::endl << "For more information refer to the manual page smolbote.7" << std::endl; + std::cout << std::endl + << "For more information refer to the manual page smolbote.7" << std::endl; #endif return 0; } |