Skip to content

Commit 7ad8360

Browse files
committed
format
1 parent 4dd0782 commit 7ad8360

File tree

3 files changed

+22
-27
lines changed

3 files changed

+22
-27
lines changed

lldb/include/lldb/Core/Telemetry.h

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#include <ctime>
2323
#include <memory>
2424
#include <optional>
25-
#include <string>
2625
#include <stack>
26+
#include <string>
2727

2828
namespace lldb_private {
2929
namespace telemetry {
@@ -91,7 +91,6 @@ class TelemetryManager : public llvm::telemetry::Manager {
9191
public:
9292
llvm::Error preDispatch(llvm::telemetry::TelemetryInfo *entry) override;
9393

94-
9594
virtual void AtDebuggerStartup(DebuggerInfo *entry);
9695
virtual void AtDebuggerExit(DebuggerInfo *entry);
9796

@@ -115,38 +114,36 @@ class TelemetryManager : public llvm::telemetry::Manager {
115114

116115
/// Helper RAII class for collecting telemetry.
117116
class ScopeTelemetryCollector {
118-
public:
119-
ScopeTelemetryCollector () {
117+
public:
118+
ScopeTelemetryCollector() {
120119
if (TelemetryEnabled())
121120
m_start = std::chrono::steady_clock::now();
122121
}
123122

124123
~ScopeTelemetryCollector() {
125-
while(! m_exit_funcs.empty()) {
124+
while (!m_exit_funcs.empty()) {
126125
(m_exit_funcs.top())();
127126
m_exit_funcs.pop();
128127
}
129128
}
130129

131130
bool TelemetryEnabled() {
132-
TelemetryManager* instance = TelemetryManager::GetInstance();
133-
return instance != nullptr && instance->GetConfig()->EnableTelemetry;
131+
TelemetryManager *instance = TelemetryManager::GetInstance();
132+
return instance != nullptr && instance->GetConfig()->EnableTelemetry;
134133
}
135134

135+
SteadyTimePoint GetStartTime() { return m_start; }
136+
SteadyTimePoint GetCurrentTime() { return std::chrono::steady_clock::now(); }
136137

137-
SteadyTimePoint GetStartTime() {return m_start;}
138-
SteadyTimePoint GetCurrentTime() { return std::chrono::steady_clock::now(); }
139-
140-
template <typename Fp>
141-
void RunAtScopeExit(Fp&& F){
142-
assert(llvm::telemetry::Config::BuildTimeEnableTelemetry && "Telemetry should have been enabled");
143-
m_exit_funcs.push(std::forward<Fp>(F));
144-
}
138+
template <typename Fp> void RunAtScopeExit(Fp &&F) {
139+
assert(llvm::telemetry::Config::BuildTimeEnableTelemetry &&
140+
"Telemetry should have been enabled");
141+
m_exit_funcs.push(std::forward<Fp>(F));
142+
}
145143

146-
private:
144+
private:
147145
SteadyTimePoint m_start;
148146
std::stack<std::function<void()>> m_exit_funcs;
149-
150147
};
151148

152149
} // namespace telemetry

lldb/source/Core/Debugger.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "lldb/Core/PluginManager.h"
1818
#include "lldb/Core/Progress.h"
1919
#include "lldb/Core/StreamAsynchronousIO.h"
20+
#include "lldb/Core/Telemetry.h"
2021
#include "lldb/DataFormatters/DataVisualization.h"
2122
#include "lldb/Expression/REPL.h"
2223
#include "lldb/Host/File.h"
@@ -52,7 +53,6 @@
5253
#include "lldb/Utility/State.h"
5354
#include "lldb/Utility/Stream.h"
5455
#include "lldb/Utility/StreamString.h"
55-
#include "lldb/Core/Telemetry.h"
5656
#include "lldb/lldb-enumerations.h"
5757

5858
#if defined(_WIN32)
@@ -71,7 +71,6 @@
7171
#include "llvm/Support/Threading.h"
7272
#include "llvm/Support/raw_ostream.h"
7373

74-
7574
#include <chrono>
7675
#include <cstdio>
7776
#include <cstdlib>
@@ -769,15 +768,15 @@ DebuggerSP Debugger::CreateInstance(lldb::LogOutputCallback log_callback,
769768
DebuggerSP debugger_sp(new Debugger(log_callback, baton));
770769

771770
if (helper.TelemetryEnabled()) {
772-
helper.RunAtScopeExit([&](){
773-
lldb_private::telemetry::TelemetryManager * manager = lldb_private::telemetry::TelemetryManager::GetInstance();
771+
helper.RunAtScopeExit([&]() {
772+
lldb_private::telemetry::TelemetryManager *manager =
773+
lldb_private::telemetry::TelemetryManager::GetInstance();
774774
lldb_private::telemetry::DebuggerInfo entry;
775775
entry.debugger = debugger_sp.get();
776776
entry.start_time = helper.GetStartTime();
777777
entry.end_time = helper.GetCurrentTime();
778778
manager->AtDebuggerStartup(&entry);
779779
});
780-
781780
}
782781

783782
if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
@@ -1009,9 +1008,9 @@ void Debugger::Clear() {
10091008
lldb_private::telemetry::ScopeTelemetryCollector helper;
10101009
if (helper.TelemetryEnabled()) {
10111010
// TBD: We *may* have to send off the log BEFORE the ClearIOHanders()?
1012-
helper.RunAtScopeExit([&helper, this](){
1013-
lldb_private::telemetry::TelemetryManager* manager
1014-
= lldb_private::telemetry::TelemetryManager::GetInstance();
1011+
helper.RunAtScopeExit([&helper, this]() {
1012+
lldb_private::telemetry::TelemetryManager *manager =
1013+
lldb_private::telemetry::TelemetryManager::GetInstance();
10151014
lldb_private::telemetry::DebuggerInfo entry;
10161015
entry.debugger = this;
10171016
entry.exit_desc = {0, ""}; // If we are here, there was no error.

lldb/source/Core/Telemetry.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void TelemetryManager::AtDebuggerStartup(DebuggerInfo *entry) {
9696
}
9797
}
9898

99-
void TelemetryManager::AtDebuggerExit(DebuggerInfo * entry) {
99+
void TelemetryManager::AtDebuggerExit(DebuggerInfo *entry) {
100100
// There must be a reference to the debugger at this point.
101101
assert(entry->debugger != nullptr);
102102

@@ -119,6 +119,5 @@ void TelemetryManager::SetInstance(std::unique_ptr<TelemetryManager> manager) {
119119
g_instance = std::move(manager);
120120
}
121121

122-
123122
} // namespace telemetry
124123
} // namespace lldb_private

0 commit comments

Comments
 (0)