Skip to contentSkip to conversation

Add new trace-cmd sub-command "dump"

PATCH New Tzvetomir Stoyanov (VMware) 1 participant 4 messages Jan 9, 2020 Documentation

lore
Share & tools
lore
#0 lore raw

cover Add new trace-cmd sub-command "dump"

The new trace-cmd sub-command "dump" prints all meta data information, stored in a trace file. It also can be used to check if a file is a valid trace file, created by trace-cmd.

Tzvetomir Stoyanov (VMware) (3):
trace-cmd: Implement new sub-command "dump"
trace-cmd: Man page of "trace-cmd dump" sub-command
trace-cmd: bash completion of "trace-cmd dump" sub-command

 Documentation/trace-cmd-dump.1.txt | 132 +++++++
 tracecmd/Makefile                  |   1 +
 tracecmd/include/trace-local.h     |   2 +
 tracecmd/trace-cmd.bash            |  21 +
 tracecmd/trace-cmd.c               |   2 +
 tracecmd/trace-dump.c              | 615 +++++++++++++++++++++++++++++
 tracecmd/trace-usage.c             |  20 +
 7 files changed, 793 insertions(+)
 create mode 100644 Documentation/trace-cmd-dump.1.txt
 create mode 100644 tracecmd/trace-dump.c
Signature · 1 line
2.24.1
#1 lore raw

PATCH 1/3 trace-cmd: Implement new sub-command "dump"

The new trace-cmd sub-command "dump" prints all meta data information, stored in a trace file. It also can be used to check if a file is a valid trace file, created by trace-cmd.

---
 tracecmd/Makefile              |   1 +
 tracecmd/include/trace-local.h |   2 +
 tracecmd/trace-cmd.c           |   2 +
 tracecmd/trace-dump.c          | 615 +++++++++++++++++++++++++++++++++
 tracecmd/trace-usage.c         |  20 ++
 5 files changed, 640 insertions(+)
 create mode 100644 tracecmd/trace-dump.c
tracecmd/Makefile +1 -0
index 29a623b..bacbd0d 100644
@@ -30,6 +30,7 @@ TRACE_CMD_OBJS += trace-check-events.o
 TRACE_CMD_OBJS += trace-show.o
 TRACE_CMD_OBJS += trace-list.o
 TRACE_CMD_OBJS += trace-usage.o
+TRACE_CMD_OBJS += trace-dump.o
 
 ifeq ($(VSOCK_DEFINED), 1)
 TRACE_CMD_OBJS += trace-agent.o
tracecmd/include/trace-local.h +2 -0
index fedc0b7..0658115 100644
@@ -96,6 +96,8 @@ void trace_list(int argc, char **argv);
 
 void trace_usage(int argc, char **argv);
 
+void trace_dump(int argc, char **argv);
+
 int trace_record_agent(struct tracecmd_msg_handle *msg_handle,
 		       int cpus, int *fds,
 		       int argc, char **argv, bool use_fifos);
tracecmd/trace-cmd.c +2 -0
index 9cbfce0..4e670f1 100644
@@ -101,7 +101,9 @@ struct command commands[] = {
 	{"options", trace_option},
 	{"show", trace_show},
 	{"list", trace_list},
+	{"list", trace_list},
 	{"help", trace_usage},
+	{"dump", trace_dump},
 	{"-h", trace_usage},
 };
 
tracecmd/trace-dump.c new file +615 -0

615 lines not on this page · raw message

tracecmd/trace-usage.c +20 -0
index 05ec021..502a410 100644
@@ -310,6 +310,26 @@ static struct usage_help usage_help[] = {
 		" %s check-events [-N]\n"
 		"          -N do not load any plugins\n"
 	},
+	{
+		"dump",
+		"read out the meta data from a trace file",
+		" %s dump [options]\n"
+		"          -i input file, default is trace.dat\n"
+		"          -v validate a trace file\n"
+		"          --all print all meta data from a trace file\n"
+		"          --summary print a meta data summary\n"
+		"          --head-page print header page information\n"
+		"          --head-event print header event information\n"
+		"          --ftrace-events print ftrace events format\n"
+		"          --systems print recorded event systems\n"
+		"          --events print format of recorded events\n"
+		"          --kallsyms print information of the mapping of function addresses to the function names\n"
+		"          --printk print trace_printk() format strings\n"
+		"          --cmd-lines print information mapping a PID to a process name\n"
+		"          --options print options\n"
+		"          --flyrecord information of offset and count of recorded events per CPU\n"
+		"          -h, --help show usage information\n"
+	},
 	{
 		NULL, NULL, NULL
 	}
Signature · 1 line
2.24.1
#2 lore raw

PATCH 2/3 trace-cmd: Man page of "trace-cmd dump" sub-command

In reply to Tzvetomir Stoyanov (VMware)

The man page describes all options and use cases of "trace-cmd dump" sub-command

---
 Documentation/trace-cmd-dump.1.txt | 132 +++++++++++++++++++++++++++++
 1 file changed, 132 insertions(+)
 create mode 100644 Documentation/trace-cmd-dump.1.txt
Documentation/trace-cmd-dump.1.txt new file +132 -0
new file mode 100644
index 0000000..9c36779
@@ -0,0 +1,132 @@
+TRACE-CMD-DUMP(1)
+===================
+
+NAME
+----
+trace-cmd-dump - show a meta data from a trace file, created by trace-cmd record
+
+SYNOPSIS
+--------
+*trace-cmd dump* ['OPTIONS'] ['input-file']
+
+DESCRIPTION
+-----------
+The trace-cmd(1) dump command will display the meta data from a trace file
+created by trace-cmd record.
+
+OPTIONS
+-------
+*-i* 'input-file'::
+    By default, trace-cmd dump will read the file 'trace.dat'. But the *-i*
+    option open up the given 'input-file' instead. Note, the input file may
+    also be specified as the last item on the command line.
+*-v*, *--validate*::
+    Check if the input file is a valid trace file, created by trace-cmd.
+*--summary*::
+    Print a meta data summary - initial format and a short description of each
+    file section. This is the default action, if no arguments are specified.
+*--head-page*::
+    Print the header page information, stored in the file.
+*--head-event*::
+    Print the event header information, stored in the file.
+*--ftrace-events*::
+    Print formats of ftrace specific events.
+*--systems*::
+    Print information of event systems, stored in the file - name and number of
+    events for each system.
+*--events*::
+    Print formats of all events, stored in the file.
+*--kallsyms*::
+    Print information of the mapping of function addresses to the function names.
+*--printk*::
+    Print trace_printk() format strings, stored in the file.
+*--cmd-lines*::
+    Print mapping a PID to a process name.
+*--options*::
+    Print all options, stored in the file.
+*--flyrecord*::
+    Print the offset and the size of tracing data per each CPU.
+*--all*::
+    Print all meta data from the file.
+*--help*::
+    Print usage information.
+
+EXAMPLES
+--------
+
+# trace-cmd dump --summary -i trace.dat
+
+ Tracing meta data in file trace.dat:
+	[Initial format]
+		6	[Version]
+		0	[Little endian]
+		8	[Bytes in a long]
+		4096	[Page size, bytes]
+	[Header info, 205 bytes]
+	[Header event, 205 bytes]
+	[Ftrace format, 15 events]
+	[Events format, 2 systems]
+	[Kallsyms, 7144493 bytes]
+	[Trace printk, 2131 bytes]
+	[Saved command lines, 117 bytes]
+	8 [CPUs with tracing data]
+	[12 options]
+	[Flyrecord tracing data]
+------------------------------------------
+
+# trace-cmd dump --flyrecord -i trace.dat
+	[Flyrecord tracing data]
+		 7176192 0	[offset, size of cpu 0]
+		 7176192 0	[offset, size of cpu 1]
+		 7176192 0	[offset, size of cpu 2]
+		 7176192 4096	[offset, size of cpu 3]
+		 7180288 4096	[offset, size of cpu 4]
+		 7184384 0	[offset, size of cpu 5]
+		 7184384 0	[offset, size of cpu 6]
+		 7184384 0	[offset, size of cpu 7]
+------------------------------------------
+
+# trace-cmd dump --summary --systems -i trace.dat
+
+ Tracing meta data in file trace.dat:
+	[Initial format]
+		6	[Version]
+		0	[Little endian]
+		8	[Bytes in a long]
+		4096	[Page size, bytes]
+	[Header info, 205 bytes]
+	[Header event, 205 bytes]
+	[Ftrace format, 15 events]
+	[Events format, 3 systems]
+		sched 23 [system, events]
+		irq 5 [system, events]
+		kvm 70 [system, events]
+	[Kallsyms, 7144493 bytes]
+	[Trace printk, 2131 bytes]
+	[Saved command lines, 157 bytes]
+	8 [CPUs with tracing data]
+	[11 options]
+	[Flyrecord tracing data]
+------------------------------------------
+
+# trace-cmd dump --summary --systems -i trace.dat
+File trace.dat is a valid trace-cmd file
+------------------------------------------
+SEE ALSO
+--------
+trace-cmd(1), trace-cmd.dat(1)
+
+AUTHOR
+------
+*Steven Rostedt* <[email protected]>, author of *trace-cmd*.
+*Tzvetomir Stoyanov* <[email protected]>, author of this man page.
+
+RESOURCES
+---------
+git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
+
+COPYING
+-------
+Copyright \(C) 2010 Red Hat, Inc. Free use of this software is granted under
+the terms of the GNU Public License (GPL).
+
Signature · 1 line
2.24.1
#3 lore raw

PATCH 3/3 trace-cmd: bash completion of "trace-cmd dump" sub-command

In reply to Tzvetomir Stoyanov (VMware)

Update trace-cmd bash completion logic to support "trace-cmd dump" sub-command

---
 tracecmd/trace-cmd.bash | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
tracecmd/trace-cmd.bash +21 -0
index bdc1410..85f6743 100644
@@ -183,6 +183,23 @@ __trace_cmd_report_complete()
     esac
 }
 
+__trace_cmd_dump_complete()
+{
+    local prev=$1
+    local cur=$2
+    shift 2
+    local words=("$@")
+
+    case "$prev" in
+	-i)
+	    __show_files
+	    ;;
+	*)
+	    cmd_options dump "$cur"
+	    ;;
+    esac
+}
+
 __show_command_options()
 {
     local command="$1"
@@ -246,6 +263,10 @@ _trace_cmd_complete()
 	    __trace_cmd_report_complete "${prev}" "${cur}" ${words[@]}
 	    return 0
 	    ;;
+	dump)
+	    __trace_cmd_dump_complete "${prev}" "${cur}" ${words[@]}
+	    return 0
+	    ;;
         *)
 	    __show_command_options "$w" "${cur}"
             ;;
Signature · 1 line
2.24.1