zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

stap-probe.h (2695B) - Raw


      1 /* Macros for defining Systemtap <sys/sdt.h> static probe points.
      2    Copyright (C) 2012-2025 Free Software Foundation, Inc.
      3    This file is part of the GNU C Library.
      4 
      5    The GNU C Library is free software; you can redistribute it and/or
      6    modify it under the terms of the GNU Lesser General Public
      7    License as published by the Free Software Foundation; either
      8    version 2.1 of the License, or (at your option) any later version.
      9 
     10    The GNU C Library is distributed in the hope that it will be useful,
     11    but WITHOUT ANY WARRANTY; without even the implied warranty of
     12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13    Lesser General Public License for more details.
     14 
     15    You should have received a copy of the GNU Lesser General Public
     16    License along with the GNU C Library; if not, see
     17    <https://www.gnu.org/licenses/>.  */
     18 
     19 #ifndef _STAP_PROBE_H
     20 #define _STAP_PROBE_H 1
     21 
     22 #ifdef USE_STAP_PROBE
     23 
     24 # include <stap-probe-machine.h>
     25 # include <sys/sdt.h>
     26 
     27 /* Our code uses one macro LIBC_PROBE (name, n, arg1, ..., argn).
     28 
     29    Without USE_STAP_PROBE, that does nothing but evaluates all
     30    its arguments (to prevent bit rot, unlike e.g. assert).
     31 
     32    Systemtap's header defines the macros STAP_PROBE (provider, name) and
     33    STAP_PROBEn (provider, name, arg1, ..., argn).  For "provider" we paste
     34    in MODULE_NAME (libc, libpthread, etc.) automagically.
     35 
     36    The format of the arg parameters is discussed here:
     37 
     38    https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation
     39 
     40    The precise details of how register names are specified is
     41    architecture specific and can be found in the gdb and SystemTap
     42    source code.  */
     43 
     44 # define LIBC_PROBE(name, n, ...)	\
     45   LIBC_PROBE_1 (MODULE_NAME, name, n, ## __VA_ARGS__)
     46 
     47 # define LIBC_PROBE_1(lib, name, n, ...) \
     48   STAP_PROBE##n (lib, name, ## __VA_ARGS__)
     49 
     50 # define STAP_PROBE0		STAP_PROBE
     51 
     52 # define LIBC_PROBE_ASM(name, template) \
     53   STAP_PROBE_ASM (MODULE_NAME, name, template)
     54 
     55 # define LIBC_PROBE_ASM_OPERANDS STAP_PROBE_ASM_OPERANDS
     56 
     57 #else  /* Not USE_STAP_PROBE.  */
     58 
     59 # ifndef __ASSEMBLER__
     60 /* Evaluate all the arguments and verify that N matches their number.  */
     61 #  define LIBC_PROBE(name, n, ...) STAP_PROBE##n (__VA_ARGS__)
     62 
     63 #  define STAP_PROBE0()				do {} while (0)
     64 #  define STAP_PROBE1(a1)			do {} while (0)
     65 #  define STAP_PROBE2(a1, a2)			do {} while (0)
     66 #  define STAP_PROBE3(a1, a2, a3)		do {} while (0)
     67 #  define STAP_PROBE4(a1, a2, a3, a4)		do {} while (0)
     68 
     69 # else
     70 #  define LIBC_PROBE(name, n, ...)		/* Nothing.  */
     71 # endif
     72 
     73 # define LIBC_PROBE_ASM(name, template)		/* Nothing.  */
     74 # define LIBC_PROBE_ASM_OPERANDS(n, ...)	/* Nothing.  */
     75 
     76 #endif	/* USE_STAP_PROBE.  */
     77 
     78 #endif	/* stap-probe.h */