[Lldb-commits] [lldb] [lldb] Add repeat command for `frame variable` (PR #194195)
Dave Lee via lldb-commits
lldb-commits at lists.llvm.org
Tue Apr 28 12:56:05 PDT 2026
================
@@ -435,6 +437,70 @@ may even involve JITing and running code in the target program.)");
Options *GetOptions() override { return &m_option_group; }
+ // `frame variable` repeats by incrementing the printing depth. When the depth
+ // is too shallow, hitting enter a few times will quickly expand the data.
+ std::optional<std::string> GetRepeatCommand(Args ¤t_command_args,
+ uint32_t index) override {
+ Args repeat_args;
+ auto increment_option =
+ [&](llvm::StringRef option) -> std::optional<std::string> {
+ uint32_t num;
+ bool failed = option.getAsInteger(10, num);
+ if (failed)
+ return std::nullopt;
+ return llvm::utostr(num + 1);
+ };
+
+ bool has_depth_option = false;
+ bool increment_next_arg = false;
+ for (const auto &entry : current_command_args) {
+ llvm::StringRef arg = entry.ref();
+
+ if (increment_next_arg) {
+ increment_next_arg = false;
+ if (auto maybe_opt = increment_option(arg)) {
+ repeat_args.AppendArgument(*maybe_opt);
+ continue;
+ }
+ }
+
+ if (arg == "--depth" || arg == "-D") {
----------------
kastiglione wrote:
Thanks for pointing this out. I followed the approach of `CommandObjectThreadBacktrace` which does:
```cpp
llvm::StringRef count_opt("--count");
...
if (arg == "-c" || count_opt.starts_with(arg)) {
...
}
```
I added a test for `--de` too.
https://github.com/llvm/llvm-project/pull/194195
More information about the lldb-commits
mailing list