51{
61
62
64
65
69 }
70
71
73 test_fail( __FILE__, __LINE__,
"PAPI_get_component_info", 0 );
74 }
75
76
77 if ( cmpinfo->
attach == 0 ) {
79 "Platform does not support attaching",0 );
80 }
81
82
86 }
87
88
91 }
92
93
94
95
96
99
101 if ( ptrace( PTRACE_ATTACH,
pid, NULL, NULL ) == -1 ) {
102 perror( "ptrace(PTRACE_ATTACH)" );
103 return 1;
104 }
105 if ( waitpid(
pid, &status, 0 ) == -1 ) {
106 perror( "waitpid()" );
107 exit( 1 );
108 }
109 if ( WIFSTOPPED( status ) == 0 ) {
111 "Child process didnt return true to WIFSTOPPED", 0 );
112 }
113 }
114
118 }
119
121 sprintf( add_event_str,
"PAPI_add_event[%s]",
event_name );
122
123
124
126
127
132
133
135 if ( ptrace( PTRACE_CONT,
pid, NULL, NULL ) == -1 ) {
136 perror( "ptrace(PTRACE_CONT)" );
137 return 1;
138 }
139 if ( waitpid(
pid, &status, 0 ) == -1 ) {
140 perror( "waitpid()" );
141 exit( 1 );
142 }
143 if ( WIFSTOPPED( status ) == 0 ) {
145 "Child process didn't return true to WIFSTOPPED", 0 );
146 }
147 if ( WSTOPSIG( status ) != SIGSTOP ) {
149 "Child process didn't stop on SIGSTOP", 0 );
150 }
151 }
152
156 }
157
161 }
162
163
165 if ( ptrace( PTRACE_CONT,
pid, NULL, NULL ) == -1 ) {
166 perror( "ptrace(PTRACE_ATTACH)" );
167 return 1;
168 }
169 if ( waitpid(
pid, &status, 0 ) == -1 ) {
170 perror( "waitpid()" );
171 exit( 1 );
172 }
173 if ( WIFSTOPPED( status ) == 0 ) {
175 "Child process didn't return true to WIFSTOPPED", 0 );
176 }
177 if ( WSTOPSIG( status ) != SIGSTOP ) {
179 "Child process didn't stop on SIGSTOP", 0 );
180 }
181 }
182
187
190 printf( "Warning: PAPI_stop returned error %d, probably ok.\n",
192 }
193
196 printf( "Warning: PAPI_stop returned error %d, probably ok.\n",
198 }
199
202
204 if ( ptrace( PTRACE_CONT,
pid, NULL, NULL ) == -1 ) {
205 perror( "ptrace(PTRACE_CONT)" );
206 return 1;
207 }
208 }
209
210 if ( waitpid(
pid, &status, 0 ) == -1 ) {
211 perror( "waitpid()" );
212 exit( 1 );
213 }
214 if ( WIFEXITED( status ) == 0 ) {
216 "Child process didn't return true to WIFEXITED", 0 );
217 }
218
219
220
221
222
224 printf( "Test case: multiple 3rd party attach start, stop.\n" );
225 printf( "-----------------------------------------------\n" );
229 printf(
"Default granularity is: %d (%s)\n",
tmp,
231 printf(
"Using %d iterations of c += a*b\n",
NUM_FLOPS );
232 printf( "-------------------------------------------------------------------------\n" );
233
234 sprintf( add_event_str, "(PID self) %-12s : \t",
237 sprintf( add_event_str, "(PID self) PAPI_TOT_CYC : \t" );
239 sprintf( add_event_str,
"(PID %jd) %-12s : \t", ( intmax_t )
pid,
242 sprintf( add_event_str, "(PID %jd) PAPI_TOT_CYC : \t",
247 printf(
TAB1,
"Virt usec : \t", elapsed_virt_us );
248 printf(
TAB1,
"Virt cycles : \t", elapsed_virt_cyc );
249
250 printf( "-------------------------------------------------------------------------\n" );
251
252 printf( "Verification: none\n" );
253
254 }
255
257
258 return 0;
259}
static int wait_for_attach_and_loop(void)
Attach PAPI event set to the specified thread id.
get information about a specific software component
Get PAPI library or event set options.
get real time counter value in clock cycles Returns the total real time passed since some arbitrary s...
get real time counter value in microseconds
get virtual time counter value in clock cycles
get virtual time counter values in microseconds
initialize the PAPI library.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
char event_name[2][PAPI_MAX_STR_LEN]
#define PAPI_2MAX_STR_LEN
static long long values[NUM_EVENTS]
int tests_quiet(int argc, char **argv)
char * stringify_all_domains(int domains)
char * stringify_granularity(int granularity)
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
long long ** allocate_test_space(int num_tests, int num_events)
void PAPI_NORETURN test_pass(const char *filename)
int add_two_events(int *num_events, int *papi_event, int *mask)
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
int remove_test_events(int *EventSet, int mask)
unsigned int attach_must_ptrace