[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 08:23:27 +01:00
|
|
|
//===-- CommandObjectStats.cpp --------------------------------------------===//
|
2018-03-23 21:55:48 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-03-23 21:55:48 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
#include "CommandObjectStats.h"
|
2021-10-20 14:49:09 -07:00
|
|
|
#include "lldb/Core/Debugger.h"
|
|
|
|
|
#include "lldb/Host/OptionParser.h"
|
2022-07-13 20:11:37 -07:00
|
|
|
#include "lldb/Interpreter/CommandOptionArgumentTable.h"
|
2018-03-23 21:55:48 +00:00
|
|
|
#include "lldb/Interpreter/CommandReturnObject.h"
|
2018-04-13 18:02:39 +00:00
|
|
|
#include "lldb/Target/Target.h"
|
2018-03-23 21:55:48 +00:00
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
2018-04-13 18:02:39 +00:00
|
|
|
class CommandObjectStatsEnable : public CommandObjectParsed {
|
|
|
|
|
public:
|
|
|
|
|
CommandObjectStatsEnable(CommandInterpreter &interpreter)
|
|
|
|
|
: CommandObjectParsed(interpreter, "enable",
|
|
|
|
|
"Enable statistics collection", nullptr,
|
|
|
|
|
eCommandProcessMustBePaused) {}
|
|
|
|
|
|
|
|
|
|
~CommandObjectStatsEnable() override = default;
|
|
|
|
|
|
|
|
|
|
protected:
|
2023-10-30 10:21:00 -10:00
|
|
|
void DoExecute(Args &command, CommandReturnObject &result) override {
|
2021-10-20 14:49:09 -07:00
|
|
|
if (DebuggerStats::GetCollectingStats()) {
|
2018-04-13 18:02:39 +00:00
|
|
|
result.AppendError("statistics already enabled");
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2018-04-13 18:02:39 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-20 14:49:09 -07:00
|
|
|
DebuggerStats::SetCollectingStats(true);
|
2018-04-13 18:02:39 +00:00
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CommandObjectStatsDisable : public CommandObjectParsed {
|
|
|
|
|
public:
|
|
|
|
|
CommandObjectStatsDisable(CommandInterpreter &interpreter)
|
|
|
|
|
: CommandObjectParsed(interpreter, "disable",
|
|
|
|
|
"Disable statistics collection", nullptr,
|
|
|
|
|
eCommandProcessMustBePaused) {}
|
|
|
|
|
|
|
|
|
|
~CommandObjectStatsDisable() override = default;
|
|
|
|
|
|
|
|
|
|
protected:
|
2023-10-30 10:21:00 -10:00
|
|
|
void DoExecute(Args &command, CommandReturnObject &result) override {
|
2021-10-20 14:49:09 -07:00
|
|
|
if (!DebuggerStats::GetCollectingStats()) {
|
2018-04-13 18:02:39 +00:00
|
|
|
result.AppendError("need to enable statistics before disabling them");
|
2023-10-30 10:21:00 -10:00
|
|
|
return;
|
2018-04-13 18:02:39 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-20 14:49:09 -07:00
|
|
|
DebuggerStats::SetCollectingStats(false);
|
2018-04-13 18:02:39 +00:00
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2021-10-20 14:49:09 -07:00
|
|
|
#define LLDB_OPTIONS_statistics_dump
|
|
|
|
|
#include "CommandOptions.inc"
|
|
|
|
|
|
2018-04-13 18:02:39 +00:00
|
|
|
class CommandObjectStatsDump : public CommandObjectParsed {
|
2021-10-20 14:49:09 -07:00
|
|
|
class CommandOptions : public Options {
|
|
|
|
|
public:
|
2022-01-23 11:07:14 -08:00
|
|
|
CommandOptions() { OptionParsingStarting(nullptr); }
|
2021-10-20 14:49:09 -07:00
|
|
|
|
|
|
|
|
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
|
|
|
|
|
ExecutionContext *execution_context) override {
|
|
|
|
|
Status error;
|
|
|
|
|
const int short_option = m_getopt_table[option_idx].val;
|
|
|
|
|
|
|
|
|
|
switch (short_option) {
|
|
|
|
|
case 'a':
|
|
|
|
|
m_all_targets = true;
|
|
|
|
|
break;
|
2024-02-06 19:47:34 -05:00
|
|
|
case 's':
|
|
|
|
|
m_stats_options.summary_only = true;
|
|
|
|
|
break;
|
2021-10-20 14:49:09 -07:00
|
|
|
default:
|
|
|
|
|
llvm_unreachable("Unimplemented option");
|
|
|
|
|
}
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OptionParsingStarting(ExecutionContext *execution_context) override {
|
|
|
|
|
m_all_targets = false;
|
2024-02-06 19:47:34 -05:00
|
|
|
m_stats_options = StatisticsOptions();
|
2021-10-20 14:49:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
|
2023-01-09 18:11:07 +01:00
|
|
|
return llvm::ArrayRef(g_statistics_dump_options);
|
2021-10-20 14:49:09 -07:00
|
|
|
}
|
|
|
|
|
|
2024-02-06 19:47:34 -05:00
|
|
|
const StatisticsOptions &GetStatisticsOptions() { return m_stats_options; }
|
|
|
|
|
|
2021-10-20 14:49:09 -07:00
|
|
|
bool m_all_targets = false;
|
2024-02-06 19:47:34 -05:00
|
|
|
StatisticsOptions m_stats_options = StatisticsOptions();
|
2021-10-20 14:49:09 -07:00
|
|
|
};
|
|
|
|
|
|
2018-04-13 18:02:39 +00:00
|
|
|
public:
|
|
|
|
|
CommandObjectStatsDump(CommandInterpreter &interpreter)
|
2021-10-20 14:49:09 -07:00
|
|
|
: CommandObjectParsed(
|
|
|
|
|
interpreter, "statistics dump", "Dump metrics in JSON format",
|
|
|
|
|
"statistics dump [<options>]", eCommandRequiresTarget) {}
|
2018-04-13 18:02:39 +00:00
|
|
|
|
|
|
|
|
~CommandObjectStatsDump() override = default;
|
|
|
|
|
|
2021-10-20 14:49:09 -07:00
|
|
|
Options *GetOptions() override { return &m_options; }
|
|
|
|
|
|
2018-04-13 18:02:39 +00:00
|
|
|
protected:
|
2023-10-30 10:21:00 -10:00
|
|
|
void DoExecute(Args &command, CommandReturnObject &result) override {
|
2021-10-21 16:01:00 -07:00
|
|
|
Target *target = nullptr;
|
|
|
|
|
if (!m_options.m_all_targets)
|
|
|
|
|
target = m_exe_ctx.GetTargetPtr();
|
|
|
|
|
|
|
|
|
|
result.AppendMessageWithFormatv(
|
2024-02-06 19:47:34 -05:00
|
|
|
"{0:2}", DebuggerStats::ReportStatistics(
|
|
|
|
|
GetDebugger(), target, m_options.GetStatisticsOptions()));
|
2018-04-13 18:02:39 +00:00
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
|
|
|
|
}
|
2021-10-20 14:49:09 -07:00
|
|
|
|
|
|
|
|
CommandOptions m_options;
|
2018-04-13 18:02:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CommandObjectStats::CommandObjectStats(CommandInterpreter &interpreter)
|
|
|
|
|
: CommandObjectMultiword(interpreter, "statistics",
|
|
|
|
|
"Print statistics about a debugging session",
|
|
|
|
|
"statistics <subcommand> [<subcommand-options>]") {
|
|
|
|
|
LoadSubCommand("enable",
|
|
|
|
|
CommandObjectSP(new CommandObjectStatsEnable(interpreter)));
|
|
|
|
|
LoadSubCommand("disable",
|
|
|
|
|
CommandObjectSP(new CommandObjectStatsDisable(interpreter)));
|
|
|
|
|
LoadSubCommand("dump",
|
|
|
|
|
CommandObjectSP(new CommandObjectStatsDump(interpreter)));
|
2018-03-23 21:55:48 +00:00
|
|
|
}
|
|
|
|
|
|
2018-04-13 18:02:39 +00:00
|
|
|
CommandObjectStats::~CommandObjectStats() = default;
|