Bug 1401400 - Part 1. Option to analyze all threads. r=gsvelto

MozReview-Commit-ID: HYSslbqnJuM
This commit is contained in:
Adam Gashlin 2017-10-17 15:02:18 -07:00
Родитель 04879cba6b
Коммит c9def865c8
3 изменённых файлов: 44 добавлений и 7 удалений

Просмотреть файл

@ -642,6 +642,8 @@ GetProgramPath(const string& exename)
int main(int argc, char** argv)
{
bool minidumpAllThreads = false;
gArgc = argc;
gArgv = argv;
@ -653,7 +655,12 @@ int main(int argc, char** argv)
if (!UIInit())
return 0;
if (argc > 1) {
if (argc == 3) {
if (!strcmp(argv[1], "--full")) {
minidumpAllThreads = true;
}
gReporterDumpFile = argv[2];
} else if (argc == 2) {
gReporterDumpFile = argv[1];
}
@ -664,6 +671,9 @@ int main(int argc, char** argv)
// Start by running minidump analyzer to gather stack traces.
string reporterDumpFile = gReporterDumpFile;
vector<string> args = { reporterDumpFile };
if (minidumpAllThreads) {
args.insert(args.begin(), "--full");
}
UIRunProgram(GetProgramPath(UI_MINIDUMP_ANALYZER_FILENAME),
args, /* wait */ true);

Просмотреть файл

@ -247,6 +247,7 @@ static nsCString* crashEventAPIData = nullptr;
static nsCString* notesField = nullptr;
static bool isGarbageCollecting;
static uint32_t eventloopNestingLevel = 0;
static bool minidumpAnalysisAllThreads = false;
// Avoid a race during application termination.
static Mutex* dumpSafetyLock;
@ -818,7 +819,8 @@ WriteGlobalMemoryStatus(PlatformWriter* apiData, PlatformWriter* eventFile)
* to the launched program
*/
static bool
LaunchProgram(const XP_CHAR* aProgramPath, const XP_CHAR* aMinidumpPath)
LaunchProgram(const XP_CHAR* aProgramPath, const XP_CHAR* aMinidumpPath,
bool aAllThreads)
{
#ifdef XP_WIN
XP_CHAR cmdLine[CMDLINE_SIZE];
@ -827,7 +829,11 @@ LaunchProgram(const XP_CHAR* aProgramPath, const XP_CHAR* aMinidumpPath)
size_t size = CMDLINE_SIZE;
p = Concat(cmdLine, L"\"", &size);
p = Concat(p, aProgramPath, &size);
p = Concat(p, L"\" \"", &size);
p = Concat(p, L"\" ", &size);
if (aAllThreads) {
p = Concat(p, L"--full ", &size);
}
p = Concat(p, L"\"", &size);
p = Concat(p, aMinidumpPath, &size);
Concat(p, L"\"", &size);
@ -847,12 +853,20 @@ LaunchProgram(const XP_CHAR* aProgramPath, const XP_CHAR* aMinidumpPath)
setenv("DYLD_LIBRARY_PATH", libraryPath, /* overwrite */ 1);
pid_t pid = 0;
char* const my_argv[] = {
char* my_argv[] = {
const_cast<char*>(aProgramPath),
const_cast<char*>(aMinidumpPath),
nullptr,
nullptr
};
char fullArg[] = "--full";
if (aAllThreads) {
my_argv[2] = my_argv[1];
my_argv[1] = fullArg;
}
char **env = nullptr;
char ***nsEnv = _NSGetEnviron();
if (nsEnv) {
@ -873,8 +887,14 @@ LaunchProgram(const XP_CHAR* aProgramPath, const XP_CHAR* aMinidumpPath)
// need to clobber this, as libcurl might load NSS,
// and we want it to load the system NSS.
unsetenv("LD_LIBRARY_PATH");
Unused << execl(aProgramPath,
aProgramPath, aMinidumpPath, (char*)0);
if (aAllThreads) {
Unused << execl(aProgramPath,
aProgramPath, "--full", aMinidumpPath, (char*)0);
} else {
Unused << execl(aProgramPath,
aProgramPath, aMinidumpPath, (char*)0);
}
_exit(1);
}
#endif // XP_MACOSX
@ -1224,7 +1244,8 @@ bool MinidumpCallback(
returnValue = LaunchCrashReporterActivity(crashReporterPath, minidumpPath,
succeeded);
#else // Windows, Mac, Linux, etc...
returnValue = LaunchProgram(crashReporterPath, minidumpPath);
returnValue = LaunchProgram(crashReporterPath, minidumpPath,
minidumpAnalysisAllThreads);
#ifdef XP_WIN
TerminateProcess(GetCurrentProcess(), 1);
#endif
@ -2373,6 +2394,11 @@ void SetEventloopNestingLevel(uint32_t level)
eventloopNestingLevel = level;
}
void SetMinidumpAnalysisAllThreads()
{
minidumpAnalysisAllThreads = true;
}
nsresult AppendAppNotesToCrashReport(const nsACString& data)
{
if (!GetEnabled())

Просмотреть файл

@ -84,6 +84,7 @@ void AnnotatePendingIPC(size_t aNumOfPendingIPC,
uint32_t aTopPendingIPCType);
nsresult SetGarbageCollecting(bool collecting);
void SetEventloopNestingLevel(uint32_t level);
void SetMinidumpAnalysisAllThreads();
nsresult SetRestartArgs(int argc, char** argv);
nsresult SetupExtraData(nsIFile* aAppDataDirectory,