/src/libreoffice/include/desktop/crashreport.hxx
Line | Count | Source |
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 | | |
14 | | #include <rtl/ustring.hxx> |
15 | | |
16 | | #include <config_features.h> |
17 | | |
18 | | #if HAVE_FEATURE_BREAKPAD |
19 | | #include <desktop/dllapi.h> |
20 | | #include <osl/mutex.hxx> |
21 | | // vector not sort the entries |
22 | | #include <memory> |
23 | | #include <vector> |
24 | | #include <deque> |
25 | | #include <string> |
26 | | |
27 | | namespace google_breakpad |
28 | | { |
29 | | class ExceptionHandler; |
30 | | } |
31 | | #endif |
32 | | |
33 | | /** |
34 | | * Provides access to the crash reporter service. |
35 | | * |
36 | | * Valid keys are: |
37 | | * * AdapterVendorId |
38 | | * * AdapterDeviceId |
39 | | * |
40 | | */ |
41 | | class |
42 | | #if HAVE_FEATURE_BREAKPAD |
43 | | // MSVC 2013 has undefined symbols for inline functions if it's exported |
44 | | CRASHREPORT_DLLPUBLIC |
45 | | #endif |
46 | | /*class*/ CrashReporter |
47 | | { |
48 | | public: |
49 | | typedef enum {AddItem, Write, Create} tAddKeyHandling; |
50 | | #if HAVE_FEATURE_BREAKPAD |
51 | | static void addKeyValue(const OUString& rKey, const OUString& rValue, tAddKeyHandling AddKeyHandling); |
52 | | |
53 | | static void installExceptionHandler(); |
54 | | static void removeExceptionHandler(); |
55 | | |
56 | | static void setActiveSfxObjectName(const OUString& rActiveSfxObjectName); |
57 | | static OUString getActiveSfxObjectName(); |
58 | | |
59 | | static void logUnoCommand(const OUString& rUnoCommand); |
60 | | static OUString getLoggedUnoCommands(); |
61 | | |
62 | | static bool crashReportInfoExists(); |
63 | | |
64 | | static bool readSendConfig(std::string& response); |
65 | | |
66 | | static bool IsDumpEnable(); |
67 | | |
68 | | private: |
69 | | static osl::Mutex maMutex; |
70 | | static osl::Mutex maActiveSfxObjectNameMutex; |
71 | | static osl::Mutex maUnoLogCmdMutex; |
72 | | static bool mbInit; |
73 | | typedef struct _mpair |
74 | | { |
75 | | OUString first; |
76 | | OUString second; |
77 | | _mpair(const OUString& First, const OUString& Second) |
78 | | { |
79 | | first = First; |
80 | | second = Second; |
81 | | }; |
82 | | } mpair; |
83 | | |
84 | | typedef std::vector<mpair> vmaKeyValues; |
85 | | static vmaKeyValues maKeyValues; // used to temporarily save entries before the old info has been uploaded |
86 | | typedef std::deque<OUString> vmaloggedUnoCommands; |
87 | | static vmaloggedUnoCommands maloggedUnoCommands; |
88 | | static OUString msActiveSfxObjectName; |
89 | | |
90 | | static std::unique_ptr<google_breakpad::ExceptionHandler> mpExceptionHandler; |
91 | | |
92 | | static std::string getIniFileName(); |
93 | | static void writeCommonInfo(); |
94 | | static void writeSystemInfo(); |
95 | | static void writeToFile(std::ios_base::openmode Openmode); |
96 | | // when we create the ExceptionHandler we have no access to the user |
97 | | // profile yet, so update when we have access |
98 | | static void updateMinidumpLocation(); |
99 | | |
100 | | #else |
101 | | // Add dummy methods for the non-breakpad case. That allows us to use |
102 | | // // the code without linking to the lib and without adding HAVE_FEATURE_BREAKPAD |
103 | | // // everywhere we want to log something to the crash report system. |
104 | 0 | inline static void addKeyValue(SAL_UNUSED_PARAMETER const OUString& /*rKey*/, SAL_UNUSED_PARAMETER const OUString& /*rValue*/, SAL_UNUSED_PARAMETER tAddKeyHandling /*AddKeyHandling*/) {}; |
105 | 24.5k | inline static void setActiveSfxObjectName(SAL_UNUSED_PARAMETER const OUString& /*rActiveSfxObjectName*/) {}; |
106 | | inline static OUString getActiveSfxObjectName() |
107 | 0 | { |
108 | 0 | return OUString(); |
109 | 0 | } |
110 | 0 | inline static void logUnoCommand(SAL_UNUSED_PARAMETER const OUString& /*rUnoCommand*/) {}; |
111 | | inline static OUString getLoggedUnoCommands() |
112 | 0 | { |
113 | 0 | return OUString(); |
114 | 0 | } |
115 | | #endif // HAVE_FEATURE_BREAKPAD |
116 | | }; |
117 | | |
118 | | #endif // INCLUDED_DESKTOP_CRASHREPORT_HXX |
119 | | |
120 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |