blob: a5b1e346a3d30cc7bd2e2ec344b86954ab93b832 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#include "leaktracethread.h"
#include "apitracecall.h"
#include <QDebug>
#include <QProcess>
void LeakTraceThread::run()
{
QString msg = QLatin1String("Replay finished!");
/*
* Construct command line
*/
QString prog = "apitrace";
QStringList arguments;
arguments << "leaks";
arguments << filename;
/*
* Start the process.
*/
{
QDebug debug(QtDebugMsg);
debug << "Running:";
debug << prog;
foreach (const QString &argument, arguments) {
debug << argument;
}
}
QProcess process;
process.start(prog, arguments, QIODevice::ReadOnly);
if (!process.waitForStarted(-1)) {
return;
}
/*
* Wait for process termination
*/
process.waitForFinished(-1);
if (process.exitStatus() != QProcess::NormalExit) {
msg = QLatin1String("Process crashed");
} else if (process.exitCode() != 0) {
msg = QLatin1String("Process exited with non zero exit code");
}
/*
* Parse errors.
*/
QList<ApiTraceError> errors;
process.setReadChannel(QProcess::StandardError);
QRegExp regexp("(^\\d+): +(\\b\\w+\\b): ([^\\r\\n]+)[\\r\\n]*$");
while (!process.atEnd()) {
QString line = process.readLine();
qDebug() << line;
if (regexp.indexIn(line) != -1) {
qDebug() << "error";
ApiTraceError error;
error.callIndex = regexp.cap(1).toInt();
error.type = regexp.cap(2);
error.message = regexp.cap(3);
errors.append(error);
} else {
qDebug() << line;
}
}
/*
* Emit signals
*/
error = !errors.empty();
emit leakTraceErrors(errors);
}
|