Add -B option to trace-cmd extract so that it can extract listed
instances. As with start, stop, and reset, the top level instance is not
included when any -B are given. However, -t makes it also include the
top instance. As with other commands, if neither option is given, only
operate on the top instance.

Signed-off-by: Howard Cochran <hcoch...@kernelspring.com>
---
 trace-record.c | 20 +++++++++++++-------
 trace-usage.c  |  6 ++++--
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/trace-record.c b/trace-record.c
index 6e0ab3b..8340416 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -523,17 +523,20 @@ static int create_recorder(struct buffer_instance 
*instance, int cpu,
 
 static void flush_threads(void)
 {
+       struct buffer_instance *instance;
        long ret;
        int i;
 
        if (!cpu_count)
                return;
 
-       for (i = 0; i < cpu_count; i++) {
-               /* Extract doesn't support sub buffers yet */
-               ret = create_recorder(&top_instance, i, TRACE_TYPE_EXTRACT, 
NULL);
-               if (ret < 0)
-                       die("error reading ring buffer");
+       for_all_instances(instance) {
+               for (i = 0; i < cpu_count; i++) {
+                       /* Extract doesn't support sub buffers yet */
+                       ret = create_recorder(instance, i, TRACE_TYPE_EXTRACT, 
NULL);
+                       if (ret < 0)
+                               die("error reading ring buffer");
+               }
        }
 }
 
@@ -3873,7 +3876,7 @@ void trace_record (int argc, char **argv)
                };
 
                if (extract)
-                       opts = "+haf:Fp:co:O:sr:g:l:n:P:N:tb:ksiT";
+                       opts = "+haf:Fp:co:O:sr:g:l:n:P:N:tb:B:ksiT";
                else
                        opts = 
"+hae:f:Fp:cC:dDGo:O:s:r:vg:l:n:P:N:tb:R:B:ksSiTm:M:H:";
                c = getopt_long (argc-1, argv+1, opts, long_options, 
&option_index);
@@ -4061,7 +4064,10 @@ void trace_record (int argc, char **argv)
                        instance->cpumask = optarg;
                        break;
                case 't':
-                       use_tcp = 1;
+                       if (extract)
+                               topt = 1; /* Extract top instance also */
+                       else
+                               use_tcp = 1;
                        break;
                case 'b':
                        instance->buffer_size = atoi(optarg);
diff --git a/trace-usage.c b/trace-usage.c
index 520b14b..a708a85 100644
--- a/trace-usage.c
+++ b/trace-usage.c
@@ -62,9 +62,11 @@ static struct usage_help usage_help[] = {
        {
                "extract",
                "extract a trace from the kernel",
-               " %s extract [-p plugin][-O option][-o file][-s]\n"
-               "          Uses same options as record, but only reads an 
existing trace.\n"
+               " %s extract [-p plugin][-O option][-o file][-B buf][-s][-t]\n"
+               "          Uses similar options as record, but only reads an 
existing trace.\n"
                "          -s : extract the snapshot instead of the main 
buffer\n"
+               "          -B : extract a given buffer (more than one may be 
specified)\n"
+               "          -t : include the top level buffer (useful with -B)\n"
        },
        {
                "stop",
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to