[Lldb-commits] [lldb] Add options to "statistics dump" to control what sections are dumped (PR #95075)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 14 12:13:59 PDT 2024


================
@@ -133,7 +133,9 @@ struct ConstStringStats {
 struct StatisticsOptions {
   bool summary_only = false;
   bool load_all_debug_info = false;
-  bool include_transcript = false;
+  bool include_targets = true;
+  bool include_modules = true;
----------------
clayborg wrote:

Do we want to make all of the StatisticsOptions bool values `std::optional<bool>` values? Then we will know if the user has set them and we can do the reasoning. Accessors can be added to this `StatisticsOptions` class to do the right thing. Then instead of people directly accessing each `std::optional<bool>` we would have accessors. Something like:
```
class StatisticsOptions {
private: // Stop direct access to the member variables
  std::optional<bool> m_summary_only;
  std::optional<bool> m_load_all_debug_info;
  std::optional<bool> m_include_transcript;
  std::optional<bool> m_include_targets;
  std::optional<bool> m_include_modules;
public:
  // Summary only defaults to false.
  bool GetSummaryOnly() const { return m_summary_only.value_or(false); }
  void SetSummaryOnly(bool value) { m_summary_only = value; }
  // Now we can reason about what values to return depending on m_summary_only:
  bool GetIncludeTargets() const {
    if (m_include_targets.has_value())
      return m_include_targets.value();
    // m_include_targets has no value set, so return a value base on m_summary_only
    return !GetSummaryOnly();
  }
```
Then this allows you to always do the right thing depending on what options people select.

https://github.com/llvm/llvm-project/pull/95075


More information about the lldb-commits mailing list