[Crash-utility] [PATCH] extensions/trace: Fix ftrace_get_event_type_name()

Namhyung Kim namhyung at gmail.com
Sat Jul 9 11:21:43 UTC 2016


The recent kernel change dcb0b5575d24 ("tracing: Remove
TRACE_EVENT_FL_USE_CALL_FILTER logic") changed the bit index so it makes
checking TRACE_EVENT_FL_TRACEPOINT flag failed.  It should be 0x20 for
newer kernels.  Without this patch, the crash tool refused to load
trace.so extension due to invalid access to event names:

  crash> extend trace.so
  extend: /path/to/crash/extensions/trace.so: no commands registered: shared object unloaded

Instead of using the hard-coded value, read the enum value from the
kernel dynamically.

Reported-by: Minchan Kim <minchan at kernel.org>
Cc: Steven Rostedt <rostedt at goodmis.org>
Signed-off-by: Namhyung Kim <namhyung at gmail.com>
---
 extensions/trace.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/extensions/trace.c b/extensions/trace.c
index 782d62f..f8ccd91 100644
--- a/extensions/trace.c
+++ b/extensions/trace.c
@@ -1015,8 +1015,6 @@ static void ftrace_destroy_event_types(void)
 	free(ftrace_common_fields);
 }
 
-#define TRACE_EVENT_FL_TRACEPOINT 0x40
-
 static
 int ftrace_get_event_type_name(ulong call, char *name, int len)
 {
@@ -1024,8 +1022,9 @@ int ftrace_get_event_type_name(ulong call, char *name, int len)
 	static int name_offset;
 	static int flags_offset;
 	static int tp_name_offset;
-	uint flags;
+	static long tracepoint_flag;
 
+	uint flags;
 	ulong name_addr;
 
 	if (inited)
@@ -1051,6 +1050,9 @@ int ftrace_get_event_type_name(ulong call, char *name, int len)
 	if (tp_name_offset < 0)
 		return -1;
 
+	if (!enumerator_value("TRACE_EVENT_FL_TRACEPOINT", &tracepoint_flag))
+		return -1;
+
 	inited = 2;
 
 work:
@@ -1067,7 +1069,7 @@ work:
 			     RETURN_ON_ERROR))
 			return -1;
 
-		if (flags & TRACE_EVENT_FL_TRACEPOINT) {
+		if (flags & (uint)tracepoint_flag) {
 			if (!readmem(name_addr + tp_name_offset, KVADDR,
 				     &name_addr, sizeof(name_addr),
 				     "read tracepoint name", RETURN_ON_ERROR))
-- 
2.8.0




More information about the Crash-utility mailing list