22 #include <sys/ptrace.h> 32 #define _LINUX_SOURCE_COMPAT 35 #if defined(__FreeBSD__) 36 # define PTRACE_ATTACH PT_ATTACH 37 # define PTRACE_CONT PT_CONTINUE 43 kill( getpid( ), SIGSTOP );
45 kill( getpid( ), SIGSTOP );
50 main(
int argc,
char **argv )
73 test_fail( __FILE__, __LINE__,
"PAPI_get_component_info", 0 );
77 if ( cmpinfo->
attach == 0 ) {
79 "Platform does not support attaching",0 );
101 if ( ptrace( PTRACE_ATTACH,
pid, NULL, NULL ) == -1 ) {
102 perror(
"ptrace(PTRACE_ATTACH)" );
105 if ( waitpid(
pid, &
status, 0 ) == -1 ) {
106 perror(
"waitpid()" );
109 if ( WIFSTOPPED(
status ) == 0 ) {
111 "Child process didnt return true to WIFSTOPPED", 0 );
121 sprintf( add_event_str,
"PAPI_add_event[%s]",
event_name );
135 if ( ptrace( PTRACE_CONT,
pid, NULL, NULL ) == -1 ) {
136 perror(
"ptrace(PTRACE_CONT)" );
139 if ( waitpid(
pid, &
status, 0 ) == -1 ) {
140 perror(
"waitpid()" );
143 if ( WIFSTOPPED(
status ) == 0 ) {
145 "Child process didn't return true to WIFSTOPPED", 0 );
147 if ( WSTOPSIG(
status ) != SIGSTOP ) {
149 "Child process didn't stop on SIGSTOP", 0 );
165 if ( ptrace( PTRACE_CONT,
pid, NULL, NULL ) == -1 ) {
166 perror(
"ptrace(PTRACE_ATTACH)" );
169 if ( waitpid(
pid, &
status, 0 ) == -1 ) {
170 perror(
"waitpid()" );
173 if ( WIFSTOPPED(
status ) == 0 ) {
175 "Child process didn't return true to WIFSTOPPED", 0 );
177 if ( WSTOPSIG(
status ) != SIGSTOP ) {
179 "Child process didn't stop on SIGSTOP", 0 );
190 printf(
"Warning: PAPI_stop returned error %d, probably ok.\n",
196 printf(
"Warning: PAPI_stop returned error %d, probably ok.\n",
204 if ( ptrace( PTRACE_CONT,
pid, NULL, NULL ) == -1 ) {
205 perror(
"ptrace(PTRACE_CONT)" );
210 if ( waitpid(
pid, &
status, 0 ) == -1 ) {
211 perror(
"waitpid()" );
214 if ( WIFEXITED(
status ) == 0 ) {
216 "Child process didn't return true to WIFEXITED", 0 );
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" );
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 );
250 printf(
"-------------------------------------------------------------------------\n" );
252 printf(
"Verification: none\n" );
char event_name[2][PAPI_MAX_STR_LEN]
int PAPI_stop(int EventSet, long long *values)
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
void test_pass(const char *filename)
long long PAPI_get_virt_usec(void)
char * stringify_granularity(int granularity)
long long PAPI_get_virt_cyc(void)
Return codes and api definitions.
void test_skip(const char *file, int line, const char *call, int retval)
int PAPI_library_init(int version)
int main(int argc, char **argv)
char * stringify_all_domains(int domains)
unsigned int attach_must_ptrace
int PAPI_get_opt(int option, PAPI_option_t *ptr)
int add_two_events(int *num_events, int *papi_event, int *mask)
int kill(__pid_t __pid, int __sig) __attribute__((__nothrow__
long long PAPI_get_real_usec(void)
int tests_quiet(int argc, char **argv)
void test_fail(const char *file, int line, const char *call, int retval)
int wait_for_attach_and_loop(int num)
int PAPI_attach(int EventSet, unsigned long tid)
long long PAPI_get_real_cyc(void)
int PAPI_start(int EventSet)
static long long values[NUM_EVENTS]
long long ** allocate_test_space(int num_tests, int num_events)
int remove_test_events(int *EventSet, int mask)