diff options
author | Gongyu Deng <gy_deng@icloud.com> | 2020-05-11 15:21:37 +0200 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2020-05-11 15:21:51 +0200 |
commit | 0e50b9a43bf65714cc6669203aeb1c175878a7da (patch) | |
tree | 9bb2d2297d6cdeaa6e12a900bf215b8580e84efb /lldb/source/Commands/CommandCompletions.cpp | |
parent | c25b20c0f6c13d68dbc2e185764082d61ae4a132 (diff) | |
download | llvm-0e50b9a43bf65714cc6669203aeb1c175878a7da.zip llvm-0e50b9a43bf65714cc6669203aeb1c175878a7da.tar.gz llvm-0e50b9a43bf65714cc6669203aeb1c175878a7da.tar.bz2 |
Complete breakpoint enable/disable/delete/modify with a list of breakpoint IDs
Summary:
1. A new common completion `CommandCompletions::Breakpoints` to provide a list of the breakpoints of the current context;
2. Apply the completion above to the commands breakpoint enable/disable/delete/modify;
3. Unit test.
Reviewers: teemperor, JDevlieghere
Reviewed By: teemperor
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D79666
Diffstat (limited to 'lldb/source/Commands/CommandCompletions.cpp')
-rw-r--r-- | lldb/source/Commands/CommandCompletions.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index 1e90315..d4e4f6a 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -57,6 +57,7 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks( {eArchitectureCompletion, CommandCompletions::ArchitectureNames}, {eVariablePathCompletion, CommandCompletions::VariablePath}, {eRegisterCompletion, CommandCompletions::Registers}, + {eBreakpointCompletion, CommandCompletions::Breakpoints}, {eNoCompletion, nullptr} // This one has to be last in the list. }; @@ -549,4 +550,35 @@ void CommandCompletions::Registers(CommandInterpreter &interpreter, request.TryCompleteCurrentArg(reg_prefix + reg_info->name, reg_info->alt_name); } -}
\ No newline at end of file +} + +void CommandCompletions::Breakpoints(CommandInterpreter &interpreter, + CompletionRequest &request, + SearchFilter *searcher) { + lldb::TargetSP target = interpreter.GetDebugger().GetSelectedTarget(); + if (!target) + return; + + const BreakpointList &breakpoints = target->GetBreakpointList(); + + std::unique_lock<std::recursive_mutex> lock; + target->GetBreakpointList().GetListMutex(lock); + + size_t num_breakpoints = breakpoints.GetSize(); + if (num_breakpoints == 0) + return; + + for (size_t i = 0; i < num_breakpoints; ++i) { + lldb::BreakpointSP bp = breakpoints.GetBreakpointAtIndex(i); + + StreamString s; + bp->GetDescription(&s, lldb::eDescriptionLevelBrief); + llvm::StringRef bp_info = s.GetString(); + + const size_t colon_pos = bp_info.find_first_of(':'); + if (colon_pos != llvm::StringRef::npos) + bp_info = bp_info.drop_front(colon_pos + 2); + + request.TryCompleteCurrentArg(std::to_string(bp->GetID()), bp_info); + } +} |