return m_frameOffsets.size();
}
-int Loader::numberOfCallsInFrame(int frameIdx)
+int Loader::numberOfCallsInFrame(int frameIdx) const
{
if (frameIdx > m_frameOffsets.size()) {
return 0;
}
-
- return m_frameOffsets[frameIdx].numberOfCalls;
+ FrameOffsets::const_iterator itr =
+ m_frameOffsets.find(frameIdx);
+ return itr->second.numberOfCalls;
}
bool Loader::open(const char *filename)
File::Offset startOffset;
int numOfFrames = 0;
int numOfCalls = 0;
+ unsigned callNum = 0;
startOffset = m_parser.currentOffset();
+ callNum = m_parser.currentCallNumber();
while ((call = m_parser.parse_call())) {
if (isCallAFrameMarker(call)) {
File::Offset endOffset = m_parser.currentOffset();
- FrameOffset frameOffset(startOffset, endOffset);
-
+ FrameOffset frameOffset(startOffset);
frameOffset.numberOfCalls = numOfCalls;
+ frameOffset.callNumber = callNum;
+
m_frameOffsets[numOfFrames] = frameOffset;
++numOfFrames;
startOffset = endOffset;
+ callNum = m_parser.currentCallNumber();
numOfCalls = 0;
}
//call->dump(std::cout, color);
{
int numOfCalls = numberOfCallsInFrame(idx);
if (numOfCalls) {
+ const FrameOffset &frameOffset = m_frameOffsets[idx];
std::vector<Trace::Call*> calls(numOfCalls);
- m_parser.setCurrentOffset(m_frameOffsets[idx].start);
+ m_parser.setCurrentOffset(frameOffset.start);
+ m_parser.setCurrentCallNumber(frameOffset.callNumber);
Trace::Call *call;
int parsedCalls = 0;
void setFrameMarker(Loader::FrameMarker marker);
int numberOfFrames() const;
- int numberOfCallsInFrame(int frameIdx);
+ int numberOfCallsInFrame(int frameIdx) const;
bool open(const char *filename);
void close();
FrameOffset()
: numberOfCalls(0)
{}
- FrameOffset(const File::Offset &s,
- const File::Offset &e)
+ FrameOffset(const File::Offset &s)
: start(s),
- end(e),
numberOfCalls(0)
{}
File::Offset start;
- File::Offset end;
int numberOfCalls;
+ unsigned callNumber;
};
bool isCallAFrameMarker(const Trace::Call *call) const;
std::map<int, Trace::Frame*> m_frameCache;
std::queue<Trace::Frame*> m_loadedFrames;
- std::map<int, FrameOffset> m_frameOffsets;
+ typedef std::map<int, FrameOffset> FrameOffsets;
+ FrameOffsets m_frameOffsets;
Trace::File *file;
};
Call *call = new Call(sig);
- if (hasCallBeenParsed(offset)) {
- call->no = callNumForOffset(offset);
- } else {
- call->no = next_call_no++;
- m_callNumOffsets.insert(
- std::pair<File::Offset, unsigned>(offset, call->no));
- }
+
+ call->no = next_call_no++;
if (parse_call_details(call)) {
calls.push_back(call);
return m_bitmaskSigOffsets.find(offset) != m_bitmaskSigOffsets.end();
}
-bool Parser::hasCallBeenParsed(const File::Offset &offset) const
-{
- return m_callNumOffsets.find(offset) != m_callNumOffsets.end();
-}
-
-unsigned Parser::callNumForOffset(const File::Offset &offset) const
-{
- CallNumOffsets::const_iterator itr = m_callNumOffsets.find(offset);
- assert(itr != m_callNumOffsets.end());
- return itr->second;
-}
-
} /* namespace Trace */
bool supportsOffsets() const
{
- return file-supportsOffsets();
+ return file->supportsOffsets();
}
File::Offset currentOffset()
bool structWithSignature(const File::Offset &offset) const;
bool enumWithSignature(const File::Offset &offset) const;
bool bitmaskWithSignature(const File::Offset &offset) const;
- bool hasCallBeenParsed(const File::Offset &offset) const;
- unsigned callNumForOffset(const File::Offset &offset) const;
+
+ unsigned currentCallNumber() const
+ {
+ return next_call_no;
+ }
+
+ void setCurrentCallNumber(unsigned num)
+ {
+ next_call_no = num;
+ }
protected:
void parse_enter(void);