48{
58
59
61
62
66 }
67
69 test_fail( __FILE__, __LINE__,
"PAPI_get_component_info", 0 );
70 }
71
72 if ( cmpinfo->
attach == 0 ) {
74 "Platform does not support attaching", 0 );
75 }
76
80 }
83 }
84
85
86
87
88
90
92 if ( ptrace( PTRACE_ATTACH,
pid, NULL, NULL ) == -1 ) {
93 perror( "ptrace(PTRACE_ATTACH)" );
94 return 1;
95 }
96 if ( waitpid(
pid, &status, 0 ) == -1 ) {
97 perror( "waitpid()" );
98 exit( 1 );
99 }
100 if ( WIFSTOPPED( status ) == 0 )
102 "Child process didnt return true to WIFSTOPPED", 0 );
103 }
104
108
112 sprintf( add_event_str,
"PAPI_add_event[%s]",
event_name );
113
114
115
117
122
123
125 if ( ptrace( PTRACE_CONT,
pid, NULL, NULL ) == -1 ) {
126 perror( "ptrace(PTRACE_CONT)" );
127 return 1;
128 }
129 if ( waitpid(
pid, &status, 0 ) == -1 ) {
130 perror( "waitpid()" );
131 exit( 1 );
132 }
133 if ( WIFSTOPPED( status ) == 0 ) {
135 "Child process didn't return true to WIFSTOPPED", 0 );
136 }
137 if ( WSTOPSIG( status ) != SIGSTOP ) {
139 "Child process didn't stop on SIGSTOP", 0 );
140 }
141 }
142
146 }
147
148
150 if ( ptrace( PTRACE_CONT,
pid, NULL, NULL ) == -1 ) {
151 perror( "ptrace(PTRACE_CONT)" );
152 return 1;
153 }
154 if ( waitpid(
pid, &status, 0 ) == -1 ) {
155 perror( "waitpid()" );
156 exit( 1 );
157 }
158 if ( WIFSTOPPED( status ) == 0 ) {
160 "Child process didn't return true to WIFSTOPPED", 0 );
161 }
162 if ( WSTOPSIG( status ) != SIGSTOP ) {
164 "Child process didn't stop on SIGSTOP", 0 );
165 }
166 }
167
172
176 }
177
179
181 if ( ptrace( PTRACE_CONT,
pid, NULL, NULL ) == -1 ) {
182 perror( "ptrace(PTRACE_CONT)" );
183 return 1;
184 }
185 }
186
187 if ( waitpid(
pid, &status, 0 ) == -1 ) {
188 perror( "waitpid()" );
189 exit( 1 );
190 }
191 if ( WIFEXITED( status ) == 0 ) {
193 "Child process didn't return true to WIFEXITED", 0 );
194 }
195
197 printf( "Test case: 3rd party attach start, stop.\n" );
198 printf( "-----------------------------------------------\n" );
200 printf(
"Default domain is: %d (%s)\n",
tmp,
203 printf(
"Default granularity is: %d (%s)\n",
tmp,
205 printf(
"Using %d iterations of c += a*b\n",
NUM_FLOPS );
206 printf( "-------------------------------------------------------------------------\n" );
207
208 printf( "Test type : \t 1\n" );
209
210 sprintf( add_event_str,
"%-12s : \t",
event_name );
212 printf(
TAB1,
"PAPI_TOT_CYC : \t",
values[0][0] );
215 printf(
TAB1,
"Virt usec : \t", elapsed_virt_us );
216 printf(
TAB1,
"Virt cycles : \t", elapsed_virt_cyc );
217
218 printf( "-------------------------------------------------------------------------\n" );
219
220 printf( "Verification: none\n" );
221 }
222
224
225 return 0;
226}
Attach PAPI event set to the specified thread id.
Convert a numeric hardware event code to a name.
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
int wait_for_attach_and_loop(void)