From 10166c74683ccc4680c5db8437cb43bc2b8bb065 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Fri, 23 Mar 2018 21:55:48 +0000 Subject: [PATCH] [Commands] Add a (currently empty) `stats` command. This one will be used to print statistics about lldb sessions (including, e.g. number of expression evaluation succeeded or failed). I decided to commit the skeleton first so that we have a clean reference on how a command should be implemented. My future commits are going to populate this command and test it. llvm-svn: 328378 --- lldb/lldb.xcodeproj/project.pbxproj | 8 ++++++++ lldb/source/Commands/CMakeLists.txt | 1 + lldb/source/Commands/CommandObjectStats.cpp | 28 ++++++++++++++++++++++++++ lldb/source/Commands/CommandObjectStats.h | 27 +++++++++++++++++++++++++ lldb/source/Interpreter/CommandInterpreter.cpp | 2 ++ 5 files changed, 66 insertions(+) create mode 100644 lldb/source/Commands/CommandObjectStats.cpp create mode 100644 lldb/source/Commands/CommandObjectStats.h diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index fcbfa1b..d561cf4 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -765,6 +765,8 @@ 4CF52AF8142829390051E832 /* SBFileSpecList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CF52AF7142829390051E832 /* SBFileSpecList.cpp */; }; 54067BF11DF2041B00749AA5 /* UBSanRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 54067BEC1DF2034B00749AA5 /* UBSanRuntime.cpp */; }; 6B74D89B200696BB0074051B /* Environment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 22DC561920064C9600A7E9E8 /* Environment.cpp */; }; + 6B8894792065AE5D002E5C59 /* CommandObjectStats.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 6B8894772065AE5C002E5C59 /* CommandObjectStats.h */; }; + 6B88947A2065AE5D002E5C59 /* CommandObjectStats.cpp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 6B8894782065AE5C002E5C59 /* CommandObjectStats.cpp */; }; 6D0F61431C80AAAE00A4ECEE /* JavaASTContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D0F61411C80AAAA00A4ECEE /* JavaASTContext.cpp */; }; 6D0F61481C80AAD600A4ECEE /* DWARFASTParserJava.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D0F61441C80AACF00A4ECEE /* DWARFASTParserJava.cpp */; }; 6D0F614E1C80AB0700A4ECEE /* JavaLanguageRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D0F614A1C80AB0400A4ECEE /* JavaLanguageRuntime.cpp */; }; @@ -1266,6 +1268,8 @@ dstPath = "$(DEVELOPER_INSTALL_DIR)/usr/share/man/man1"; dstSubfolderSpec = 0; files = ( + 6B88947A2065AE5D002E5C59 /* CommandObjectStats.cpp in CopyFiles */, + 6B8894792065AE5D002E5C59 /* CommandObjectStats.h in CopyFiles */, 7F94D7182040A13A006EE3EA /* CleanUpTest.cpp in CopyFiles */, AF90106515AB7D3600FF120D /* lldb.1 in CopyFiles */, ); @@ -2667,6 +2671,8 @@ 69A01E1C1236C5D400C660B5 /* Host.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Host.cpp; sourceTree = ""; }; 69A01E1F1236C5D400C660B5 /* Symbols.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Symbols.cpp; sourceTree = ""; }; 6B74D89C2006972D0074051B /* Environment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Environment.h; path = include/lldb/Utility/Environment.h; sourceTree = ""; }; + 6B8894772065AE5C002E5C59 /* CommandObjectStats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectStats.h; path = source/Commands/CommandObjectStats.h; sourceTree = ""; }; + 6B8894782065AE5C002E5C59 /* CommandObjectStats.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectStats.cpp; path = source/Commands/CommandObjectStats.cpp; sourceTree = ""; }; 6D0F613C1C80AA8900A4ECEE /* DebugMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DebugMacros.h; path = include/lldb/Symbol/DebugMacros.h; sourceTree = ""; }; 6D0F613D1C80AA8900A4ECEE /* JavaASTContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JavaASTContext.h; path = include/lldb/Symbol/JavaASTContext.h; sourceTree = ""; }; 6D0F61411C80AAAA00A4ECEE /* JavaASTContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JavaASTContext.cpp; path = source/Symbol/JavaASTContext.cpp; sourceTree = ""; }; @@ -5165,6 +5171,8 @@ 26BC7D0D10F1B71D00F91463 /* Commands */ = { isa = PBXGroup; children = ( + 6B8894782065AE5C002E5C59 /* CommandObjectStats.cpp */, + 6B8894772065AE5C002E5C59 /* CommandObjectStats.h */, 4CA9637A11B6E99A00780E28 /* CommandObjectApropos.h */, 4CA9637911B6E99A00780E28 /* CommandObjectApropos.cpp */, 26BC7D1410F1B76300F91463 /* CommandObjectBreakpoint.h */, diff --git a/lldb/source/Commands/CMakeLists.txt b/lldb/source/Commands/CMakeLists.txt index f0199eb..1dbaab5 100644 --- a/lldb/source/Commands/CMakeLists.txt +++ b/lldb/source/Commands/CMakeLists.txt @@ -20,6 +20,7 @@ add_lldb_library(lldbCommands CommandObjectRegister.cpp CommandObjectSettings.cpp CommandObjectSource.cpp + CommandObjectStats.cpp CommandObjectTarget.cpp CommandObjectThread.cpp CommandObjectType.cpp diff --git a/lldb/source/Commands/CommandObjectStats.cpp b/lldb/source/Commands/CommandObjectStats.cpp new file mode 100644 index 0000000..84a8a6c --- /dev/null +++ b/lldb/source/Commands/CommandObjectStats.cpp @@ -0,0 +1,28 @@ +//===-- CommandObjectStats.cpp ----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "CommandObjectStats.h" +#include "lldb/Host/Host.h" +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/CommandReturnObject.h" + +using namespace lldb; +using namespace lldb_private; + +CommandObjectStats::CommandObjectStats(CommandInterpreter &interpreter) + : CommandObjectParsed( + interpreter, "stats", "Print statistics about a debugging session", + nullptr) { +} + +bool CommandObjectStats::DoExecute(Args &command, CommandReturnObject &result) { + return true; +} + +CommandObjectStats::~CommandObjectStats() {} diff --git a/lldb/source/Commands/CommandObjectStats.h b/lldb/source/Commands/CommandObjectStats.h new file mode 100644 index 0000000..b71fac4 --- /dev/null +++ b/lldb/source/Commands/CommandObjectStats.h @@ -0,0 +1,27 @@ +//===-- CommandObjectStats.h ------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_CommandObjectStats_h_ +#define liblldb_CommandObjectStats_h_ + +#include "lldb/Interpreter/CommandObject.h" + +namespace lldb_private { +class CommandObjectStats : public CommandObjectParsed { +public: + CommandObjectStats(CommandInterpreter &interpreter); + + ~CommandObjectStats() override; + +protected: + bool DoExecute(Args &command, CommandReturnObject &result) override; +}; +} // namespace lldb_private + +#endif // liblldb_CommandObjectLanguage_h_ diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index cb793f7..8900bad 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -33,6 +33,7 @@ #include "../Commands/CommandObjectRegister.h" #include "../Commands/CommandObjectSettings.h" #include "../Commands/CommandObjectSource.h" +#include "../Commands/CommandObjectStats.h" #include "../Commands/CommandObjectTarget.h" #include "../Commands/CommandObjectThread.h" #include "../Commands/CommandObjectType.h" @@ -424,6 +425,7 @@ void CommandInterpreter::LoadCommandDictionary() { CommandObjectSP(new CommandObjectMultiwordSettings(*this)); m_command_dict["source"] = CommandObjectSP(new CommandObjectMultiwordSource(*this)); + m_command_dict["stats"] = CommandObjectSP(new CommandObjectStats(*this)); m_command_dict["target"] = CommandObjectSP(new CommandObjectMultiwordTarget(*this)); m_command_dict["thread"] = -- 2.7.4