1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-03 09:29:30 +02:00

Add debug report (crash report) to Help menu

This captures crashes on Windows along with the stack backtrace.

On Linux (fedora 21 at least), the necessary function to enable
capture is not included in the system wx libs.  But, a self built
version works fine and capture the backtrace, so I'm assuming
other distros will probably work as well.

On OSX, the crashes are caught, but it does not include the
backtrace.

But, really, the backtraces aren't all that useful in a release
build since we don't ship with debug symbols and optimization
plays havoc with proper backtraces anyway.

The real benefit will be for the support folks as they can now
get consistent info from user by asking the to generate a report
from the "Help->Generate Support Data" menu item.
This commit is contained in:
Leland Lucius 2015-04-18 05:06:28 -05:00
parent 2a9690b902
commit 923827966c
7 changed files with 122 additions and 2 deletions

View File

@ -99,6 +99,12 @@ It handles initialization and termination by subclassing wxApp.
#include "import/Import.h"
#if defined(EXPERIMENTAL_CRASH_REPORT)
#include <wx/debugrpt.h>
#include <wx/evtloop.h>
#include <wx/textdlg.h>
#endif
#ifdef EXPERIMENTAL_SCOREALIGN
#include "effects/ScoreAlignDialog.h"
#endif
@ -184,6 +190,13 @@ It handles initialization and termination by subclassing wxApp.
# pragma comment(lib, "libvamp")
# endif
# if defined(EXPERIMENTAL_CRASH_REPORT)
# if defined(__WXDEBUG__)
# pragma comment(lib, "wxmsw28ud_qa")
# else
# pragma comment(lib, "wxmsw28u_qa")
# endif
# endif
#endif //(__WXMSW__)
#include "../images/AudacityLogoWithName.xpm"
@ -925,7 +938,9 @@ bool AudacityApp::ShouldShowMissingAliasedFileWarning()
AudacityLogger *AudacityApp::GetLogger()
{
return static_cast<AudacityLogger *>(wxLog::GetActiveTarget());
// Use dynamic_cast so that we get a NULL ptr if we haven't yet
// setup our logger.
return dynamic_cast<AudacityLogger *>(wxLog::GetActiveTarget());
}
void AudacityApp::InitLang( const wxString & lang )
@ -984,12 +999,55 @@ void AudacityApp::InitLang( const wxString & lang )
Internat::Init();
}
// Only used when checking plugins
void AudacityApp::OnFatalException()
{
#if defined(EXPERIMENTAL_CRASH_REPORT)
GenerateCrashReport(wxDebugReport::Context_Exception);
#endif
exit(-1);
}
#if defined(EXPERIMENTAL_CRASH_REPORT)
void AudacityApp::GenerateCrashReport(wxDebugReport::Context ctx)
{
wxDebugReportCompress rpt;
rpt.AddAll(ctx);
wxFileName fn(FileNames::DataDir(), wxT("audacity.cfg"));
rpt.AddFile(fn.GetFullPath(), wxT("Audacity Configuration"));
rpt.AddFile(FileNames::PluginRegistry(), wxT("Plugin Registry"));
rpt.AddFile(FileNames::PluginSettings(), wxT("Plugin Settings"));
AudacityLogger *logger = GetLogger();
if (logger)
{
rpt.AddText(wxT("log.txt"), logger->GetLog(), wxT("Audacity Log"));
}
bool ok = wxDebugReportPreviewStd().Show(rpt);
#if defined(__WXMSW__)
wxEventLoop::SetCriticalWindow(NULL);
#endif
if (ok && rpt.Process())
{
wxTextEntryDialog dlg(NULL,
_("Report generated to:"),
_("Audacity Support Data"),
rpt.GetCompressedFileName(),
wxOK | wxCENTER);
dlg.ShowModal();
wxLogMessage(wxT("Report generated to: %s"),
rpt.GetCompressedFileName().c_str());
rpt.Reset();
}
}
#endif
#if defined(__WXGTK__)
// On wxGTK, there's a focus issue where dialogs do not automatically pass focus
// to the first child. This means that you can use the keyboard to navigate within
@ -1014,6 +1072,15 @@ int AudacityApp::FilterEvent(wxEvent & event)
}
#endif
AudacityApp::AudacityApp()
{
#if defined(EXPERIMENTAL_CRASH_REPORT)
#if defined(wxUSE_ON_FATAL_EXCEPTION) && wxUSE_ON_FATAL_EXCEPTION
wxHandleFatalExceptions();
#endif
#endif
}
// The `main program' equivalent, creating the windows and returning the
// main frame
bool AudacityApp::OnInit()

View File

@ -31,6 +31,10 @@
#include "ondemand/ODTaskThread.h"
#include "Experimental.h"
#if defined(EXPERIMENTAL_CRASH_REPORT)
#include <wx/debugrpt.h>
#endif
class IPCServ;
class Importer;
class CommandHandler;
@ -98,6 +102,7 @@ class BlockFile;
class AudacityApp:public wxApp {
public:
AudacityApp();
virtual bool OnInit(void);
void FinishInits();
#if wxCHECK_VERSION(3, 0, 0)
@ -201,6 +206,10 @@ class AudacityApp:public wxApp {
AudacityLogger *GetLogger();
#if defined(EXPERIMENTAL_CRASH_REPORT)
void GenerateCrashReport(wxDebugReport::Context ctx);
#endif
#if defined(__WXGTK__)
/** \brief This flag is set true when in a keyboard event handler.
* Used to work around a hang issue with ibus (bug 154) */

View File

@ -259,6 +259,13 @@ void AudacityLogger::Show(bool show)
Flush();
}
#if defined(EXPERIMENTAL_CRASH_REPORT)
wxString AudacityLogger::GetLog()
{
return mBuffer;
}
#endif
void AudacityLogger::OnCloseWindow(wxCloseEvent & WXUNUSED(e))
{
#if defined(__WXMAC__)

View File

@ -22,6 +22,8 @@
#include <wx/textctrl.h>
#include <wx/string.h>
#include "Experimental.h"
class AudacityLogger:public wxEvtHandler, public wxLog {
public:
AudacityLogger();
@ -30,6 +32,10 @@ class AudacityLogger:public wxEvtHandler, public wxLog {
void Show(bool show = true);
void Destroy();
#if defined(EXPERIMENTAL_CRASH_REPORT)
wxString GetLog();
#endif
protected:
virtual void Flush();
virtual void DoLogString(const wxChar *szString, time_t t);

View File

@ -178,4 +178,11 @@
// You must define EXPERIMENTAL_SCRUBBING_BASIC if you enable this:
#define EXPERIMENTAL_SCRUBBING_SCROLL_WHEEL
// Define to include crash reporting
#define EXPERIMENTAL_CRASH_REPORT
#if !defined(wxUSE_DEBUGREPORT) || !wxUSE_DEBUGREPORT
#undef EXPERIMENTAL_CRASH_REPORT
#endif
#endif

View File

@ -36,6 +36,7 @@ simplifies construction of menu items.
#include <limits>
#include <math.h>
#include <wx/defs.h>
#include <wx/docview.h>
#include <wx/msgdlg.h>
@ -117,6 +118,10 @@ simplifies construction of menu items.
#include "CaptureEvents.h"
#include "Snap.h"
#if defined(EXPERIMENTAL_CRASH_REPORT)
#include <wx/debugrpt.h>
#endif
#ifdef EXPERIMENTAL_SCOREALIGN
#include "effects/ScoreAlignDialog.h"
#include "audioreader.h"
@ -1061,6 +1066,10 @@ void AudacityProject::CreateMenusAndCommands()
c->AddItem(wxT("Log"), _("Show &Log..."), FN(OnShowLog));
#if defined(EXPERIMENTAL_CRASH_REPORT)
c->AddItem(wxT("CrashReport"), _("&Generate Support Data..."), FN(OnCrashReport));
#endif
#ifndef __WXMAC__
c->AddSeparator();
#endif
@ -6175,6 +6184,18 @@ void AudacityProject::OnBenchmark()
::RunBenchmark(this);
}
#if defined(EXPERIMENTAL_CRASH_REPORT)
void AudacityProject::OnCrashReport()
{
// Change to "1" to test a real crash
#if 0
char *p = 0;
*p = 1234;
#endif
wxGetApp().GenerateCrashReport(wxDebugReport::Context_Current);
}
#endif
void AudacityProject::OnScreenshot()
{
::OpenScreenshotTools();

View File

@ -372,6 +372,9 @@ void OnManual();
void OnShowLog();
void OnHelpWelcome();
void OnBenchmark();
#if defined(EXPERIMENTAL_CRASH_REPORT)
void OnCrashReport();
#endif
void OnScreenshot();
void OnAudioDeviceInfo();