[Libreoffice-commits] core.git: desktop/inc desktop/Library_sofficeapp.mk desktop/source include/desktop

Markus Mohrhard markus.mohrhard at googlemail.com
Thu Feb 25 00:50:34 UTC 2016


 desktop/Library_sofficeapp.mk               |    1 
 desktop/inc/lib/init.hxx                    |    2 
 desktop/source/app/crashreport.cxx          |   33 ++++++++++++++++
 desktop/source/app/sofficemain.cxx          |    2 
 desktop/source/app/sofficemain.h            |    2 
 desktop/source/inc/desktopdllapi.h          |   24 -----------
 desktop/source/pkgchk/unopkg/unopkg_app.cxx |    2 
 desktop/source/pkgchk/unopkg/unopkg_main.h  |    2 
 include/desktop/crashreport.hxx             |   57 ++++++++++++++++++++++++++++
 include/desktop/dllapi.h                    |   24 +++++++++++
 10 files changed, 120 insertions(+), 29 deletions(-)

New commits:
commit 98a8eafa915b8d57b8bdccab9981e537d77f6f4a
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Nov 25 16:50:22 2015 +0100

    add way to add additional information to the crash report
    
    We can add several additional key value pairs during the execution of
    the program that will be used on the server to show more information.
    
    Change-Id: I4102adc15fc821415fa0b997ca7fe0dc4f7abcec
    Reviewed-on: https://gerrit.libreoffice.org/22553
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index 13b8115..c7e1e69 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -87,6 +87,7 @@ $(eval $(call gb_Library_add_exception_objects,sofficeapp,\
     desktop/source/app/check_ext_deps \
     desktop/source/app/cmdlineargs \
     desktop/source/app/cmdlinehelp \
+    desktop/source/app/crashreport \
     desktop/source/app/desktopcontext \
     desktop/source/app/desktopresid \
     desktop/source/app/dispatchwatcher \
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index d077297..5b386e4 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -16,7 +16,7 @@
 #include <com/sun/star/lang/XComponent.hpp>
 #include <memory>
 #include <map>
-#include "../../source/inc/desktopdllapi.h"
+#include <desktop/dllapi.h>
 #include <osl/thread.h>
 
 class LOKInteractionHandler;
diff --git a/desktop/source/app/crashreport.cxx b/desktop/source/app/crashreport.cxx
new file mode 100644
index 0000000..0bde059
--- /dev/null
+++ b/desktop/source/app/crashreport.cxx
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <desktop/crashreport.hxx>
+
+#include <string>
+#include <fstream>
+
+osl::Mutex CrashReporter::maMutex;
+
+#if HAVE_FEATURE_BREAKPAD
+void CrashReporter::AddKeyValue(const OUString& rKey, const OUString& rValue)
+{
+    osl::MutexGuard aGuard(maMutex);
+    std::string ini_path = getIniFileName();
+    std::ofstream ini_file(ini_path, std::ios_base::app);
+    ini_file << rtl::OUStringToOString(rKey, RTL_TEXTENCODING_UTF8).getStr() << "=";
+    ini_file << rtl::OUStringToOString(rValue, RTL_TEXTENCODING_UTF8).getStr() << "\n";
+}
+#endif
+
+const char* CrashReporter::getIniFileName()
+{
+    return "/tmp/dump.ini";
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/source/app/sofficemain.cxx b/desktop/source/app/sofficemain.cxx
index abdcd37..7acd97c 100644
--- a/desktop/source/app/sofficemain.cxx
+++ b/desktop/source/app/sofficemain.cxx
@@ -21,7 +21,7 @@
 #include <config_features.h>
 #include <config_folders.h>
 
-#include "desktopdllapi.h"
+#include <desktop/dllapi.h>
 
 #include "app.hxx"
 #include "exithelper.h"
diff --git a/desktop/source/app/sofficemain.h b/desktop/source/app/sofficemain.h
index d0a9988..c291df7 100644
--- a/desktop/source/app/sofficemain.h
+++ b/desktop/source/app/sofficemain.h
@@ -20,7 +20,7 @@
 #ifndef INCLUDED_DESKTOP_SOURCE_APP_SOFFICEMAIN_H
 #define INCLUDED_DESKTOP_SOURCE_APP_SOFFICEMAIN_H
 
-#include "desktopdllapi.h"
+#include <desktop/dllapi.h>
 
 #if defined __cplusplus
 extern "C" {
diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx
index d3afd07..93fa127 100644
--- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx
+++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx
@@ -18,7 +18,7 @@
  */
 
 
-#include "desktopdllapi.h"
+#include <desktop/dllapi.h>
 #include "dp_misc.h"
 #include "unopkg_main.h"
 #include "unopkg_shared.h"
diff --git a/desktop/source/pkgchk/unopkg/unopkg_main.h b/desktop/source/pkgchk/unopkg/unopkg_main.h
index 6cac46a..bfd9ee6 100644
--- a/desktop/source/pkgchk/unopkg/unopkg_main.h
+++ b/desktop/source/pkgchk/unopkg/unopkg_main.h
@@ -20,7 +20,7 @@
 #ifndef INCLUDED_DESKTOP_SOURCE_PKGCHK_UNOPKG_UNOPKG_MAIN_H
 #define INCLUDED_DESKTOP_SOURCE_PKGCHK_UNOPKG_UNOPKG_MAIN_H
 
-#include "desktopdllapi.h"
+#include <desktop/dllapi.h>
 
 #if defined __cplusplus
 extern "C" {
diff --git a/include/desktop/crashreport.hxx b/include/desktop/crashreport.hxx
new file mode 100644
index 0000000..ace76c7
--- /dev/null
+++ b/include/desktop/crashreport.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_DESKTOP_CRASHREPORT_HXX
+#define INCLUDED_DESKTOP_CRASHREPORT_HXX
+
+#include <desktop/dllapi.h>
+
+#include <rtl/ustring.hxx>
+#include <osl/mutex.hxx>
+
+#include <config_features.h>
+
+#include <map>
+
+/**
+ * Provides access to the crash reporter service.
+ *
+ * Valid keys are:
+ *      * AdapterVendorId
+ *      * AdapterDeviceId
+ *
+ */
+class DESKTOP_DLLPUBLIC CrashReporter
+{
+public:
+    static void AddKeyValue(const OUString& rKey, const OUString& rValue);
+
+    const char* getIniFileName();
+
+private:
+
+    static std::map<OUString, OUString> maValueMap;
+
+    static osl::Mutex maMutex;
+};
+
+// Add dummy methods for the non-breakpad case. That allows us to use
+// the code without linking to the lib and without adding HAVE_FEATURE_BREAKPAD
+// everywhere we want to log something to the crash report system.
+#if HAVE_FEATURE_BREAKPAD
+#else
+void CrashReporter::AddKeyValue(const OUString& /*rKey*/, const OUString& /*rValue*/)
+{
+}
+#endif
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/source/inc/desktopdllapi.h b/include/desktop/dllapi.h
similarity index 100%
rename from desktop/source/inc/desktopdllapi.h
rename to include/desktop/dllapi.h


More information about the Libreoffice-commits mailing list