Diffusion Baloo 446aeb07d922

Detect valgrind, avoid database removal when using valgrind

Authored by bruns on Jun 4 2019, 4:13 PM.

Description

Detect valgrind, avoid database removal when using valgrind

Summary:
The mmap size supported by valgrind is set at valgrind compile time. If
the application tries to mmap in total more than the supported size,
the mmap fails. As a result lmdb fails to open the DB which is
interpreted as a broken DB, thus the DB is deleted.

Valgrind can be detected at runtime using the RUNNING_ON_VALGRIND
macro from valgrind.h, which is added to the sources:

You are encouraged to copy the valgrind/*.h headers into your project's
include directory, so your program doesn't have a compile-time
dependency on Valgrind being installed. The Valgrind headers, unlike
most of the rest of the code, are under a BSD-style license so you may
include them without worrying about license incompatibility.

Test Plan:
valgrind --tool=callgrind baloo_file

org.kde.baloo.engine: Valgrind detected, limiting DB mmap to 40 GByte

Reviewers: Baloo, ngraham, astippich, poboiko, broulik, mgallien

Reviewed By: Baloo, ngraham, mgallien

Subscribers: mgallien, kde-frameworks-devel

Tags: Frameworks, Baloo

Differential Revision: https://phabricator.kde.org/D21581