[Lldb-commits] [PATCH] D119046: Add a repeat command option for "thread backtrace --count N".

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Feb 4 16:29:17 PST 2022


jingham created this revision.
jingham added a reviewer: JDevlieghere.
jingham requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

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 10 frames at a time.
Previously the repeat just redid the previous command.  "thread backtrace" without a
--count will continue to just dump the complete 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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119046

Files:
  lldb/include/lldb/Interpreter/CommandObject.h
  lldb/include/lldb/Interpreter/CommandObjectMultiword.h
  lldb/source/API/SBCommandInterpreter.cpp
  lldb/source/Commands/CommandObjectCommands.cpp
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/source/Commands/CommandObjectMultiword.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Commands/CommandObjectSource.cpp
  lldb/source/Commands/CommandObjectThread.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/test/API/commands/thread/backtrace/Makefile
  lldb/test/API/commands/thread/backtrace/TestThreadBacktraceRepeat.py
  lldb/test/API/commands/thread/backtrace/main.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119046.406125.patch
Type: text/x-patch
Size: 21745 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220205/9e1a03dd/attachment-0001.bin>


More information about the lldb-commits mailing list