HPCToolkit
sample_event.h
Go to the documentation of this file.
1 // -*-Mode: C++;-*- // technically C99
2 
3 // * BeginRiceCopyright *****************************************************
4 //
5 // $HeadURL$
6 // $Id$
7 //
8 // --------------------------------------------------------------------------
9 // Part of HPCToolkit (hpctoolkit.org)
10 //
11 // Information about sources of support for research and development of
12 // HPCToolkit is at 'hpctoolkit.org' and in 'README.Acknowledgments'.
13 // --------------------------------------------------------------------------
14 //
15 // Copyright ((c)) 2002-2019, Rice University
16 // All rights reserved.
17 //
18 // Redistribution and use in source and binary forms, with or without
19 // modification, are permitted provided that the following conditions are
20 // met:
21 //
22 // * Redistributions of source code must retain the above copyright
23 // notice, this list of conditions and the following disclaimer.
24 //
25 // * Redistributions in binary form must reproduce the above copyright
26 // notice, this list of conditions and the following disclaimer in the
27 // documentation and/or other materials provided with the distribution.
28 //
29 // * Neither the name of Rice University (RICE) nor the names of its
30 // contributors may be used to endorse or promote products derived from
31 // this software without specific prior written permission.
32 //
33 // This software is provided by RICE and contributors "as is" and any
34 // express or implied warranties, including, but not limited to, the
35 // implied warranties of merchantability and fitness for a particular
36 // purpose are disclaimed. In no event shall RICE or contributors be
37 // liable for any direct, indirect, incidental, special, exemplary, or
38 // consequential damages (including, but not limited to, procurement of
39 // substitute goods or services; loss of use, data, or profits; or
40 // business interruption) however caused and on any theory of liability,
41 // whether in contract, strict liability, or tort (including negligence
42 // or otherwise) arising in any way out of the use of this software, even
43 // if advised of the possibility of such damage.
44 //
45 // ******************************************************* EndRiceCopyright *
46 
47 #ifndef SAMPLE_EVENT_H
48 #define SAMPLE_EVENT_H
49 
50 #include <stdint.h>
51 #include <stdbool.h>
52 
53 #include "cct.h"
54 #include "thread_data.h"
55 #include "cct_insert_backtrace.h"
56 
59 #include <messages/messages.h>
60 
61 
62 //***************************************************************************
63 
64 // The async blocks are now superseded by the hpcrun_safe_enter() and
65 // hpcrun_safe_exit() functions. See: safe-sampling.h
66 
67 //***************************************************************************
68 
69 
70 extern bool private_hpcrun_sampling_disabled; // private!
71 
72 static inline bool
74 {
76 }
77 
78 static inline void
80 {
81  TMSG(SPECIAL,"Sampling disabled");
83 }
84 
85 static inline void
87 {
88  TMSG(SPECIAL,"Sampling disabled");
90 }
91 
92 extern void hpcrun_drop_sample(void);
93 
94 
95 typedef struct sample_val_s {
96  cct_node_t* sample_node; // CCT leaf representing innermost call path frame
97  cct_node_t* trace_node; // CCT leaf representing trace record
98 } sample_val_t;
99 
100 
101 static inline void
103 {
104  //memset(x, 0, sizeof(*x));
105  x->sample_node = 0;
106  x->trace_node = 0;
107 }
108 
109 // --------------------------------------------------------------------------
110 // additional sampling info
111 // --------------------------------------------------------------------------
112 
113 #define SAMPLING_IN_MALLOC 1
114 #define SAMPLING_FIRST_TOUCH 2
115 #define SAMPLING_DATA_NODE 4
116 
117 typedef struct sampling_info_s {
118  uint64_t flags; // see the above constants SAMPLING_*
119 
120  uint64_t sample_clock; // time can be used for tracing
121  struct cct_custom_update_s sample_custom_cct;
123 
124 
125 extern sample_val_t hpcrun_sample_callpath(void *context, int metricId,
126  hpcrun_metricVal_t metricIncr,
127  int skipInner, int isSync, sampling_info_t *data);
128 
129 extern cct_node_t* hpcrun_gen_thread_ctxt(void *context);
130 
131 extern cct_node_t* hpcrun_sample_callpath_w_bt(void *context,
132  int metricId, uint64_t metricIncr,
134  int isSync);
135 #endif // sample_event_h
cct_node_t * hpcrun_gen_thread_ctxt(void *context)
Definition: sample_event.c:322
void hpcrun_drop_sample(void)
Definition: sample_event.c:151
struct sample_val_s sample_val_t
uint64_t sample_clock
Definition: sample_event.h:120
void * bt_fn_arg
Definition: backtrace.h:100
static bool hpcrun_is_sampling_disabled(void)
Definition: sample_event.h:73
cct_node_t * hpcrun_sample_callpath_w_bt(void *context, int metricId, uint64_t metricIncr, bt_mut_fn bt_fn, bt_fn_arg arg, int isSync)
cct_node_t * sample_node
Definition: sample_event.h:96
sample_val_t hpcrun_sample_callpath(void *context, int metricId, hpcrun_metricVal_t metricIncr, int skipInner, int isSync, sampling_info_t *data)
Definition: sample_event.c:160
struct sampling_info_s sampling_info_t
void(* bt_mut_fn)(backtrace_t *bt, bt_fn_arg arg)
Definition: backtrace.h:101
#define TMSG(f,...)
Definition: messages.h:93
static void hpcrun_enable_sampling(void)
Definition: sample_event.h:86
static void hpcrun_disable_sampling(void)
Definition: sample_event.h:79
Definition: cct.c:96
bool private_hpcrun_sampling_disabled
Definition: sample_event.c:148
static void hpcrun_sample_val_init(sample_val_t *x)
Definition: sample_event.h:102
bool bt_fn(backtrace_t *bt, ucontext_t *context)
Definition: backtrace.h:99
cct_node_t * trace_node
Definition: sample_event.h:97