зеркало из https://github.com/mozilla/gecko-dev.git
Bug 379290 - Add env var to auto submit crashes r=gsvelto
MozReview-Commit-ID: HguIy4GKMb0 --HG-- extra : rebase_source : ae9f9b5276f8b7c8cb448999ce13bd0a13c8eee2
This commit is contained in:
Родитель
5b9ee89503
Коммит
3531136866
|
@ -44,6 +44,7 @@ string gEventsPath;
|
||||||
string gPingPath;
|
string gPingPath;
|
||||||
int gArgc;
|
int gArgc;
|
||||||
char** gArgv;
|
char** gArgv;
|
||||||
|
bool gAutoSubmit;
|
||||||
|
|
||||||
enum SubmissionResult {Succeeded, Failed};
|
enum SubmissionResult {Succeeded, Failed};
|
||||||
|
|
||||||
|
@ -57,6 +58,10 @@ static const char kMemoryReportExtension[] = ".memory.json.gz";
|
||||||
|
|
||||||
void UIError(const string& message)
|
void UIError(const string& message)
|
||||||
{
|
{
|
||||||
|
if (gAutoSubmit) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
string errorMessage;
|
string errorMessage;
|
||||||
if (!gStrings[ST_CRASHREPORTERERROR].empty()) {
|
if (!gStrings[ST_CRASHREPORTERERROR].empty()) {
|
||||||
char buf[2048];
|
char buf[2048];
|
||||||
|
@ -647,13 +652,19 @@ int main(int argc, char** argv)
|
||||||
gArgc = argc;
|
gArgc = argc;
|
||||||
gArgv = argv;
|
gArgv = argv;
|
||||||
|
|
||||||
|
string autoSubmitEnv = UIGetEnv("MOZ_CRASHREPORTER_AUTO_SUBMIT");
|
||||||
|
if (!autoSubmitEnv.empty()) {
|
||||||
|
gAutoSubmit = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ReadConfig()) {
|
if (!ReadConfig()) {
|
||||||
UIError("Couldn't read configuration.");
|
UIError("Couldn't read configuration.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!UIInit())
|
if (!UIInit()) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (argc == 3) {
|
if (argc == 3) {
|
||||||
if (!strcmp(argv[1], "--full")) {
|
if (!strcmp(argv[1], "--full")) {
|
||||||
|
@ -666,7 +677,9 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
if (gReporterDumpFile.empty()) {
|
if (gReporterDumpFile.empty()) {
|
||||||
// no dump file specified, run the default UI
|
// no dump file specified, run the default UI
|
||||||
UIShowDefaultUI();
|
if (!gAutoSubmit) {
|
||||||
|
UIShowDefaultUI();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Start by running minidump analyzer to gather stack traces.
|
// Start by running minidump analyzer to gather stack traces.
|
||||||
string reporterDumpFile = gReporterDumpFile;
|
string reporterDumpFile = gReporterDumpFile;
|
||||||
|
@ -810,13 +823,13 @@ int main(int argc, char** argv)
|
||||||
sendURL = urlEnv;
|
sendURL = urlEnv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// see if this version has been end-of-lifed
|
// see if this version has been end-of-lifed
|
||||||
if (queryParameters.find("Version") != queryParameters.end() &&
|
if (queryParameters.find("Version") != queryParameters.end() &&
|
||||||
CheckEndOfLifed(queryParameters["Version"])) {
|
CheckEndOfLifed(queryParameters["Version"])) {
|
||||||
UIError(gStrings[ST_ERROR_ENDOFLIFE]);
|
UIError(gStrings[ST_ERROR_ENDOFLIFE]);
|
||||||
DeleteDump();
|
DeleteDump();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringTable files;
|
StringTable files;
|
||||||
files["upload_file_minidump"] = gReporterDumpFile;
|
files["upload_file_minidump"] = gReporterDumpFile;
|
||||||
|
|
|
@ -93,6 +93,7 @@ namespace CrashReporter {
|
||||||
extern std::string gEventsPath;
|
extern std::string gEventsPath;
|
||||||
extern int gArgc;
|
extern int gArgc;
|
||||||
extern char** gArgv;
|
extern char** gArgv;
|
||||||
|
extern bool gAutoSubmit;
|
||||||
|
|
||||||
void UIError(const std::string& message);
|
void UIError(const std::string& message);
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ GThread* gSendThreadID;
|
||||||
// From crashreporter_linux.cpp
|
// From crashreporter_linux.cpp
|
||||||
void SaveSettings();
|
void SaveSettings();
|
||||||
void SendReport();
|
void SendReport();
|
||||||
|
void DisableGUIAndSendReport();
|
||||||
void TryInitGnome();
|
void TryInitGnome();
|
||||||
void UpdateSubmit();
|
void UpdateSubmit();
|
||||||
|
|
||||||
|
@ -93,7 +94,9 @@ static bool RestartApplication()
|
||||||
// Quit the app, used as a timeout callback
|
// Quit the app, used as a timeout callback
|
||||||
static gboolean CloseApp(gpointer data)
|
static gboolean CloseApp(gpointer data)
|
||||||
{
|
{
|
||||||
gtk_main_quit();
|
if (!gAutoSubmit) {
|
||||||
|
gtk_main_quit();
|
||||||
|
}
|
||||||
g_thread_join(gSendThreadID);
|
g_thread_join(gSendThreadID);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -211,10 +214,13 @@ gpointer SendThread(gpointer args)
|
||||||
}
|
}
|
||||||
|
|
||||||
SendCompleted(success, response);
|
SendCompleted(success, response);
|
||||||
// Apparently glib is threadsafe, and will schedule this
|
|
||||||
// on the main thread, see:
|
if (!gAutoSubmit) {
|
||||||
// http://library.gnome.org/devel/gtk-faq/stable/x499.html
|
// Apparently glib is threadsafe, and will schedule this
|
||||||
g_idle_add(ReportCompleted, (gpointer)success);
|
// on the main thread, see:
|
||||||
|
// http://library.gnome.org/devel/gtk-faq/stable/x499.html
|
||||||
|
g_idle_add(ReportCompleted, (gpointer)success);
|
||||||
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -243,7 +249,7 @@ static void MaybeSubmitReport()
|
||||||
{
|
{
|
||||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gSubmitReportCheck))) {
|
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gSubmitReportCheck))) {
|
||||||
gDidTrySend = true;
|
gDidTrySend = true;
|
||||||
SendReport();
|
DisableGUIAndSendReport();
|
||||||
} else {
|
} else {
|
||||||
gtk_main_quit();
|
gtk_main_quit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,16 @@ void SaveSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendReport()
|
void SendReport()
|
||||||
|
{
|
||||||
|
#ifdef MOZ_ENABLE_GCONF
|
||||||
|
LoadProxyinfo();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// spawn a thread to do the sending
|
||||||
|
gSendThreadID = g_thread_create(SendThread, nullptr, TRUE, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisableGUIAndSendReport()
|
||||||
{
|
{
|
||||||
// disable all our gui controls, show the throbber + change the progress text
|
// disable all our gui controls, show the throbber + change the progress text
|
||||||
gtk_widget_set_sensitive(gSubmitReportCheck, FALSE);
|
gtk_widget_set_sensitive(gSubmitReportCheck, FALSE);
|
||||||
|
@ -112,13 +122,7 @@ void SendReport()
|
||||||
gtk_label_set_text(GTK_LABEL(gProgressLabel),
|
gtk_label_set_text(GTK_LABEL(gProgressLabel),
|
||||||
gStrings[ST_REPORTDURINGSUBMIT].c_str());
|
gStrings[ST_REPORTDURINGSUBMIT].c_str());
|
||||||
|
|
||||||
#ifdef MOZ_ENABLE_GCONF
|
SendReport();
|
||||||
LoadProxyinfo();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// and spawn a thread to do the sending
|
|
||||||
GError* err;
|
|
||||||
gSendThreadID = g_thread_create(SendThread, nullptr, TRUE, &err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShowReportInfo(GtkTextView* viewReportTextView)
|
static void ShowReportInfo(GtkTextView* viewReportTextView)
|
||||||
|
@ -391,6 +395,12 @@ bool UIShowCrashUI(const StringTable& files,
|
||||||
if (gQueryParameters.find("URL") != gQueryParameters.end())
|
if (gQueryParameters.find("URL") != gQueryParameters.end())
|
||||||
gURLParameter = gQueryParameters["URL"];
|
gURLParameter = gQueryParameters["URL"];
|
||||||
|
|
||||||
|
if (gAutoSubmit) {
|
||||||
|
SendReport();
|
||||||
|
CloseApp(nullptr);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
gWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
gWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
gtk_window_set_title(GTK_WINDOW(gWindow),
|
gtk_window_set_title(GTK_WINDOW(gWindow),
|
||||||
gStrings[ST_CRASHREPORTERTITLE].c_str());
|
gStrings[ST_CRASHREPORTERTITLE].c_str());
|
||||||
|
|
|
@ -111,6 +111,12 @@ static bool RestartApplication()
|
||||||
gQueryParameters = queryParameters;
|
gQueryParameters = queryParameters;
|
||||||
gSendURL = sendURL;
|
gSendURL = sendURL;
|
||||||
|
|
||||||
|
if (gAutoSubmit) {
|
||||||
|
gDidTrySend = true;
|
||||||
|
[self sendReport];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
[mWindow setTitle:Str(ST_CRASHREPORTERTITLE)];
|
[mWindow setTitle:Str(ST_CRASHREPORTERTITLE)];
|
||||||
[mHeaderLabel setStringValue:Str(ST_CRASHREPORTERHEADER)];
|
[mHeaderLabel setStringValue:Str(ST_CRASHREPORTERHEADER)];
|
||||||
|
|
||||||
|
@ -537,12 +543,17 @@ static bool RestartApplication()
|
||||||
{
|
{
|
||||||
if (![self setupPost]) {
|
if (![self setupPost]) {
|
||||||
LogMessage("Crash report submission failed: could not set up POST data");
|
LogMessage("Crash report submission failed: could not set up POST data");
|
||||||
[self setStringFitVertically:mProgressText
|
|
||||||
|
if (gAutoSubmit) {
|
||||||
|
[NSApp terminate:self];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self setStringFitVertically:mProgressText
|
||||||
string:Str(ST_SUBMITFAILED)
|
string:Str(ST_SUBMITFAILED)
|
||||||
resizeWindow:YES];
|
resizeWindow:YES];
|
||||||
// quit after 5 seconds
|
// quit after 5 seconds
|
||||||
[self performSelector:@selector(closeMeDown:) withObject:nil
|
[self performSelector:@selector(closeMeDown:) withObject:nil
|
||||||
afterDelay:5.0];
|
afterDelay:5.0];
|
||||||
}
|
}
|
||||||
|
|
||||||
[NSThread detachNewThreadSelector:@selector(uploadThread:)
|
[NSThread detachNewThreadSelector:@selector(uploadThread:)
|
||||||
|
@ -627,6 +638,10 @@ static bool RestartApplication()
|
||||||
|
|
||||||
SendCompleted(success, reply);
|
SendCompleted(success, reply);
|
||||||
|
|
||||||
|
if (gAutoSubmit) {
|
||||||
|
[NSApp terminate:self];
|
||||||
|
}
|
||||||
|
|
||||||
[mProgressIndicator stopAnimation:self];
|
[mProgressIndicator stopAnimation:self];
|
||||||
if (success) {
|
if (success) {
|
||||||
[self setStringFitVertically:mProgressText
|
[self setStringFitVertically:mProgressText
|
||||||
|
@ -766,8 +781,12 @@ bool UIInit()
|
||||||
gStrings["isRTL"] == "yes")
|
gStrings["isRTL"] == "yes")
|
||||||
gRTLlayout = true;
|
gRTLlayout = true;
|
||||||
|
|
||||||
[NSBundle loadNibNamed:(gRTLlayout ? @"MainMenuRTL" : @"MainMenu")
|
if (gAutoSubmit) {
|
||||||
owner:NSApp];
|
gUI = [[CrashReporterUI alloc] init];
|
||||||
|
} else {
|
||||||
|
[NSBundle loadNibNamed:(gRTLlayout ? @"MainMenuRTL" : @"MainMenu")
|
||||||
|
owner:NSApp];
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -414,7 +414,14 @@ static DWORD WINAPI SendThreadProc(LPVOID param)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PostMessage(td->hDlg, WM_UPLOADCOMPLETE, finishedOk ? 1 : 0, 0);
|
if (gAutoSubmit) {
|
||||||
|
// Ordinarily this is done on the main thread in CrashReporterDialogProc,
|
||||||
|
// for auto submit we don't run that and it should be safe to finish up
|
||||||
|
// here as is done on other platforms.
|
||||||
|
SendCompleted(finishedOk, WideToUTF8(gSendData.serverResponse));
|
||||||
|
} else {
|
||||||
|
PostMessage(td->hDlg, WM_UPLOADCOMPLETE, finishedOk ? 1 : 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1357,6 +1364,16 @@ bool UIShowCrashUI(const StringTable& files,
|
||||||
gStrings["isRTL"] == "yes")
|
gStrings["isRTL"] == "yes")
|
||||||
gRTLlayout = true;
|
gRTLlayout = true;
|
||||||
|
|
||||||
|
if (gAutoSubmit) {
|
||||||
|
gSendData.queryParameters = gQueryParameters;
|
||||||
|
|
||||||
|
gThreadHandle = CreateThread(nullptr, 0, SendThreadProc, &gSendData, 0,
|
||||||
|
nullptr);
|
||||||
|
WaitForSingleObject(gThreadHandle, INFINITE);
|
||||||
|
// SendCompleted was called from SendThreadProc
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return 1 == DialogBoxParamMaybeRTL(IDD_SENDDIALOG, nullptr,
|
return 1 == DialogBoxParamMaybeRTL(IDD_SENDDIALOG, nullptr,
|
||||||
(DLGPROC)CrashReporterDialogProc, 0);
|
(DLGPROC)CrashReporterDialogProc, 0);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче