|
|
63cddd |
--- crash-trace-command-2.0/trace.c.orig
|
|
|
63cddd |
+++ crash-trace-command-2.0/trace.c
|
|
|
63cddd |
@@ -26,9 +26,21 @@ static int nr_cpu_ids;
|
|
|
63cddd |
*/
|
|
|
63cddd |
static int lockless_ring_buffer;
|
|
|
63cddd |
static int per_cpu_buffer_sizes;
|
|
|
63cddd |
+/*
|
|
|
63cddd |
+ * global and encapsulated current_trace are both supported
|
|
|
63cddd |
+ */
|
|
|
63cddd |
+static int encapsulated_current_trace;
|
|
|
63cddd |
+/*
|
|
|
63cddd |
+ * trace_buffer is supported
|
|
|
63cddd |
+ */
|
|
|
63cddd |
+static int trace_buffer_available;
|
|
|
63cddd |
|
|
|
63cddd |
#define koffset(struct, member) struct##_##member##_offset
|
|
|
63cddd |
|
|
|
63cddd |
+static int koffset(trace_array, current_trace);
|
|
|
63cddd |
+static int koffset(trace_array, trace_buffer);
|
|
|
63cddd |
+static int koffset(trace_array, max_buffer);
|
|
|
63cddd |
+static int koffset(trace_buffer, buffer);
|
|
|
63cddd |
static int koffset(trace_array, buffer);
|
|
|
63cddd |
static int koffset(tracer, name);
|
|
|
63cddd |
|
|
|
63cddd |
@@ -85,6 +97,8 @@ struct ring_buffer_per_cpu {
|
|
|
63cddd |
};
|
|
|
63cddd |
|
|
|
63cddd |
static ulong global_trace;
|
|
|
63cddd |
+static ulong global_trace_buffer;
|
|
|
63cddd |
+static ulong global_max_buffer;
|
|
|
63cddd |
static ulong global_ring_buffer;
|
|
|
63cddd |
static unsigned global_pages;
|
|
|
63cddd |
static struct ring_buffer_per_cpu *global_buffers;
|
|
|
63cddd |
@@ -144,8 +158,16 @@ static int init_offsets(void)
|
|
|
63cddd |
} \
|
|
|
63cddd |
} while (0)
|
|
|
63cddd |
|
|
|
63cddd |
+ if (encapsulated_current_trace)
|
|
|
63cddd |
+ init_offset(trace_array, current_trace);
|
|
|
63cddd |
|
|
|
63cddd |
- init_offset(trace_array, buffer);
|
|
|
63cddd |
+ if (trace_buffer_available) {
|
|
|
63cddd |
+ init_offset(trace_array, trace_buffer);
|
|
|
63cddd |
+ init_offset(trace_array, max_buffer);
|
|
|
63cddd |
+ init_offset(trace_buffer, buffer);
|
|
|
63cddd |
+ } else {
|
|
|
63cddd |
+ init_offset(trace_array, buffer);
|
|
|
63cddd |
+ }
|
|
|
63cddd |
init_offset(tracer, name);
|
|
|
63cddd |
|
|
|
63cddd |
if (MEMBER_EXISTS("ring_buffer_per_cpu", "nr_pages")) {
|
|
|
63cddd |
@@ -400,8 +422,13 @@ out_fail:
|
|
|
63cddd |
|
|
|
63cddd |
static int ftrace_int_global_trace(void)
|
|
|
63cddd |
{
|
|
|
63cddd |
- read_value(global_ring_buffer, global_trace, trace_array, buffer);
|
|
|
63cddd |
- read_value(global_pages, global_ring_buffer, ring_buffer, pages);
|
|
|
63cddd |
+ if (trace_buffer_available) {
|
|
|
63cddd |
+ global_trace_buffer = global_trace + koffset(trace_array, trace_buffer);
|
|
|
63cddd |
+ read_value(global_ring_buffer, global_trace_buffer, trace_buffer, buffer);
|
|
|
63cddd |
+ } else {
|
|
|
63cddd |
+ read_value(global_ring_buffer, global_trace, trace_array, buffer);
|
|
|
63cddd |
+ read_value(global_pages, global_ring_buffer, ring_buffer, pages);
|
|
|
63cddd |
+ }
|
|
|
63cddd |
|
|
|
63cddd |
global_buffers = calloc(sizeof(*global_buffers), nr_cpu_ids);
|
|
|
63cddd |
if (global_buffers == NULL)
|
|
|
63cddd |
@@ -420,12 +447,17 @@ out_fail:
|
|
|
63cddd |
|
|
|
63cddd |
static int ftrace_int_max_tr_trace(void)
|
|
|
63cddd |
{
|
|
|
63cddd |
- read_value(max_tr_ring_buffer, max_tr_trace, trace_array, buffer);
|
|
|
63cddd |
+ if (trace_buffer_available) {
|
|
|
63cddd |
+ global_max_buffer = global_trace + koffset(trace_array, max_buffer);
|
|
|
63cddd |
+ read_value(max_tr_ring_buffer, global_max_buffer, trace_buffer, buffer);
|
|
|
63cddd |
+ } else {
|
|
|
63cddd |
+ read_value(max_tr_ring_buffer, max_tr_trace, trace_array, buffer);
|
|
|
63cddd |
|
|
|
63cddd |
- if (!max_tr_ring_buffer)
|
|
|
63cddd |
- return 0;
|
|
|
63cddd |
+ if (!max_tr_ring_buffer)
|
|
|
63cddd |
+ return 0;
|
|
|
63cddd |
|
|
|
63cddd |
- read_value(max_tr_pages, max_tr_ring_buffer, ring_buffer, pages);
|
|
|
63cddd |
+ read_value(max_tr_pages, max_tr_ring_buffer, ring_buffer, pages);
|
|
|
63cddd |
+ }
|
|
|
63cddd |
|
|
|
63cddd |
max_tr_buffers = calloc(sizeof(*max_tr_buffers), nr_cpu_ids);
|
|
|
63cddd |
if (max_tr_buffers == NULL)
|
|
|
63cddd |
@@ -449,7 +481,12 @@ static int ftrace_init_current_tracer(vo
|
|
|
63cddd |
char tmp[128];
|
|
|
63cddd |
|
|
|
63cddd |
/* Get current tracer name */
|
|
|
63cddd |
- read_value(addr, current_trace, POINTER_SYM, POINTER);
|
|
|
63cddd |
+ if (encapsulated_current_trace) {
|
|
|
63cddd |
+ read_value(addr, global_trace, trace_array, current_trace);
|
|
|
63cddd |
+ } else {
|
|
|
63cddd |
+ read_value(addr, current_trace, POINTER_SYM, POINTER);
|
|
|
63cddd |
+ }
|
|
|
63cddd |
+
|
|
|
63cddd |
read_value(addr, addr, tracer, name);
|
|
|
63cddd |
read_string(addr, tmp, 128);
|
|
|
63cddd |
|
|
|
63cddd |
@@ -471,19 +508,33 @@ static int ftrace_init(void)
|
|
|
63cddd |
struct syment *sym_current_trace;
|
|
|
63cddd |
|
|
|
63cddd |
sym_global_trace = symbol_search("global_trace");
|
|
|
63cddd |
- sym_max_tr_trace = symbol_search("max_tr");
|
|
|
63cddd |
sym_ftrace_events = symbol_search("ftrace_events");
|
|
|
63cddd |
- sym_current_trace = symbol_search("current_trace");
|
|
|
63cddd |
|
|
|
63cddd |
- if (sym_global_trace == NULL || sym_max_tr_trace == NULL
|
|
|
63cddd |
- || sym_ftrace_events == NULL
|
|
|
63cddd |
- || sym_current_trace == NULL)
|
|
|
63cddd |
+ if (sym_global_trace == NULL || sym_ftrace_events == NULL)
|
|
|
63cddd |
return -1;
|
|
|
63cddd |
|
|
|
63cddd |
global_trace = sym_global_trace->value;
|
|
|
63cddd |
- max_tr_trace = sym_max_tr_trace->value;
|
|
|
63cddd |
ftrace_events = sym_ftrace_events->value;
|
|
|
63cddd |
- current_trace = sym_current_trace->value;
|
|
|
63cddd |
+
|
|
|
63cddd |
+ if (MEMBER_EXISTS("trace_array", "current_trace")) {
|
|
|
63cddd |
+ encapsulated_current_trace = 1;
|
|
|
63cddd |
+ } else {
|
|
|
63cddd |
+ sym_current_trace = symbol_search("current_trace");
|
|
|
63cddd |
+ if (sym_current_trace == NULL)
|
|
|
63cddd |
+ return -1;
|
|
|
63cddd |
+
|
|
|
63cddd |
+ current_trace = sym_current_trace->value;
|
|
|
63cddd |
+ }
|
|
|
63cddd |
+
|
|
|
63cddd |
+ if (MEMBER_EXISTS("trace_array", "trace_buffer")) {
|
|
|
63cddd |
+ trace_buffer_available = 1;
|
|
|
63cddd |
+ } else {
|
|
|
63cddd |
+ sym_max_tr_trace = symbol_search("max_tr");
|
|
|
63cddd |
+ if (sym_max_tr_trace == NULL)
|
|
|
63cddd |
+ return -1;
|
|
|
63cddd |
+
|
|
|
63cddd |
+ max_tr_trace = sym_max_tr_trace->value;
|
|
|
63cddd |
+ }
|
|
|
63cddd |
|
|
|
63cddd |
if (!try_get_symbol_data("nr_cpu_ids", sizeof(int), &nr_cpu_ids))
|
|
|
63cddd |
nr_cpu_ids = 1;
|
|
|
63cddd |
@@ -1453,6 +1504,7 @@ static void ftrace_show(int argc, char *
|
|
|
63cddd |
if ((file = popen(trace_cmd, "r"))) {
|
|
|
63cddd |
ret = fread(buf, 1, sizeof(buf), file);
|
|
|
63cddd |
buf[ret] = 0;
|
|
|
63cddd |
+ pclose(file);
|
|
|
63cddd |
}
|
|
|
63cddd |
if (!strstr(buf, "trace-cmd version")) {
|
|
|
63cddd |
if (env_trace_cmd)
|