diff options
author | Gongyu Deng <gy_deng@icloud.com> | 2020-08-11 13:38:36 +0200 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2020-08-11 14:25:09 +0200 |
commit | 4f3559db1f313eed8bd84377de0fb2300a58125b (patch) | |
tree | 17ba7811adbd3657d1ac1607d3e25a7452c1aaa6 /lldb/source/Commands/CommandCompletions.cpp | |
parent | 3483c28c5bc16d37d6c0f4e760357e4934f83b97 (diff) | |
download | llvm-4f3559db1f313eed8bd84377de0fb2300a58125b.zip llvm-4f3559db1f313eed8bd84377de0fb2300a58125b.tar.gz llvm-4f3559db1f313eed8bd84377de0fb2300a58125b.tar.bz2 |
[lldb] watchpoint ID common completion for commands `watchpoint delete/enable/disable/modify/ignore`
1. Added a common completion WatchPointIDs to complete with a list of the IDs of the current watchpoints;
2. Applied the completion to these commands: watchpoint delete/enable/disable/modify/ignore;
3. Added a correlated test case.
Reviewed By: teemperor
Differential Revision: https://reviews.llvm.org/D84104
Diffstat (limited to 'lldb/source/Commands/CommandCompletions.cpp')
-rw-r--r-- | lldb/source/Commands/CommandCompletions.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index 526efe3..4ed11e14 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -9,6 +9,7 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringSet.h" +#include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Core/FileSpecList.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" @@ -68,6 +69,7 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks( {eFrameIndexCompletion, CommandCompletions::FrameIndexes}, {eStopHookIDCompletion, CommandCompletions::StopHookIDs}, {eThreadIndexCompletion, CommandCompletions::ThreadIndexes}, + {eWatchPointIDCompletion, CommandCompletions::WatchPointIDs}, {eNoCompletion, nullptr} // This one has to be last in the list. }; @@ -697,3 +699,21 @@ void CommandCompletions::ThreadIndexes(CommandInterpreter &interpreter, strm.GetString()); } } + +void CommandCompletions::WatchPointIDs(CommandInterpreter &interpreter, + CompletionRequest &request, + SearchFilter *searcher) { + const ExecutionContext &exe_ctx = interpreter.GetExecutionContext(); + if (!exe_ctx.HasTargetScope()) + return; + + const WatchpointList &wp_list = exe_ctx.GetTargetPtr()->GetWatchpointList(); + const size_t wp_num = wp_list.GetSize(); + for (size_t idx = 0; idx < wp_num; ++idx) { + const lldb::WatchpointSP wp_sp = wp_list.GetByIndex(idx); + StreamString strm; + wp_sp->Dump(&strm); + request.TryCompleteCurrentArg(std::to_string(wp_sp->GetID()), + strm.GetString()); + } +} |