The root cause of the problem was a bug in the implementation of
getZygoteProcessName. When the wrap.$procname approach is used, reading
/proc/cmdline produces "$procname\0/system/bin\0--application\0"... (with
embedded zero characters).
Fixed by simply not supplying length argument to the truncate call, which will
truncate to strlen(). The same bug is also present in getProcessName.
Carl Worth [Mon, 11 Mar 2013 20:22:05 +0000 (13:22 -0700)]
Use skiplist-based FastCallSet within trace::CallSet
The FastCallSet supports only ranges step of 1 and freq of
FREQUENCY_ALL, so store any such ranges there, and store all other
ranges in the existing, linear list of CallRange.
For manually entered call sets on the command line, the performance
hit of the linear lookup was not generally a problem. But when taking
the (potentially huge) output of "apitrace trim --print-callset" the
performance hit made things quite painful. This makes things usable
again.
Carl Worth [Mon, 11 Mar 2013 19:14:06 +0000 (12:14 -0700)]
Extend trim::CallSet with a new range-based add method.
Previously, individual calls had to be added one-at-a-time. This was
adequate for trimming functionality where one call is examined at a
time.
But I'm now wanting to use this same CallSet code to dramatically
optimize the performance of callset specifications on the apitrace
command-line, (in particular large callsets resulting from "apitrace
trim --print-callset"). In this case, we really want to add entire
call ranges rather than just one call at a time.
Carl Worth [Wed, 22 Aug 2012 18:59:12 +0000 (11:59 -0700)]
trim: Use custom skiplist for required list (instead of std::set<unsigned>)
The std::set<unsigned>::insert method has been dominating profile
output for trimming large traces. Meanwhile, the access patterns of
TraceAnalyzer on the required list is extremely structured; it often
adds the next sequential integer. So we can optimize this data
structure dramatically with two additions:
1. Store ranges rather than single elements, so that the addition of
a new number can expand an existing range rather than inserting a
new element.
2. Remember the most recent element looked-up so that we can check
it first and not do any new lookup for in-order accesses.
With these two changes we get O(1) behavior for the access pattern of
adding sequential integers. For other cases we can still get
logarithmic behavior, but we can keep N dramatically smaller.
Unfortunately, we can't implement either change (that I can see) with
STL. I don't see any way to support lookup with range-based elements
in any STL data structure.
So here, I implement a skip-list based callset data structure. It
provides optimization (1) above and affords an easy implementation of
(2) as well, (though that is postponed to a later commit).
The skip-list implementation is ported from a C version which Keith
Packard and I implemented for cairo, and with the identical license as
the license of apitrace. The reference I used is the commit named c2509f8a721ec489e1b44fa8a68be165363787a7 in the cairo repository.
In addition to changing from C to C++, I implemented range-based
elements.
Do not call trimDirectory() on the proc_name of Zygote processes, because
a Zyogote process name never contains a path separator. The proc_name of
a Zygote process is the application's package name (such as
com.exampe.myapp) because ActivityManager rewrites argv[0].
There exists an undiagnosed problem with trimDirectory, but I have been
unsuccessful diagnosing it. On the other hand, the call to trimDirectory
isn't needed and its removal fixes the bug's symptoms.
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
José Fonseca [Mon, 10 Jun 2013 07:05:29 +0000 (08:05 +0100)]
gltrace: Expose marker functions when tracing is disabled.
Matches the output of change proposed by Peter Lohrmann in issue #138,
but with slightly less new code.
This is achieved by adding a new hook point, doInvokeFunction (could not
think of a better name), used to generate the call to the real function,
both when trace is enabled or disabled.
Gregory Hainaut [Sun, 9 Jun 2013 08:06:28 +0000 (09:06 +0100)]
gltrace: Prevent crash in _glGetDebugMessageLog_length (issue #140).
The function was not being called correctly from glGetDebugMessageLog
(and others).
From the spec the GL function:
lengths is an array provided by the application and count is the
maximum number of message that the driver will report into attribute
array (ie lengths). That mean if the driver report 3 messages only
lengths[0 to 2] are valid, others part are not valid and could have
random data.
José Fonseca [Tue, 4 Jun 2013 15:59:21 +0000 (16:59 +0100)]
retrace: Remove the -c/--compare=PREFIX .
That is, remove the ability to compare images while replaying.
For several reasons:
- This duplicates diff-images command.
- It is less versatile -- it is unable to output diff images.
- It will be necessary to change how snapshots are done to properly
accommodate APIs that have no concept of current context, like
Direct3D APIs, so the less fat on this code the better.
It seems that elf.c for some reason includes snappy/config.h instead of
its own generated config.h, possbily due to wrong order of include
directories. Solved it by explicitly including
${CMAKE_CURRENT_BINARY_DIR} before all other paths.
José Fonseca [Thu, 30 May 2013 13:00:44 +0000 (14:00 +0100)]
dxgitrace: Handle simultanous D3D11 maps.
On D3D11 Map/Unmap are context methods, not resource methods, but in order
to handle simultanous maps we need to put the book-keeping in the
resource objects.
Vasil Dimov [Fri, 24 May 2013 11:50:51 +0000 (14:50 +0300)]
In Android.mk: explicitly specify the toolchain
If NDK is cloned from git://codeaurora.org/platform/prebuilt instead of
from git://android.git.linaro.org/platform/prebuilt then
prebuilt/linux-x86/toolchain/ contains some extra entries that confuse
the toolchain pickup logic in cmake/toolchain/android.toolchain.cmake,
thus we explicitly specify the toolchain via ANDROID_TOOLCHAIN_NAME.
libbacktrace #include's two header files from GCC. Provide minimal
replacements for those files. For filenames.h, declare missing macros
assuming POSIX-style paths. For dwarf2.h, #include system dwarf.h and
declare missing enum tags and define missing enum values as macros.
There was a bool field that was caching results of 'is_backtrace_needed'
lookups. Now that field is gone, and 'is_backtrace_needed' is called
repeatedly. I guess it's not that bad (it boils down to a lookup in an
std::set), but that function was also printing notices for functions
with enabled stack trace recording, and now those messages are printed
repeatedly as well. The following patch removes the notices completely
and slightly cleans up the surrounding code.