aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Commands')
-rw-r--r--lldb/source/Commands/CommandObjectCommands.cpp6
-rw-r--r--lldb/source/Commands/CommandObjectMemory.cpp18
-rw-r--r--lldb/source/Commands/CommandObjectMultiword.cpp16
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp6
-rw-r--r--lldb/source/Commands/CommandObjectSource.cpp8
-rw-r--r--lldb/source/Commands/CommandObjectThread.cpp60
6 files changed, 84 insertions, 30 deletions
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index 4b4932d..ebb84bc 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -56,9 +56,9 @@ public:
~CommandObjectCommandsSource() override = default;
- const char *GetRepeatCommand(Args &current_command_args,
- uint32_t index) override {
- return "";
+ llvm::Optional<std::string> GetRepeatCommand(Args &current_command_args,
+ uint32_t index) override {
+ return std::string("");
}
void
diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp
index 1033d13..fe33dfa 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -345,9 +345,9 @@ public:
Options *GetOptions() override { return &m_option_group; }
- const char *GetRepeatCommand(Args &current_command_args,
- uint32_t index) override {
- return m_cmd_name.c_str();
+ llvm::Optional<std::string> GetRepeatCommand(Args &current_command_args,
+ uint32_t index) override {
+ return m_cmd_name;
}
protected:
@@ -1586,9 +1586,9 @@ public:
~CommandObjectMemoryHistory() override = default;
- const char *GetRepeatCommand(Args &current_command_args,
- uint32_t index) override {
- return m_cmd_name.c_str();
+ llvm::Optional<std::string> GetRepeatCommand(Args &current_command_args,
+ uint32_t index) override {
+ return m_cmd_name;
}
protected:
@@ -1750,11 +1750,11 @@ protected:
return false;
}
- const char *GetRepeatCommand(Args &current_command_args,
- uint32_t index) override {
+ llvm::Optional<std::string> GetRepeatCommand(Args &current_command_args,
+ uint32_t index) override {
// If we repeat this command, repeat it without any arguments so we can
// show the next memory range
- return m_cmd_name.c_str();
+ return m_cmd_name;
}
lldb::addr_t m_prev_end_addr;
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 &current_command_args,
- uint32_t index) {
+llvm::Optional<std::string>
+CommandObjectMultiword::GetRepeatCommand(Args &current_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 &current_command_args,
- uint32_t index) {
+llvm::Optional<std::string>
+CommandObjectProxy::GetRepeatCommand(Args &current_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() {
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index c73f0df..459aef6 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -145,10 +145,10 @@ public:
Options *GetOptions() override { return &m_all_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 {
// No repeat for "process launch"...
- return "";
+ return std::string("");
}
protected:
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:
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index f604293..4108adf 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -125,6 +125,58 @@ public:
Options *GetOptions() override { return &m_options; }
+ llvm::Optional<std::string> GetRepeatCommand(Args &current_args,
+ uint32_t idx) override {
+ llvm::StringRef count_opt("--count");
+ llvm::StringRef start_opt("--start");
+
+ // If no "count" was provided, we are dumping the entire backtrace, so
+ // there isn't a repeat command. So we search for the count option in
+ // the args, and if we find it, we make a copy and insert or modify the
+ // start option's value to start count indices greater.
+
+ Args copy_args(current_args);
+ size_t num_entries = copy_args.GetArgumentCount();
+ // These two point at the index of the option value if found.
+ size_t count_idx = 0;
+ size_t start_idx = 0;
+ size_t count_val = 0;
+ size_t start_val = 0;
+
+ for (size_t idx = 0; idx < num_entries; idx++) {
+ llvm::StringRef arg_string = copy_args[idx].ref();
+ if (arg_string.equals("-c") || count_opt.startswith(arg_string)) {
+ idx++;
+ if (idx == num_entries)
+ return llvm::None;
+ count_idx = idx;
+ if (copy_args[idx].ref().getAsInteger(0, count_val))
+ return llvm::None;
+ } else if (arg_string.equals("-s") || start_opt.startswith(arg_string)) {
+ idx++;
+ if (idx == num_entries)
+ return llvm::None;
+ start_idx = idx;
+ if (copy_args[idx].ref().getAsInteger(0, start_val))
+ return llvm::None;
+ }
+ }
+ if (count_idx == 0)
+ return llvm::None;
+
+ std::string new_start_val = llvm::formatv("{0}", start_val + count_val);
+ if (start_idx == 0) {
+ copy_args.AppendArgument(start_opt);
+ copy_args.AppendArgument(new_start_val);
+ } else {
+ copy_args.ReplaceArgumentAtIndex(start_idx, new_start_val);
+ }
+ std::string repeat_command;
+ if (!copy_args.GetQuotedCommandString(repeat_command))
+ return llvm::None;
+ return repeat_command;
+ }
+
protected:
void DoExtendedBacktrace(Thread *thread, CommandReturnObject &result) {
SystemRuntime *runtime = thread->GetProcess()->GetSystemRuntime();
@@ -960,7 +1012,7 @@ protected:
uint32_t index_ptr = 0, end_ptr;
std::vector<addr_t> address_list;
- // Find the beginning & end index of the
+ // Find the beginning & end index of the
AddressRange fun_addr_range = sc.function->GetAddressRange();
Address fun_start_addr = fun_addr_range.GetBaseAddress();
line_table->FindLineEntryByAddress(fun_start_addr, function_start,
@@ -2132,11 +2184,11 @@ 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 {
current_command_args.GetCommandString(m_repeat_command);
m_create_repeat_command_just_invoked = true;
- return m_repeat_command.c_str();
+ return m_repeat_command;
}
protected: