[Libreoffice-commits] core.git: desktop/source include/desktop sfx2/source
Gopi Krishna Menon (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jun 18 07:06:18 UTC 2021
desktop/source/app/crashreport.cxx | 20 +++++++++---------
include/desktop/crashreport.hxx | 16 +++++++-------
sfx2/source/control/shell.cxx | 16 ++++++++++++++
sfx2/source/view/viewfrm.cxx | 41 -------------------------------------
4 files changed, 35 insertions(+), 58 deletions(-)
New commits:
commit a3d89265e0be3f9ee8ae813e4aeaa90af1714348
Author: Gopi Krishna Menon <gopi.menon at collabora.com>
AuthorDate: Wed Jun 16 10:02:23 2021 +0000
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Fri Jun 18 09:05:36 2021 +0200
Add Active Sfx Object Name To CrashReport Dump
Adds Active-SfxObject field in CrashReport to assist in investigating the crashes
Change-Id: I08637a66ae95977e7afe4f5dce634b46c928a423
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117318
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 b6d8b14d8beb..7d3fc8e036b6 100644
--- a/desktop/source/app/crashreport.cxx
+++ b/desktop/source/app/crashreport.cxx
@@ -43,16 +43,17 @@
#endif
osl::Mutex CrashReporter::maMutex;
-osl::Mutex CrashReporter::maActiveNameMutex;
+osl::Mutex CrashReporter::maActiveSfxObjectNameMutex;
std::unique_ptr<google_breakpad::ExceptionHandler> CrashReporter::mpExceptionHandler;
bool CrashReporter::mbInit = false;
CrashReporter::vmaKeyValues CrashReporter::maKeyValues;
-OUString CrashReporter::mActiveApp;
+OUString CrashReporter::msActiveSfxObjectName;
+
#if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID
static bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, void* /*context*/, bool succeeded)
{
- CrashReporter::addKeyValue("Active-App",CrashReporter::currentActiveApp(),CrashReporter::AddItem);
+ CrashReporter::addKeyValue("Active-SfxObject",CrashReporter::getActiveSfxObjectName(),CrashReporter::AddItem);
CrashReporter::addKeyValue("DumpFile", OStringToOUString(descriptor.path(), RTL_TEXTENCODING_UTF8), CrashReporter::Write);
SAL_WARN("desktop", "minidump generated: " << descriptor.path());
@@ -70,7 +71,7 @@ static bool dumpCallback(const wchar_t* path, const wchar_t* id,
#endif
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-App",CrashReporter::currentActiveApp(),CrashReporter::AddItem);
+ CrashReporter::addKeyValue("Active-SfxObject",CrashReporter::getActiveSfxObjectName(),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);
@@ -162,15 +163,16 @@ void CrashReporter::writeCommonInfo()
updateMinidumpLocation();
}
-void CrashReporter::setActiveApp(const OUString& rActiveApp)
+void CrashReporter::setActiveSfxObjectName(const OUString& rActiveSfxObjectName)
{
- osl::MutexGuard aGuard(maActiveNameMutex);
- mActiveApp=rActiveApp;
+ osl::MutexGuard aGuard(maActiveSfxObjectNameMutex);
+ msActiveSfxObjectName = rActiveSfxObjectName;
}
-OUString CrashReporter::currentActiveApp()
+OUString CrashReporter::getActiveSfxObjectName()
{
- return mActiveApp;
+ osl::MutexGuard aGuard(maActiveSfxObjectNameMutex);
+ return msActiveSfxObjectName;
}
namespace {
diff --git a/include/desktop/crashreport.hxx b/include/desktop/crashreport.hxx
index c16b4a7eb80b..e7fd0d15d39b 100644
--- a/include/desktop/crashreport.hxx
+++ b/include/desktop/crashreport.hxx
@@ -50,18 +50,18 @@ public:
static void installExceptionHandler();
static void removeExceptionHandler();
+ static void setActiveSfxObjectName(const OUString& rActiveSfxObjectName);
+ static OUString getActiveSfxObjectName();
+
static bool crashReportInfoExists();
static bool readSendConfig(std::string& response);
static bool IsDumpEnable();
- static void setActiveApp(const OUString& rActiveApp);
- static OUString currentActiveApp();
-
private:
static osl::Mutex maMutex;
- static osl::Mutex maActiveNameMutex;
+ static osl::Mutex maActiveSfxObjectNameMutex;
static bool mbInit;
typedef struct _mpair
{
@@ -76,7 +76,7 @@ private:
typedef std::vector<mpair> vmaKeyValues;
static vmaKeyValues maKeyValues; // used to temporarily save entries before the old info has been uploaded
- static OUString mActiveApp;
+ static OUString msActiveSfxObjectName;
static std::unique_ptr<google_breakpad::ExceptionHandler> mpExceptionHandler;
@@ -93,11 +93,11 @@ private:
// // the code without linking to the lib and without adding HAVE_FEATURE_BREAKPAD
// // everywhere we want to log something to the crash report system.
inline static void addKeyValue(SAL_UNUSED_PARAMETER const OUString& /*rKey*/, SAL_UNUSED_PARAMETER const OUString& /*rValue*/, SAL_UNUSED_PARAMETER tAddKeyHandling /*AddKeyHandling*/) {};
- inline static void setActiveApp(SAL_UNUSED_PARAMETER const OUString& /*rActiveApp*/) {};
- inline static OUString currentActiveApp()
+ inline static void setActiveSfxObjectName(SAL_UNUSED_PARAMETER const OUString& /*rActiveSfxObjectName*/) {};
+ inline static OUString getActiveSfxObjectName()
{
return OUString();
- };
+ }
#endif // HAVE_FEATURE_BREAKPAD
};
diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx
index 78639a958a4f..5a8dc39aaaf5 100644
--- a/sfx2/source/control/shell.cxx
+++ b/sfx2/source/control/shell.cxx
@@ -47,6 +47,8 @@
#include <vector>
#include <map>
+#include <desktop/crashreport.hxx>
+
using namespace com::sun::star;
struct SfxShell_Impl: public SfxBroadcaster
@@ -289,6 +291,20 @@ void SfxShell::HandleOpenXmlFilterSettings(SfxRequest & rReq)
void SfxShell::DoActivate_Impl( SfxViewFrame *pFrame, bool bMDI )
{
+ SfxObjectShell* pObjectShell = GetObjectShell();
+ if ( pObjectShell )
+ {
+ const OUString sActiveDocName = pObjectShell->GetTitle();
+ if( !pImpl->aObjectName.startsWith(sActiveDocName) )
+ {
+ CrashReporter::setActiveSfxObjectName(pImpl->aObjectName);
+ }
+ }
+ else
+ {
+ CrashReporter::setActiveSfxObjectName(pImpl->aObjectName);
+ }
+
#ifdef DBG_UTIL
const SfxInterface *p_IF = GetInterface();
if ( !p_IF )
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index e6bb74f628be..b7fa742cabe8 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -98,8 +98,6 @@
#include <commandpopup/CommandPopup.hxx>
-#include <desktop/crashreport.hxx>
-
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -148,42 +146,6 @@ using ::com::sun::star::container::XIndexContainer;
SFX_IMPL_SUPERCLASS_INTERFACE(SfxViewFrame,SfxShell)
-static OUString lcl_getModuleId(SfxViewFrame* pFrame)
-{
- try
- {
- const auto xContext= comphelper::getProcessComponentContext();
- const Reference<frame::XFrame>& xFrame = pFrame->GetFrame().GetFrameInterface();
- const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create(xContext);
-
- return xModuleManager->identify(xFrame);
- }
- catch( css::frame::UnknownModuleException& )
- {
- return OUString();
- }
-}
-
-static OUString lcl_activeAppName(SfxViewFrame* pFrame)
-{
- const OUString aModuleId = lcl_getModuleId(pFrame);
- if ( aModuleId.startsWith("com.sun.star.text.") || aModuleId.startsWith("com.sun.star.xforms.") )
- return "Writer";
- else if ( aModuleId.startsWith("com.sun.star.sheet.") )
- return "Calc";
- else if ( aModuleId.startsWith("com.sun.star.presentation.") )
- return "Impress";
- else if ( aModuleId.startsWith("com.sun.star.drawing." ) )
- return "Draw";
- else if ( aModuleId.startsWith("com.sun.star.formula." ) )
- return "Math";
- else if ( aModuleId.startsWith("com.sun.star.sdb.") )
- return "Base";
- else
- return OUString();
-
-}
-
void SfxViewFrame::InitInterface_Impl()
{
GetStaticInterface()->RegisterChildWindow(SID_BROWSER);
@@ -3417,10 +3379,7 @@ void SfxViewFrame::UpdateDocument_Impl()
void SfxViewFrame::SetViewFrame( SfxViewFrame* pFrame )
{
if(pFrame)
- {
- CrashReporter::setActiveApp(lcl_activeAppName(pFrame));
SetSVHelpData(pFrame->m_pHelpData);
- }
SetSVWinData(pFrame ? pFrame->m_pWinData : nullptr);
More information about the Libreoffice-commits
mailing list