Add support for the perf_counter_open system call. Fixes #211498.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10907
This commit is contained in:
Tom Hughes 2009-10-27 09:19:26 +00:00
parent d32144bb8d
commit 141ec942a1
7 changed files with 84 additions and 8 deletions

View File

@ -47,6 +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);
// POSIX, but various sub-cases differ between Linux and Darwin.
DECL_TEMPLATE(linux, sys_fcntl);

View File

@ -1374,13 +1374,13 @@ const SyscallTableEntry ML_(syscall_table)[] = {
LINX_(__NR_eventfd2, sys_eventfd2), // 290
LINXY(__NR_epoll_create1, sys_epoll_create1), // 291
// (__NR_dup3, sys_ni_syscall) // 292
LINXY(__NR_pipe2, sys_pipe2) // 293
LINXY(__NR_pipe2, sys_pipe2), // 293
// (__NR_inotify_init1, sys_ni_syscall) // 294
// (__NR_preadv, sys_ni_syscall) // 295
// (__NR_pwritev, sys_ni_syscall) // 296
// (__NR_rt_tgsigqueueinfo, sys_ni_syscall) // 297
// (__NR_perf_counter_open, sys_ni_syscall) // 298
LINXY(__NR_perf_counter_open, sys_perf_counter_open) // 298
};
const UInt ML_(syscall_table_size) =

View File

@ -2392,6 +2392,30 @@ PRE(sys_stime)
PRE_MEM_READ( "stime(t)", ARG1, sizeof(vki_time_t) );
}
PRE(sys_perf_counter_open)
{
PRINT("sys_perf_counter_open ( %#lx, %ld, %ld, %ld, %ld )",
ARG1,ARG2,ARG3,ARG4,ARG5);
PRE_REG_READ5(long, "perf_counter_open",
struct vki_perf_counter_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) );
}
POST(sys_perf_counter_open)
{
vg_assert(SUCCESS);
if (!ML_(fd_allowed)(RES, "perf_counter_open", tid, True)) {
VG_(close)(RES);
SET_STATUS_Failure( VKI_EMFILE );
} else {
if (VG_(clo_track_fds))
ML_(record_fd_open_nameless)(tid, RES);
}
}
/* ---------------------------------------------------------------------
utime wrapper
------------------------------------------------------------------ */

View File

@ -1866,9 +1866,9 @@ const SyscallTableEntry ML_(syscall_table)[] = {
LINX_(__NR_eventfd2, sys_eventfd2), // 314
LINXY(__NR_epoll_create1, sys_epoll_create1), // 315
// (__NR_dup3, sys_ni_syscall) // 316
LINXY(__NR_pipe2, sys_pipe2) // 317
LINXY(__NR_pipe2, sys_pipe2), // 317
// (__NR_inotify_init1, sys_ni_syscall) // 318
// (__NR_perf_counter_open, sys_ni_syscall) // 319
LINXY(__NR_perf_counter_open, sys_perf_counter_open) // 319
// (__NR_preadv, sys_ni_syscall) // 320
// (__NR_pwritev, sys_ni_syscall) // 321
// (__NR_rt_tgsigqueueinfo, sys_ni_syscall) // 322

View File

@ -1506,9 +1506,9 @@ const SyscallTableEntry ML_(syscall_table)[] = {
LINX_(__NR_eventfd2, sys_eventfd2), // 314
LINXY(__NR_epoll_create1, sys_epoll_create1), // 315
// (__NR_dup3, sys_ni_syscall) // 316
LINXY(__NR_pipe2, sys_pipe2) // 317
LINXY(__NR_pipe2, sys_pipe2), // 317
// (__NR_inotify_init1, sys_ni_syscall) // 318
// (__NR_perf_counter_open, sys_ni_syscall) // 319
LINXY(__NR_perf_counter_open, sys_perf_counter_open) // 319
// (__NR_preadv, sys_ni_syscall) // 320
// (__NR_pwritev, sys_ni_syscall) // 321
// (__NR_rt_tgsigqueueinfo, sys_ni_syscall) // 322

View File

@ -2253,13 +2253,13 @@ const SyscallTableEntry ML_(syscall_table)[] = {
LINXY(__NR_epoll_create1, sys_epoll_create1), // 329
// (__NR_dup3, sys_ni_syscall) // 330
LINXY(__NR_pipe2, sys_pipe2) // 331
LINXY(__NR_pipe2, sys_pipe2), // 331
// (__NR_inotify_init1, sys_ni_syscall) // 332
// (__NR_preadv, sys_ni_syscall) // 333
// (__NR_pwritev, sys_ni_syscall) // 334
// (__NR_rt_tgsigqueueinfo, sys_ni_syscall) // 335
// (__NR_perf_counter_open, sys_ni_syscall) // 336
LINXY(__NR_perf_counter_open, sys_perf_counter_open) // 336
};
const UInt ML_(syscall_table_size) =

View File

@ -2570,6 +2570,57 @@ struct vki_iwreq
union vki_iwreq_data u;
};
/*--------------------------------------------------------------------*/
// From linux-2.6.31.5/include/linux/perf_counter.h
/*--------------------------------------------------------------------*/
struct vki_perf_counter_attr {
/*
* Major type: hardware/software/tracepoint/etc.
*/
__vki_u32 type;
/*
* Size of the attr structure, for fwd/bwd compat.
*/
__vki_u32 size;
/*
* Type specific configuration information.
*/
__vki_u64 config;
union {
__vki_u64 sample_period;
__vki_u64 sample_freq;
};
__vki_u64 sample_type;
__vki_u64 read_format;
__vki_u64 disabled : 1, /* off by default */
inherit : 1, /* children inherit it */
pinned : 1, /* must always be on PMU */
exclusive : 1, /* only group on PMU */
exclude_user : 1, /* don't count user */
exclude_kernel : 1, /* ditto kernel */
exclude_hv : 1, /* ditto hypervisor */
exclude_idle : 1, /* don't count when idle */
mmap : 1, /* include mmap data */
comm : 1, /* include comm data */
freq : 1, /* use freq, not period */
inherit_stat : 1, /* per task counts */
enable_on_exec : 1, /* next exec enables */
task : 1, /* trace fork/exit */
__reserved_1 : 50;
__vki_u32 wakeup_events; /* wakeup every n events */
__vki_u32 __reserved_2;
__vki_u64 __reserved_3;
};
#endif // __VKI_LINUX_H