Skip to content

Commit fd788c4

Browse files
makelinuxlenticularis39
authored andcommitted
tools/rtla: Consolidate -D/--debug option parsing
Each rtla tool duplicates parsing of -D/--debug. Migrate the option parsing from individual tools to the common_parse_options(). Signed-off-by: Costa Shulyupin <costa.shul@redhat.com> Link: https://lore.kernel.org/r/20251209100047.2692515-4-costa.shul@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
1 parent edb23c8 commit fd788c4

5 files changed

Lines changed: 9 additions & 21 deletions

File tree

tools/tracing/rtla/src/common.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
5959
static struct option long_options[] = {
6060
{"cpus", required_argument, 0, 'c'},
6161
{"cgroup", optional_argument, 0, 'C'},
62+
{"debug", no_argument, 0, 'D'},
6263
{0, 0, 0, 0}
6364
};
6465

6566
opterr = 0;
66-
c = getopt_long(argc, argv, "c:C::", long_options, NULL);
67+
c = getopt_long(argc, argv, "c:C::D", long_options, NULL);
6768
opterr = 1;
6869

6970
switch (c) {
@@ -76,6 +77,9 @@ int common_parse_options(int argc, char **argv, struct common_params *common)
7677
common->cgroup = 1;
7778
common->cgroup_name = parse_optional_arg(argc, argv);
7879
break;
80+
case 'D':
81+
config_debug = 1;
82+
break;
7983
default:
8084
optind = saved_state;
8185
return 0;

tools/tracing/rtla/src/osnoise_hist.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ static struct common_params
485485
{"auto", required_argument, 0, 'a'},
486486
{"bucket-size", required_argument, 0, 'b'},
487487
{"entries", required_argument, 0, 'E'},
488-
{"debug", no_argument, 0, 'D'},
489488
{"duration", required_argument, 0, 'd'},
490489
{"house-keeping", required_argument, 0, 'H'},
491490
{"help", no_argument, 0, 'h'},
@@ -513,7 +512,7 @@ static struct common_params
513512
if (common_parse_options(argc, argv, &params->common))
514513
continue;
515514

516-
c = getopt_long(argc, argv, "a:b:d:e:E:DhH:p:P:r:s:S:t::T:01234:5:6:7:",
515+
c = getopt_long(argc, argv, "a:b:d:e:E:hH:p:P:r:s:S:t::T:01234:5:6:7:",
517516
long_options, NULL);
518517

519518
/* detect the end of the options. */
@@ -539,9 +538,6 @@ static struct common_params
539538
params->common.hist.bucket_size >= 1000000)
540539
fatal("Bucket size needs to be > 0 and <= 1000000");
541540
break;
542-
case 'D':
543-
config_debug = 1;
544-
break;
545541
case 'd':
546542
params->common.duration = parse_seconds_duration(optarg);
547543
if (!params->common.duration)

tools/tracing/rtla/src/osnoise_top.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
339339
while (1) {
340340
static struct option long_options[] = {
341341
{"auto", required_argument, 0, 'a'},
342-
{"debug", no_argument, 0, 'D'},
343342
{"duration", required_argument, 0, 'd'},
344343
{"event", required_argument, 0, 'e'},
345344
{"house-keeping", required_argument, 0, 'H'},
@@ -364,7 +363,7 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
364363
if (common_parse_options(argc, argv, &params->common))
365364
continue;
366365

367-
c = getopt_long(argc, argv, "a:d:De:hH:p:P:qr:s:S:t::T:0:1:2:3:",
366+
c = getopt_long(argc, argv, "a:d:e:hH:p:P:qr:s:S:t::T:0:1:2:3:",
368367
long_options, NULL);
369368

370369
/* Detect the end of the options. */
@@ -383,9 +382,6 @@ struct common_params *osnoise_top_parse_args(int argc, char **argv)
383382
if (!trace_output)
384383
trace_output = "osnoise_trace.txt";
385384

386-
break;
387-
case 'D':
388-
config_debug = 1;
389385
break;
390386
case 'd':
391387
params->common.duration = parse_seconds_duration(optarg);

tools/tracing/rtla/src/timerlat_hist.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,6 @@ static struct common_params
792792
static struct option long_options[] = {
793793
{"auto", required_argument, 0, 'a'},
794794
{"bucket-size", required_argument, 0, 'b'},
795-
{"debug", no_argument, 0, 'D'},
796795
{"entries", required_argument, 0, 'E'},
797796
{"duration", required_argument, 0, 'd'},
798797
{"house-keeping", required_argument, 0, 'H'},
@@ -831,7 +830,7 @@ static struct common_params
831830
if (common_parse_options(argc, argv, &params->common))
832831
continue;
833832

834-
c = getopt_long(argc, argv, "a:b:d:e:E:DhH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
833+
c = getopt_long(argc, argv, "a:b:d:e:E:hH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:",
835834
long_options, NULL);
836835

837836
/* detect the end of the options. */
@@ -860,9 +859,6 @@ static struct common_params
860859
params->common.hist.bucket_size >= 1000000)
861860
fatal("Bucket size needs to be > 0 and <= 1000000");
862861
break;
863-
case 'D':
864-
config_debug = 1;
865-
break;
866862
case 'd':
867863
params->common.duration = parse_seconds_duration(optarg);
868864
if (!params->common.duration)

tools/tracing/rtla/src/timerlat_top.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,6 @@ static struct common_params
561561
while (1) {
562562
static struct option long_options[] = {
563563
{"auto", required_argument, 0, 'a'},
564-
{"debug", no_argument, 0, 'D'},
565564
{"duration", required_argument, 0, 'd'},
566565
{"event", required_argument, 0, 'e'},
567566
{"help", no_argument, 0, 'h'},
@@ -595,7 +594,7 @@ static struct common_params
595594
if (common_parse_options(argc, argv, &params->common))
596595
continue;
597596

598-
c = getopt_long(argc, argv, "a:d:De:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
597+
c = getopt_long(argc, argv, "a:d:e:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:",
599598
long_options, NULL);
600599

601600
/* detect the end of the options. */
@@ -632,9 +631,6 @@ static struct common_params
632631
/* set aa_only to avoid parsing the trace */
633632
params->common.aa_only = 1;
634633
break;
635-
case 'D':
636-
config_debug = 1;
637-
break;
638634
case 'd':
639635
params->common.duration = parse_seconds_duration(optarg);
640636
if (!params->common.duration)

0 commit comments

Comments
 (0)