tst_Q*Application: debug a crashing application
Implemented for lldb and gdb. MSVC comes with lldb.exe (it doesn't work, but maybe some day). I couldn't find out even how to install cdb.exe, so that's left as a task for someone else. Pick-to: 6.9 6.8 Change-Id: I9d93747476531d4cfd53fffddecc5b3339d2fd7c Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
This commit is contained in:
parent
b03921eb9f
commit
0f9860618f
@ -38,6 +38,41 @@ inline void run()
|
||||
if (qint8(process.exitCode()) == -1)
|
||||
QSKIP("Process requested skip: " + process.readAllStandardOutput().trimmed());
|
||||
|
||||
auto debugCrash = qScopeGuard([&] {
|
||||
if (process.exitStatus() != QProcess::CrashExit)
|
||||
return;
|
||||
# if defined(Q_CC_MSVC)
|
||||
// ### implement cdb support
|
||||
# endif
|
||||
|
||||
QString lldb = QStandardPaths::findExecutable("lldb");
|
||||
QString gdb
|
||||
# if !defined(Q_OS_DARWIN) && !defined(Q_CC_MSVC)
|
||||
// don't search for gdb:
|
||||
// - it requires running with sudo to work on Apple systems
|
||||
// - it doesn't know how to decode MSVC debug information (but lldb does)
|
||||
= QStandardPaths::findExecutable("gdb")
|
||||
# endif
|
||||
;
|
||||
|
||||
if (!gdb.isEmpty()) {
|
||||
process.setArguments({ "--nx", "--batch", "-ex", "run", "-ex", "thread apply all bt",
|
||||
"--args", process.program(), process.arguments().first() });
|
||||
process.setProgram(gdb);
|
||||
} else if (!lldb.isEmpty()) {
|
||||
process.setArguments({ "--no-lldbinit", "--batch", "-o", "run", "-o", "bt all",
|
||||
"--", process.program(), process.arguments().first() });
|
||||
process.setProgram(lldb);
|
||||
} else {
|
||||
qInfo("Cannot debug '%s': cannot find a debugger", qPrintable(process.program()));
|
||||
return;
|
||||
}
|
||||
process.setProcessChannelMode(QProcess::ForwardedChannels);
|
||||
process.start();
|
||||
process.closeWriteChannel();
|
||||
process.waitForFinished();
|
||||
});
|
||||
|
||||
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
|
||||
QCOMPARE(process.readAllStandardError(), QString());
|
||||
QCOMPARE(process.exitCode(), 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user