stap-probe.h 2.6 KB

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