[all-commits] [llvm/llvm-project] 70f41a: [lldb] Add/change options in `statistics dump` to ...

royitaqi via All-commits all-commits at lists.llvm.org
Tue Jun 18 17:21:42 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 70f41a8c305478cb16bcda9f9967af96ab1e3a20
      https://github.com/llvm/llvm-project/commit/70f41a8c305478cb16bcda9f9967af96ab1e3a20
  Author: royitaqi <royitaqi at users.noreply.github.com>
  Date:   2024-06-18 (Tue, 18 Jun 2024)

  Changed paths:
    M lldb/include/lldb/API/SBStatisticsOptions.h
    M lldb/include/lldb/Interpreter/OptionArgParser.h
    M lldb/include/lldb/Target/Statistics.h
    M lldb/source/API/SBStatisticsOptions.cpp
    M lldb/source/Commands/CommandObjectStats.cpp
    M lldb/source/Commands/Options.td
    M lldb/source/Interpreter/OptionArgParser.cpp
    M lldb/source/Target/Statistics.cpp
    M lldb/test/API/commands/statistics/basic/TestStats.py
    M lldb/unittests/Interpreter/TestOptionArgParser.cpp

  Log Message:
  -----------
  [lldb] Add/change options in `statistics dump` to control what sections are dumped (#95075)

# Added/changed options

The following options are **added** to the `statistics dump` command:
* `--targets=bool`: Boolean. Dumps the `targets` section.
* `--modules=bool`: Boolean. Dumps the `modules` section.
When both options are given, the field `moduleIdentifiers` will be
dumped for each target in the `targets` section.

The following options are **changed**:
* `--transcript=bool`: Changed to a boolean. Dumps the `transcript`
section.

# Behavior of `statistics dump` with various options

The behavior is **backward compatible**:
- When no options are provided, `statistics dump` dumps all sections.
- When `--summary` is provided, only dumps the summary info.

**New** behavior:
- `--targets=bool`, `--modules=bool`, `--transcript=bool` overrides the
above "default".

For **example**:
- `statistics dump --modules=false` dumps summary + targets +
transcript. No modules.
- `statistics dump --summary --targets=true --transcript=true` dumps
summary + targets (in summary mode) + transcript.


# Added options into public API

In `SBStatisticsOptions`, add:
* `Set/GetIncludeTargets`
* `Set/GetIncludeModules`
* `Set/GetIncludeTranscript`

**Alternative considered**: Thought about adding
`Set/GetIncludeSections(string sections_spec)`, which receives a
comma-separated list of section names to be included ("targets",
"modules", "transcript"). The **benefit** of this approach is that the
API is more future-proof when it comes to possible adding/changing of
section names. **However**, I feel the section names are likely to
remain unchanged for a while - it's not like we plan to make big changes
to the output of `statistics dump` any time soon. The **downsides** of
this approach are: 1\ the readability of the API is worse (requires
reading doc to understand what string can be accepted), 2\ string input
are more prone to human error (e.g. typo "target" instead of expected
"targets").


# Tests

```
bin/llvm-lit -sv ../external/llvm-project/lldb/test/API/commands/statistics/basic/TestStats.py
```

```
./tools/lldb/unittests/Interpreter/InterpreterTests
```

New test cases have been added to verify:
* Different sections are dumped/not dumped when different
`StatisticsOptions` are given through command line (CLI or
`HandleCommand`; see `test_sections_existence_through_command`) or API
(see `test_sections_existence_through_api`).
* The order in which the options are given in command line does not
matter (see `test_order_of_options_do_not_matter`).

---------

Co-authored-by: Roy Shi <royshi at meta.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list