diff options
author | Jim Ingham <jingham@apple.com> | 2022-02-04 15:16:31 -0800 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2022-02-14 15:48:06 -0800 |
commit | 635f03fe976e250cc64999663f47716412dfa029 (patch) | |
tree | f4f49f4aae21d4d9393775a90f9e43db5a8db2f1 /lldb/source/Commands/CommandObjectMultiword.cpp | |
parent | a7c2a6289c22624f8b21b6c0e3f27047c4d4113d (diff) | |
download | llvm-635f03fe976e250cc64999663f47716412dfa029.zip llvm-635f03fe976e250cc64999663f47716412dfa029.tar.gz llvm-635f03fe976e250cc64999663f47716412dfa029.tar.bz2 |
Add a repeat command option for "thread backtrace --count N".
This way if you have a long stack, you can issue "thread backtrace --count 10"
and then subsequent <Return>-s will page you through the stack.
This took a little more effort than just adding the repeat command, since
the GetRepeatCommand API was returning a "const char *". That meant the command
had to keep the repeat string alive, which is inconvenient. The original
API returned either a nullptr, or a const char *, so I changed the private API to
return an llvm::Optional<std::string>. Most of the patch is propagating that change.
Also, there was a little thinko in fetching the repeat command. We don't
fetch repeat commands for commands that aren't being added to history, which
is in general reasonable. And we don't add repeat commands to the history -
also reasonable. But we do want the repeat command to be able to generate
the NEXT repeat command. So I adjusted the logic in HandleCommand to work
that way.
Differential Revision: https://reviews.llvm.org/D119046
Diffstat (limited to 'lldb/source/Commands/CommandObjectMultiword.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectMultiword.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp index 0629342..e4fdb73 100644 --- a/lldb/source/Commands/CommandObjectMultiword.cpp +++ b/lldb/source/Commands/CommandObjectMultiword.cpp @@ -290,15 +290,16 @@ void CommandObjectMultiword::HandleCompletion(CompletionRequest &request) { sub_command_object->HandleCompletion(request); } -const char *CommandObjectMultiword::GetRepeatCommand(Args ¤t_command_args, - uint32_t index) { +llvm::Optional<std::string> +CommandObjectMultiword::GetRepeatCommand(Args ¤t_command_args, + uint32_t index) { index++; if (current_command_args.GetArgumentCount() <= index) - return nullptr; + return llvm::None; CommandObject *sub_command_object = GetSubcommandObject(current_command_args[index].ref()); if (sub_command_object == nullptr) - return nullptr; + return llvm::None; return sub_command_object->GetRepeatCommand(current_command_args, index); } @@ -419,12 +420,13 @@ void CommandObjectProxy::HandleArgumentCompletion( proxy_command->HandleArgumentCompletion(request, opt_element_vector); } -const char *CommandObjectProxy::GetRepeatCommand(Args ¤t_command_args, - uint32_t index) { +llvm::Optional<std::string> +CommandObjectProxy::GetRepeatCommand(Args ¤t_command_args, + uint32_t index) { CommandObject *proxy_command = GetProxyCommandObject(); if (proxy_command) return proxy_command->GetRepeatCommand(current_command_args, index); - return nullptr; + return llvm::None; } llvm::StringRef CommandObjectProxy::GetUnsupportedError() { |