mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2025-07-07 10:30:35 +00:00
Code review issue 9002: Add paranoid logging to Inspector & Reporter
A=jeremy moskovich R=nealsid git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@333 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
e438d9cc0b
commit
ed1f6e754a
|
@ -88,7 +88,7 @@ kern_return_t OnDemandServer::Initialize(const char *server_command,
|
||||||
&service_port_);
|
&service_port_);
|
||||||
|
|
||||||
if (kr != KERN_SUCCESS) {
|
if (kr != KERN_SUCCESS) {
|
||||||
//PRINT_MACH_RESULT(kr, "bootstrap_create_service() : ");
|
PRINT_MACH_RESULT(kr, "bootstrap_create_service() : ");
|
||||||
|
|
||||||
// perhaps the service has already been created - try to look it up
|
// perhaps the service has already been created - try to look it up
|
||||||
kr = bootstrap_look_up(bootstrap_port, (char*)service_name, &service_port_);
|
kr = bootstrap_look_up(bootstrap_port, (char*)service_name, &service_port_);
|
||||||
|
|
|
@ -160,8 +160,15 @@ void ConfigFile::WriteFile(const SimpleStringDictionary *configurationParameters
|
||||||
sizeof(config_file_path_));
|
sizeof(config_file_path_));
|
||||||
config_file_ = mkstemp(config_file_path_);
|
config_file_ = mkstemp(config_file_path_);
|
||||||
|
|
||||||
if (config_file_ == -1)
|
if (config_file_ == -1) {
|
||||||
|
DEBUGLOG(stderr,
|
||||||
|
"mkstemp(config_file_path_) == -1 (%s)\n",
|
||||||
|
strerror(errno));
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DEBUGLOG(stderr, "Writing config file to (%s)\n", config_file_path_);
|
||||||
|
}
|
||||||
|
|
||||||
has_created_file_ = true;
|
has_created_file_ = true;
|
||||||
|
|
||||||
|
@ -177,6 +184,10 @@ void ConfigFile::WriteFile(const SimpleStringDictionary *configurationParameters
|
||||||
SimpleStringDictionaryIterator iter(dictionary);
|
SimpleStringDictionaryIterator iter(dictionary);
|
||||||
|
|
||||||
while ((entry = iter.Next())) {
|
while ((entry = iter.Next())) {
|
||||||
|
DEBUGLOG(stderr,
|
||||||
|
"config: (%s) -> (%s)\n",
|
||||||
|
entry->GetKey(),
|
||||||
|
entry->GetValue());
|
||||||
result = AppendConfigString(entry->GetKey(), entry->GetValue());
|
result = AppendConfigString(entry->GetKey(), entry->GetValue());
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
|
@ -348,6 +359,7 @@ void Inspector::SetCrashTimeParameters() {
|
||||||
bool Inspector::InspectTask() {
|
bool Inspector::InspectTask() {
|
||||||
// keep the task quiet while we're looking at it
|
// keep the task quiet while we're looking at it
|
||||||
task_suspend(remote_task_);
|
task_suspend(remote_task_);
|
||||||
|
DEBUGLOG(stderr, "Suspsended Remote task\n");
|
||||||
|
|
||||||
NSString *minidumpDir;
|
NSString *minidumpDir;
|
||||||
|
|
||||||
|
@ -375,6 +387,9 @@ bool Inspector::InspectTask() {
|
||||||
minidumpDir = [[NSString stringWithUTF8String:minidumpDirectory]
|
minidumpDir = [[NSString stringWithUTF8String:minidumpDirectory]
|
||||||
stringByExpandingTildeInPath];
|
stringByExpandingTildeInPath];
|
||||||
}
|
}
|
||||||
|
DEBUGLOG(stderr,
|
||||||
|
"Writing minidump to directory (%s)\n",
|
||||||
|
[minidumpDir UTF8String]);
|
||||||
|
|
||||||
MinidumpLocation minidumpLocation(minidumpDir);
|
MinidumpLocation minidumpLocation(minidumpDir);
|
||||||
|
|
||||||
|
@ -393,14 +408,18 @@ bool Inspector::InspectTask() {
|
||||||
|
|
||||||
NSString *minidumpPath = [NSString stringWithFormat:@"%s/%s.dmp",
|
NSString *minidumpPath = [NSString stringWithFormat:@"%s/%s.dmp",
|
||||||
minidumpLocation.GetPath(), minidumpLocation.GetID()];
|
minidumpLocation.GetPath(), minidumpLocation.GetID()];
|
||||||
|
DEBUGLOG(stderr,
|
||||||
|
"minidump path (%s)\n",
|
||||||
|
[minidumpPath UTF8String]);
|
||||||
|
|
||||||
|
|
||||||
bool result = generator.Write([minidumpPath fileSystemRepresentation]);
|
bool result = generator.Write([minidumpPath fileSystemRepresentation]);
|
||||||
|
|
||||||
DEBUGLOG(stderr, "Inspector: finished writing minidump file: %s\n",
|
DEBUGLOG(stderr, "Wrote minidump - %s\n", result ? "OK" : "FAILED");
|
||||||
[minidumpPath fileSystemRepresentation]);
|
|
||||||
|
|
||||||
// let the task continue
|
// let the task continue
|
||||||
task_resume(remote_task_);
|
task_resume(remote_task_);
|
||||||
|
DEBUGLOG(stderr, "Resumed remote task\n");
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#import "crash_report_sender.h"
|
#import "crash_report_sender.h"
|
||||||
#import "common/mac/GTMLogger.h"
|
#import "common/mac/GTMLogger.h"
|
||||||
|
|
||||||
|
|
||||||
#define kLastSubmission @"LastSubmission"
|
#define kLastSubmission @"LastSubmission"
|
||||||
const int kMinidumpFileLengthLimit = 800000;
|
const int kMinidumpFileLengthLimit = 800000;
|
||||||
|
|
||||||
|
@ -704,13 +705,13 @@ doCommandBySelector:(SEL)commandSelector {
|
||||||
const char *dest = [destString fileSystemRepresentation];
|
const char *dest = [destString fileSystemRepresentation];
|
||||||
|
|
||||||
if (rename(src, dest) == 0) {
|
if (rename(src, dest) == 0) {
|
||||||
fprintf(stderr, "Breakpad Reporter: Renamed %s to %s after successful " \
|
GTMLoggerInfo(@"Breakpad Reporter: Renamed %s to %s after successful " \
|
||||||
"upload\n",src, dest);
|
"upload",src, dest);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// can't rename - don't worry - it's not important for users
|
// can't rename - don't worry - it's not important for users
|
||||||
fprintf(stderr, "Breakpad Reporter: successful upload report ID = %s\n",
|
GTMLoggerDebug(@"Breakpad Reporter: successful upload report ID = %s\n",
|
||||||
reportID );
|
reportID );
|
||||||
}
|
}
|
||||||
[result release];
|
[result release];
|
||||||
}
|
}
|
||||||
|
@ -749,6 +750,11 @@ doCommandBySelector:(SEL)commandSelector {
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
int main(int argc, const char *argv[]) {
|
int main(int argc, const char *argv[]) {
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
#if DEBUG
|
||||||
|
// Log to stderr in debug builds.
|
||||||
|
[GTMLogger setSharedLogger:[GTMLogger standardLoggerWithStderr]];
|
||||||
|
#endif
|
||||||
|
GTMLoggerDebug(@"Reporter Launched, argc=%d", argc);
|
||||||
// The expectation is that there will be one argument which is the path
|
// The expectation is that there will be one argument which is the path
|
||||||
// to the configuration file
|
// to the configuration file
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
|
@ -758,11 +764,20 @@ int main(int argc, const char *argv[]) {
|
||||||
// Open the file before (potentially) switching to console user
|
// Open the file before (potentially) switching to console user
|
||||||
int configFile = open(argv[1], O_RDONLY, 0600);
|
int configFile = open(argv[1], O_RDONLY, 0600);
|
||||||
|
|
||||||
|
if (configFile == -1) {
|
||||||
|
GTMLoggerDebug(@"Couldn't open config file %s - %s",
|
||||||
|
argv[1],
|
||||||
|
strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
// we want to avoid a build-up of old config files even if they
|
// we want to avoid a build-up of old config files even if they
|
||||||
// have been incorrectly written by the framework
|
// have been incorrectly written by the framework
|
||||||
unlink(argv[1]);
|
unlink(argv[1]);
|
||||||
|
|
||||||
if (configFile == -1) {
|
if (configFile == -1) {
|
||||||
|
GTMLoggerDebug(@"Couldn't unlink config file %s - %s",
|
||||||
|
argv[1],
|
||||||
|
strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -770,6 +785,7 @@ int main(int argc, const char *argv[]) {
|
||||||
|
|
||||||
// Gather the configuration data
|
// Gather the configuration data
|
||||||
if (![reporter readConfigurationData]) {
|
if (![reporter readConfigurationData]) {
|
||||||
|
GTMLoggerDebug(@"reporter readConfigurationData failed");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,23 +809,37 @@ int main(int argc, const char *argv[]) {
|
||||||
struct passwd *pw = getpwnam("nobody");
|
struct passwd *pw = getpwnam("nobody");
|
||||||
|
|
||||||
// If we can't get a non-root uid, don't send the report
|
// If we can't get a non-root uid, don't send the report
|
||||||
if (!pw)
|
if (!pw) {
|
||||||
|
GTMLoggerDebug(@"!pw - %s", strerror(errno));
|
||||||
exit(0);
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (setgid(pw->pw_gid) == -1)
|
if (setgid(pw->pw_gid) == -1) {
|
||||||
|
GTMLoggerDebug(@"setgid(pw->pw_gid) == -1 - %s", strerror(errno));
|
||||||
exit(0);
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (setuid(pw->pw_uid) == -1)
|
if (setuid(pw->pw_uid) == -1) {
|
||||||
|
GTMLoggerDebug(@"setuid(pw->pw_uid) == -1 - %s", strerror(errno));
|
||||||
exit(0);
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
GTMLoggerDebug(@"getuid() !=0 || geteuid() != 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (okayToSend && shouldSubmitReport) {
|
if (okayToSend && shouldSubmitReport) {
|
||||||
|
GTMLoggerDebug(@"Sending Report");
|
||||||
[reporter report];
|
[reporter report];
|
||||||
|
GTMLoggerDebug(@"Report Sent!");
|
||||||
|
} else {
|
||||||
|
GTMLoggerDebug(@"Not sending crash report okayToSend=%d, "\
|
||||||
|
"shouldSubmitReport=%d", okayToSend, shouldSubmitReport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GTMLoggerDebug(@"Exiting with no errors");
|
||||||
// Cleanup
|
// Cleanup
|
||||||
[reporter release];
|
[reporter release];
|
||||||
[pool release];
|
[pool release];
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue