1 #include "traceprocess.h"
8 TraceProcess::TraceProcess(QObject *parent)
12 m_process = new QProcess(this);
14 connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)),
15 this, SLOT(traceFinished()));
16 connect(m_process, SIGNAL(error(QProcess::ProcessError)),
17 this, SLOT(traceError(QProcess::ProcessError)));
20 QString format = QLatin1String("%1;");
22 QString format = QLatin1String("%1:");
24 QString buildPath = format.arg(APITRACE_BINARY_DIR);
25 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
26 env.insert("PATH", buildPath + env.value("PATH"));
27 qputenv("PATH", env.value("PATH").toLatin1());
30 TraceProcess::~TraceProcess()
34 void TraceProcess::setApi(const QString &str)
39 void TraceProcess::setExecutablePath(const QString &str)
43 QFileInfo fi(m_execPath);
44 QString baseName = fi.baseName();
46 QString format = QString::fromLatin1("%1.trace");
52 while (QFile::exists(m_tracePath)) {
53 format = QString::fromLatin1("%1.%2.trace");
60 QString TraceProcess::executablePath() const
65 void TraceProcess::setArguments(const QStringList &args)
70 QStringList TraceProcess::arguments() const
75 void TraceProcess::traceFinished()
78 qDebug()<<"trace finished on " << m_tracePath;
79 qDebug()<<"\terr = "<<m_process->readAllStandardError();
80 qDebug()<<"\tout = "<<m_process->readAllStandardOutput();
82 emit tracedFile(m_tracePath);
85 void TraceProcess::traceError(QProcess::ProcessError err)
88 qDebug()<<"trace error = "<<m_tracePath;
89 qDebug()<<"\terr = "<<m_process->readAllStandardError();
90 qDebug()<<"\tout = "<<m_process->readAllStandardOutput();
92 emit error(m_process->readAllStandardError());
96 void TraceProcess::start()
98 QStringList arguments;
100 arguments << QLatin1String("trace");
101 arguments << QLatin1String("--api");
103 arguments << QLatin1String("--output");
104 arguments << m_tracePath;
105 arguments << QLatin1String("--");
106 arguments << m_execPath;
109 m_process->start(QLatin1String("apitrace"), arguments);
112 bool TraceProcess::canTrace() const
117 #include "traceprocess.moc"