04db8c
--- crash-trace-command-2.0/trace.c.orig
04db8c
+++ crash-trace-command-2.0/trace.c
04db8c
@@ -34,6 +34,10 @@ static int encapsulated_current_trace;
04db8c
  * trace_buffer is supported
04db8c
  */
04db8c
 static int trace_buffer_available;
04db8c
+/*
04db8c
+ * max_buffer is supported
04db8c
+ */
04db8c
+static int max_buffer_available;
04db8c
 
04db8c
 #define koffset(struct, member) struct##_##member##_offset
04db8c
 
04db8c
@@ -154,6 +158,7 @@ static int init_offsets(void)
04db8c
 		if (koffset(struct, member) < 0) {			\
04db8c
 			fprintf(fp, "failed to init the offset, struct:"\
04db8c
 				#struct ", member:" #member);		\
04db8c
+			fprintf(fp, "\n");				\
04db8c
 			return -1;					\
04db8c
 		}							\
04db8c
 	} while (0)
04db8c
@@ -163,8 +168,10 @@ static int init_offsets(void)
04db8c
 
04db8c
 	if (trace_buffer_available) {
04db8c
 		init_offset(trace_array, trace_buffer);
04db8c
-		init_offset(trace_array, max_buffer);
04db8c
 		init_offset(trace_buffer, buffer);
04db8c
+
04db8c
+		if (max_buffer_available)
04db8c
+			init_offset(trace_array, max_buffer);
04db8c
 	} else {
04db8c
 		init_offset(trace_array, buffer);
04db8c
 	}
04db8c
@@ -176,6 +183,9 @@ static int init_offsets(void)
04db8c
 			fprintf(fp, "per cpu buffer sizes\n");
04db8c
 	}
04db8c
 
04db8c
+	if (kernel_symbol_exists("ring_buffer_read"))
04db8c
+		gdb_set_crash_scope(symbol_value("ring_buffer_read"), "ring_buffer_read");
04db8c
+
04db8c
 	if (!per_cpu_buffer_sizes)
04db8c
 		init_offset(ring_buffer, pages);
04db8c
 	init_offset(ring_buffer, flags);
04db8c
@@ -205,7 +215,12 @@ static int init_offsets(void)
04db8c
 
04db8c
 	init_offset(list_head, next);
04db8c
 
04db8c
-	init_offset(ftrace_event_call, list);
04db8c
+	koffset(ftrace_event_call, list) = MAX(MEMBER_OFFSET("ftrace_event_call", "list"), 
04db8c
+		MEMBER_OFFSET("trace_event_call", "list"));
04db8c
+	if (koffset(ftrace_event_call, list) < 0) {
04db8c
+		fprintf(fp, "failed to init the offset, struct:[f]trace_event_call member:list)\n");
04db8c
+		return -1;					\
04db8c
+	}
04db8c
 
04db8c
 	init_offset(ftrace_event_field, link);
04db8c
 	init_offset(ftrace_event_field, name);
04db8c
@@ -448,6 +463,9 @@ out_fail:
04db8c
 static int ftrace_int_max_tr_trace(void)
04db8c
 {
04db8c
 	if (trace_buffer_available) {
04db8c
+		if (!max_buffer_available)
04db8c
+			return 0;
04db8c
+
04db8c
 		global_max_buffer = global_trace + koffset(trace_array, max_buffer);
04db8c
 		read_value(max_tr_ring_buffer, global_max_buffer, trace_buffer, buffer);
04db8c
 	} else {
04db8c
@@ -528,6 +546,9 @@ static int ftrace_init(void)
04db8c
 
04db8c
 	if (MEMBER_EXISTS("trace_array", "trace_buffer")) {
04db8c
 		trace_buffer_available = 1;
04db8c
+
04db8c
+		if (MEMBER_EXISTS("trace_array", "max_buffer"))
04db8c
+			max_buffer_available = 1;
04db8c
 	} else {
04db8c
 		sym_max_tr_trace = symbol_search("max_tr");
04db8c
 		if (sym_max_tr_trace == NULL)
04db8c
@@ -710,7 +731,8 @@ static int syscall_get_enter_fields(ulon
04db8c
 		goto work;
04db8c
 
04db8c
 	inited = 1;
04db8c
-	data_offset = MEMBER_OFFSET("ftrace_event_call", "data");
04db8c
+	data_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "data"), 
04db8c
+		MEMBER_OFFSET("trace_event_call", "data"));
04db8c
 	if (data_offset < 0)
04db8c
 		return -1;
04db8c
 
04db8c
@@ -742,7 +764,8 @@ static int syscall_get_exit_fields_old(u
04db8c
 		goto work;
04db8c
 
04db8c
 	inited = 1;
04db8c
-	data_offset = MEMBER_OFFSET("ftrace_event_call", "data");
04db8c
+	data_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "data"),
04db8c
+		MEMBER_OFFSET("trace_event_call", "data"));
04db8c
 	if (data_offset < 0)
04db8c
 		return -1;
04db8c
 
04db8c
@@ -803,18 +826,22 @@ int ftrace_get_event_type_fields(ulong c
04db8c
 		goto work;
04db8c
 
04db8c
 	inited = 1;
04db8c
-	fields_offset = MEMBER_OFFSET("ftrace_event_call", "fields");
04db8c
+	fields_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "fields"),
04db8c
+		MEMBER_OFFSET("trace_event_call", "fields"));
04db8c
 
04db8c
-	class_offset = MEMBER_OFFSET("ftrace_event_call", "class");
04db8c
+	class_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "class"),
04db8c
+		MEMBER_OFFSET("trace_event_call", "class"));
04db8c
 	if (class_offset < 0)
04db8c
 		goto work;
04db8c
 
04db8c
 	inited = 2;
04db8c
-	fields_offset = MEMBER_OFFSET("ftrace_event_class", "fields");
04db8c
+	fields_offset = MAX(MEMBER_OFFSET("ftrace_event_class", "fields"),
04db8c
+		MEMBER_OFFSET("trace_event_class", "fields"));
04db8c
 	if (fields_offset < 0)
04db8c
 		return -1;
04db8c
 
04db8c
-	get_fields_offset = MEMBER_OFFSET("ftrace_event_class", "get_fields");
04db8c
+	get_fields_offset = MAX(MEMBER_OFFSET("ftrace_event_class", "get_fields"),
04db8c
+		MEMBER_OFFSET("trace_event_class", "get_fields"));
04db8c
 	if ((sp = symbol_search("syscall_get_enter_fields")) != NULL)
04db8c
 		syscall_get_enter_fields_value = sp->value;
04db8c
 	if ((sp = symbol_search("syscall_get_exit_fields")) != NULL)
04db8c
@@ -988,19 +1015,45 @@ static void ftrace_destroy_event_types(v
04db8c
 	free(ftrace_common_fields);
04db8c
 }
04db8c
 
04db8c
+#define TRACE_EVENT_FL_TRACEPOINT 0x40
04db8c
+
04db8c
 static
04db8c
 int ftrace_get_event_type_name(ulong call, char *name, int len)
04db8c
 {
04db8c
 	static int inited;
04db8c
 	static int name_offset;
04db8c
+	static int flags_offset;
04db8c
+	static int tp_name_offset;
04db8c
+	uint flags;
04db8c
 
04db8c
 	ulong name_addr;
04db8c
 
04db8c
-	if (!inited) {
04db8c
-		inited = 1;
04db8c
-		name_offset = MEMBER_OFFSET("ftrace_event_call", "name");
04db8c
-	}
04db8c
+	if (inited)
04db8c
+		goto work;
04db8c
 
04db8c
+	inited = 1;
04db8c
+	name_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "name"),
04db8c
+		MEMBER_OFFSET("trace_event_call", "name"));
04db8c
+	if (name_offset >= 0)
04db8c
+		goto work;
04db8c
+
04db8c
+	name_offset = MAX(ANON_MEMBER_OFFSET("ftrace_event_call", "name"),
04db8c
+		ANON_MEMBER_OFFSET("trace_event_call", "name"));
04db8c
+	if (name_offset < 0)
04db8c
+		return -1;
04db8c
+
04db8c
+	flags_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "flags"),
04db8c
+		MEMBER_OFFSET("trace_event_call", "flags"));
04db8c
+	if (flags_offset < 0)
04db8c
+		return -1;
04db8c
+
04db8c
+	tp_name_offset = MEMBER_OFFSET("tracepoint", "name");
04db8c
+	if (tp_name_offset < 0)
04db8c
+		return -1;
04db8c
+
04db8c
+	inited = 2;
04db8c
+
04db8c
+work:
04db8c
 	if (name_offset < 0)
04db8c
 		return -1;
04db8c
 
04db8c
@@ -1008,6 +1061,21 @@ int ftrace_get_event_type_name(ulong cal
04db8c
 			"read ftrace_event_call name_addr", RETURN_ON_ERROR))
04db8c
 		return -1;
04db8c
 
04db8c
+	if (inited == 2) {
04db8c
+		if (!readmem(call + flags_offset, KVADDR, &flags,
04db8c
+			     sizeof(flags), "read ftrace_event_call flags",
04db8c
+			     RETURN_ON_ERROR))
04db8c
+			return -1;
04db8c
+
04db8c
+		if (flags & TRACE_EVENT_FL_TRACEPOINT) {
04db8c
+			if (!readmem(name_addr + tp_name_offset, KVADDR,
04db8c
+				     &name_addr, sizeof(name_addr),
04db8c
+				     "read tracepoint name", RETURN_ON_ERROR))
04db8c
+				return -1;
04db8c
+		}
04db8c
+
04db8c
+	}
04db8c
+
04db8c
 	if (!read_string(name_addr, name, len))
04db8c
 		return -1;
04db8c
 
04db8c
@@ -1028,16 +1096,19 @@ int ftrace_get_event_type_system(ulong c
04db8c
 		goto work;
04db8c
 
04db8c
 	inited = 1;
04db8c
-	sys_offset = MEMBER_OFFSET("ftrace_event_call", "system");
04db8c
+	sys_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "system"),
04db8c
+		MEMBER_OFFSET("trace_event_call", "system"));
04db8c
 
04db8c
 	if (sys_offset >= 0)
04db8c
 		goto work;
04db8c
 
04db8c
-	class_offset = MEMBER_OFFSET("ftrace_event_call", "class");
04db8c
+	class_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "class"),
04db8c
+		MEMBER_OFFSET("trace_event_call", "class"));
04db8c
 	if (class_offset < 0)
04db8c
 		return -1;
04db8c
 
04db8c
-	sys_offset = MEMBER_OFFSET("ftrace_event_class", "system");
04db8c
+	sys_offset = MAX(MEMBER_OFFSET("ftrace_event_class", "system"),
04db8c
+		MEMBER_OFFSET("trace_event_class", "system"));
04db8c
 	inited = 2;
04db8c
 
04db8c
 work:
04db8c
@@ -1109,7 +1180,8 @@ int ftrace_get_event_type_print_fmt(ulon
04db8c
 
04db8c
 	if (!inited) {
04db8c
 		inited = 1;
04db8c
-		fmt_offset = MEMBER_OFFSET("ftrace_event_call", "print_fmt");
04db8c
+		fmt_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "print_fmt"),
04db8c
+			MEMBER_OFFSET("trace_event_call", "print_fmt"));
04db8c
 	}
04db8c
 
04db8c
 	if (fmt_offset < 0) {
04db8c
@@ -1132,11 +1204,13 @@ int ftrace_get_event_type_id(ulong call,
04db8c
 
04db8c
 	if (!inited) {
04db8c
 		inited = 1;
04db8c
-		id_offset = MEMBER_OFFSET("ftrace_event_call", "id");
04db8c
+		id_offset = MAX(MEMBER_OFFSET("ftrace_event_call", "id"),
04db8c
+			MEMBER_OFFSET("trace_event_call", "id"));
04db8c
 
04db8c
 		if (id_offset < 0) {
04db8c
 			/* id = call->event.type */
04db8c
-			int f1 = MEMBER_OFFSET("ftrace_event_call", "event");
04db8c
+			int f1 = MAX(MEMBER_OFFSET("ftrace_event_call", "event"),
04db8c
+				MEMBER_OFFSET("trace_event_call", "event"));
04db8c
 			int f2 = MEMBER_OFFSET("trace_event", "type");
04db8c
 
04db8c
 			if (f1 >= 0 && f2 >= 0)
04db8c
@@ -1495,7 +1569,6 @@ static void ftrace_show(int argc, char *
04db8c
 	FILE *file;
04db8c
 	size_t ret;
04db8c
 	size_t nitems __attribute__ ((__unused__));
04db8c
-	char *unused __attribute__ ((__unused__));
04db8c
 
04db8c
 	/* check trace-cmd */
04db8c
 	if (env_trace_cmd)
04db8c
@@ -1519,8 +1592,9 @@ static void ftrace_show(int argc, char *
04db8c
 	}
04db8c
 
04db8c
 	/* dump trace.dat to the temp file */
04db8c
-	unused = mktemp(tmp);
04db8c
-	fd = open(tmp, O_WRONLY | O_CREAT | O_TRUNC, 0644);
04db8c
+	fd = mkstemp(tmp);
04db8c
+	if (fd < 0)
04db8c
+		return;
04db8c
 	if (trace_cmd_data_output(fd) < 0)
04db8c
 		goto out;
04db8c