diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-02-07 00:19:09 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-02-27 11:51:35 +0000 |
commit | b78209ae74af5bf4fc5dacde8c9b7e709cbb1a70 (patch) | |
tree | 8ae3017f83a32786b114f93b3ce6f5996e2ffad0 /desktop | |
parent | 65694793e9588106e570d82b359c9c9e25a5cf0d (diff) |
work on adding crash report UI
Change-Id: I66f4dca3cd32381ecd52cc36490e7ee1dddf3699
Reviewed-on: https://gerrit.libreoffice.org/22566
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/app/app.cxx | 62 | ||||
-rw-r--r-- | desktop/source/app/crashreport.cxx | 15 | ||||
-rw-r--r-- | desktop/source/app/sofficemain.cxx | 22 |
3 files changed, 75 insertions, 24 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index cc69bbb60257..3d0435b43b07 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -105,6 +105,7 @@ #include <svl/itemset.hxx> #include <svl/eitem.hxx> #include <basic/sbstar.hxx> +#include <desktop/crashreport.hxx> #include <svtools/fontsubstconfig.hxx> #include <svtools/accessibilityoptions.hxx> @@ -119,6 +120,10 @@ #include <tubes/manager.hxx> #endif +#if HAVE_FEATURE_BREAKPAD +#include <fstream> +#endif + #if defined MACOSX #include <errno.h> #include <sys/wait.h> @@ -1017,6 +1022,50 @@ bool Desktop::isUIOnSessionShutdownAllowed() ::get(); } +namespace { + +bool crashReportInfoExists() +{ +#if HAVE_FEATURE_BREAKPAD + std::string path = CrashReporter::getIniFileName(); + std::ifstream aFile(path); + while (!aFile.eof()) + { + std::string line; + std::getline(aFile, line); + int sep = line.find('='); + if (sep >= 0) + { + std::string key = line.substr(0, sep); + std::string value = line.substr(sep + 1); + if (key == "DumpFile") + return true; + } + } +#endif + return false; +} + +#if HAVE_FEATURE_BREAKPAD +void handleCrashReport() +{ + static const char SERVICENAME_CRASHREPORT[] = "com.sun.star.comp.svx.CrashReportUI"; + + css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + + Reference< css::frame::XSynchronousDispatch > xRecoveryUI( + xContext->getServiceManager()->createInstanceWithContext(SERVICENAME_CRASHREPORT, xContext), + css::uno::UNO_QUERY_THROW); + + Reference< css::util::XURLTransformer > xURLParser = + css::util::URLTransformer::create(::comphelper::getProcessComponentContext()); + + css::util::URL aURL; + css::uno::Any aRet = xRecoveryUI->dispatchWithReturnValue(aURL, css::uno::Sequence< css::beans::PropertyValue >()); + bool bRet = false; + aRet >>= bRet; +} +#endif /** @short check if recovery must be started or not. @@ -1038,7 +1087,7 @@ void impl_checkRecoveryState(bool& bCrashed , bool& bRecoveryDataExists, bool& bSessionDataExists ) { - bCrashed = officecfg::Office::Recovery::RecoveryInfo::Crashed::get(); + bCrashed = officecfg::Office::Recovery::RecoveryInfo::Crashed::get() || crashReportInfoExists(); bool elements = officecfg::Office::Recovery::RecoveryList::get()-> hasElements(); bool session @@ -1085,6 +1134,8 @@ bool impl_callRecoveryUI(bool bEmergencySave , return !bEmergencySave || bRet; } +} + /* * Save all open documents so they will be reopened * the next time the application is started @@ -1092,7 +1143,6 @@ bool impl_callRecoveryUI(bool bEmergencySave , * returns sal_True if at least one document could be saved... * */ - bool Desktop::SaveTasks() { return impl_callRecoveryUI( @@ -2218,6 +2268,11 @@ void Desktop::OpenClients() // need some time, where the user won't see any results and wait for finishing the office startup... bool bAllowRecoveryAndSessionManagement = ( !rArgs.IsNoRestore() ) && ( !rArgs.IsHeadless() ); +#if HAVE_FEATURE_BREAKPAD + if (crashReportInfoExists()) + handleCrashReport(); +#endif + if ( ! bAllowRecoveryAndSessionManagement ) { try @@ -2292,6 +2347,9 @@ void Desktop::OpenClients() } } } +#if HAVE_FEATURE_BREAKPAD + CrashReporter::writeCommonInfo(); +#endif OfficeIPCThread::EnableRequests(); diff --git a/desktop/source/app/crashreport.cxx b/desktop/source/app/crashreport.cxx index 1ded7f0ed80e..6d148c56157d 100644 --- a/desktop/source/app/crashreport.cxx +++ b/desktop/source/app/crashreport.cxx @@ -9,6 +9,8 @@ #include <desktop/crashreport.hxx> +#include <config_version.h> + #include <string> #include <fstream> @@ -27,7 +29,18 @@ void CrashReporter::AddKeyValue(const OUString& rKey, const OUString& rValue) #endif -const char* CrashReporter::getIniFileName() +void CrashReporter::writeCommonInfo() +{ + // limit the amount of code that needs to be executed before the crash reporting + std::string ini_path = CrashReporter::getIniFileName(); + std::ofstream minidump_file(ini_path, std::ios_base::trunc); + minidump_file << "ProductName=LibreOffice\n"; + minidump_file << "Version=" << LIBO_VERSION_DOTTED << "\n"; + minidump_file << "URL=" << "http://127.0.0.1:8000/submit" << "\n"; + minidump_file.close(); +} + +std::string CrashReporter::getIniFileName() { // TODO: we need a generic solution for the location return "/tmp/dump.ini"; diff --git a/desktop/source/app/sofficemain.cxx b/desktop/source/app/sofficemain.cxx index 866c19859f10..3484b8437737 100644 --- a/desktop/source/app/sofficemain.cxx +++ b/desktop/source/app/sofficemain.cxx @@ -65,14 +65,6 @@ #if HAVE_FEATURE_BREAKPAD -OString getLibDir() -{ - OUString aOriginal = "$BRAND_BASE_DIR/" LIBO_LIBEXEC_FOLDER; - rtl::Bootstrap::expandMacros(aOriginal); - - return rtl::OUStringToOString(aOriginal, RTL_TEXTENCODING_UTF8); -} - #if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID static bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, void* /*context*/, bool succeeded) { @@ -80,11 +72,7 @@ static bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, std::ofstream minidump_file(ini_path, std::ios_base::app); minidump_file << "DumpFile=" << descriptor.path() << "\n";; minidump_file.close(); - // send the minidump to the server (not yet implemented) - SAL_WARN("destkop.crashreport", "minidump generated: " << descriptor.path()); - OString aCommand = getLibDir().copy(7) + "/minidump_upload " + ini_path.c_str(); - int retVal = std::system(aCommand.getStr()); - SAL_WARN_IF(retVal != 0, "destkop.crashreport", "Failed to upload minidump. Error Code: " << retVal); + SAL_WARN("crashreport", "minidump generated: " << descriptor.path()); return succeeded; } #endif @@ -93,14 +81,6 @@ static bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, extern "C" int DESKTOP_DLLPUBLIC soffice_main() { #if HAVE_FEATURE_BREAKPAD - //limit the amount of code that needs to be executed before the crash reporting - - std::string ini_path = CrashReporter::getIniFileName(); - std::ofstream minidump_file(ini_path, std::ios_base::trunc); - minidump_file << "ProductName=LibreOffice\n"; - minidump_file << "Version=" LIBO_VERSION_DOTTED "\n"; - minidump_file << "URL=http://127.0.0.1:8000/submit\n"; - minidump_file.close(); #if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID google_breakpad::MinidumpDescriptor descriptor("/tmp"); |