|
48 | 48 |
|
49 | 49 | struct switch_output { |
50 | 50 | bool signal; |
| 51 | + const char *str; |
| 52 | + bool set; |
51 | 53 | }; |
52 | 54 |
|
53 | 55 | struct record { |
@@ -1356,6 +1358,22 @@ static int record__parse_mmap_pages(const struct option *opt, |
1356 | 1358 | return ret; |
1357 | 1359 | } |
1358 | 1360 |
|
| 1361 | +static int switch_output_setup(struct record *rec) |
| 1362 | +{ |
| 1363 | + struct switch_output *s = &rec->switch_output; |
| 1364 | + |
| 1365 | + if (!s->set) |
| 1366 | + return 0; |
| 1367 | + |
| 1368 | + if (!strcmp(s->str, "signal")) { |
| 1369 | + s->signal = true; |
| 1370 | + pr_debug("switch-output with SIGUSR2 signal\n"); |
| 1371 | + return 0; |
| 1372 | + } |
| 1373 | + |
| 1374 | + return -1; |
| 1375 | +} |
| 1376 | + |
1359 | 1377 | static const char * const __record_usage[] = { |
1360 | 1378 | "perf record [<options>] [<command>]", |
1361 | 1379 | "perf record [<options>] -- <command> [<options>]", |
@@ -1523,8 +1541,9 @@ static struct option __record_options[] = { |
1523 | 1541 | "Record build-id of all DSOs regardless of hits"), |
1524 | 1542 | OPT_BOOLEAN(0, "timestamp-filename", &record.timestamp_filename, |
1525 | 1543 | "append timestamp to output filename"), |
1526 | | - OPT_BOOLEAN(0, "switch-output", &record.switch_output.signal, |
1527 | | - "Switch output when receive SIGUSR2"), |
| 1544 | + OPT_STRING_OPTARG_SET(0, "switch-output", &record.switch_output.str, |
| 1545 | + &record.switch_output.set, "signal", |
| 1546 | + "Switch output when receive SIGUSR2", "signal"), |
1528 | 1547 | OPT_BOOLEAN(0, "dry-run", &dry_run, |
1529 | 1548 | "Parse options then exit"), |
1530 | 1549 | OPT_END() |
@@ -1582,6 +1601,11 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused) |
1582 | 1601 | return -EINVAL; |
1583 | 1602 | } |
1584 | 1603 |
|
| 1604 | + if (switch_output_setup(rec)) { |
| 1605 | + parse_options_usage(record_usage, record_options, "switch-output", 0); |
| 1606 | + return -EINVAL; |
| 1607 | + } |
| 1608 | + |
1585 | 1609 | if (rec->switch_output.signal) |
1586 | 1610 | rec->timestamp_filename = true; |
1587 | 1611 |
|
|
0 commit comments