glibc/include/stap-probe.h
Siddhesh Poyarekar 520d437b94 [BZ #16195] Fix build warnings from systemtap probes in non-systemtap configurations
Joseph pointed out in the bug report (and in an earlier thread) that
systemtap probes cause build time warnings like the following:

    ../sysdeps/ieee754/dbl-64/e_atan2.c:602:4: warning: the address of
    'p' will always evaluate as 'true' [-Waddress]

due to the fact that we're now passing non-weak variables to
LIBC_PROBE in the libm probes.  This happens only on configurations
that do not enable systemtap.  The macro definition of LIBC_PROBE in
this case only acts as a sanity checker to ensure that the number
parameters passed to LIBC_PROBE is equal to the argument count
parameter passed before it.  This can be done in a much simpler manner
by just adding a macro definition for each number of arguments.  I am
assuming here that we don't really want to bother with supporting
LIBC_PROBE with an indeterminate number of arguments and if there is a
need for a probe to have more data than what is currently supported (4
arguments), one could simply add an additional macro here.
2013-12-03 12:26:12 +05:30

82 lines
2.8 KiB
C

/* Macros for defining Systemtap <sys/sdt.h> static probe points.
Copyright (C) 2012-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _STAP_PROBE_H
#define _STAP_PROBE_H 1
#ifdef USE_STAP_PROBE
# include <sys/sdt.h>
/* Our code uses one macro LIBC_PROBE (name, n, arg1, ..., argn).
Without USE_STAP_PROBE, that does nothing but evaluates all
its arguments (to prevent bit rot, unlike e.g. assert).
Systemtap's header defines the macros STAP_PROBE (provider, name) and
STAP_PROBEn (provider, name, arg1, ..., argn). For "provider" we paste
in the IN_LIB name (libc, libpthread, etc.) automagically. */
# ifndef NOT_IN_libc
# define IN_LIB libc
# elif !defined IN_LIB
/* This is intentionally defined with extra unquoted commas in it so
that macro substitution will bomb out when it is used. We don't
just use #error here, so that this header can be included by
other headers that use LIBC_PROBE inside their own macros. We
only want such headers to fail to compile if those macros are
actually used in a context where IN_LIB has not been defined. */
# define IN_LIB ,,,missing -DIN_LIB=... -- not extra-lib.mk?,,,
# endif
# define LIBC_PROBE(name, n, ...) \
LIBC_PROBE_1 (IN_LIB, name, n, ## __VA_ARGS__)
# define LIBC_PROBE_1(lib, name, n, ...) \
STAP_PROBE##n (lib, name, ## __VA_ARGS__)
# define STAP_PROBE0 STAP_PROBE
# define LIBC_PROBE_ASM(name, template) \
STAP_PROBE_ASM (IN_LIB, name, template)
# define LIBC_PROBE_ASM_OPERANDS STAP_PROBE_ASM_OPERANDS
#else /* Not USE_STAP_PROBE. */
# ifndef __ASSEMBLER__
/* Evaluate all the arguments and verify that N matches their number. */
#define LIBC_PROBE(name, n, ...) STAP_PROBE##n (__VA_ARGS__)
#define STAP_PROBE0()
#define STAP_PROBE1(a1)
#define STAP_PROBE2(a1, a2)
#define STAP_PROBE3(a1, a2, a3)
#define STAP_PROBE4(a1, a2, a3, a4)
# else
# define LIBC_PROBE(name, n, ...) /* Nothing. */
# endif
# define LIBC_PROBE_ASM(name, template) /* Nothing. */
# define LIBC_PROBE_ASM_OPERANDS(n, ...) /* Nothing. */
#endif /* USE_STAP_PROBE. */
#endif /* stap-probe.h */