mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 581341 - Part 2: Hook up CrashReporter functions to IPC. r=ted
--HG-- extra : rebase_source : 3ed9d9967fbe4ea5ace629974f3f12bb156f67f8
This commit is contained in:
parent
84e67ec8c4
commit
e8e31a90e2
@ -127,4 +127,6 @@ ifdef ENABLE_TESTS
|
|||||||
TOOL_DIRS = test
|
TOOL_DIRS = test
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
include $(topsrcdir)/config/config.mk
|
||||||
|
include $(topsrcdir)/ipc/chromium/chromium-config.mk
|
||||||
include $(topsrcdir)/config/rules.mk
|
include $(topsrcdir)/config/rules.mk
|
||||||
|
@ -37,6 +37,9 @@
|
|||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
#include "mozilla/dom/CrashReporterChild.h"
|
||||||
|
#include "nsXULAppAPI.h"
|
||||||
|
|
||||||
#include "nsExceptionHandler.h"
|
#include "nsExceptionHandler.h"
|
||||||
|
|
||||||
#if defined(XP_WIN32)
|
#if defined(XP_WIN32)
|
||||||
@ -112,6 +115,8 @@ using google_breakpad::CrashGenerationServer;
|
|||||||
using google_breakpad::ClientInfo;
|
using google_breakpad::ClientInfo;
|
||||||
using mozilla::Mutex;
|
using mozilla::Mutex;
|
||||||
using mozilla::MutexAutoLock;
|
using mozilla::MutexAutoLock;
|
||||||
|
using mozilla::dom::CrashReporterChild;
|
||||||
|
using mozilla::dom::PCrashReporterChild;
|
||||||
|
|
||||||
namespace CrashReporter {
|
namespace CrashReporter {
|
||||||
|
|
||||||
@ -801,7 +806,7 @@ nsresult SetExceptionHandler(nsILocalFile* aXREDirectory,
|
|||||||
|
|
||||||
bool GetEnabled()
|
bool GetEnabled()
|
||||||
{
|
{
|
||||||
return gExceptionHandler != nsnull && !gExceptionHandler->IsOutOfProcess();
|
return gExceptionHandler != nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetMinidumpPath(nsAString& aPath)
|
bool GetMinidumpPath(nsAString& aPath)
|
||||||
@ -1095,11 +1100,9 @@ static PLDHashOperator EnumerateEntries(const nsACString& key,
|
|||||||
return PL_DHASH_NEXT;
|
return PL_DHASH_NEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult AnnotateCrashReport(const nsACString& key, const nsACString& data)
|
static nsresult
|
||||||
|
EscapeAnnotation(const nsACString& key, nsCString& data)
|
||||||
{
|
{
|
||||||
if (!GetEnabled())
|
|
||||||
return NS_ERROR_NOT_INITIALIZED;
|
|
||||||
|
|
||||||
if (DoFindInReadable(key, NS_LITERAL_CSTRING("=")) ||
|
if (DoFindInReadable(key, NS_LITERAL_CSTRING("=")) ||
|
||||||
DoFindInReadable(key, NS_LITERAL_CSTRING("\n")))
|
DoFindInReadable(key, NS_LITERAL_CSTRING("\n")))
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
@ -1107,16 +1110,35 @@ nsresult AnnotateCrashReport(const nsACString& key, const nsACString& data)
|
|||||||
if (DoFindInReadable(data, NS_LITERAL_CSTRING("\0")))
|
if (DoFindInReadable(data, NS_LITERAL_CSTRING("\0")))
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
nsCString escapedData(data);
|
|
||||||
|
|
||||||
// escape backslashes
|
// escape backslashes
|
||||||
ReplaceChar(escapedData, NS_LITERAL_CSTRING("\\"),
|
ReplaceChar(data, NS_LITERAL_CSTRING("\\"),
|
||||||
NS_LITERAL_CSTRING("\\\\"));
|
NS_LITERAL_CSTRING("\\\\"));
|
||||||
// escape newlines
|
// escape newlines
|
||||||
ReplaceChar(escapedData, NS_LITERAL_CSTRING("\n"),
|
ReplaceChar(data, NS_LITERAL_CSTRING("\n"),
|
||||||
NS_LITERAL_CSTRING("\\n"));
|
NS_LITERAL_CSTRING("\\n"));
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
nsresult rv = crashReporterAPIData_Hash->Put(key, escapedData);
|
nsresult AnnotateCrashReport(const nsACString& key, const nsACString& data)
|
||||||
|
{
|
||||||
|
if (!GetEnabled())
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
|
nsCString escapedData(data);
|
||||||
|
nsresult rv = EscapeAnnotation(key, escapedData);
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
return rv;
|
||||||
|
|
||||||
|
if (XRE_GetProcessType() != GeckoProcessType_Default) {
|
||||||
|
PCrashReporterChild* reporter = CrashReporterChild::GetCrashReporter();
|
||||||
|
if (!reporter)
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
if (!reporter->SendAnnotateCrashReport(nsCString(key), escapedData))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
crashReporterAPIData_Hash->Put(key, escapedData);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// now rebuild the file contents
|
// now rebuild the file contents
|
||||||
@ -1135,6 +1157,24 @@ nsresult AppendAppNotesToCrashReport(const nsACString& data)
|
|||||||
if (DoFindInReadable(data, NS_LITERAL_CSTRING("\0")))
|
if (DoFindInReadable(data, NS_LITERAL_CSTRING("\0")))
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
|
if (XRE_GetProcessType() != GeckoProcessType_Default) {
|
||||||
|
PCrashReporterChild* reporter = CrashReporterChild::GetCrashReporter();
|
||||||
|
if (!reporter)
|
||||||
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
|
// Since we don't go through AnnotateCrashReport in the parent process,
|
||||||
|
// we must ensure that the data is escaped and valid before the parent
|
||||||
|
// sees it.
|
||||||
|
nsCString escapedData(data);
|
||||||
|
nsresult rv = EscapeAnnotation(NS_LITERAL_CSTRING("Notes"), escapedData);
|
||||||
|
if (NS_FAILED(rv))
|
||||||
|
return rv;
|
||||||
|
|
||||||
|
if (!reporter->SendAppendAppNotes(escapedData))
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
notesField->Append(data);
|
notesField->Append(data);
|
||||||
return AnnotateCrashReport(NS_LITERAL_CSTRING("Notes"), *notesField);
|
return AnnotateCrashReport(NS_LITERAL_CSTRING("Notes"), *notesField);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user