libcollector.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* Copyright (C) 2021-2022 Free Software Foundation, Inc.
  2. Contributed by Oracle.
  3. This file is part of GNU Binutils.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3, or (at your option)
  7. any later version.
  8. This program 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
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, 51 Franklin Street - Fifth Floor, Boston,
  15. MA 02110-1301, USA. */
  16. #ifndef _LIBCOLLECTOR_H
  17. #define _LIBCOLLECTOR_H
  18. typedef struct
  19. {
  20. unsigned int offset;
  21. unsigned int lineno;
  22. } Lineno;
  23. #ifdef __cplusplus
  24. extern "C"
  25. {
  26. #endif
  27. /* This file contains function prototypes for the user-callable API
  28. routines in libcollector for C and C++ codes. */
  29. /* Routine to record a sample in the experiment. */
  30. void collector_sample (char *name);
  31. /* Routine to suspend data collection during an experiment. */
  32. void collector_pause (void);
  33. /* Routine to resume data collection during an experiment. */
  34. void collector_resume (void);
  35. /* Routine to suspend per-thread data collection during an experiment. */
  36. void collector_thread_pause (unsigned int tid);
  37. /* Routine to resume per-thread data collection during an experiment. */
  38. void collector_thread_resume (unsigned int tid);
  39. /* Routine to close the experiment, and stop all data collection. */
  40. void collector_terminate_expt (void);
  41. /* Routines to let libcollector know about a dynamically loaded function. */
  42. void collector_func_load (char *name, char *alias, char *sourcename,
  43. void *vaddr, int size, int lntsize, Lineno *lntable);
  44. void collector_func_unload (void *vaddr);
  45. /* Define the weak symbols for the API. */
  46. void collector_sample () __attribute__ ((weak));
  47. void collector_pause () __attribute__ ((weak));
  48. void collector_resume () __attribute__ ((weak));
  49. void collector_thread_pause () __attribute__ ((weak));
  50. void collector_thread_resume () __attribute__ ((weak));
  51. void collector_terminate_expt () __attribute__ ((weak));
  52. void collector_func_load () __attribute__ ((weak));
  53. void collector_func_unload () __attribute__ ((weak));
  54. #ifdef __cplusplus
  55. }
  56. #endif
  57. /* Define the macros that actually get inserted in the caller's code. */
  58. #define collector_sample(x) (collector_sample ? collector_sample(x), 0 : 0)
  59. #define collector_pause() (collector_pause ? collector_pause(), 0 : 0)
  60. #define collector_resume() (collector_resume ? collector_resume(),0 : 0
  61. #define collector_thread_pause(tid) \
  62. (collector_thread_pause ? collector_thread_pause(tid), 0 : 0)
  63. #define collector_thread_resume(tid) \
  64. (collector_thread_resume ? collector_thread_resume(tid), 0 : 0)
  65. #define collector_terminate_expt() \
  66. (collector_terminate_expt ? collector_terminate_expt(), 0 : 0)
  67. #define collector_func_load(x0,x1,x2,x3,x4,x5,x6) \
  68. collector_func_load ? collector_func_load(x0,x1,x2,x3,x4,x5,x6), 0 : 0)
  69. #define collector_func_unload(x) \
  70. (collector_func_unload ? collector_func_unload(x), 0 : 0)
  71. #endif /* _LIBCOLLECTOR_H */