blob: 34639c634d4893ad55d38617ebc0a7307c9f53c7 (
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
#include "trimprocess.h"
#include "apitrace.h"
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QFileInfo>
TrimProcess::TrimProcess(QObject *parent)
: QObject(parent)
{
m_process = new QProcess(this);
connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)),
this, SLOT(trimFinished()));
connect(m_process, SIGNAL(error(QProcess::ProcessError)),
this, SLOT(trimError(QProcess::ProcessError)));
}
TrimProcess::~TrimProcess()
{
}
void TrimProcess::trimFinished()
{
// consume verbose output spew
QByteArray outputStrings = m_process->readAllStandardOutput();
QByteArray errorStrings = m_process->readAllStandardError();
#if 0
qDebug()<<"trim finished on " << m_trimPath;
qDebug()<<"\terr = "<<errorStrings;
qDebug()<<"\tout = "<<outputStrings;
#endif
emit trimmedFile(m_trimPath);
}
void TrimProcess::trimError(QProcess::ProcessError err)
{
// consume verbose output spew
QByteArray outputStrings = m_process->readAllStandardOutput();
QByteArray errorStrings = m_process->readAllStandardError();
#if 1
qDebug()<<"trace error = "<<m_tracePath;
qDebug()<<"\terr = "<<errorStrings;
qDebug()<<"\tout = "<<outputStrings;
#endif
emit error(errorStrings);
}
void TrimProcess::start()
{
QStringList arguments;
QString outputFormat = QLatin1String("--output=%1");
QString outputArgument = outputFormat
.arg(m_trimPath);
QString callSetFormat = QLatin1String("--calls=0-%1");
QString callSetArgument = callSetFormat
.arg(m_trimIndex);
arguments << QLatin1String("trim");
arguments << outputArgument;
arguments << callSetArgument;
arguments << m_tracePath;
m_process->start(QLatin1String("apitrace"), arguments);
}
int TrimProcess::trimIndex()
{
return m_trimIndex;
}
void TrimProcess::setTrimIndex(int trimIndex)
{
m_trimIndex = trimIndex;
updateTrimPath();
}
void TrimProcess::setTracePath(const QString &str)
{
m_tracePath = str;
updateTrimPath();
}
QString TrimProcess::tracePath() const
{
return m_tracePath;
}
void TrimProcess::updateTrimPath()
{
QFileInfo fi(m_tracePath);
QString baseName = fi.baseName();
QString path = fi.path();
QString format = QString::fromLatin1("%1/%2.%3.trim.trace");
m_trimPath = format
.arg(path)
.arg(baseName)
.arg(m_trimIndex);
}
#include "trimprocess.moc"
|