HPCToolkit
none.c
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 //
48 // NONE sample source simple oo interface
49 //
50 
51 /******************************************************************************
52  * system includes
53  *****************************************************************************/
54 
55 #include <stdlib.h>
56 #include <stddef.h>
57 #include <string.h>
58 #include <assert.h>
59 #include <unistd.h>
60 
61 
62 
63 /******************************************************************************
64  * libmonitor
65  *****************************************************************************/
66 
67 #include <monitor.h>
68 
69 
70 
71 /******************************************************************************
72  * local includes
73  *****************************************************************************/
74 
75 #include <hpcrun/hpcrun_options.h>
76 #include <hpcrun/disabled.h>
77 #include <hpcrun/metrics.h>
78 #include <sample_event.h>
79 #include "sample_source_obj.h"
80 #include "common.h"
82 // #include "simple_oo.h"
83 #include <hpcrun/thread_data.h>
84 #include <utilities/tokenize.h>
85 
86 #include <messages/messages.h>
87 
88 
89 
90 /******************************************************************************
91  * method definitions
92  *****************************************************************************/
93 
94 static void
95 METHOD_FN(init)
96 {
97  self->state = INIT; // no actual init actions necessary for NONE
98 }
99 
100 
101 static void
102 METHOD_FN(thread_init)
103 {
104  TMSG(NONE_CTL, "thread init (no action needed)");
105 }
106 
107 static void
108 METHOD_FN(thread_init_action)
109 {
110  TMSG(NONE_CTL, "thread init action (noop)");
111 }
112 
113 static void
114 METHOD_FN(start)
115 {
116  TMSG(NONE_CTL,"starting NONE");
117 
118  TD_GET(ss_state)[self->sel_idx] = START;
119 }
120 
121 static void
122 METHOD_FN(thread_fini_action)
123 {
124  TMSG(NONE_CTL, "thread fini action (noop)");
125 }
126 
127 static void
129 {
130  TMSG(NONE_CTL,"stopping NONE");
131  TD_GET(ss_state)[self->sel_idx] = STOP;
132 }
133 
134 static void
135 METHOD_FN(shutdown)
136 {
137  METHOD_CALL(self,stop); // make sure stop has been called
138  self->state = UNINIT;
139 }
140 
141 static bool
142 METHOD_FN(supports_event,const char *ev_str)
143 {
144  return hpcrun_ev_is(ev_str,"NONE");
145 }
146 
147 
148 //
149 // Special NONE protocol:
150 // if event is NONE@xxx, then create log file and process the TMSG logging
151 // if event is just plain NONE, then
152 // no log file or any other evidence of hpcrun
153 //
154 static void
155 METHOD_FN(process_event_list,int lush_metrics)
156 {
157  char *event_str = METHOD_CALL(self,get_event_str);
158  char *none_str = strstr(event_str,"NONE");
159  if (none_str) {
160  char *use_log = strchr(none_str,'@');
161  if (use_log == NULL) {
163  }
164  }
165 }
166 
167 
168 //
169 // Event sets not relevant for this sample source
170 // It DOES NOT SAMPLE, so there are NO event sets
171 //
172 static void
173 METHOD_FN(gen_event_set,int lush_metrics)
174 {
175 }
176 
177 
178 //
179 // There are no events defined for this sample source
180 //
181 static void
182 METHOD_FN(display_events)
183 {
184 }
185 
186 /***************************************************************************
187  * object
188  ***************************************************************************/
189 
190 #define ss_name none
191 #define ss_cls SS_HARDWARE
192 
193 #include "ss_obj.h"
194 
195 /******************************************************************************
196  * interface functions
197  *****************************************************************************/
198 
199 void
201 {
202  sample_source_t *none = &_none_obj;
203 
204  METHOD_CALL(none, process_event_list, 0);
205 
206  if (getenv("SHOW_NONE") && hpcrun_get_disabled()) {
207  static char none_msg[] = "NOTE: sample source NONE is specified\n";
208  write(2, none_msg, strlen(none_msg));
209  }
210 }
ssize_t MONITOR_EXT_WRAP_NAME() write(int fd, const void *buf, size_t count)
Definition: io-over.c:189
void hpcrun_process_sample_source_none(void)
Definition: none.c:200
void hpcrun_set_disabled(void)
Definition: disabled.c:87
int lush_metrics
Definition: main.c:188
static void METHOD_FN(init)
Definition: none.c:95
#define TD_GET(field)
Definition: thread_data.h:256
bool hpcrun_ev_is(const char *candidate, const char *event_name)
Definition: tokenize.c:194
#define TMSG(f,...)
Definition: messages.h:93
#define METHOD_CALL(obj, meth,...)
Definition: simple_oo.h:87
#define NULL
Definition: ElfHelper.cpp:85
bool hpcrun_get_disabled(void)
Definition: disabled.c:80