summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <[email protected]>2025-05-14 17:54:06 -0700
committerThiago Macieira <[email protected]>2025-05-25 13:24:27 -0700
commit4fcd8546573ddc0b933378f7aa8530103cf76910 (patch)
treec32c8a85ab8cb6cbddbeb9e2f22d996f66023df5
parentc8d3d7a7af73d97e0415b99df8d8378edb3117f5 (diff)
QTest::CrashHandler: switch to execvp() instead of execlp()
There will be variable options. Change-Id: Ie633615daeac87e8bd2cfffd962666a85d91d5cd Reviewed-by: Ahmad Samir <[email protected]> Reviewed-by: Edward Welbourne <[email protected]>
-rw-r--r--src/testlib/qtestcrashhandler_unix.cpp29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/testlib/qtestcrashhandler_unix.cpp b/src/testlib/qtestcrashhandler_unix.cpp
index 9bc0fd2fa9b..15ba4bb1c7f 100644
--- a/src/testlib/qtestcrashhandler_unix.cpp
+++ b/src/testlib/qtestcrashhandler_unix.cpp
@@ -383,20 +383,39 @@ void generateStackTrace()
// child process
(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) {
case None:
Q_UNREACHABLE();
break;
case Gdb:
- execlp("gdb", "gdb", "--nx", "--batch", "-ex", "thread apply all bt",
- "-ex", "info proc mappings",
- "--pid", pidbuffer.array.data(), nullptr);
+ argv << "gdb" << "--nx" << "--batch"
+ << "-ex" << "thread apply all bt"
+ << "-ex" << "printf \"\\n\""
+ << "-ex" << "info proc mappings"
+ << "--pid";
break;
case Lldb:
- execlp("lldb", "lldb", "--no-lldbinit", "--batch", "-o", "bt all",
- "--attach-pid", pidbuffer.array.data(), nullptr);
+ argv << "lldb" << "--no-lldbinit" << "--batch"
+ << "-o" << "bt all"
+ << "--attach-pid";
break;
}
+ if (argv.count) {
+ argv << pidbuffer.array.data() << nullptr;
+ execvp(argv.argv[0], argv);
+ }
_exit(1);
} else if (pid < 0) {
writeToStderr("Failed to start debugger.\n");