summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGopi Krishna Menon <gopi.menon@collabora.com>2021-06-07 14:21:33 +0000
committerTor Lillqvist <tml@collabora.com>2021-06-16 14:45:35 +0200
commit4b925781760ba84e62cb847ddfe8f8c667a44c95 (patch)
tree0aac7bdda3cae5d84a0845eb42e0b6ce8d9ac43c
parent3f9fcf0e7f154e49bbffeaea925edb6055add494 (diff)
Add Active App Name Field To Crash Report
Adds a Active-App field in Crash Report to assist in investigating the crashes Change-Id: I30e5f307045b8e5def9986447551f39e70b94edc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116786 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com>
-rw-r--r--desktop/source/app/crashreport.cxx15
-rw-r--r--include/desktop/crashreport.hxx10
-rw-r--r--sfx2/Library_sfx.mk3
-rw-r--r--sfx2/source/view/viewfrm.cxx43
4 files changed, 70 insertions, 1 deletions
diff --git a/desktop/source/app/crashreport.cxx b/desktop/source/app/crashreport.cxx
index 6f3d72934d51..b6d8b14d8beb 100644
--- a/desktop/source/app/crashreport.cxx
+++ b/desktop/source/app/crashreport.cxx
@@ -43,14 +43,16 @@
#endif
osl::Mutex CrashReporter::maMutex;
+osl::Mutex CrashReporter::maActiveNameMutex;
std::unique_ptr<google_breakpad::ExceptionHandler> CrashReporter::mpExceptionHandler;
bool CrashReporter::mbInit = false;
CrashReporter::vmaKeyValues CrashReporter::maKeyValues;
-
+OUString CrashReporter::mActiveApp;
#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("DumpFile", OStringToOUString(descriptor.path(), RTL_TEXTENCODING_UTF8), CrashReporter::Write);
SAL_WARN("desktop", "minidump generated: " << descriptor.path());
@@ -68,6 +70,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("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);
@@ -159,6 +162,16 @@ void CrashReporter::writeCommonInfo()
updateMinidumpLocation();
}
+void CrashReporter::setActiveApp(const OUString& rActiveApp)
+{
+ osl::MutexGuard aGuard(maActiveNameMutex);
+ mActiveApp=rActiveApp;
+}
+
+OUString CrashReporter::currentActiveApp()
+{
+ return mActiveApp;
+}
namespace {
diff --git a/include/desktop/crashreport.hxx b/include/desktop/crashreport.hxx
index 8d55b85487d0..c16b4a7eb80b 100644
--- a/include/desktop/crashreport.hxx
+++ b/include/desktop/crashreport.hxx
@@ -56,8 +56,12 @@ public:
static bool IsDumpEnable();
+ static void setActiveApp(const OUString& rActiveApp);
+ static OUString currentActiveApp();
+
private:
static osl::Mutex maMutex;
+ static osl::Mutex maActiveNameMutex;
static bool mbInit;
typedef struct _mpair
{
@@ -72,6 +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 std::unique_ptr<google_breakpad::ExceptionHandler> mpExceptionHandler;
@@ -88,6 +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()
+ {
+ return OUString();
+ };
#endif // HAVE_FEATURE_BREAKPAD
};
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index cab55c2a3335..0120cee75b4e 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -65,6 +65,9 @@ $(eval $(call gb_Library_use_libraries,sfx,\
ucbhelper \
utl \
vcl \
+ $(if $(ENABLE_BREAKPAD), \
+ crashreport \
+ ) \
))
$(eval $(call gb_Library_use_externals,sfx,\
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index be8ea298b978..f15e0aa5bfc4 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -68,6 +68,8 @@
#include <com/sun/star/task/InteractionHandler.hpp>
#include <com/sun/star/drawing/XDrawView.hpp>
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
+#include <com/sun/star/frame/UnknownModuleException.hpp>
#include <rtl/ustrbuf.hxx>
#include <sal/log.hxx>
@@ -95,6 +97,8 @@
#include <commandpopup/CommandPopup.hxx>
+#include <desktop/crashreport.hxx>
+
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -143,6 +147,42 @@ 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);
@@ -3385,7 +3425,10 @@ 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);