StackTraceHandler: simplify the gdb and lldb commands

Instead of piping stuff via the shell into them, just use batch mode.
And also take the opportunity to tell them not to read their user-
provided configuration files.

Pick-to: 6.3
Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eba21e71afaefa
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Thiago Macieira 2022-05-03 08:32:19 -07:00
parent 6b739f836b
commit 4ea5e39b27

View File

@ -286,20 +286,11 @@ static void prepareStackTrace()
// prepare the command to be run (our PID shouldn't change!)
# ifdef Q_OS_LINUX
qsnprintf(stackTraceCommand.data(), stackTraceCommand.size(),
"gdb --pid %d 1>&2 2>/dev/null <<EOF\n"
"set prompt\n"
"set height 0\n"
"thread apply all where full\n"
"detach\n"
"quit\n"
"EOF\n",
"gdb --nx --batch --pid %d -ex 'thread apply all bt' 1>&2",
static_cast<int>(getpid()));
# elif defined(Q_OS_MACOS)
qsnprintf(stackTraceCommand.data(), stackTraceCommand.size(),
"lldb -p %d 1>&2 2>/dev/null <<EOF\n"
"bt all\n"
"quit\n"
"EOF\n",
"lldb --batch --no-lldbinit -p %d -o 'bt all' 1>&2",
static_cast<int>(getpid()));
# endif
}