HPCToolkit
event_custom.h
Go to the documentation of this file.
1 // -*-Mode: C++;-*- // technically C99
2 
3 // * BeginRiceCopyright *****************************************************
4 //
5 // --------------------------------------------------------------------------
6 // Part of HPCToolkit (hpctoolkit.org)
7 //
8 // Information about sources of support for research and development of
9 // HPCToolkit is at 'hpctoolkit.org' and in 'README.Acknowledgments'.
10 // --------------------------------------------------------------------------
11 //
12 // Copyright ((c)) 2002-2019, Rice University
13 // All rights reserved.
14 //
15 // Redistribution and use in source and binary forms, with or without
16 // modification, are permitted provided that the following conditions are
17 // met:
18 //
19 // * Redistributions of source code must retain the above copyright
20 // notice, this list of conditions and the following disclaimer.
21 //
22 // * Redistributions in binary form must reproduce the above copyright
23 // notice, this list of conditions and the following disclaimer in the
24 // documentation and/or other materials provided with the distribution.
25 //
26 // * Neither the name of Rice University (RICE) nor the names of its
27 // contributors may be used to endorse or promote products derived from
28 // this software without specific prior written permission.
29 //
30 // This software is provided by RICE and contributors "as is" and any
31 // express or implied warranties, including, but not limited to, the
32 // implied warranties of merchantability and fitness for a particular
33 // purpose are disclaimed. In no event shall RICE or contributors be
34 // liable for any direct, indirect, incidental, special, exemplary, or
35 // consequential damages (including, but not limited to, procurement of
36 // substitute goods or services; loss of use, data, or profits; or
37 // business interruption) however caused and on any theory of liability,
38 // whether in contract, strict liability, or tort (including negligence
39 // or otherwise) arising in any way out of the use of this software, even
40 // if advised of the possibility of such damage.
41 //
42 // ******************************************************* EndRiceCopyright *
43 
44 #ifndef __CUSTOM_EVENT_H__
45 #define __CUSTOM_EVENT_H__
46 
47 #include "sample_event.h"
50 
51 
52 // --------------------------------------------------------------
53 // data type
54 // --------------------------------------------------------------
55 
56 
57 typedef struct event_handler_arg_s {
58  int metric; /* metric id */
59  double metric_value; /* the value of the metric by perf handler */
60  void *context; /* current context */
61 
62  sample_val_t *sample; /* the result of sampling by hpcrun callpath */
63 
64  struct event_info_s *current; /* info of the event */
65  struct perf_mmap_data_s *data; /* additional data from Linux kernel */
67 
68 
70 
71 // callback functions
73  event_custom_t *event,
74  struct event_threshold_s *period);
75 
77 
79 
80 // --------------------------------------------------------------
81 // data structure for our customized event
82 // this type should be used only within perf module.
83 // --------------------------------------------------------------
84 typedef struct event_custom_s {
85  const char *name; // unique name of the event
86  const char *desc; // brief description of the event
87 
88  register_event_t *register_fn;// function to register the event
89  event_handler_t *handler_fn; // callback to be used during the sampling
90 
91  event_handle_type_t handle_type; // whether the handler will be called exclusively or inclusively (all events)
92 
94 
95 
96 // --------------------------------------------------------------
97 // Function interface
98 // --------------------------------------------------------------
99 
100 /***
101  * create a custom event
102  */
103 int event_custom_create_event(sample_source_t *self, char *name);
108 event_custom_t *event_custom_find(const char *name);
109 
117 
121 void event_custom_display(FILE *std);
122 
128 
129 
130 #endif
event_handle_type_e
Definition: event_custom.h:78
struct event_info_s * current
Definition: event_custom.h:64
int event_custom_create_event(sample_source_t *self, char *name)
Definition: event_custom.c:136
struct event_custom_s event_custom_t
Definition: event_custom.h:69
enum event_handle_type_e event_handle_type_t
event_handler_t * handler_fn
Definition: event_custom.h:89
struct event_handler_arg_s event_handler_arg_t
int register_event_t(sample_source_t *self, event_custom_t *event, struct event_threshold_s *period)
Definition: event_custom.h:72
struct perf_mmap_data_s * data
Definition: event_custom.h:65
const char * desc
Definition: event_custom.h:86
void event_custom_display(FILE *std)
Definition: event_custom.c:86
event_custom_t * event_custom_find(const char *name)
int event_custom_register(event_custom_t *event)
Definition: event_custom.c:110
register_event_t * register_fn
Definition: event_custom.h:88
event_handle_type_t handle_type
Definition: event_custom.h:91
void event_handler_t(event_handler_arg_t *args)
Definition: event_custom.h:76
const char * name
Definition: event_custom.h:85
static long period
Definition: itimer.c:194
int event_custom_handler(event_handler_arg_t *args)
Definition: event_custom.c:151
sample_val_t * sample
Definition: event_custom.h:62