From: Tom Hughes Date: Wed, 8 Jun 2011 09:10:40 +0000 (+0000) Subject: It seems that the perf_counter_open system call was renamed to X-Git-Tag: svn/VALGRIND_3_7_0~433 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=912fe515535ef68639c412dbcb721aa2436c9957;p=thirdparty%2Fvalgrind.git It seems that the perf_counter_open system call was renamed to perf_event_open some time after we added it, so correct the name wherever it appears to match the current kernel source. Also fixup the PRE handler to do the check correctly, using the size field of the structure to work out how much data there is. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11804 --- diff --git a/coregrind/m_syswrap/priv_syswrap-linux.h b/coregrind/m_syswrap/priv_syswrap-linux.h index e2a21d6ba2..28b6911e58 100644 --- a/coregrind/m_syswrap/priv_syswrap-linux.h +++ b/coregrind/m_syswrap/priv_syswrap-linux.h @@ -47,7 +47,7 @@ extern SysRes ML_(do_fork_clone) ( ThreadId tid, UInt flags, DECL_TEMPLATE(linux, sys_mount); DECL_TEMPLATE(linux, sys_oldumount); DECL_TEMPLATE(linux, sys_umount); -DECL_TEMPLATE(linux, sys_perf_counter_open); +DECL_TEMPLATE(linux, sys_perf_event_open); DECL_TEMPLATE(linux, sys_preadv); DECL_TEMPLATE(linux, sys_pwritev); DECL_TEMPLATE(linux, sys_dup3); diff --git a/coregrind/m_syswrap/syswrap-amd64-linux.c b/coregrind/m_syswrap/syswrap-amd64-linux.c index ece1a73b44..b58c17189f 100644 --- a/coregrind/m_syswrap/syswrap-amd64-linux.c +++ b/coregrind/m_syswrap/syswrap-amd64-linux.c @@ -1410,7 +1410,7 @@ static SyscallTableEntry syscall_table[] = { LINXY(__NR_preadv, sys_preadv), // 295 LINX_(__NR_pwritev, sys_pwritev), // 296 LINXY(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo),// 297 - LINXY(__NR_perf_counter_open, sys_perf_counter_open) // 298 + LINXY(__NR_perf_event_open, sys_perf_event_open) // 298 }; SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index e3c57d69b0..f4f75532ef 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -2583,22 +2583,26 @@ PRE(sys_stime) PRE_MEM_READ( "stime(t)", ARG1, sizeof(vki_time_t) ); } -PRE(sys_perf_counter_open) +PRE(sys_perf_event_open) { - PRINT("sys_perf_counter_open ( %#lx, %ld, %ld, %ld, %ld )", + struct vki_perf_event_attr *attr; + PRINT("sys_perf_event_open ( %#lx, %ld, %ld, %ld, %ld )", ARG1,ARG2,ARG3,ARG4,ARG5); - PRE_REG_READ5(long, "perf_counter_open", - struct vki_perf_counter_attr *, attr, + PRE_REG_READ5(long, "perf_event_open", + struct vki_perf_event_attr *, attr, vki_pid_t, pid, int, cpu, int, group_fd, unsigned long, flags); - PRE_MEM_READ( "perf_counter_open(attr)", - ARG1, sizeof(struct vki_perf_counter_attr) ); + attr = (struct vki_perf_event_attr *)ARG1; + PRE_MEM_READ( "perf_event_open(attr->size)", + &attr->size, sizeof(attr->size) ); + PRE_MEM_READ( "perf_event_open(attr)", + attr, attr->size ); } -POST(sys_perf_counter_open) +POST(sys_perf_event_open) { vg_assert(SUCCESS); - if (!ML_(fd_allowed)(RES, "perf_counter_open", tid, True)) { + if (!ML_(fd_allowed)(RES, "perf_event_open", tid, True)) { VG_(close)(RES); SET_STATUS_Failure( VKI_EMFILE ); } else { diff --git a/coregrind/m_syswrap/syswrap-ppc32-linux.c b/coregrind/m_syswrap/syswrap-ppc32-linux.c index 9baf8d8e06..997acf3a3d 100644 --- a/coregrind/m_syswrap/syswrap-ppc32-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc32-linux.c @@ -1890,7 +1890,7 @@ static SyscallTableEntry syscall_table[] = { LINXY(__NR_dup3, sys_dup3), // 316 LINXY(__NR_pipe2, sys_pipe2), // 317 LINXY(__NR_inotify_init1, sys_inotify_init1), // 318 - LINXY(__NR_perf_counter_open, sys_perf_counter_open),// 319 + LINXY(__NR_perf_event_open, sys_perf_event_open), // 319 LINXY(__NR_preadv, sys_preadv), // 320 LINX_(__NR_pwritev, sys_pwritev), // 321 LINXY(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo) // 322 diff --git a/coregrind/m_syswrap/syswrap-ppc64-linux.c b/coregrind/m_syswrap/syswrap-ppc64-linux.c index 6e91052d78..54e866d014 100644 --- a/coregrind/m_syswrap/syswrap-ppc64-linux.c +++ b/coregrind/m_syswrap/syswrap-ppc64-linux.c @@ -1531,7 +1531,7 @@ static SyscallTableEntry syscall_table[] = { LINXY(__NR_dup3, sys_dup3), // 316 LINXY(__NR_pipe2, sys_pipe2), // 317 LINXY(__NR_inotify_init1, sys_inotify_init1), // 318 - LINXY(__NR_perf_counter_open, sys_perf_counter_open),// 319 + LINXY(__NR_perf_event_open, sys_perf_event_open), // 319 LINXY(__NR_preadv, sys_preadv), // 320 LINX_(__NR_pwritev, sys_pwritev), // 321 LINXY(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo) // 322 diff --git a/coregrind/m_syswrap/syswrap-x86-linux.c b/coregrind/m_syswrap/syswrap-x86-linux.c index 4b526563bc..ecd2e13393 100644 --- a/coregrind/m_syswrap/syswrap-x86-linux.c +++ b/coregrind/m_syswrap/syswrap-x86-linux.c @@ -2280,7 +2280,7 @@ static SyscallTableEntry syscall_table[] = { LINX_(__NR_pwritev, sys_pwritev), // 334 LINXY(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo),// 335 - LINXY(__NR_perf_counter_open, sys_perf_counter_open) // 336 + LINXY(__NR_perf_event_open, sys_perf_event_open) // 336 }; SyscallTableEntry* ML_(get_linux_syscall_entry) ( UInt sysno ) diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h index eee044d564..e3e1d93956 100644 --- a/include/vki/vki-linux.h +++ b/include/vki/vki-linux.h @@ -2625,10 +2625,10 @@ struct vki_iwreq }; /*--------------------------------------------------------------------*/ -// From linux-2.6.31.5/include/linux/perf_counter.h +// From linux-2.6.31.5/include/linux/perf_event.h /*--------------------------------------------------------------------*/ -struct vki_perf_counter_attr { +struct vki_perf_event_attr { /* * Major type: hardware/software/tracepoint/etc. @@ -2667,13 +2667,37 @@ struct vki_perf_counter_attr { inherit_stat : 1, /* per task counts */ enable_on_exec : 1, /* next exec enables */ task : 1, /* trace fork/exit */ + watermark : 1, /* wakeup_watermark */ + /* + * precise_ip: + * + * 0 - SAMPLE_IP can have arbitrary skid + * 1 - SAMPLE_IP must have constant skid + * 2 - SAMPLE_IP requested to have 0 skid + * 3 - SAMPLE_IP must have 0 skid + * + * See also PERF_RECORD_MISC_EXACT_IP + */ + precise_ip : 2, /* skid constraint */ + mmap_data : 1, /* non-exec mmap data */ + sample_id_all : 1, /* sample_type all events */ + + __reserved_1 : 45; - __reserved_1 : 50; - - __vki_u32 wakeup_events; /* wakeup every n events */ - __vki_u32 __reserved_2; + union { + __vki_u32 wakeup_events; /* wakeup every n events */ + __vki_u32 wakeup_watermark; /* bytes before wakeup */ + }; - __vki_u64 __reserved_3; + __vki_u32 bp_type; + union { + __vki_u64 bp_addr; + __vki_u64 config1; /* extension of config */ + }; + union { + __vki_u64 bp_len; + __vki_u64 config2; /* extension of config1 */ + }; }; /*--------------------------------------------------------------------*/ diff --git a/include/vki/vki-scnums-amd64-linux.h b/include/vki/vki-scnums-amd64-linux.h index f891f9472b..d5b2bf8aff 100644 --- a/include/vki/vki-scnums-amd64-linux.h +++ b/include/vki/vki-scnums-amd64-linux.h @@ -379,7 +379,7 @@ #define __NR_preadv 295 #define __NR_pwritev 296 #define __NR_rt_tgsigqueueinfo 297 -#define __NR_perf_counter_open 298 +#define __NR_perf_event_open 298 #endif /* __VKI_SCNUMS_AMD64_LINUX_H */ diff --git a/include/vki/vki-scnums-ppc32-linux.h b/include/vki/vki-scnums-ppc32-linux.h index 223565321c..b98cfbb9b9 100644 --- a/include/vki/vki-scnums-ppc32-linux.h +++ b/include/vki/vki-scnums-ppc32-linux.h @@ -361,7 +361,7 @@ #define __NR_dup3 316 #define __NR_pipe2 317 #define __NR_inotify_init1 318 -#define __NR_perf_counter_open 319 +#define __NR_perf_event_open 319 #define __NR_preadv 320 #define __NR_pwritev 321 #define __NR_rt_tgsigqueueinfo 322 diff --git a/include/vki/vki-scnums-ppc64-linux.h b/include/vki/vki-scnums-ppc64-linux.h index e019e6f54d..83dcbb3231 100644 --- a/include/vki/vki-scnums-ppc64-linux.h +++ b/include/vki/vki-scnums-ppc64-linux.h @@ -353,7 +353,7 @@ #define __NR_dup3 316 #define __NR_pipe2 317 #define __NR_inotify_init1 318 -#define __NR_perf_counter_open 319 +#define __NR_perf_event_open 319 #define __NR_preadv 320 #define __NR_pwritev 321 #define __NR_rt_tgsigqueueinfo 322 diff --git a/include/vki/vki-scnums-x86-linux.h b/include/vki/vki-scnums-x86-linux.h index f1942775af..e53ca257c4 100644 --- a/include/vki/vki-scnums-x86-linux.h +++ b/include/vki/vki-scnums-x86-linux.h @@ -370,7 +370,7 @@ #define __NR_preadv 333 #define __NR_pwritev 334 #define __NR_rt_tgsigqueueinfo 335 -#define __NR_perf_counter_open 336 +#define __NR_perf_event_open 336 #endif /* __VKI_SCNUMS_X86_LINUX_H */