mtrace.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* mtrace API for `malloc'.
  2. Copyright (C) 1991-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. #if !IS_IN (libc)
  16. # include "mtrace-impl.c"
  17. #else
  18. # include <shlib-compat.h>
  19. # include <libc-symbols.h>
  20. #endif
  21. #if IS_IN (libc) && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_34)
  22. /* Compatibility symbols that were introduced to help break at allocation sites
  23. for specific memory allocations. This is unusable with ASLR, although gdb
  24. may allow predictable allocation addresses. Even then, gdb has watchpoint
  25. and conditional breakpoint support which should provide the same
  26. functionality without having this kludge. These symbols are preserved in
  27. case some applications ended up linking against them but they don't actually
  28. do anything anymore; not that they did much before anyway. */
  29. void *mallwatch;
  30. compat_symbol (libc, mallwatch, mallwatch, GLIBC_2_0);
  31. void
  32. tr_break (void)
  33. {
  34. }
  35. compat_symbol (libc, tr_break, tr_break, GLIBC_2_0);
  36. #endif
  37. void
  38. mtrace (void)
  39. {
  40. #if !IS_IN (libc)
  41. do_mtrace ();
  42. #endif
  43. }
  44. void
  45. muntrace (void)
  46. {
  47. #if !IS_IN (libc)
  48. do_muntrace ();
  49. #endif
  50. }