From dbbb3ec59c8af169c516360d27423af1cab923f6 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Thu, 2 Feb 2012 12:27:35 -0500 Subject: [PATCH] Update lttng-kernel.h with padding Rename LTTNG_SYM_NAME_LEN to LTTNG_KERNEL_SYM_NAME_LEN. (following lttng-modules ABI). Signed-off-by: David Goulet --- src/bin/lttng-sessiond/trace-kernel.c | 16 ++++++++-------- src/common/lttng-kernel.h | 22 ++++++++++++++++------ tests/test_kernel_data_trace.c | 2 +- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c index 7de98b03a..36f7c9708 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -184,8 +184,8 @@ struct ltt_kernel_event *trace_kernel_create_event(struct lttng_event *ev) attr->u.kprobe.addr = ev->attr.probe.addr; attr->u.kprobe.offset = ev->attr.probe.offset; strncpy(attr->u.kprobe.symbol_name, - ev->attr.probe.symbol_name, LTTNG_SYM_NAME_LEN); - attr->u.kprobe.symbol_name[LTTNG_SYM_NAME_LEN - 1] = '\0'; + ev->attr.probe.symbol_name, LTTNG_KERNEL_SYM_NAME_LEN); + attr->u.kprobe.symbol_name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0'; break; case LTTNG_EVENT_FUNCTION: attr->instrumentation = LTTNG_KERNEL_KRETPROBE; @@ -193,14 +193,14 @@ struct ltt_kernel_event *trace_kernel_create_event(struct lttng_event *ev) attr->u.kretprobe.offset = ev->attr.probe.offset; attr->u.kretprobe.offset = ev->attr.probe.offset; strncpy(attr->u.kretprobe.symbol_name, - ev->attr.probe.symbol_name, LTTNG_SYM_NAME_LEN); - attr->u.kretprobe.symbol_name[LTTNG_SYM_NAME_LEN - 1] = '\0'; + ev->attr.probe.symbol_name, LTTNG_KERNEL_SYM_NAME_LEN); + attr->u.kretprobe.symbol_name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0'; break; case LTTNG_EVENT_FUNCTION_ENTRY: attr->instrumentation = LTTNG_KERNEL_FUNCTION; strncpy(attr->u.ftrace.symbol_name, - ev->attr.ftrace.symbol_name, LTTNG_SYM_NAME_LEN); - attr->u.ftrace.symbol_name[LTTNG_SYM_NAME_LEN - 1] = '\0'; + ev->attr.ftrace.symbol_name, LTTNG_KERNEL_SYM_NAME_LEN); + attr->u.ftrace.symbol_name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0'; break; case LTTNG_EVENT_TRACEPOINT: attr->instrumentation = LTTNG_KERNEL_TRACEPOINT; @@ -217,8 +217,8 @@ struct ltt_kernel_event *trace_kernel_create_event(struct lttng_event *ev) } /* Copy event name */ - strncpy(attr->name, ev->name, LTTNG_SYM_NAME_LEN); - attr->name[LTTNG_SYM_NAME_LEN - 1] = '\0'; + strncpy(attr->name, ev->name, LTTNG_KERNEL_SYM_NAME_LEN); + attr->name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0'; /* Setting up a kernel event */ lke->fd = 0; diff --git a/src/common/lttng-kernel.h b/src/common/lttng-kernel.h index 6451c9638..e1d99ceee 100644 --- a/src/common/lttng-kernel.h +++ b/src/common/lttng-kernel.h @@ -23,7 +23,7 @@ #include -#define LTTNG_SYM_NAME_LEN 256 +#define LTTNG_KERNEL_SYM_NAME_LEN 256 /* * LTTng DebugFS ABI structures. @@ -58,14 +58,19 @@ enum lttng_kernel_context_type { struct lttng_kernel_perf_counter_ctx { uint32_t type; uint64_t config; - char name[LTTNG_SYM_NAME_LEN]; + char name[LTTNG_KERNEL_SYM_NAME_LEN]; }; /* Event/Channel context */ +#define LTTNG_KERNEL_CONTEXT_PADDING1 16 +#define LTTNG_KERNEL_CONTEXT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32 struct lttng_kernel_context { enum lttng_kernel_context_type ctx; + char padding[LTTNG_KERNEL_CONTEXT_PADDING1]; + union { struct lttng_kernel_perf_counter_ctx perf_counter; + char padding[LTTNG_KERNEL_CONTEXT_PADDING2]; } u; }; @@ -73,7 +78,7 @@ struct lttng_kernel_kretprobe { uint64_t addr; uint64_t offset; - char symbol_name[LTTNG_SYM_NAME_LEN]; + char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; }; /* @@ -83,22 +88,27 @@ struct lttng_kernel_kprobe { uint64_t addr; uint64_t offset; - char symbol_name[LTTNG_SYM_NAME_LEN]; + char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; }; /* Function tracer */ struct lttng_kernel_function { - char symbol_name[LTTNG_SYM_NAME_LEN]; + char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; }; +#define LTTNG_KERNEL_EVENT_PADDING1 16 +#define LTTNG_KERNEL_EVENT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32 struct lttng_kernel_event { - char name[LTTNG_SYM_NAME_LEN]; + char name[LTTNG_KERNEL_SYM_NAME_LEN]; enum lttng_kernel_instrumentation instrumentation; + char padding[LTTNG_KERNEL_EVENT_PADDING1]; + /* Per instrumentation type configuration */ union { struct lttng_kernel_kretprobe kretprobe; struct lttng_kernel_kprobe kprobe; struct lttng_kernel_function ftrace; + char padding[LTTNG_KERNEL_EVENT_PADDING2]; } u; }; diff --git a/tests/test_kernel_data_trace.c b/tests/test_kernel_data_trace.c index 30d79a4eb..6dba1f523 100644 --- a/tests/test_kernel_data_trace.c +++ b/tests/test_kernel_data_trace.c @@ -141,7 +141,7 @@ static void create_kernel_event(void) struct ltt_kernel_event *event; struct lttng_event ev; - strncpy(ev.name, get_random_string(), LTTNG_SYM_NAME_LEN); + strncpy(ev.name, get_random_string(), LTTNG_KERNEL_SYM_NAME_LEN); ev.type = LTTNG_EVENT_TRACEPOINT; printf("Creating kernel event: "); -- 2.34.1