Milian Wolff [Sun, 22 Jan 2017 00:01:08 +0000 (01:01 +0100)]
Fix CMake warning about minimum version when trying to find KF5
Disable even trying to build the GUI when we deal with a CMake older
than 2.8.12.
CMake Warning (dev) at /home/milian/projects/compiled/kf5/share/ECM/modules/ECMFindModuleHelpers.cmake:133 (message):
Your project should require at least CMake 2.8.12 to use FindKF5.cmake
Call Stack (most recent call first):
/home/milian/projects/compiled/kf5/share/ECM/find-modules/FindKF5.cmake:52 (ecm_find_package_version_check)
CMakeLists.txt:35 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
Milian Wolff [Sat, 21 Jan 2017 23:57:17 +0000 (00:57 +0100)]
Update copyright header in two more places
Milian Wolff [Sat, 21 Jan 2017 23:42:23 +0000 (00:42 +0100)]
Elide text of flamegraph items
This prevents the flickering when hovering an item with a long text.
That lead the label to wordwrap, increasing the height of the label,
decreasing the height of the view, moving the scene, thus the mouse
points to a different view and we would repeat again.
Now we simply elide the text on the right of the label. This works,
but it's cutting of the text too soon, since it cannot cope with
the HTML and thinks all of these chars will get painted...
Milian Wolff [Sat, 21 Jan 2017 22:48:46 +0000 (23:48 +0100)]
Use new LocationData::Ptr typedef everywhere
Milian Wolff [Sat, 21 Jan 2017 22:46:24 +0000 (23:46 +0100)]
Add context menu to open file location to model views
This just goes through QDesktopServices and does not yet allow
the user to configure what editor he wants to use to open the file.
Milian Wolff [Sat, 21 Jan 2017 18:35:44 +0000 (19:35 +0100)]
Properly connect filters to corresponding view proxy model
Burkhard Lück [Sat, 21 Jan 2017 16:29:29 +0000 (17:29 +0100)]
move Messages.sh to follow code changes
Milian Wolff [Sat, 21 Jan 2017 12:58:21 +0000 (13:58 +0100)]
Make it possible to run heaptrack from the build folder
By setting the correct CMake properties, the libraries, shell runner
and executables land in the correct folder layout in the build
directory. This way, we can run heaptrack directly from the build
dir, i.e.:
cd heaptrack/build
make
./bin/heaptrack <your app>
./bin/heaptrack_gui <data file>
Milian Wolff [Sat, 21 Jan 2017 12:40:21 +0000 (13:40 +0100)]
Move libunwind CMake logic into FindLibunwind.cmake
This fixes a build regression when using a clean build folder.
The find script is copied from zbackup, cf.:
https://raw.githubusercontent.com/zbackup/zbackup/master/cmake/FindLibUnwind.cmake
It was slightly adapted to find the symbols required for heaptrack
and not depend on symbols we don't actually need here.
While at it, extract the configuration defines out into its own
libunwind_config.h.
Milian Wolff [Sat, 21 Jan 2017 11:49:57 +0000 (12:49 +0100)]
Collapse recursive frames by default in flame graph
When enabled, this option cleans up the flamegraph in face of
recursive function calls. Note that this only skips recursion when
a function is calling itself directly - if there is another function
inbetween, the frames won't get collapsed.
Milian Wolff [Sat, 21 Jan 2017 11:37:24 +0000 (12:37 +0100)]
Reorder caller/callee columns
- put location first
- then show peak memory consumption and leaked cost
- followed by number of allocations and temporary allocations
- finally show throughput of total bytes allocated
- sort by peak memory consumption
Milian Wolff [Sat, 21 Jan 2017 11:30:55 +0000 (12:30 +0100)]
Don't increment caller/callee cost multiple times for recursive stacks
When we encounter a call stack with a recursive function call, we must
not increment the caller/callee cost more than once per stack. This
fixes the cost calculation for such stacks, which used to produce
costs that where sometimes beyond the actual peak cost.
Milian Wolff [Sat, 21 Jan 2017 11:29:22 +0000 (12:29 +0100)]
Remove extra ';'
Fixes compiler warnings in pedantic mode.
Fabrizio Oddone [Fri, 20 Jan 2017 21:52:43 +0000 (13:52 -0800)]
Include cinttypes where required.
This change is required to fix compilation errors under DevToolset4 on
CentOS with gcc 5.2.1, cf.:
https://www.softwarecollections.org/en/scls/rhscl/devtoolset-4/
Milian Wolff [Wed, 11 Jan 2017 15:06:38 +0000 (16:06 +0100)]
Update copyright year
Milian Wolff [Wed, 11 Jan 2017 13:50:24 +0000 (14:50 +0100)]
Restructure source code directory layout
Everything that's not 3rdparty or tests is now moved into the src
subfolder. That one in turn contains the following folders:
- util: shared helper functionality
- track: core functionality of heaptrack, i.e. the stuff that
gets injected into the client code
- interpret: does the first-level aggregation and DWARF translations
on the raw instruction pointers returned by tracking code
- analyze: high-level analyzers, i.e.:
print: the ASCII dumper
gui: the Qt/KDE GUI
Milian Wolff [Sun, 8 Jan 2017 23:00:51 +0000 (00:00 +0100)]
Merge remote-tracking branch 'paulmenzel/improve-readme.md'
Milian Wolff [Sun, 8 Jan 2017 22:58:22 +0000 (23:58 +0100)]
Fix flamegraph tooltip for top-level item
Use the item's "function" directly, as that one is actually a
tooltip-like label already for the top-level item.
Milian Wolff [Sun, 8 Jan 2017 22:46:10 +0000 (23:46 +0100)]
Add screenshots to README.md file
Milian Wolff [Sun, 8 Jan 2017 22:33:04 +0000 (23:33 +0100)]
Use the internal `__libc_dlopen_mode` symbol instead of `dlmopen`
Both, `dlmopen` and `dlopen` are only available when the debugeee
application links against libdl. When that is not the case, one
could not inject heaptrack at runtime.
By instead using the libc.so internal `__libc_dlopen_mode` function,
we get rid of this limitation and we can also inject into applications
that only link against libc.so but not libdl.
This trick was found in the linux-inject project:
https://github.com/gaffe23/linux-inject
Milian Wolff [Sun, 8 Jan 2017 22:33:01 +0000 (23:33 +0100)]
Document that you need gdb for runtime-attaching.
Milian Wolff [Sun, 8 Jan 2017 22:10:28 +0000 (23:10 +0100)]
Make dependency on KChart optional
The heaptrack_gui is pretty useable without KChart. So for those
who don't have access to KChart, simply skip charting and only
display the table views of raw data. Still better than using
heaptrack_print.
Milian Wolff [Sun, 8 Jan 2017 21:26:38 +0000 (22:26 +0100)]
Add basic documentation on how to build heaptrack
Most notably, tell the world about the various dependencies that
heaptrack has, both the core data collector as well as the analyzer
GUI.
Milian Wolff [Tue, 15 Nov 2016 22:29:54 +0000 (23:29 +0100)]
Link against libunwind directly, we don't need to link against the backtrace library here.
Milian Wolff [Tue, 15 Nov 2016 22:26:53 +0000 (23:26 +0100)]
Fix use-after-free in usage of libbacktrace.
We passed the c_str of a temporary std::string to libbacktrace,
which stored that in internal data structures. Later on, that dangling
pointer was accessed leading to subtle bugs which for odd reasons
did not became apparent until recently. Running the interpreter
through valgrind easily showed the problem though.
This fixes the 'failed to read executable information' error messages
emitted by heaptrack, and also ensures the profile data attributes
costs to the correct modules.
CCMAIL: apol@kde.org
Paul Menzel [Thu, 1 Sep 2016 13:30:37 +0000 (15:30 +0200)]
README: Remove trailing whitespace
Paul Menzel [Thu, 1 Sep 2016 13:31:33 +0000 (15:31 +0200)]
README: Add newline to end of file
Text files should end with a newline. So add one.
Milian Wolff [Tue, 16 Aug 2016 08:08:48 +0000 (10:08 +0200)]
Extend error message.
If dwarf.h is not found, then either elfutils-dev or libdwarf-dev need to be installed
Milian Wolff [Mon, 20 Jun 2016 09:42:59 +0000 (11:42 +0200)]
Add pool-allocator API for heaptrack.
This is a header-only API that you can use to add support for
pool-allocators or other custom allocators to heaptrack. Simply
include the header and call the `heaptrack_report_*` macros in
your custom allocator. When you trace your code under heaptrack,
the allocations will then be tracked. If you don't run under
heaptrack, nothing will happen.
#include <heaptrack.h>
void* MyPool::allocate(size_t s)
{
void* ptr = /* allocate s */;
heaptrack_report_malloc(ptr, s);
return ptr;
}
void MyPool::free(void* ptr)
{
heaptrack_report_free(ptr);
/* actually free */
}
Milian Wolff [Thu, 16 Jun 2016 10:21:37 +0000 (12:21 +0200)]
Make libheaptrack.h C-compliant.
Milian Wolff [Mon, 20 Jun 2016 11:52:16 +0000 (13:52 +0200)]
Skip top rows without cost.
This can happen when diffing files.
Milian Wolff [Fri, 17 Jun 2016 16:47:35 +0000 (18:47 +0200)]
Remove rows without cost from caller/callee data.
This reduces clutter for diffs.
Milian Wolff [Fri, 17 Jun 2016 16:28:00 +0000 (18:28 +0200)]
Merge branch 'wip/diffing'
Milian Wolff [Fri, 17 Jun 2016 16:27:22 +0000 (18:27 +0200)]
Also disable flame graphs in diff mode.
In the future, we may want to implement differential flame graphs,
but for now this is too much work.
Milian Wolff [Fri, 17 Jun 2016 15:38:32 +0000 (17:38 +0200)]
Disable charts in diff mode.
This could be implemented eventually, but is a lot of work.
Milian Wolff [Fri, 17 Jun 2016 15:23:14 +0000 (17:23 +0200)]
Load diff base data in parallel to primary data file.
Slightly improves performance when diffing.
Milian Wolff [Fri, 17 Jun 2016 14:41:23 +0000 (16:41 +0200)]
Reword --diff CLI help text, add -d, for heaptrack_gui.
Milian Wolff [Fri, 17 Jun 2016 14:38:45 +0000 (16:38 +0200)]
Make it possible to easily diff between files from the heaptrack_gui.
Milian Wolff [Fri, 17 Jun 2016 11:56:36 +0000 (13:56 +0200)]
Add some more code comments for the diffing method.
Milian Wolff [Tue, 14 Jun 2016 21:45:36 +0000 (23:45 +0200)]
Convert more data types to signed integers.
We now also calculate the difference between time, peakRSS and
system info when diffing heaptrack data files.
Milian Wolff [Tue, 31 May 2016 22:06:12 +0000 (00:06 +0200)]
Add diff support between files to heaptrack_{print,gui}.
Both executables get a new `--diff <file>` argument. The file
that is passed gets parsed in addition to the primary data file.
The allocation data therein will then be subtracted from the data
found in the primary data file.
The algorithm is somewhat complicated, because we have to ignore
instruction pointer addresses, as these will vary between runs
due to address space randomization. Paired with (partial) lack of
debug symbols, we end up with non-trivial situation to map allocations
from one run to that of another.
Essentially, we need to find the correct allocation that shares the
same backtrace while ignoring instruction pointer addresses.
Milian Wolff [Tue, 14 Jun 2016 15:20:29 +0000 (17:20 +0200)]
Don't crash when switching the call-stack direction.
Milian Wolff [Mon, 13 Jun 2016 09:13:11 +0000 (11:13 +0200)]
Add basic README.md
Milian Wolff [Mon, 30 May 2016 19:27:23 +0000 (21:27 +0200)]
Refactor code to use signed data types.
This is required to handle diffing between files or between
individual timestamps. Since we use 64bit data types, we
can still handle a lot of allocations this way (a bit more than
9 exabytes).
Milian Wolff [Tue, 31 May 2016 22:06:02 +0000 (00:06 +0200)]
Add minus operator to AllocationData
Milian Wolff [Wed, 8 Jun 2016 16:27:34 +0000 (18:27 +0200)]
Make it possible to skip building of heaptrack_gui.
For embedded, we never want to build the gui, and having the
find scripts spit out their errors there is just noisy.
Now, the recommended way to build heaptrack for embedded Linux is:
cmake -DCMAKE_TOOLCHAIN_FILE=... -DHEAPTRACK_BUILD_GUI=OFF
Milian Wolff [Wed, 8 Jun 2016 15:16:27 +0000 (17:16 +0200)]
Refactor code to remove reliance on undefined behavior.
Previously, the code got away with a c-style reinterpret_cast
in a constexpr function, which is not allowed according to the
standard. I think I was just lucky that the compiler didn't saw
through that yet.
Also, the code assumed (and enforced) that all function pointers
are sizeof(void*), which worked, but was a bit clunky.
Now, we simply get rid of the list of addresses, and iterate
manually over all hooks. With C++17's apply, this could be implemented
even nicer with a tuple and std::apply. That doesn't exist yet, so
we manually call the functions.
Milian Wolff [Wed, 8 Jun 2016 13:08:16 +0000 (15:08 +0200)]
Slightly cleanup code of preload hooks.
We instantiate directly with the decltype of a function
pointer now, so thereis no need to construct the pointer
via a secondary type anymore.
Milian Wolff [Wed, 8 Jun 2016 12:48:59 +0000 (14:48 +0200)]
Increase portability to systems that don't have cfree available.
cfree should not be used, according to its man page, but if it's
being used then we need to overload it. On systems where it is not
available, simply skip this step to keep heaptrack compiling.
Milian Wolff [Sat, 4 Jun 2016 17:36:02 +0000 (19:36 +0200)]
Track temporary allocations by their AllocationInfo index.
There is no need to output a boolean '1' for temporary allocations,
as we have the same information when looking at the AllocationInfo
index that corresponds to a unique size and location. I.e. we used
to output
+ 12
- 12 1
+ 42
- 43
But the same information is held by
+ 12
- 12
+ 42
- 43
Milian Wolff [Fri, 3 Jun 2016 19:29:54 +0000 (21:29 +0200)]
Move MergedAllocation struct to heaptrack_print.
It's only being used there.
Milian Wolff [Thu, 2 Jun 2016 10:02:07 +0000 (12:02 +0200)]
Make heaptrack.sh shell script work with dash.
Milian Wolff [Thu, 2 Jun 2016 10:01:29 +0000 (12:01 +0200)]
Improve bash compatibility of heaptrack shell script.
- don't use case fall-through via ;;&
- access /proc/$pid/comm directly
Milian Wolff [Sun, 29 May 2016 18:05:10 +0000 (20:05 +0200)]
Update display text when navigation through history.
Milian Wolff [Sun, 29 May 2016 17:44:32 +0000 (19:44 +0200)]
Make text in labels selectable by mouse.
Milian Wolff [Sun, 29 May 2016 17:39:51 +0000 (19:39 +0200)]
Make it possible to go back/forward in flamegraph via keyboard.
We keep a simple list of items around that got selected and use
that when the user presses the standard back/forward keys to
reset the view state accordingly.
Milian Wolff [Tue, 10 May 2016 08:21:07 +0000 (10:21 +0200)]
Fix compile: include cmath and use std::round.
Milian Wolff [Thu, 28 Apr 2016 17:11:43 +0000 (19:11 +0200)]
Add a dock widget with the important graphs.
This allows the data to be visible when looking at other data
and that makes it easier to correlate then.
Milian Wolff [Thu, 28 Apr 2016 16:13:23 +0000 (18:13 +0200)]
Improve tooltips on total data of charts.
Frederik Schwarzer [Sun, 10 Apr 2016 18:10:23 +0000 (20:10 +0200)]
Remove wrong unit. formatByteSize() returns the right one.
Milian Wolff [Sat, 9 Apr 2016 12:02:02 +0000 (14:02 +0200)]
Add tooltips for more UI elements in the flame graph view.
Milian Wolff [Sat, 9 Apr 2016 11:29:43 +0000 (13:29 +0200)]
Set cursors to show that you can interact with the flame graph.
Milian Wolff [Sat, 9 Apr 2016 11:16:23 +0000 (13:16 +0200)]
Use monospace font for function labels in description.
Note: <tt> uses the wrong font, afaik that got fixed for 5.6.1 or 5.7.
Milian Wolff [Sat, 9 Apr 2016 11:15:06 +0000 (13:15 +0200)]
Enable wordwrap to prevent layout issues on wide function labels.
Stephen Kelly [Wed, 6 Apr 2016 14:41:00 +0000 (16:41 +0200)]
Move the frame description to the bottom of the ui
Otherwise the tooltip fades away too quickly, and often the mouse cursor covers
and hides the number at the start of it.
Stephen Kelly [Wed, 6 Apr 2016 09:48:50 +0000 (11:48 +0200)]
Replace rigid layout with a QSplitter
Milian Wolff [Tue, 5 Apr 2016 21:39:19 +0000 (23:39 +0200)]
HTML-escape strings in tooltips, esp. required for C++ templates.
Milian Wolff [Tue, 5 Apr 2016 21:34:25 +0000 (23:34 +0200)]
Fix wrong conditional that lead to excessive i18n calls.
Milian Wolff [Tue, 5 Apr 2016 21:33:40 +0000 (23:33 +0200)]
Cache QPen and QBrush used by ChartModel.
This removes quite a few allocations that would otherwise happen
when the data is queried by KDiagram.
Milian Wolff [Tue, 5 Apr 2016 20:50:30 +0000 (22:50 +0200)]
Add relative cost numbers to the tree model tooltips.
Milian Wolff [Tue, 5 Apr 2016 20:39:34 +0000 (22:39 +0200)]
Show cost fractions in flamegraph tooltips.
Milian Wolff [Tue, 5 Apr 2016 20:30:23 +0000 (22:30 +0200)]
Introduce cost threshold for flamegraph to minimize memory overhead.
For larger data files, the flamegraph can easily consume hundreds
of megabytes of ram and take multiple seconds to be build up. This
is mostly due to the dozens of small leaf items, all of which only
have tiny cost and will not be shown most of the time.
The new default cut-off of 0.1% drastically reduces the memory
overhead and the flamegraph will be build nearly instantly even for
larger data sets.
In the future, one could even refine the data on-demand.
Milian Wolff [Thu, 24 Mar 2016 23:07:10 +0000 (00:07 +0100)]
Add an experimental perf->heaptrack data converter.
The resulting data file is much smaller than a perf.data file, and
can be visualized with heaptrack_gui. Of course, the labels will be
all off, but this is a good first step towards visualizing perf data
files with the heaptrack code infrastructure.
Milian Wolff [Thu, 24 Mar 2016 22:49:19 +0000 (23:49 +0100)]
Prevent off-by-one data access in chart models.
Milian Wolff [Thu, 24 Mar 2016 21:34:08 +0000 (22:34 +0100)]
Make code more error resilient when parsing data files.
Milian Wolff [Thu, 24 Mar 2016 21:33:36 +0000 (22:33 +0100)]
Check validity of allocation index when parsing data file.
Milian Wolff [Thu, 24 Mar 2016 19:33:10 +0000 (20:33 +0100)]
Never divide by zero.
Milian Wolff [Thu, 24 Mar 2016 19:31:27 +0000 (20:31 +0100)]
Intern caller/callee data by location data.
Milian Wolff [Thu, 24 Mar 2016 18:21:54 +0000 (19:21 +0100)]
Add caller/callee table view of data.
Milian Wolff [Thu, 24 Mar 2016 17:08:07 +0000 (18:08 +0100)]
Reuse common AllocationData class, with operator+=, operator+.
Simplifies the code in some areas.
Milian Wolff [Wed, 23 Mar 2016 15:09:35 +0000 (16:09 +0100)]
Make it possible to select different cost sources for the flame graph.
Also put the bottom-down action into the new control toolbar.
Milian Wolff [Wed, 23 Mar 2016 14:14:57 +0000 (15:14 +0100)]
Don't print unknown file/line location in tooltip.
Milian Wolff [Tue, 15 Mar 2016 19:18:00 +0000 (20:18 +0100)]
Colorize model cost cells background based on relative cost to total.
Maniphest Task: https://phabricator.kde.org/T1709
Milian Wolff [Wed, 9 Mar 2016 17:42:33 +0000 (18:42 +0100)]
Properly skip 32bit versions of operator new.
Milian Wolff [Wed, 9 Mar 2016 17:20:38 +0000 (18:20 +0100)]
Fix compile warnings on 32bit machines
Milian Wolff [Wed, 9 Mar 2016 17:15:47 +0000 (18:15 +0100)]
Update libbacktrace from GCC trunk@234085.
Milian Wolff [Mon, 29 Feb 2016 13:39:46 +0000 (14:39 +0100)]
Don't show functions that triggered no temporary allocations in top list.
Milian Wolff [Fri, 26 Feb 2016 20:47:30 +0000 (21:47 +0100)]
Add executable to measure malloc overhead.
Milian Wolff [Fri, 26 Feb 2016 17:15:44 +0000 (18:15 +0100)]
Filter rows that did not leak anything in TopProxy.
Milian Wolff [Thu, 25 Feb 2016 19:44:39 +0000 (20:44 +0100)]
Include total system memory and peak RSS usage in output.
We now track the RSS by parsing /proc/self/statm on every timestamp.
The total system memory is taken from sysconf.
The RSS may potentially miss its true peaks, which can be handled in
the future via getrusage(). Still, this is a nice and useful addition
I think.
Milian Wolff [Mon, 22 Feb 2016 12:56:37 +0000 (13:56 +0100)]
Show minimal statistics directly after heaptrack finished.
Milian Wolff [Wed, 24 Feb 2016 01:40:53 +0000 (02:40 +0100)]
Pass correct data to dl_iterate_phdr.
I wonder why this didn't crash before...
Milian Wolff [Wed, 24 Feb 2016 01:31:21 +0000 (02:31 +0100)]
Don't access invalid memory for tiny or broken input files.
Milian Wolff [Wed, 24 Feb 2016 00:58:06 +0000 (01:58 +0100)]
Put summary text into three columns to save vertical space.
Milian Wolff [Wed, 24 Feb 2016 00:41:32 +0000 (01:41 +0100)]
Display the time when the memory peak was encountered.
Milian Wolff [Wed, 24 Feb 2016 00:37:03 +0000 (01:37 +0100)]
Remove resize-to-contents call.
Milian Wolff [Wed, 24 Feb 2016 00:24:47 +0000 (01:24 +0100)]
Add summary tab and display all top functions there.
Milian Wolff [Tue, 23 Feb 2016 22:59:56 +0000 (23:59 +0100)]
Show error when we failed to parse an input file.
Milian Wolff [Tue, 23 Feb 2016 22:48:45 +0000 (23:48 +0100)]
Use monospace font family in tooltips.
Bug got fixed upstream in Qt but for older Qt this improves
readability significantly.
Milian Wolff [Tue, 23 Feb 2016 22:48:10 +0000 (23:48 +0100)]
Don't show 'backtrace: ' without a backtrace in the tooltip.