[Lldb-commits] [lldb] [LLDB][Telemetry]Defind telemetry::CommandInfo (PR #129354)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Feb 28 20:09:10 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 823a597d2ad0a76e8d5278a789f37a07b393cd2a 5a992aff351a93ff820d15ace3ebc2bea59dd5fc --extensions h,cpp -- lldb/include/lldb/Core/Telemetry.h lldb/source/Core/Telemetry.cpp lldb/source/Interpreter/CommandInterpreter.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/lldb/include/lldb/Core/Telemetry.h b/lldb/include/lldb/Core/Telemetry.h
index 30b8474156..fcd3c45c93 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -11,12 +11,12 @@
#include "lldb/Core/StructuredDataImpl.h"
#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Utility/StructuredData.h"
#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/StructuredData.h"
#include "lldb/lldb-forward.h"
+#include "llvm/ADT/FunctionExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/FunctionExtras.h"
#include "llvm/Support/JSON.h"
#include "llvm/Telemetry/Telemetry.h"
#include <atomic>
@@ -34,7 +34,8 @@ struct LLDBConfig : public ::llvm::telemetry::Config {
const bool m_collect_original_command;
explicit LLDBConfig(bool enable_telemetry, bool collect_original_command)
- : ::llvm::telemetry::Config(enable_telemetry), m_collect_original_command(collect_original_command) {}
+ : ::llvm::telemetry::Config(enable_telemetry),
+ m_collect_original_command(collect_original_command) {}
};
struct LLDBEntryKind : public ::llvm::telemetry::EntryKind {
@@ -68,7 +69,6 @@ struct LLDBBaseTelemetryInfo : public llvm::telemetry::TelemetryInfo {
void serialize(llvm::telemetry::Serializer &serializer) const override;
};
-
struct CommandInfo : public LLDBBaseTelemetryInfo {
// If the command is/can be associated with a target entry this field contains
@@ -92,13 +92,15 @@ struct CommandInfo : public LLDBBaseTelemetryInfo {
lldb::ReturnStatus ret_status;
std::string error_data;
-
CommandInfo() = default;
- llvm::telemetry::KindType getKind() const override { return LLDBEntryKind::CommandInfo; }
+ llvm::telemetry::KindType getKind() const override {
+ return LLDBEntryKind::CommandInfo;
+ }
static bool classof(const llvm::telemetry::TelemetryInfo *T) {
- return (T->getKind() & LLDBEntryKind::CommandInfo) == LLDBEntryKind::CommandInfo;
+ return (T->getKind() & LLDBEntryKind::CommandInfo) ==
+ LLDBEntryKind::CommandInfo;
}
void serialize(Serializer &serializer) const override;
@@ -113,7 +115,7 @@ public:
int MakeNextCommandId();
- LLDBConfig* GetConfig() { return m_config.get(); }
+ LLDBConfig *GetConfig() { return m_config.get(); }
virtual llvm::StringRef GetInstanceName() const = 0;
static TelemetryManager *getInstance();
@@ -151,10 +153,9 @@ template <typename Info> struct ScopedDispatcher {
debugger = debugger;
}
-
template typename<T>
- T GetIfEnable(llvm::unique_function<T(TelemetryManager*)> callable,
- T default_value) {
+ T GetIfEnable(llvm::unique_function<T(TelemetryManager *)> callable,
+ T default_value) {
TelemetryManager *manager = TelemetryManager::GetInstanceIfEnabled();
if (!manager)
return default_value;
@@ -163,11 +164,13 @@ template <typename Info> struct ScopedDispatcher {
void SetDebugger(Debugger *debugger) { debugger = debugger; }
- void SetFinalCallback(llvm::unique_function<void(Info *info)> final_callback) {
+ void
+ SetFinalCallback(llvm::unique_function<void(Info *info)> final_callback) {
m_final_callback(std::move(final_callback));
}
- void DispatchIfEnable(llvm::unique_function<void(Info *info)> populate_fields_cb) {
+ void
+ DispatchIfEnable(llvm::unique_function<void(Info *info)> populate_fields_cb) {
TelemetryManager *manager = TelemetryManager::GetInstanceIfEnabled();
if (!manager)
return;
@@ -183,7 +186,6 @@ template <typename Info> struct ScopedDispatcher {
LLDB_LOG_ERROR(GetLog(LLDBLog::Object), std::move(er),
"Failed to dispatch entry of type: {0}", m_info.getKind());
}
-
}
~ScopedDispatcher() {
@@ -194,7 +196,7 @@ template <typename Info> struct ScopedDispatcher {
private:
SteadyTimePoint m_start_time;
llvm::unique_function<void(Info *info)> m_final_callback;
- Debugger * debugger;
+ Debugger *debugger;
};
} // namespace telemetry
diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp
index 7fb32f75f4..7284ef3dc0 100644
--- a/lldb/source/Core/Telemetry.cpp
+++ b/lldb/source/Core/Telemetry.cpp
@@ -76,9 +76,7 @@ llvm::Error TelemetryManager::preDispatch(TelemetryInfo *entry) {
return llvm::Error::success();
}
-int TelemetryManager::MakeNextCommandId() {
-
-}
+int TelemetryManager::MakeNextCommandId() {}
std::unique_ptr<TelemetryManager> TelemetryManager::g_instance = nullptr;
TelemetryManager *TelemetryManager::getInstance() { return g_instance.get(); }
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index aab85145b4..f50a88cae3 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1886,22 +1886,26 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
CommandReturnObject &result,
bool force_repeat_command) {
lldb_private::telemetry::ScopedDispatcher<
- lldb_private::telemetry:CommandInfo> helper;
- const int command_id = helper.GetIfEnable<int>([](lldb_private::telemetry::TelemetryManager* ins){
- return ins->MakeNextCommandId(); }, 0);
+ lldb_private::telemetry : CommandInfo>
+ helper;
+ const int command_id = helper.GetIfEnable<int>(
+ [](lldb_private::telemetry::TelemetryManager *ins) {
+ return ins->MakeNextCommandId();
+ },
+ 0);
std::string command_string(command_line);
std::string original_command_string(command_string);
std::string real_original_command_string(command_string);
- helper.DispatchIfEnable([&](lldb_private::telemetry:CommandInfo* info,
- lldb_private::telemetry::TelemetryManager* ins){
+ helper.DispatchIfEnable([&](lldb_private::telemetry : CommandInfo *info,
+ lldb_private::telemetry::TelemetryManager *ins) {
info.command_id = command_id;
- if (Target* target = GetExecutionContext().GetTargetPtr()) {
+ if (Target *target = GetExecutionContext().GetTargetPtr()) {
// If we have a target attached to this command, then get the UUID.
info.target_uuid = target->GetExecutableModule() != nullptr
- ? GetExecutableModule()->GetUUID().GetAsString()
- : "";
+ ? GetExecutableModule()->GetUUID().GetAsString()
+ : "";
}
if (ins->GetConfig()->m_collect_original_command)
info.original_command = original_command_string;
``````````
</details>
https://github.com/llvm/llvm-project/pull/129354
More information about the lldb-commits
mailing list