diff options
author | José Fonseca <jose.r.fonseca@gmail.com> | 2011-09-11 14:14:21 +0100 |
---|---|---|
committer | José Fonseca <jose.r.fonseca@gmail.com> | 2011-09-11 14:14:21 +0100 |
commit | 6a6d3e49f4dfc942e0f7a7f1cbcee9c5e1b0008c (patch) | |
tree | 54c6d056279532bfc985f242dc3dbe6bc632f283 /trace_parser.hpp | |
parent | 7b1d0135921b9f5e795798e9a020c59a58301e8c (diff) |
Parse the signatures only once.
Also use simple offset comparison instead of search in a set to determine
weather a signature is to be expected or not.
Diffstat (limited to 'trace_parser.hpp')
-rw-r--r-- | trace_parser.hpp | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/trace_parser.hpp b/trace_parser.hpp index 15b0ccb..1a2f9e1 100644 --- a/trace_parser.hpp +++ b/trace_parser.hpp @@ -46,27 +46,31 @@ protected: typedef std::list<Call *> CallList; CallList calls; - typedef std::vector<FunctionSig *> FunctionMap; - FunctionMap functions; + // Helper template that extends a base signature structure, with additional + // parsing information. + template< class T > + struct SigState : public T { + // Offset in the file of where signature was defined. It is used when + // reparsing to determine whether the signature definition is to be + // expected next or not. + File::Offset offset; + }; + + typedef SigState<FunctionSig> FunctionSigState; + typedef SigState<StructSig> StructSigState; + typedef SigState<EnumSig> EnumSigState; + typedef SigState<BitmaskSig> BitmaskSigState; + + typedef std::vector<FunctionSigState *> FunctionMap; + typedef std::vector<StructSigState *> StructMap; + typedef std::vector<EnumSigState *> EnumMap; + typedef std::vector<BitmaskSigState *> BitmaskMap; - typedef std::vector<StructSig *> StructMap; + FunctionMap functions; StructMap structs; - - typedef std::vector<EnumSig *> EnumMap; EnumMap enums; - - typedef std::vector<BitmaskSig *> BitmaskMap; BitmaskMap bitmasks; - typedef std::set<File::Offset> TraceOffsets; - TraceOffsets m_callSigOffsets; - TraceOffsets m_structSigOffsets; - TraceOffsets m_enumSigOffsets; - TraceOffsets m_bitmaskSigOffsets; - - typedef std::map<File::Offset, unsigned> CallNumOffsets; - CallNumOffsets m_callNumOffsets; - bool m_supportsSeeking; unsigned next_call_no; @@ -99,11 +103,6 @@ public: file->setCurrentOffset(offset); } - bool callWithSignature(const File::Offset &offset) const; - bool structWithSignature(const File::Offset &offset) const; - bool enumWithSignature(const File::Offset &offset) const; - bool bitmaskWithSignature(const File::Offset &offset) const; - unsigned currentCallNumber() const { return next_call_no; @@ -122,6 +121,11 @@ public: Call *scan_call(); protected: + FunctionSig *parse_function_sig(void); + StructSig *parse_struct_sig(); + EnumSig *parse_enum_sig(); + BitmaskSig *parse_bitmask_sig(); + void parse_enter(void); Call *parse_leave(void); |