[Lldb-commits] [PATCH] D138315: [lldb] Introduce dwim-print command

Dave Lee via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Nov 18 11:39:26 PST 2022


kastiglione created this revision.
kastiglione added reviewers: JDevlieghere, aprantl, jingham, labath, werat, cmtice.
Herald added a project: All.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Implements `dwim-print`, a printing command that chooses the most direct, efficient, and resilient means of printing a given expression.

DWIM is an acronym for Do What I Mean. From Wikipedia, DWIM is described as:

  > attempt to anticipate what users intend to do, correcting trivial errors
  > automatically rather than blindly executing users' explicit but
  > potentially incorrect input

The `dwim-print` command serves as a single print command for users who don't yet know, or prefer not to know, the various lldb commands that can be used to print, and when to use them.

This initial implementation is the base foundation for `dwim-print`. It accepts no flags, only an expression. If the expression is the name of a variable in the frame, then effectively `frame variable` is used to get, and print, its value. Otherwise, printing falls back to using `expression` evaluation. In this initial version, frame variable paths will be handled with `expression`.

Following this, there are a number of improvements that can be made. Some improvements include supporting `frame variable` expressions or registers.

To provide transparency, especially as the `dwim-print` command evolves, a new setting is also introduced: `dwim-print-verbosity`. This setting instructs `dwim-print` optionally to print a message showing the effective command being run. For example `dwim-print var.meth()` can print a message such as: "note: ran `expression var.meth()`.

See https://discourse.llvm.org/t/dwim-print-command/66078 for the proposal and discussion.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138315

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/source/Commands/CMakeLists.txt
  lldb/source/Commands/CommandObjectDWIMPrint.cpp
  lldb/source/Commands/CommandObjectDWIMPrint.h
  lldb/source/Core/CoreProperties.td
  lldb/source/Core/Debugger.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/test/API/commands/dwim-print/Makefile
  lldb/test/API/commands/dwim-print/TestDWIMPrint.py
  lldb/test/API/commands/dwim-print/main.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138315.476540.patch
Type: text/x-patch
Size: 12030 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20221118/81c7ba39/attachment-0001.bin>


More information about the lldb-commits mailing list