diff options
Diffstat (limited to 'lldb/source/Commands/CommandObjectSource.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectSource.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index bbc3142..5fdf157 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -1201,6 +1201,62 @@ protected: std::string m_reverse_name; }; +class CommandObjectSourceCacheDump : public CommandObjectParsed { +public: + CommandObjectSourceCacheDump(CommandInterpreter &interpreter) + : CommandObjectParsed(interpreter, "source cache dump", + "Dump the state of the source code cache. Intended " + "to be used for debugging LLDB itself.", + nullptr) {} + + ~CommandObjectSourceCacheDump() override = default; + +protected: + bool DoExecute(Args &command, CommandReturnObject &result) override { + SourceManager::SourceFileCache &cache = GetDebugger().GetSourceFileCache(); + cache.Dump(result.GetOutputStream()); + result.SetStatus(eReturnStatusSuccessFinishResult); + return result.Succeeded(); + } +}; + +class CommandObjectSourceCacheClear : public CommandObjectParsed { +public: + CommandObjectSourceCacheClear(CommandInterpreter &interpreter) + : CommandObjectParsed(interpreter, "source cache clear", + "Clear the source code cache.\n", nullptr) {} + + ~CommandObjectSourceCacheClear() override = default; + +protected: + bool DoExecute(Args &command, CommandReturnObject &result) override { + SourceManager::SourceFileCache &cache = GetDebugger().GetSourceFileCache(); + cache.Clear(); + result.SetStatus(eReturnStatusSuccessFinishNoResult); + return result.Succeeded(); + } +}; + +class CommandObjectSourceCache : public CommandObjectMultiword { +public: + CommandObjectSourceCache(CommandInterpreter &interpreter) + : CommandObjectMultiword(interpreter, "source cache", + "Commands for managing the source code cache.", + "source cache <sub-command>") { + LoadSubCommand( + "dump", CommandObjectSP(new CommandObjectSourceCacheDump(interpreter))); + LoadSubCommand("clear", CommandObjectSP(new CommandObjectSourceCacheClear( + interpreter))); + } + + ~CommandObjectSourceCache() override = default; + +private: + CommandObjectSourceCache(const CommandObjectSourceCache &) = delete; + const CommandObjectSourceCache & + operator=(const CommandObjectSourceCache &) = delete; +}; + #pragma mark CommandObjectMultiwordSource // CommandObjectMultiwordSource @@ -1216,6 +1272,8 @@ CommandObjectMultiwordSource::CommandObjectMultiwordSource( CommandObjectSP(new CommandObjectSourceInfo(interpreter))); LoadSubCommand("list", CommandObjectSP(new CommandObjectSourceList(interpreter))); + LoadSubCommand("cache", + CommandObjectSP(new CommandObjectSourceCache(interpreter))); } CommandObjectMultiwordSource::~CommandObjectMultiwordSource() = default; |