aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectSource.cpp
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2022-02-04 15:16:31 -0800
committerJim Ingham <jingham@apple.com>2022-02-14 15:48:06 -0800
commit635f03fe976e250cc64999663f47716412dfa029 (patch)
treef4f49f4aae21d4d9393775a90f9e43db5a8db2f1 /lldb/source/Commands/CommandObjectSource.cpp
parenta7c2a6289c22624f8b21b6c0e3f27047c4d4113d (diff)
downloadllvm-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/CommandObjectSource.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectSource.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp
index 6c6706f..79f1ce4 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -728,8 +728,8 @@ public:
Options *GetOptions() override { return &m_options; }
- const char *GetRepeatCommand(Args &current_command_args,
- uint32_t index) override {
+ llvm::Optional<std::string> GetRepeatCommand(Args &current_command_args,
+ uint32_t index) override {
// This is kind of gross, but the command hasn't been parsed yet so we
// can't look at the option values for this invocation... I have to scan
// the arguments directly.
@@ -738,13 +738,13 @@ public:
return e.ref() == "-r" || e.ref() == "--reverse";
});
if (iter == current_command_args.end())
- return m_cmd_name.c_str();
+ return m_cmd_name;
if (m_reverse_name.empty()) {
m_reverse_name = m_cmd_name;
m_reverse_name.append(" -r");
}
- return m_reverse_name.c_str();
+ return m_reverse_name;
}
protected: