20#include <sys/ptrace.h>
29#define _LINUX_SOURCE_COMPAT
32#if defined(__FreeBSD__)
33# define PTRACE_ATTACH PT_ATTACH
34# define PTRACE_CONT PT_CONTINUE
40 kill( getpid( ), SIGSTOP );
42 kill( getpid( ), SIGSTOP );
47main(
int argc,
char **argv )
69 test_fail( __FILE__, __LINE__,
"PAPI_get_component_info", 0 );
72 if ( cmpinfo->
attach == 0 ) {
74 "Platform does not support attaching", 0 );
92 if ( ptrace( PTRACE_ATTACH,
pid, NULL, NULL ) == -1 ) {
93 perror(
"ptrace(PTRACE_ATTACH)" );
96 if ( waitpid(
pid, &status, 0 ) == -1 ) {
97 perror(
"waitpid()" );
100 if ( WIFSTOPPED( status ) == 0 )
102 "Child process didnt return true to WIFSTOPPED", 0 );
112 sprintf( add_event_str,
"PAPI_add_event[%s]",
event_name );
125 if ( ptrace( PTRACE_CONT,
pid, NULL, NULL ) == -1 ) {
126 perror(
"ptrace(PTRACE_CONT)" );
129 if ( waitpid(
pid, &status, 0 ) == -1 ) {
130 perror(
"waitpid()" );
133 if ( WIFSTOPPED( status ) == 0 ) {
135 "Child process didn't return true to WIFSTOPPED", 0 );
137 if ( WSTOPSIG( status ) != SIGSTOP ) {
139 "Child process didn't stop on SIGSTOP", 0 );
150 if ( ptrace( PTRACE_CONT,
pid, NULL, NULL ) == -1 ) {
151 perror(
"ptrace(PTRACE_CONT)" );
154 if ( waitpid(
pid, &status, 0 ) == -1 ) {
155 perror(
"waitpid()" );
158 if ( WIFSTOPPED( status ) == 0 ) {
160 "Child process didn't return true to WIFSTOPPED", 0 );
162 if ( WSTOPSIG( status ) != SIGSTOP ) {
164 "Child process didn't stop on SIGSTOP", 0 );
181 if ( ptrace( PTRACE_CONT,
pid, NULL, NULL ) == -1 ) {
182 perror(
"ptrace(PTRACE_CONT)" );
187 if ( waitpid(
pid, &status, 0 ) == -1 ) {
188 perror(
"waitpid()" );
191 if ( WIFEXITED( status ) == 0 ) {
193 "Child process didn't return true to WIFEXITED", 0 );
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" );
208 printf(
"Test type : \t 1\n" );
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 );
218 printf(
"-------------------------------------------------------------------------\n" );
220 printf(
"Verification: none\n" );
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]
Return codes and api definitions.
int kill(__pid_t __pid, int __sig) __attribute__((__nothrow__
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)