aboutsummaryrefslogtreecommitdiffstats
path: root/executor
diff options
context:
space:
mode:
Diffstat (limited to 'executor')
-rw-r--r--executor/executor_linux.h59
1 files changed, 18 insertions, 41 deletions
diff --git a/executor/executor_linux.h b/executor/executor_linux.h
index 9de1b1c40..e66c92e3d 100644
--- a/executor/executor_linux.h
+++ b/executor/executor_linux.h
@@ -14,35 +14,21 @@
const unsigned long KCOV_TRACE_PC = 0;
const unsigned long KCOV_TRACE_CMP = 1;
-template <typename kernel_u64_t, int N>
+template <int N>
struct kcov_remote_arg {
- unsigned trace_mode;
- unsigned area_size;
- unsigned num_handles;
- kernel_u64_t common_handle;
- kernel_u64_t handles[N];
+ uint32 trace_mode;
+ uint32 area_size;
+ uint32 num_handles;
+ uint32 pad;
+ uint64 common_handle;
+ uint64 handles[N];
};
-struct uint64_aligned64 {
- uint64 v;
-} __attribute__((aligned(8)));
-
-struct uint64_aligned32 {
- uint64 v;
-} __attribute__((packed, aligned(4)));
-
-typedef kcov_remote_arg<uint64_aligned32, 0> kcov_remote_arg32;
-typedef kcov_remote_arg<uint64_aligned64, 0> kcov_remote_arg64;
-
-typedef char kcov_remote_arg32_size[sizeof(kcov_remote_arg32) == 20 ? 1 : -1];
-typedef char kcov_remote_arg64_size[sizeof(kcov_remote_arg64) == 24 ? 1 : -1];
-
#define KCOV_INIT_TRACE32 _IOR('c', 1, uint32)
#define KCOV_INIT_TRACE64 _IOR('c', 1, uint64)
#define KCOV_ENABLE _IO('c', 100)
#define KCOV_DISABLE _IO('c', 101)
-#define KCOV_REMOTE_ENABLE32 _IOW('c', 102, kcov_remote_arg32)
-#define KCOV_REMOTE_ENABLE64 _IOW('c', 102, kcov_remote_arg64)
+#define KCOV_REMOTE_ENABLE _IOW('c', 102, kcov_remote_arg<0>)
#define KCOV_SUBSYSTEM_COMMON (0x00ull << 56)
#define KCOV_SUBSYSTEM_USB (0x01ull << 56)
@@ -115,21 +101,6 @@ static void cover_unprotect(cover_t* cov)
{
}
-template <typename kernel_u64_t>
-static void enable_remote_cover(cover_t* cov, unsigned long ioctl_cmd, unsigned int kcov_mode)
-{
- kcov_remote_arg<kernel_u64_t, 1> arg = {
- .trace_mode = kcov_mode,
- };
- // Coverage buffer size of background threads.
- arg.area_size = kExtraCoverSize;
- arg.num_handles = 1;
- arg.handles[0].v = kcov_remote_handle(KCOV_SUBSYSTEM_USB, procid + 1);
- arg.common_handle.v = kcov_remote_handle(KCOV_SUBSYSTEM_COMMON, procid + 1);
- if (ioctl(cov->fd, ioctl_cmd, &arg))
- exitf("remote cover enable write trace failed");
-}
-
static void cover_enable(cover_t* cov, bool collect_comps, bool extra)
{
unsigned int kcov_mode = collect_comps ? KCOV_TRACE_CMP : KCOV_TRACE_PC;
@@ -141,10 +112,16 @@ static void cover_enable(cover_t* cov, bool collect_comps, bool extra)
exitf("cover enable write trace failed, mode=%d", kcov_mode);
return;
}
- if (is_kernel_64_bit)
- enable_remote_cover<uint64_aligned64>(cov, KCOV_REMOTE_ENABLE64, kcov_mode);
- else
- enable_remote_cover<uint64_aligned32>(cov, KCOV_REMOTE_ENABLE32, kcov_mode);
+ kcov_remote_arg<1> arg = {
+ .trace_mode = kcov_mode,
+ // Coverage buffer size of background threads.
+ .area_size = kExtraCoverSize,
+ .num_handles = 1,
+ };
+ arg.common_handle = kcov_remote_handle(KCOV_SUBSYSTEM_COMMON, procid + 1);
+ arg.handles[0] = kcov_remote_handle(KCOV_SUBSYSTEM_USB, procid + 1);
+ if (ioctl(cov->fd, KCOV_REMOTE_ENABLE, &arg))
+ exitf("remote cover enable write trace failed");
}
static void cover_reset(cover_t* cov)