]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add support for the perf_counter_open system call. Fixes #211498.
authorTom Hughes <tom@compton.nu>
Tue, 27 Oct 2009 09:19:26 +0000 (09:19 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 27 Oct 2009 09:19:26 +0000 (09:19 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10907

coregrind/m_syswrap/priv_syswrap-linux.h
coregrind/m_syswrap/syswrap-amd64-linux.c
coregrind/m_syswrap/syswrap-linux.c
coregrind/m_syswrap/syswrap-ppc32-linux.c
coregrind/m_syswrap/syswrap-ppc64-linux.c
coregrind/m_syswrap/syswrap-x86-linux.c
include/vki/vki-linux.h

index fed3ba6e191bcfbed5cb3af237fcf9e4cabbcac8..ce48a929a0366f87b87afc314e7effb1df72b597 100644 (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);
index 1e405c117e7a7fdf6d3a6ea50b98e44a8449622b..39188901211adc18dbde9656ecc443072a2cac7b 100644 (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) = 
index 7f81262fad8fb2e451c8777e9c25c9b333999d51..7a2e70862a5533a0c7e00ac120ddd8017e8a824b 100644 (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
    ------------------------------------------------------------------ */
index d4f15c7bebfe21f94e90610bac5e9153cece1a0b..d62febd4b7d22033c3f02bfdc8666d5220518692 100644 (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
index bfb930159d1af00dcd40115eb0f751ba5ab355de..2f93880982fe811a0869fae94eef9ba226e0aac0 100644 (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
index 57720dd126489c34522ddb973ec63959ad8ccfbd..ea9edc2c13144bd9cc87098940c0443d8d9694b6 100644 (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) = 
index 90bffe6b7b583a4eeb6ccaffde4b048ce1102ad7..93d4ae67218c152e2693057d156450e8fe98ece3 100644 (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