trace-cmd: Use splice to filter out rest of buffer

When the main thread tells the recorders that they are finished,
have the recorders still use splice till all data is read that
splice can handle (full page sizes only). Then use the read function
for the rest.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
trace-cmd: Do not use threads for extract

Currently the trace-cmd extract function uses the forked threads to
read the data from the ring buffers. As this is not a live trace and
the program does not end till all the buffers are flushed to disk,
there is no need to use the threads. Just serially read each buffer
into a file and then pull them together normally.

This also fixes a bug that was triggered in the kernel where reading
the trace_pipe_raw file after EOF will yield the last page again,
causing the trace-cmd extract to produce duplicate pages.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
trace-cmd: Do not record all events twice in extract

If -a is set with trace-cmd extract, simply ignore it,
otherwise, all events will be recorded twice. Once at this location,
and once during extracting.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
parse-events: Allow '*' and '/' operations in TP_printk

Add multiply and divide operations in the printk format.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
parse-events: Modify header to work in C++ programs

Replace keywords "private" and "bool" from parse-events.h to allow
it to be used in C++ programs.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
parse-event: Fix parsing of __print_flags() in TP_printk()

A update is made to the sched:sched_switch event that adds some
logic to the first parameter of the __print_flags() that shows the
state of tasks. This change cause trace-cmd to fail parsing the flags.

A simple fix is needed to have the parser be able to process ops
within the argument.

Reported-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
trace-cmd: Build and install doc by default

I have been informed that documentation (man pages) should be installed
by default and not just separate.

Reported-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
trace-cmd: Version 1.2

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
parse-event: Fix memset pointer size bugs

Fix memset(ptr, 0, sizeof(ptr)) to memset(ptr, 0, sizeof(*ptr));

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
parse-event: Let filtering numbers by string use function names

As a pointer can be converted into a function name, let the filters
work with the function name as well as with the pointer number.
If the comparison expects a string, then convert numbers into functions,
but only when the number is the same size as a long.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
parse-events: Add support for "%.*s" in bprintk events

The arg notation of '*' in bprintks is not handled by the parser.
Implement it so that they show up properly in the output and do not
kill the tracer from reporting events.

Reported-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
parse-events: Add support to show migrate disable counter

The RT kernel added a migrate disable counter in all events. Add support
to show this in the latency format.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
trace-cmd: Cross-compile fixes for LDFLAGS and include path

Add ability for the Makefile to respect LDFLAGS.
Also remove hardcoded /usr/local/include include path.

Link: http://lkml.kernel.org/r/4ED6C808.9030003@linux.intel.com

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
parse-events: Fix %pM print format arg handling

When %pM is used, the arg value must be a 6 byte character that
will be printed as a 6 byte MAC address. But the code does a break
over the main code which updates the current processing arg to point
to the next arg. If there are other print arguments after a %pM,
they will be off by one. The next arg will still be processing the
%pM arg.

Reported-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
blk plugin: replace BLK_TC_BARRIER with BLK_TC_FLUSH/BLK_TC_FUA

The BLK_TC_BARRIER flag was dropped in Linux commit c09c47caedc in
August 2011.  The blk plugin fails to build against recent kernel
headers.  Since no flag bits were left, the new BLK_TC_FLUSH flag reused
the BLK_TC_BARRIER bit.  The new BLK_TC_FUA flag was also added.

This patch updates fill_rwbs() to reflect the new
BLK_TC_FLUSH/BLK_TC_FUA flags.  This allows plugin_blk.c to build
successfully on recent kernels.  Most of the patch deals with detecting
old vs new kernel headers so we can build successfully on both.

(Namhyung Kim recommended using the makefile check used by perf and
 other tools)

Link: http://lkml.kernel.org/r/1326108639-13904-1-git-send-email-stefanha@linux.vnet.ibm.com

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
trace-cmd: fix length calculation for padding events

Padding events store size in bytes, not words. Usually this ends up pushing
the parser off the current page, but occasionally not, and when not,
it ends up desynchronizing the parser from the event stream. This would
manifest as a lot of "ug!" messages from trace-cmd, and kernelshark
crashing before displaying the UI.

Link: http://lkml.kernel.org/r/1327633215-4013-1-git-send-email-dhsharp@google.com

Signed-off-by: David Sharp <dhsharp@google.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
parse-events: Allow expressions in __print_symbolic() fields

The __print_symbolic() function takes a sequence of key-value pairs for
pretty-printing a constant.  The new kvm:kvm_exit print fmt uses the
expression:

  __print_symbolic(..., { 0x040 + 1, "DB excp" }, ...)

Currently only atoms are supported and this print fmt fails to parse.
This patch adds support for expressions instead of just atoms so that
0x040 + 1 is parsed successfully.

Link: http://lkml.kernel.org/r/1315131959-7452-1-git-send-email-stefanha@linux.vnet.ibm.com

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Cc: Avi Kivity <avi@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
parse-events: Fix trace_printk for long integers

On 32 bit systems, a conversion of the trace_printk format string
"%lu" -> "%llu" is intended (similar for %lx etc.) when a
trace was taken on a machine with 64 bit long integers. However,
the current code computes the bogus transformation "%lu" -> "%u".
Fix this.

Besides that, the transformation is only required on systems
that don't use 64 bits for long integers natively.

Link: http://lkml.kernel.org/r/1332411501-8059-3-git-send-email-wolfgang.mauerer@siemens.com

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
trace-cmd: Add NO_PYTHON option for Makefile

If someone do not want to build python plugins, [s]he can
define the option to disable python support:

  $ make NO_PYTHON=1

Link: http://lkml.kernel.org/r/1333940074-19052-2-git-send-email-namhyung.kim@lge.com

Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: David Ahern <dsahern@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
parse-events: Fix printk_cmp()

The printk_cmp function should use printk_map instead of func_map.
Also rename the variables for consistency.

Link: http://lkml.kernel.org/r/1333940074-19052-3-git-send-email-namhyung.kim@lge.com

Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: David Ahern <dsahern@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>