diff options
-rw-r--r-- | desktop/source/app/crashreport.cxx | 30 | ||||
-rw-r--r-- | include/desktop/crashreport.hxx | 12 | ||||
-rw-r--r-- | sfx2/source/control/unoctitm.cxx | 6 |
3 files changed, 48 insertions, 0 deletions
diff --git a/desktop/source/app/crashreport.cxx b/desktop/source/app/crashreport.cxx index 7d3fc8e036b6..7d70c9603d9a 100644 --- a/desktop/source/app/crashreport.cxx +++ b/desktop/source/app/crashreport.cxx @@ -44,9 +44,11 @@ osl::Mutex CrashReporter::maMutex; osl::Mutex CrashReporter::maActiveSfxObjectNameMutex; +osl::Mutex CrashReporter::maUnoLogCmdMutex; std::unique_ptr<google_breakpad::ExceptionHandler> CrashReporter::mpExceptionHandler; bool CrashReporter::mbInit = false; CrashReporter::vmaKeyValues CrashReporter::maKeyValues; +CrashReporter::vmaloggedUnoCommands CrashReporter::maloggedUnoCommands; OUString CrashReporter::msActiveSfxObjectName; @@ -54,6 +56,7 @@ OUString CrashReporter::msActiveSfxObjectName; static bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, void* /*context*/, bool succeeded) { CrashReporter::addKeyValue("Active-SfxObject",CrashReporter::getActiveSfxObjectName(),CrashReporter::AddItem); + CrashReporter::addKeyValue("Last-4-Uno-Commands",CrashReporter::getLoggedUnoCommands(),CrashReporter::AddItem); CrashReporter::addKeyValue("DumpFile", OStringToOUString(descriptor.path(), RTL_TEXTENCODING_UTF8), CrashReporter::Write); SAL_WARN("desktop", "minidump generated: " << descriptor.path()); @@ -72,6 +75,7 @@ static bool dumpCallback(const wchar_t* path, const wchar_t* id, std::wstring_convert<std::codecvt_utf8<wchar_t>> conv1; std::string aPath = conv1.to_bytes(std::wstring(path)) + conv1.to_bytes(std::wstring(id)) + ".dmp"; CrashReporter::addKeyValue("Active-SfxObject",CrashReporter::getActiveSfxObjectName(),CrashReporter::AddItem); + CrashReporter::addKeyValue("Last-4-Uno-Commands",CrashReporter::getLoggedUnoCommands(),CrashReporter::AddItem); CrashReporter::addKeyValue("DumpFile", OStringToOUString(aPath.c_str(), RTL_TEXTENCODING_UTF8), CrashReporter::AddItem); CrashReporter::addKeyValue("GDIHandles", OUString::number(::GetGuiResources(::GetCurrentProcess(), GR_GDIOBJECTS)), CrashReporter::Write); SAL_WARN("desktop", "minidump generated: " << aPath); @@ -175,6 +179,32 @@ OUString CrashReporter::getActiveSfxObjectName() return msActiveSfxObjectName; } +void CrashReporter::logUnoCommand(const OUString& rUnoCommand) +{ + osl::MutexGuard aGuard(maUnoLogCmdMutex); + + if( maloggedUnoCommands.size() == 4 ) + maloggedUnoCommands.pop_front(); + + maloggedUnoCommands.push_back(rUnoCommand); +} + +OUString CrashReporter::getLoggedUnoCommands() +{ + osl::MutexGuard aGuard(maUnoLogCmdMutex); + + OUString aCommandSeperator=""; + OUStringBuffer aUnoCommandBuffer; + + for( auto& unocommand: maloggedUnoCommands) + { + aUnoCommandBuffer.append(aCommandSeperator); + aUnoCommandBuffer.append(unocommand); + aCommandSeperator=","; + } + return aUnoCommandBuffer.toString(); +} + namespace { OUString getCrashDirectory() diff --git a/include/desktop/crashreport.hxx b/include/desktop/crashreport.hxx index e7fd0d15d39b..403e3117117d 100644 --- a/include/desktop/crashreport.hxx +++ b/include/desktop/crashreport.hxx @@ -20,6 +20,7 @@ // vector not sort the entries #include <memory> #include <vector> +#include <deque> #include <string> namespace google_breakpad @@ -53,6 +54,9 @@ public: static void setActiveSfxObjectName(const OUString& rActiveSfxObjectName); static OUString getActiveSfxObjectName(); + static void logUnoCommand(const OUString& rUnoCommand); + static OUString getLoggedUnoCommands(); + static bool crashReportInfoExists(); static bool readSendConfig(std::string& response); @@ -62,6 +66,7 @@ public: private: static osl::Mutex maMutex; static osl::Mutex maActiveSfxObjectNameMutex; + static osl::Mutex maUnoLogCmdMutex; static bool mbInit; typedef struct _mpair { @@ -76,6 +81,8 @@ private: typedef std::vector<mpair> vmaKeyValues; static vmaKeyValues maKeyValues; // used to temporarily save entries before the old info has been uploaded + typedef std::deque<OUString> vmaloggedUnoCommands; + static vmaloggedUnoCommands maloggedUnoCommands; static OUString msActiveSfxObjectName; static std::unique_ptr<google_breakpad::ExceptionHandler> mpExceptionHandler; @@ -98,6 +105,11 @@ private: { return OUString(); } + inline static void logUnoCommand(SAL_UNUSED_PARAMETER const OUString& /*rUnoCommand*/) {}; + inline static OUString getLoggedUnoCommands() + { + return OUString(); + } #endif // HAVE_FEATURE_BREAKPAD }; diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 6228266abeb6..d973da794d71 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -77,6 +77,8 @@ #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <comphelper/lok.hxx> +#include <desktop/crashreport.hxx> + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::util; @@ -613,6 +615,10 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& aArgs, const css::uno::Reference< css::frame::XDispatchResultListener >& rListener ) { + if ( aURL.Protocol == ".uno:") + { + CrashReporter::logUnoCommand(aURL.Path); + } collectUsageInformation(aURL, aArgs); collectUIInformation(aURL, aArgs); |