1 #include "traceprocess.h"
14 #ifdef APITRACE_BINARY_DIR
15 libPath = QString::fromLatin1(APITRACE_BINARY_DIR "/glxtrace.so");
16 fi = QFileInfo(libPath);
21 #ifdef APITRACE_WRAPPER_INSTALL_DIR
22 libPath = QString::fromLatin1(APITRACE_WRAPPER_INSTALL_DIR "/glxtrace.so");
23 fi = QFileInfo(libPath);
31 TraceProcess::TraceProcess(QObject *parent)
35 m_process = new QProcess(this);
37 connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)),
38 this, SLOT(traceFinished()));
39 connect(m_process, SIGNAL(error(QProcess::ProcessError)),
40 this, SLOT(traceError(QProcess::ProcessError)));
43 qWarning()<<"Windows tracing isn't supported right now!";
46 QString var = QLatin1String("LD_PRELOAD");
47 QString libPath = findPreloader();
48 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
50 if (libPath.isEmpty()) {
54 env.insert("LD_PRELOAD", libPath);
55 qputenv("LD_PRELOAD", env.value("LD_PRELOAD").toLatin1());
57 m_process->setProcessEnvironment(env);
61 TraceProcess::~TraceProcess()
65 void TraceProcess::setExecutablePath(const QString &str)
69 QFileInfo fi(m_execPath);
71 m_process->setWorkingDirectory(fi.absolutePath());
73 QString format = QString::fromLatin1("%1%2%3.trace");
76 .arg(fi.absolutePath())
77 .arg(QDir::separator())
81 while (QFile::exists(m_tracePath)) {
82 QString format = QString::fromLatin1("%1%2%3.%4.trace");
84 .arg(fi.absolutePath())
85 .arg(QDir::separator())
91 QString TraceProcess::executablePath() const
96 void TraceProcess::setArguments(const QStringList &args)
101 QStringList TraceProcess::arguments() const
106 void TraceProcess::traceFinished()
109 qDebug()<<"trace finished on " << m_tracePath;
110 qDebug()<<"\terr = "<<m_process->readAllStandardError();
111 qDebug()<<"\tout = "<<m_process->readAllStandardOutput();
113 emit tracedFile(m_tracePath);
116 void TraceProcess::traceError(QProcess::ProcessError err)
119 qDebug()<<"trace error = "<<m_tracePath;
120 qDebug()<<"\terr = "<<m_process->readAllStandardError();
121 qDebug()<<"\tout = "<<m_process->readAllStandardOutput();
123 emit error(m_process->readAllStandardError());
127 void TraceProcess::start()
129 m_process->start(m_execPath, m_args);
132 bool TraceProcess::canTrace() const
137 #include "traceprocess.moc"