46 {
47
56
57
59
60
65 }
66
67
70 }
71
72
73
74
78 }
79
81 test_fail( __FILE__, __LINE__,
"PAPI_get_component_info", 0 );
82 }
83
84 if ( cmpinfo->
attach == 0 ) {
85 test_skip( __FILE__, __LINE__,
"Platform does not support attaching",
86 0 );
87 }
88
91 test_fail( __FILE__, __LINE__,
"PAPI_get_hardware_info", 0 );
92 }
93
94
98 }
99
102 test_fail( __FILE__, __LINE__,
"PAPI_assign_eventset_component",
104 }
105
106
111 }
112
113
116 if (!
quiet) printf(
"Problem adding PAPI_TOT_INS\n");
118 }
119
120
123 }
124
125
126 pid_t child = wait( &status );
127
128 if (!
quiet) printf(
"Debugger exited wait() with %d\n",child );
129 if (WIFSTOPPED( status )) {
131 printf( "Child has stopped due to signal %d (%s)\n",
132 WSTOPSIG( status ),
133 strsignal(WSTOPSIG( status )) );
134 }
135 }
136
137 if (WIFSIGNALED( status )) {
139 printf( "Child %ld received signal %d (%s)\n",
140 (long)child,
141 WTERMSIG(status),
142 strsignal(WTERMSIG( status )) );
143 }
144 }
146 printf(
"After %d\n",
retval);
147 }
148
149
153 }
154
156 printf("Continuing\n");
157 }
158
159#if defined(__FreeBSD__)
160 if ( ptrace( PT_CONTINUE,
pid, (
vptr_t) 1, 0 ) == -1 ) {
161 perror( "ptrace(PTRACE_CONT)" );
164 return 1;
165 }
166#else
167 if ( ptrace( PTRACE_CONT,
pid, NULL, NULL ) == -1 ) {
168 perror( "ptrace(PTRACE_CONT)" );
171 }
172#endif
173
174
175
176
177 for(
i=0;
i<1000;
i++) {
179 }
180
181
182 do {
183 child = wait( &status );
185 printf( "Debugger exited wait() with %d\n", child);
186 }
187 if (WIFSTOPPED( status )) {
189 printf( "Child has stopped due to signal "
190 "%d (%s)\n",
191 WSTOPSIG( status ),
192 strsignal(WSTOPSIG( status )) );
193 }
194 }
195 if (WIFSIGNALED( status )) {
197 printf( "Child %ld received signal "
198 "%d (%s)\n",
199 (long)child,
200 WTERMSIG(status),
201 strsignal(WTERMSIG( status )) );
202 }
203 }
204 } while (!WIFEXITED( status ));
205
207 printf("Child exited with value %d\n",WEXITSTATUS(status));
208 }
209
210 if (WEXITSTATUS(status) != 0) {
212 "Exit status of child to attach to",
PAPI_EMISC);
213 }
214
215
219 }
220
224 }
225
229 }
230
232 printf( "Test case: attach validation.\n" );
233 printf( "-----------------------------------------------\n" );
237 printf(
"Default granularity is: %d (%s)\n",
tmp,
239 printf( "Using 50 million instructions\n");
240 printf( "-------------------------------------------------------------------------\n" );
241
242 printf( "Test type : \t 1\n" );
243
244 printf(
TAB1,
"PAPI_TOT_INS : \t", (
values[0] ) );
245
246 printf( "-------------------------------------------------------------------------\n" );
247
248 }
249
252 }
253
256 }
257
259
261
262 return 0;
263
264}
static int wait_for_attach_and_loop(void)
static const PAPI_hw_info_t * hw_info
add PAPI preset or native hardware event to an event set
Assign a component index to an existing but empty EventSet.
Attach PAPI event set to the specified thread id.
Empty and destroy an EventSet.
Create a new empty PAPI EventSet.
Empty and destroy an EventSet.
get information about a specific software component
get information about the system hardware
Get PAPI library or event set options.
initialize the PAPI library.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
Returns a string describing the PAPI error code.
static long long values[NUM_EVENTS]
int instructions_million(void)
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)
void PAPI_NORETURN test_pass(const char *filename)
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
unsigned int attach_must_ptrace