LibreOffice Module desktop (master)  1
crashreport.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef INCLUDED_DESKTOP_CRASHREPORT_HXX
11 #define INCLUDED_DESKTOP_CRASHREPORT_HXX
12 
13 #include <desktop/dllapi.h>
14 
15 #include <rtl/ustring.hxx>
16 #include <osl/mutex.hxx>
17 
18 #include <config_features.h>
19 
20 // vector not sort the entries
21 #include <memory>
22 #include <vector>
23 #include <deque>
24 #include <string>
25 
26 namespace google_breakpad
27 {
28 class ExceptionHandler;
29 }
30 
39 class
40 #if HAVE_FEATURE_BREAKPAD
41 // MSVC 2013 has undefined symbols for inline functions if it's exported
43 #endif
44 /*class*/ CrashReporter
45 {
46 public:
47  typedef enum {AddItem, Write, Create} tAddKeyHandling;
48 #if HAVE_FEATURE_BREAKPAD
49  static void addKeyValue(const OUString& rKey, const OUString& rValue, tAddKeyHandling AddKeyHandling);
50 
51  static void installExceptionHandler();
52  static void removeExceptionHandler();
53 
54  static void setActiveSfxObjectName(const OUString& rActiveSfxObjectName);
55  static OUString getActiveSfxObjectName();
56 
57  static void logUnoCommand(const OUString& rUnoCommand);
58  static OUString getLoggedUnoCommands();
59 
60  static bool crashReportInfoExists();
61 
62  static bool readSendConfig(std::string& response);
63 
64  static bool IsDumpEnable();
65 
66 private:
67  static osl::Mutex maMutex;
68  static osl::Mutex maActiveSfxObjectNameMutex;
69  static osl::Mutex maUnoLogCmdMutex;
70  static bool mbInit;
71  typedef struct _mpair
72  {
73  OUString first;
74  OUString second;
75  _mpair(const OUString& First, const OUString& Second)
76  {
77  first = First;
78  second = Second;
79  };
80  } mpair;
81 
82  typedef std::vector<mpair> vmaKeyValues;
83  static vmaKeyValues maKeyValues; // used to temporarily save entries before the old info has been uploaded
84  typedef std::deque<OUString> vmaloggedUnoCommands;
85  static vmaloggedUnoCommands maloggedUnoCommands;
86  static OUString msActiveSfxObjectName;
87 
88  static std::unique_ptr<google_breakpad::ExceptionHandler> mpExceptionHandler;
89 
90  static std::string getIniFileName();
91  static void writeCommonInfo();
92  static void writeSystemInfo();
93  static void writeToFile(std::ios_base::openmode Openmode);
94  // when we create the ExceptionHandler we have no access to the user
95  // profile yet, so update when we have access
96  static void updateMinidumpLocation();
97 
98 #else
99  // Add dummy methods for the non-breakpad case. That allows us to use
100  // // the code without linking to the lib and without adding HAVE_FEATURE_BREAKPAD
101  // // everywhere we want to log something to the crash report system.
102  inline static void addKeyValue(SAL_UNUSED_PARAMETER const OUString& /*rKey*/, SAL_UNUSED_PARAMETER const OUString& /*rValue*/, SAL_UNUSED_PARAMETER tAddKeyHandling /*AddKeyHandling*/) {};
103  inline static void setActiveSfxObjectName(SAL_UNUSED_PARAMETER const OUString& /*rActiveSfxObjectName*/) {};
104  inline static OUString getActiveSfxObjectName()
105  {
106  return OUString();
107  }
108  inline static void logUnoCommand(SAL_UNUSED_PARAMETER const OUString& /*rUnoCommand*/) {};
109  inline static OUString getLoggedUnoCommands()
110  {
111  return OUString();
112  }
113 #endif // HAVE_FEATURE_BREAKPAD
114 };
115 
116 #endif // INCLUDED_DESKTOP_CRASHREPORT_HXX
117 
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
std::mutex maMutex
Provides access to the crash reporter service.
Definition: crashreport.hxx:39
#define CRASHREPORT_DLLPUBLIC
Definition: dllapi.h:25
static OUString getActiveSfxObjectName()
static OUString getLoggedUnoCommands()
constexpr OUStringLiteral first
static void logUnoCommand(SAL_UNUSED_PARAMETER const OUString &)
static void setActiveSfxObjectName(SAL_UNUSED_PARAMETER const OUString &)
static void addKeyValue(SAL_UNUSED_PARAMETER const OUString &, SAL_UNUSED_PARAMETER const OUString &, SAL_UNUSED_PARAMETER tAddKeyHandling)