9 #include <sys/ptrace.h> 18 #define _LINUX_SOURCE_COMPAT 21 #if defined(__FreeBSD__) 22 # define PTRACE_ATTACH PT_ATTACH 23 # define PTRACE_TRACEME PT_TRACE_ME 30 if (ptrace(PTRACE_TRACEME, 0, 0, 0) == 0) {
33 if (!
quiet) printf(
"Child running 50 million instructions\n");
40 perror(
"PTRACE_TRACEME");
46 int main(
int argc,
char **argv ) {
81 test_fail( __FILE__, __LINE__,
"PAPI_get_component_info", 0 );
84 if ( cmpinfo->
attach == 0 ) {
85 test_skip( __FILE__, __LINE__,
"Platform does not support attaching",
91 test_fail( __FILE__, __LINE__,
"PAPI_get_hardware_info", 0 );
102 test_fail( __FILE__, __LINE__,
"PAPI_assign_eventset_component",
116 if (!
quiet) printf(
"Problem adding PAPI_TOT_INS\n");
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",
133 strsignal(WSTOPSIG(
status )) );
137 if (WIFSIGNALED(
status )) {
139 printf(
"Child %ld received signal %d (%s)\n",
142 strsignal(WTERMSIG(
status )) );
146 printf(
"After %d\n",
retval);
156 printf(
"Continuing\n");
159 #if defined(__FreeBSD__) 160 if ( ptrace( PT_CONTINUE,
pid, (
caddr_t) 1, 0 ) == -1 ) {
161 perror(
"ptrace(PTRACE_CONT)" );
167 if ( ptrace( PTRACE_CONT,
pid, NULL, NULL ) == -1 ) {
168 perror(
"ptrace(PTRACE_CONT)" );
177 for(
i=0;
i<1000;
i++) {
185 printf(
"Debugger exited wait() with %d\n", child);
187 if (WIFSTOPPED(
status )) {
189 printf(
"Child has stopped due to signal " 192 strsignal(WSTOPSIG(
status )) );
195 if (WIFSIGNALED(
status )) {
197 printf(
"Child %ld received signal " 201 strsignal(WTERMSIG(
status )) );
204 }
while (!WIFEXITED(
status ));
207 printf(
"Child exited with value %d\n",WEXITSTATUS(
status));
210 if (WEXITSTATUS(
status) != 0) {
212 "Exit status of child to attach to",
PAPI_EMISC);
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" );
242 printf(
"Test type : \t 1\n" );
244 printf(
TAB1,
"PAPI_TOT_INS : \t", (
values[0] ) );
246 printf(
"-------------------------------------------------------------------------\n" );
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)
int PAPI_add_event(int EventSet, int EventCode)
char * stringify_granularity(int granularity)
Return codes and api definitions.
int main(int argc, char **argv)
void test_skip(const char *file, int line, const char *call, int retval)
int PAPI_library_init(int version)
char * stringify_all_domains(int domains)
unsigned int attach_must_ptrace
int PAPI_get_opt(int option, PAPI_option_t *ptr)
int instructions_million(void)
static int wait_for_attach_and_loop(int quiet)
int PAPI_cleanup_eventset(int EventSet)
int PAPI_assign_eventset_component(int EventSet, int cidx)
int PAPI_create_eventset(int *EventSet)
char * PAPI_strerror(int errorCode)
int tests_quiet(int argc, char **argv)
void test_fail(const char *file, int line, const char *call, int retval)
int PAPI_destroy_eventset(int *EventSet)
int PAPI_attach(int EventSet, unsigned long tid)
int PAPI_start(int EventSet)
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
static long long values[NUM_EVENTS]
static const PAPI_hw_info_t * hw_info