apitrace/apitrace — pull request #242 by lawlove (2014-03-21 21:51:50+00:00)
Title: qapitrace: merge duplicate logic in TraceLoader

Note: This patch can supercede pull requests #228 and #240

Problem:
Two member functions of TraceLoader (parseTrace and fetchFrameContents)
are using duplicate functionality to retrieve a Frame's Call contents.
Both functions had defects in their logic. Any changes in regard to that
logic has to be made in both functions.

Examples:
Recently a patch for fetchFrameContents (pull request #228) was also
found to be needed for parseTrace.

Another recent patch (pull request #240) was because a slight logic
difference between the two causes parseTrace to fail in loading traces
with groups

Solution:
This patch combines the logic into a separate object that both member
functions can access to retrieve the data.

Implementation details:
The main difference between the two in combining the functionality is
that the Calls list is pre-allocated in the case of fetchFrameContents
but not so for the parseTrace case. (fetchFrameContents is allocated
because the frames have been pre-scanned and it's known how many calls
the frame contains whereas parseTrace loads the entire trace on
initialization with each Frame's Calls added on the fly.)

That distinction in the new object is handled by the constructor default
input argument "numOfCalls" and used as a flag for those variances.

Testing:
Tested with both trace files from issue #218 and with both parseTrace
and scanTrace (tied to fetchFrameContents); debug_khr (mutli-level
groups); and non-group trace, glxgears

Signed-off-by: Lawrence L Love