Hello Steven, On 1/25/24 18:10, Steven Rostedt wrote:
On Thu, 25 Jan 2024 11:51:47 -0500 Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:Now if I had had: trace-cmd split -i /work/traces/trace-tast.dat --top -B tast -o /tmp/trace-tast2.dat Then because there was a command "--top" before the -B but it had no -o assigned for it, then the input_file would be considered the output file and that should act like you described.Of course then things get confusing if we were to have: trace-cmd split -i /work/traces/trace-tast.dat -B foo -o /tmp/trace-foo.dat -B bar We could specify that each -B will just use the top level by default. So the above would create: /tmp/trace-foo.dat With the instance "foo" But the "bar" would be in: /work/traces/trace-tast.dat.bar because the top level didn't specify a -o. So to make it more specific. Each -B will default to the toplevel output with ".<instance>" appended to it. That is: split <top-level-commands> -B instance1 <instance1-commands> -B <instance2-commands> If a -o is specified in the <top-level-commands> it becomes the default top level output file. If a -o is not specified in any of the <instance*-commands> then, it will default to the top level output file with ".<instance-name>" attached to it unless it has its own -o specified.
I also wanted to handle the case where multiple instances could be placed in an output file. Meaning that with the patches: - -B/--top options are parsed to select the instances to keep, - a -o option ends the parsing of instances and place them in the given output file. If no -o option is parsed, then the default output file or the input file is used as a base name for the last generated output file (i.e. trace.dat.1 if no input file is specified) --- For example, with a trace recorded with: $ trace-cmd record -e sched_wakeup -B switch_instance -e sched_switch -B timer_instance -e timer Creating a test.dat file containing the top instance and the switch_instance: $ trace-cmd split --top -B switch_instance -o test.dat Creating a test.dat file containing the switch_instance as the top instance, and the initial top instance as an instance named 'old_top': $ trace-cmd split -B switch_instance --top=old_top -o test.dat Splitting all instances in different .dat files: $ trace-cmd split --top -o top.dat -B switch_instance -o switch.dat -B timer_instance -o timer.dat And by default, if no -B/--top is specified for an output file, keep all the instances (but of course all the other options provided to the split command are applied, i.e. start/end timings): Keep all the instances and place them in test.dat: $ trace-cmd split -o test.dat Keep all the instances and place them in the default file trace.dat.1: $ trace-cmd split --- Maybe the list of generated files should be printed to avoid what happened to you, i.e. generating files that were not expected. I think that having a default name with a suffix being the top instance is a good idea, but I don't think it would be possible to parse the command line to have 2 instances in one file in such case.
For multi-file splits, it will append ".0001", ".0002", etc to that file.
Regards, Pierre