mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-12 22:28:59 +02:00
Bug 600408 - Fix crashreporter launching code to launch correct architecture on OS X 10.5. r=josh a=blocking-beta7
This commit is contained in:
parent
321fbe83d7
commit
1085487644
2 changed files with 104 additions and 13 deletions
|
|
@ -41,6 +41,8 @@
|
||||||
#import <CoreFoundation/CoreFoundation.h>
|
#import <CoreFoundation/CoreFoundation.h>
|
||||||
#include "crashreporter.h"
|
#include "crashreporter.h"
|
||||||
#include "crashreporter_osx.h"
|
#include "crashreporter_osx.h"
|
||||||
|
#include <crt_externs.h>
|
||||||
|
#include <spawn.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
@ -62,6 +64,16 @@ static vector<string> gRestartArgs;
|
||||||
static bool gDidTrySend = false;
|
static bool gDidTrySend = false;
|
||||||
static bool gRTLlayout = false;
|
static bool gRTLlayout = false;
|
||||||
|
|
||||||
|
static cpu_type_t pref_cpu_types[2] = {
|
||||||
|
#if defined(__i386__)
|
||||||
|
CPU_TYPE_X86,
|
||||||
|
#elif defined(__x86_64__)
|
||||||
|
CPU_TYPE_X86_64,
|
||||||
|
#elif defined(__ppc__)
|
||||||
|
CPU_TYPE_POWERPC,
|
||||||
|
#endif
|
||||||
|
CPU_TYPE_ANY };
|
||||||
|
|
||||||
#define NSSTR(s) [NSString stringWithUTF8String:(s).c_str()]
|
#define NSSTR(s) [NSString stringWithUTF8String:(s).c_str()]
|
||||||
|
|
||||||
static NSString* Str(const char* aName)
|
static NSString* Str(const char* aName)
|
||||||
|
|
@ -73,10 +85,24 @@ static NSString* Str(const char* aName)
|
||||||
|
|
||||||
static bool RestartApplication()
|
static bool RestartApplication()
|
||||||
{
|
{
|
||||||
char** argv = reinterpret_cast<char**>(
|
vector<char*> argv(gRestartArgs.size() + 1);
|
||||||
malloc(sizeof(char*) * (gRestartArgs.size() + 1)));
|
|
||||||
|
|
||||||
if (!argv) return false;
|
posix_spawnattr_t spawnattr;
|
||||||
|
if (posix_spawnattr_init(&spawnattr) != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set spawn attributes.
|
||||||
|
size_t attr_count = sizeof(pref_cpu_types) / sizeof(pref_cpu_types[0]);
|
||||||
|
size_t attr_ocount = 0;
|
||||||
|
if (posix_spawnattr_setbinpref_np(&spawnattr,
|
||||||
|
attr_count,
|
||||||
|
pref_cpu_types,
|
||||||
|
&attr_ocount) != 0 ||
|
||||||
|
attr_ocount != attr_count) {
|
||||||
|
posix_spawnattr_destroy(&spawnattr);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for (i = 0; i < gRestartArgs.size(); i++) {
|
for (i = 0; i < gRestartArgs.size(); i++) {
|
||||||
|
|
@ -84,17 +110,20 @@ static bool RestartApplication()
|
||||||
}
|
}
|
||||||
argv[i] = 0;
|
argv[i] = 0;
|
||||||
|
|
||||||
pid_t pid = fork();
|
char **env = NULL;
|
||||||
if (pid == -1)
|
char ***nsEnv = _NSGetEnviron();
|
||||||
return false;
|
if (nsEnv)
|
||||||
else if (pid == 0) {
|
env = *nsEnv;
|
||||||
(void)execv(argv[0], argv);
|
int result = posix_spawnp(NULL,
|
||||||
_exit(1);
|
argv[0],
|
||||||
}
|
NULL,
|
||||||
|
&spawnattr,
|
||||||
|
&argv[0],
|
||||||
|
env);
|
||||||
|
|
||||||
free(argv);
|
posix_spawnattr_destroy(&spawnattr);
|
||||||
|
|
||||||
return true;
|
return result == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@implementation CrashReporterUI
|
@implementation CrashReporterUI
|
||||||
|
|
|
||||||
|
|
@ -60,9 +60,11 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <Carbon/Carbon.h>
|
#include <Carbon/Carbon.h>
|
||||||
#include <CoreFoundation/CoreFoundation.h>
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
#include <crt_externs.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <mach/mach.h>
|
#include <mach/mach.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <spawn.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "mac_utils.h"
|
#include "mac_utils.h"
|
||||||
#elif defined(XP_LINUX)
|
#elif defined(XP_LINUX)
|
||||||
|
|
@ -226,6 +228,20 @@ static const char* kSubprocessBlacklist[] = {
|
||||||
|
|
||||||
#endif // MOZ_IPC
|
#endif // MOZ_IPC
|
||||||
|
|
||||||
|
#ifdef XP_MACOSX
|
||||||
|
static cpu_type_t pref_cpu_types[2] = {
|
||||||
|
#if defined(__i386__)
|
||||||
|
CPU_TYPE_X86,
|
||||||
|
#elif defined(__x86_64__)
|
||||||
|
CPU_TYPE_X86_64,
|
||||||
|
#elif defined(__ppc__)
|
||||||
|
CPU_TYPE_POWERPC,
|
||||||
|
#endif
|
||||||
|
CPU_TYPE_ANY };
|
||||||
|
|
||||||
|
static posix_spawnattr_t spawnattr;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef XP_LINUX
|
#ifdef XP_LINUX
|
||||||
inline void
|
inline void
|
||||||
my_timetostring(time_t t, char* buffer, size_t buffer_length)
|
my_timetostring(time_t t, char* buffer, size_t buffer_length)
|
||||||
|
|
@ -417,6 +433,28 @@ bool MinidumpCallback(const XP_CHAR* dump_path,
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef XP_MACOSX
|
||||||
|
char* const my_argv[] = {
|
||||||
|
crashReporterPath,
|
||||||
|
minidumpPath,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
char **env = NULL;
|
||||||
|
char ***nsEnv = _NSGetEnviron();
|
||||||
|
if (nsEnv)
|
||||||
|
env = *nsEnv;
|
||||||
|
int result = posix_spawnp(NULL,
|
||||||
|
my_argv[0],
|
||||||
|
NULL,
|
||||||
|
&spawnattr,
|
||||||
|
my_argv,
|
||||||
|
env);
|
||||||
|
|
||||||
|
if (result != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#else // !XP_MACOSX
|
||||||
pid_t pid = sys_fork();
|
pid_t pid = sys_fork();
|
||||||
|
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
|
|
@ -429,7 +467,8 @@ bool MinidumpCallback(const XP_CHAR* dump_path,
|
||||||
crashReporterPath, minidumpPath, (char*)0);
|
crashReporterPath, minidumpPath, (char*)0);
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif // XP_MACOSX
|
||||||
|
#endif // XP_UNIX
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
@ -558,6 +597,25 @@ nsresult SetExceptionHandler(nsILocalFile* aXREDirectory,
|
||||||
#error "Implement this for your platform"
|
#error "Implement this for your platform"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef XP_MACOSX
|
||||||
|
// Initialize spawn attributes, since this calls malloc.
|
||||||
|
if (posix_spawnattr_init(&spawnattr) != 0) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set spawn attributes.
|
||||||
|
size_t attr_count = NS_ARRAY_LENGTH(pref_cpu_types);
|
||||||
|
size_t attr_ocount = 0;
|
||||||
|
if (posix_spawnattr_setbinpref_np(&spawnattr,
|
||||||
|
attr_count,
|
||||||
|
pref_cpu_types,
|
||||||
|
&attr_ocount) != 0 ||
|
||||||
|
attr_ocount != attr_count) {
|
||||||
|
posix_spawnattr_destroy(&spawnattr);
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// now set the exception handler
|
// now set the exception handler
|
||||||
gExceptionHandler = new google_breakpad::
|
gExceptionHandler = new google_breakpad::
|
||||||
ExceptionHandler(tempPath.get(),
|
ExceptionHandler(tempPath.get(),
|
||||||
|
|
@ -849,6 +907,10 @@ nsresult UnsetExceptionHandler()
|
||||||
crashReporterPath = nsnull;
|
crashReporterPath = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef XP_MACOSX
|
||||||
|
posix_spawnattr_destroy(&spawnattr);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!gExceptionHandler)
|
if (!gExceptionHandler)
|
||||||
return NS_ERROR_NOT_INITIALIZED;
|
return NS_ERROR_NOT_INITIALIZED;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue