[Libreoffice-commits] core.git: desktop/source include/desktop sfx2/source

Gopi Krishna Menon (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 18 09:01:35 UTC 2021


 desktop/source/app/crashreport.cxx |   30 ++++++++++++++++++++++++++++++
 include/desktop/crashreport.hxx    |   12 ++++++++++++
 sfx2/source/control/unoctitm.cxx   |    6 ++++++
 3 files changed, 48 insertions(+)

New commits:
commit 781c70a8c87878ac0e53c9c4619a4d19d3d737de
Author:     Gopi Krishna Menon <gopi.menon at collabora.com>
AuthorDate: Thu Jun 17 13:23:11 2021 +0000
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Fri Jun 18 11:00:57 2021 +0200

    Add Last 4 UNO Commands To CrashReport Dump
    
    Adds last 4 uno commands executed in CrashReport to assist in investigating the crashes
    
    Change-Id: Ib7307ffc62d6d51d52f9d5e7fabefc2eaf858e5b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117388
    Tested-by: Jenkins
    Reviewed-by: Tor Lillqvist <tml at collabora.com>

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);
 


More information about the Libreoffice-commits mailing list