----- Original Message -----
>
> Hi Daisuke,
>
> The trace.c extension module is no longer functional as of Linux 4.2
> due to a huge rework of the ftrace code which, most notably, changed
> symbol and structure names from "ftrace..." to "trace...".
>
> Can you take a look at addressing those changes, while maintaining
> backwards compatibility?
>
> Thanks,
> Dave
Hi Daisuke,
I *think* that the attached patch may be enough to handle the kernel changes.
It uses this construct in the relevant locations to pick the correct version:
MAX(MEMBER_OFFSET("ftrace_event_call", ...), MEMBER_OFFSET("trace_event_call", ...))
Note that I also added a gdb_set_crash_scope() call to init_offsets()
because there are multiple, different, "struct ring_buffer" declarations in
the kernel, and for whatever reason, crash was initially picking up the wrong
one from "kernel/events/internal.h".
Can you verify that this patch is sufficient and test its functionality?
Or if you prefer, can you come up with your own solution?
Thanks,
Dave
diff --git a/extensions/trace.c b/extensions/trace.c
index c269f4c..49af611 100644
--- a/extensions/trace.c
+++ b/extensions/trace.c
@@ -182,6 +182,8 @@ static int init_offsets(void)
fprintf(fp, "per cpu buffer sizes\n");
}
+ gdb_set_crash_scope(symbol_value("ring_buffer_read"), "ring_buffer_read");
+
if (!per_cpu_buffer_sizes)
init_offset(ring_buffer, pages);
init_offset(ring_buffer, flags);
@@ -211,7 +213,12 @@ static int init_offsets(void)
init_offset(list_head, next);
- init_offset(ftrace_event_call, list);
+ koffset(ftrace_event_call, list) = MAX(MEMBER_OFFSET("ftrace_event_call", "list"),
+ MEMBER_OFFSET("trace_event_call", "list"));
+ if (koffset(ftrace_event_call, list) < 0) {
+ fprintf(fp, "failed to init the offset, struct:[f]trace_event_call member:list)\n");
+ return -1; \
+ }
init_offset(ftrace_event_field, link);
init_offset(ftrace_event_field, name);
@@ -722,7 +729,8 @@ static int syscall_get_enter_fields(ulong call, ulong *fields)
goto work;
inited = 1;
- data_offset = MEMBER_OFFSET("ftrace_event_call", "data");
+ data_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "data"),
+ MEMBER_OFFSET("trace_event_call", "data"));
if (data_offset < 0)
return -1;
@@ -754,7 +762,8 @@ static int syscall_get_exit_fields_old(ulong call, ulong *fields)
goto work;
inited = 1;
- data_offset = MEMBER_OFFSET("ftrace_event_call", "data");
+ data_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "data"),
+ MEMBER_OFFSET("trace_event_call", "data"));
if (data_offset < 0)
return -1;
@@ -815,18 +824,22 @@ int ftrace_get_event_type_fields(ulong call, ulong *fields)
goto work;
inited = 1;
- fields_offset = MEMBER_OFFSET("ftrace_event_call", "fields");
+ fields_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "fields"),
+ MEMBER_OFFSET("trace_event_call", "fields"));
- class_offset = MEMBER_OFFSET("ftrace_event_call", "class");
+ class_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "class"),
+ MEMBER_OFFSET("trace_event_call", "class"));
if (class_offset < 0)
goto work;
inited = 2;
- fields_offset = MEMBER_OFFSET("ftrace_event_class", "fields");
+ fields_offset = MAX(MEMBER_OFFSET("ftrace_event_class", "fields"),
+ MEMBER_OFFSET("trace_event_class", "fields"));
if (fields_offset < 0)
return -1;
- get_fields_offset = MEMBER_OFFSET("ftrace_event_class", "get_fields");
+ get_fields_offset = MAX(MEMBER_OFFSET("ftrace_event_class", "get_fields"),
+ MEMBER_OFFSET("trace_event_class", "get_fields"));
if ((sp = symbol_search("syscall_get_enter_fields")) != NULL)
syscall_get_enter_fields_value = sp->value;
if ((sp = symbol_search("syscall_get_exit_fields")) != NULL)
@@ -1017,15 +1030,18 @@ int ftrace_get_event_type_name(ulong call, char *name, int len)
goto work;
inited = 1;
- name_offset = MEMBER_OFFSET("ftrace_event_call", "name");
+ name_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "name"),
+ MEMBER_OFFSET("trace_event_call", "name"));
if (name_offset >= 0)
goto work;
- name_offset = ANON_MEMBER_OFFSET("ftrace_event_call", "name");
+ name_offset = MAX(ANON_MEMBER_OFFSET("ftrace_event_call", "name"),
+ ANON_MEMBER_OFFSET("trace_event_call", "name"));
if (name_offset < 0)
return -1;
- flags_offset = MEMBER_OFFSET("ftrace_event_call", "flags");
+ flags_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "flags"),
+ MEMBER_OFFSET("trace_event_call", "flags"));
if (flags_offset < 0)
return -1;
@@ -1078,16 +1094,19 @@ int ftrace_get_event_type_system(ulong call, char *system, int len)
goto work;
inited = 1;
- sys_offset = MEMBER_OFFSET("ftrace_event_call", "system");
+ sys_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "system"),
+ MEMBER_OFFSET("trace_event_call", "system"));
if (sys_offset >= 0)
goto work;
- class_offset = MEMBER_OFFSET("ftrace_event_call", "class");
+ class_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "class"),
+ MEMBER_OFFSET("trace_event_call", "class"));
if (class_offset < 0)
return -1;
- sys_offset = MEMBER_OFFSET("ftrace_event_class", "system");
+ sys_offset = MAX(MEMBER_OFFSET("ftrace_event_class", "system"),
+ MEMBER_OFFSET("trace_event_class", "system"));
inited = 2;
work:
@@ -1159,7 +1178,8 @@ int ftrace_get_event_type_print_fmt(ulong call, char **print_fmt)
if (!inited) {
inited = 1;
- fmt_offset = MEMBER_OFFSET("ftrace_event_call", "print_fmt");
+ fmt_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "print_fmt"),
+ MEMBER_OFFSET("trace_event_call", "print_fmt"));
}
if (fmt_offset < 0) {
@@ -1182,11 +1202,13 @@ int ftrace_get_event_type_id(ulong call, int *id)
if (!inited) {
inited = 1;
- id_offset = MEMBER_OFFSET("ftrace_event_call", "id");
+ id_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "id"),
+ MEMBER_OFFSET("trace_event_call", "id"));
if (id_offset < 0) {
/* id = call->event.type */
- int f1 = MEMBER_OFFSET("ftrace_event_call", "event");
+ int f1 = MAX(MEMBER_OFFSET("ftrace_event_call", "event"),
+ MEMBER_OFFSET("trace_event_call", "event"));
int f2 = MEMBER_OFFSET("trace_event", "type");
if (f1 >= 0 && f2 >= 0)
--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility