Add support for inserting (a subset of) Valgrind client requests

If valgrind support is disabled, we define stub versions of the
Valgrind client requests I plan to use, so the actual code doesn't
need #ifdef hell.

[With unnecessary AC_SUBST removed as per Lennart's review -smcv]

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=37286
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Lennart Poettering <lennart@poettering.net>
This commit is contained in:
Simon McVittie 2012-02-13 17:53:51 +00:00
parent 05cc2c3348
commit b3f2ee5c6b
3 changed files with 61 additions and 1 deletions

View file

@ -1217,6 +1217,17 @@ fi
AC_SUBST([NETWORK_libs])
AC_ARG_WITH([valgrind],
[AS_HELP_STRING([--with-valgrind],
[Add instrumentation to help valgrind to understand our allocator])],
[],
[with_valgrind=no])
if test x$with_valgrind != xno; then
PKG_CHECK_MODULES([VALGRIND], [valgrind >= 3.6])
AC_DEFINE([WITH_VALGRIND], [1], [Define to add Valgrind instrumentation])
fi
#### Set up final flags
LIBDBUS_LIBS="$THREAD_LIBS $NETWORK_libs"
AC_SUBST([LIBDBUS_LIBS])

View file

@ -5,6 +5,7 @@ AM_CPPFLAGS = \
-I$(top_builddir) \
-I$(top_srcdir) \
$(SYSTEMD_CFLAGS) \
$(VALGRIND_CFLAGS) \
-DDBUS_COMPILATION \
-DDBUS_MACHINE_UUID_FILE=\""$(localstatedir)/lib/dbus/machine-id"\" \
-DDBUS_SYSTEM_CONFIG_FILE=\""$(configdir)/system.conf"\" \
@ -221,7 +222,8 @@ DBUS_SHARED_SOURCES= \
dbus-string-private.h \
$(DBUS_SHARED_arch_sources) \
dbus-sysdeps.c \
dbus-sysdeps.h
dbus-sysdeps.h \
dbus-valgrind-internal.h
### source code that is generic utility functionality used
### by the bus daemon or test apps, but is NOT included

View file

@ -0,0 +1,47 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/* dbus-valgrind-internal.h - valgrind glue
*
* Copyright © 2011 Nokia Corporation
*
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef DBUS_VALGRIND_INTERNAL_H
#define DBUS_VALGRIND_INTERNAL_H
#include "config.h"
#include "dbus-internals.h"
#ifdef WITH_VALGRIND
# include <memcheck.h>
# include <valgrind.h>
#else
# define VALGRIND_CREATE_MEMPOOL(_1, _2, _3) /* nothing */
# define VALGRIND_DESTROY_MEMPOOL(_1) /* nothing */
# define VALGRIND_MEMPOOL_ALLOC(_1, _2, _3) /* nothing */
# define VALGRIND_MEMPOOL_FREE(_1, _2) /* nothing */
# define VALGRIND_MAKE_MEM_UNDEFINED(_1, _2) (0)
# define VALGRIND_PRINTF(...) (0)
# define VALGRIND_PRINTF_BACKTRACE(...) (0)
# define RUNNING_ON_VALGRIND 0
#endif /* WITH_VALGRIND */
#endif /* header guard */