trace-cmd: Add --boundary to trace-cmd report
Add the option "--boundary" to trace-cmd report that shows the
sub buffer bondaries of the file. This is more for debugging
purposes.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
diff --git a/kbuffer-parse.c b/kbuffer-parse.c
index 40d00c0..a949a83 100644
--- a/kbuffer-parse.c
+++ b/kbuffer-parse.c
@@ -730,3 +730,14 @@
kbuf->next_event = __old_next_event;
}
+
+/**
+ * kbuffer_start_of_data - return offset of where data starts on subbuffer
+ * @kbuf: The kbuffer
+ *
+ * Returns the location on the subbuffer where the data starts.
+ */
+int kbuffer_start_of_data(struct kbuffer *kbuf)
+{
+ return kbuf->start;
+}
diff --git a/kbuffer.h b/kbuffer.h
index c831f64..03dce75 100644
--- a/kbuffer.h
+++ b/kbuffer.h
@@ -63,5 +63,6 @@
int kbuffer_subbuffer_size(struct kbuffer *kbuf);
void kbuffer_set_old_format(struct kbuffer *kbuf);
+int kbuffer_start_of_data(struct kbuffer *kbuf);
#endif /* _K_BUFFER_H */
diff --git a/trace-cmd.h b/trace-cmd.h
index 37c037e..75e0863 100644
--- a/trace-cmd.h
+++ b/trace-cmd.h
@@ -167,6 +167,8 @@
char *tracecmd_get_tracing_file(const char *name);
void tracecmd_put_tracing_file(char *name);
+int tracecmd_record_at_buffer_start(struct tracecmd_input *handle, struct pevent_record *record);
+
#ifndef SWIG
/* hack for function graph work around */
extern __thread struct tracecmd_input *tracecmd_curr_thread_handle;
diff --git a/trace-input.c b/trace-input.c
index 6f60409..0bd3599 100644
--- a/trace-input.c
+++ b/trace-input.c
@@ -2370,6 +2370,27 @@
}
/**
+ * tracecmd_record_at_buffer_start - return true if record is first on subbuffer
+ * @handle: input handle for the trace.dat file
+ * @record: The record to test if it is the first record on page
+ *
+ * Returns true if the record is the first record on the page.
+ */
+int tracecmd_record_at_buffer_start(struct tracecmd_input *handle,
+ struct pevent_record *record)
+{
+ struct page *page = record->priv;
+ struct kbuffer *kbuf = handle->cpu_data[0].kbuf;
+ int offset;
+
+ if (!page || !kbuf)
+ return 0;
+
+ offset = record->offset - page->offset;
+ return offset == kbuffer_start_of_data(kbuf);
+}
+
+/**
* tracecmd_long_size - return the size of "long" for the arch
* @handle: input handle for the trace.dat file
*/
diff --git a/trace-read.c b/trace-read.c
index 14f3d58..6555a69 100644
--- a/trace-read.c
+++ b/trace-read.c
@@ -95,6 +95,8 @@
static int wakeup_new_id;
static int sched_id;
+static int buffer_breaks = 0;
+
static struct format_field *wakeup_task;
static struct format_field *wakeup_success;
static struct format_field *wakeup_new_task;
@@ -665,6 +667,10 @@
else if (record->missed_events < 0)
trace_seq_printf(&s, "CPU:%d [EVENTS DROPPED]\n",
record->cpu);
+ if (buffer_breaks && tracecmd_record_at_buffer_start(handle, record))
+ trace_seq_printf(&s, "CPU:%d [SUBBUFFER START]\n",
+ record->cpu);
+
pevent_print_event(pevent, &s, record);
if (s.len && *(s.buffer + s.len - 1) == '\n')
s.len--;
@@ -1019,6 +1025,7 @@
}
enum {
+ OPT_boundary = 248,
OPT_stat = 249,
OPT_pid = 250,
OPT_nodate = 251,
@@ -1079,6 +1086,7 @@
OPT_check_event_parsing},
{"nodate", no_argument, NULL, OPT_nodate},
{"stat", no_argument, NULL, OPT_stat},
+ {"boundary", no_argument, NULL, OPT_boundary},
{"help", no_argument, NULL, '?'},
{NULL, 0, NULL, 0}
};
@@ -1186,6 +1194,10 @@
case OPT_stat:
show_stat = 1;
break;
+ case OPT_boundary:
+ /* Debug to look at buffer breaks */
+ buffer_breaks = 1;
+ break;
default:
usage(argv);
}