From 76706090c2f672ae933798292bfa889f9e3dac3d Mon Sep 17 00:00:00 2001 From: jeffreytan81 Date: Mon, 5 Feb 2024 13:17:29 -0800 Subject: Add commands frequency to statistics dump (#80375) Adding command interpreter statistics into "statistics dump" command so that we can track the command usage frequency for telemetry purpose. This is useful to answer questions like what is the most frequently used lldb commands across all our users. --------- Co-authored-by: jeffreytan81 --- lldb/source/Commands/CommandObjectCommands.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'lldb/source/Commands/CommandObjectCommands.cpp') diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index 5b9af4a..a51e5ab 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -1123,6 +1123,8 @@ protected: CommandReturnObject &result) override { ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter(); + m_interpreter.IncreaseCommandUsage(*this); + Status error; result.SetStatus(eReturnStatusInvalid); @@ -1644,8 +1646,9 @@ protected: llvm::Error llvm_error = m_container->LoadUserSubcommand(m_cmd_name, new_cmd_sp, m_overwrite); if (llvm_error) - result.AppendErrorWithFormat("cannot add command: %s", - llvm::toString(std::move(llvm_error)).c_str()); + result.AppendErrorWithFormat( + "cannot add command: %s", + llvm::toString(std::move(llvm_error)).c_str()); } } @@ -1788,12 +1791,13 @@ protected: return; } const char *leaf_cmd = command[num_args - 1].c_str(); - llvm::Error llvm_error = container->RemoveUserSubcommand(leaf_cmd, - /* multiword not okay */ false); + llvm::Error llvm_error = + container->RemoveUserSubcommand(leaf_cmd, + /* multiword not okay */ false); if (llvm_error) { - result.AppendErrorWithFormat("could not delete command '%s': %s", - leaf_cmd, - llvm::toString(std::move(llvm_error)).c_str()); + result.AppendErrorWithFormat( + "could not delete command '%s': %s", leaf_cmd, + llvm::toString(std::move(llvm_error)).c_str()); return; } -- cgit v1.1