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