Zack Rusin | 20b1f6d | 2011-09-06 11:50:07 -0400 | [diff] [blame] | 1 | #ifndef TRACELOADER_H |
| 2 | #define TRACELOADER_H |
| 3 | |
| 4 | |
| 5 | #include "apitrace.h" |
| 6 | #include "trace_file.hpp" |
| 7 | #include "trace_parser.hpp" |
| 8 | |
| 9 | #include <QObject> |
| 10 | #include <QList> |
| 11 | #include <QMap> |
| 12 | |
| 13 | class TraceLoader : public QObject |
| 14 | { |
| 15 | Q_OBJECT |
| 16 | public: |
Zack Rusin | ebf971e | 2011-09-06 17:44:43 -0400 | [diff] [blame] | 17 | TraceLoader(QObject *parent=0); |
Zack Rusin | 20b1f6d | 2011-09-06 11:50:07 -0400 | [diff] [blame] | 18 | ~TraceLoader(); |
| 19 | |
Zack Rusin | ebf971e | 2011-09-06 17:44:43 -0400 | [diff] [blame] | 20 | |
| 21 | ApiTraceCallSignature *signature(unsigned id); |
| 22 | void addSignature(unsigned id, ApiTraceCallSignature *signature); |
| 23 | |
| 24 | ApiTraceEnumSignature *enumSignature(unsigned id); |
| 25 | void addEnumSignature(unsigned id, ApiTraceEnumSignature *signature); |
| 26 | |
Zack Rusin | 20b1f6d | 2011-09-06 11:50:07 -0400 | [diff] [blame] | 27 | public slots: |
| 28 | void loadTrace(const QString &filename); |
Zack Rusin | 3176ebe | 2011-09-06 21:11:36 -0400 | [diff] [blame] | 29 | void loadFrame(ApiTraceFrame *frame); |
Zack Rusin | 20b1f6d | 2011-09-06 11:50:07 -0400 | [diff] [blame] | 30 | void setFrameMarker(ApiTrace::FrameMarker marker); |
Zack Rusin | 8f98c3a | 2011-09-11 18:21:29 -0400 | [diff] [blame] | 31 | void searchNext(int startFrame, |
| 32 | const QString &str, |
| 33 | Qt::CaseSensitivity sensitivity); |
| 34 | void searchPrev(int startFrame, |
| 35 | const QString &str, |
| 36 | Qt::CaseSensitivity sensitivity); |
Zack Rusin | 93e4d15 | 2011-09-13 02:23:39 -0400 | [diff] [blame] | 37 | void findFrameStart(ApiTraceFrame *frame); |
| 38 | void findFrameEnd(ApiTraceFrame *frame); |
Zack Rusin | da7579b | 2011-09-13 17:33:05 -0400 | [diff] [blame^] | 39 | void findCallIndex(int index); |
Zack Rusin | 20b1f6d | 2011-09-06 11:50:07 -0400 | [diff] [blame] | 40 | |
| 41 | signals: |
| 42 | void startedParsing(); |
Zack Rusin | ebf971e | 2011-09-06 17:44:43 -0400 | [diff] [blame] | 43 | void parsed(int percent); |
Zack Rusin | 20b1f6d | 2011-09-06 11:50:07 -0400 | [diff] [blame] | 44 | void finishedParsing(); |
| 45 | |
| 46 | void framesLoaded(const QList<ApiTraceFrame*> &frames); |
Zack Rusin | 8f98c3a | 2011-09-11 18:21:29 -0400 | [diff] [blame] | 47 | void frameContentsLoaded(ApiTraceFrame *frame, |
| 48 | const QVector<ApiTraceCall*> &calls, |
| 49 | quint64 binaryDataSize); |
Zack Rusin | 20b1f6d | 2011-09-06 11:50:07 -0400 | [diff] [blame] | 50 | |
Zack Rusin | 8f98c3a | 2011-09-11 18:21:29 -0400 | [diff] [blame] | 51 | void searchResult(ApiTrace::SearchResult result, ApiTraceCall *call); |
Zack Rusin | 93e4d15 | 2011-09-13 02:23:39 -0400 | [diff] [blame] | 52 | void foundFrameStart(ApiTraceFrame *frame); |
| 53 | void foundFrameEnd(ApiTraceFrame *frame); |
Zack Rusin | da7579b | 2011-09-13 17:33:05 -0400 | [diff] [blame^] | 54 | void foundCallIndex(ApiTraceCall *call); |
Zack Rusin | 20b1f6d | 2011-09-06 11:50:07 -0400 | [diff] [blame] | 55 | private: |
José Fonseca | 61e61f7 | 2011-09-11 16:53:34 +0100 | [diff] [blame] | 56 | struct FrameBookmark { |
| 57 | FrameBookmark() |
Zack Rusin | 20b1f6d | 2011-09-06 11:50:07 -0400 | [diff] [blame] | 58 | : numberOfCalls(0) |
| 59 | {} |
José Fonseca | 61e61f7 | 2011-09-11 16:53:34 +0100 | [diff] [blame] | 60 | FrameBookmark(const Trace::ParseBookmark &s) |
Zack Rusin | 20b1f6d | 2011-09-06 11:50:07 -0400 | [diff] [blame] | 61 | : start(s), |
| 62 | numberOfCalls(0) |
| 63 | {} |
| 64 | |
José Fonseca | 61e61f7 | 2011-09-11 16:53:34 +0100 | [diff] [blame] | 65 | Trace::ParseBookmark start; |
Zack Rusin | 20b1f6d | 2011-09-06 11:50:07 -0400 | [diff] [blame] | 66 | int numberOfCalls; |
Zack Rusin | 20b1f6d | 2011-09-06 11:50:07 -0400 | [diff] [blame] | 67 | }; |
| 68 | bool isCallAFrameMarker(const Trace::Call *call) const; |
| 69 | int numberOfFrames() const; |
| 70 | int numberOfCallsInFrame(int frameIdx) const; |
| 71 | |
| 72 | void loadHelpFile(); |
| 73 | void scanTrace(); |
| 74 | void parseTrace(); |
Zack Rusin | ebf971e | 2011-09-06 17:44:43 -0400 | [diff] [blame] | 75 | |
Zack Rusin | 8f98c3a | 2011-09-11 18:21:29 -0400 | [diff] [blame] | 76 | int callInFrame(int callIdx) const; |
| 77 | bool callContains(Trace::Call *call, |
| 78 | const QString &str, |
| 79 | Qt::CaseSensitivity sensitivity); |
| 80 | QVector<ApiTraceCall*> fetchFrameContents(ApiTraceFrame *frame); |
Zack Rusin | 121e316 | 2011-09-13 01:35:12 -0400 | [diff] [blame] | 81 | bool searchCallsBackwards(const QList<Trace::Call*> &calls, |
| 82 | int frameIdx, |
| 83 | const QString &str, |
| 84 | Qt::CaseSensitivity sensitivity); |
Zack Rusin | 8f98c3a | 2011-09-11 18:21:29 -0400 | [diff] [blame] | 85 | |
Zack Rusin | 20b1f6d | 2011-09-06 11:50:07 -0400 | [diff] [blame] | 86 | private: |
Zack Rusin | 20b1f6d | 2011-09-06 11:50:07 -0400 | [diff] [blame] | 87 | Trace::Parser m_parser; |
| 88 | QString m_fileName; |
| 89 | ApiTrace::FrameMarker m_frameMarker; |
| 90 | |
José Fonseca | 61e61f7 | 2011-09-11 16:53:34 +0100 | [diff] [blame] | 91 | typedef QMap<int, FrameBookmark> FrameBookmarks; |
| 92 | FrameBookmarks m_frameBookmarks; |
Zack Rusin | 8f98c3a | 2011-09-11 18:21:29 -0400 | [diff] [blame] | 93 | QList<ApiTraceFrame*> m_createdFrames; |
Zack Rusin | 20b1f6d | 2011-09-06 11:50:07 -0400 | [diff] [blame] | 94 | |
| 95 | QHash<QString, QUrl> m_helpHash; |
Zack Rusin | ebf971e | 2011-09-06 17:44:43 -0400 | [diff] [blame] | 96 | |
| 97 | QVector<ApiTraceCallSignature*> m_signatures; |
| 98 | QVector<ApiTraceEnumSignature*> m_enumSignatures; |
Zack Rusin | 20b1f6d | 2011-09-06 11:50:07 -0400 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | #endif |