QTest::CrashHandler: switch to execvp() instead of execlp()
There will be variable options. Change-Id: Ie633615daeac87e8bd2cfffd962666a85d91d5cd Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
c8d3d7a7af
commit
4fcd854657
@ -383,20 +383,39 @@ void generateStackTrace()
|
|||||||
// child process
|
// child process
|
||||||
(void) dup2(STDERR_FILENO, STDOUT_FILENO); // redirect stdout to stderr
|
(void) dup2(STDERR_FILENO, STDOUT_FILENO); // redirect stdout to stderr
|
||||||
|
|
||||||
|
struct Args {
|
||||||
|
std::array<const char *, 16> argv;
|
||||||
|
int count = 0;
|
||||||
|
Args &operator<<(const char *arg)
|
||||||
|
{
|
||||||
|
Q_ASSERT(count < int(argv.size()));
|
||||||
|
argv[count++] = arg;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
operator char **() const { return const_cast<char **>(argv.data()); }
|
||||||
|
} argv;
|
||||||
|
|
||||||
switch (debugger) {
|
switch (debugger) {
|
||||||
case None:
|
case None:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
case Gdb:
|
case Gdb:
|
||||||
execlp("gdb", "gdb", "--nx", "--batch", "-ex", "thread apply all bt",
|
argv << "gdb" << "--nx" << "--batch"
|
||||||
"-ex", "info proc mappings",
|
<< "-ex" << "thread apply all bt"
|
||||||
"--pid", pidbuffer.array.data(), nullptr);
|
<< "-ex" << "printf \"\\n\""
|
||||||
|
<< "-ex" << "info proc mappings"
|
||||||
|
<< "--pid";
|
||||||
break;
|
break;
|
||||||
case Lldb:
|
case Lldb:
|
||||||
execlp("lldb", "lldb", "--no-lldbinit", "--batch", "-o", "bt all",
|
argv << "lldb" << "--no-lldbinit" << "--batch"
|
||||||
"--attach-pid", pidbuffer.array.data(), nullptr);
|
<< "-o" << "bt all"
|
||||||
|
<< "--attach-pid";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (argv.count) {
|
||||||
|
argv << pidbuffer.array.data() << nullptr;
|
||||||
|
execvp(argv.argv[0], argv);
|
||||||
|
}
|
||||||
_exit(1);
|
_exit(1);
|
||||||
} else if (pid < 0) {
|
} else if (pid < 0) {
|
||||||
writeToStderr("Failed to start debugger.\n");
|
writeToStderr("Failed to start debugger.\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user