[Lldb-commits] [PATCH] D148531: [lldb][DataFormatter] Fix libcxx std::deque formatter for references and pointers

Michael Buch via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 17 07:09:40 PDT 2023


Michael137 created this revision.
Michael137 added reviewers: aprantl, jingham.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

(Addresses GH#62153)

The `SBType` APIs to retrieve details about template arguments,
such as `GetTemplateArgumentType` or `GetTemplateArgumentKind`
don't "desugar" LValueReferences/RValueReferences or pointers.
So when we try to format a `std::deque&`, the python call to
`GetTemplateArgumentType` fails to get a type, leading to
an `element_size` of `0` and a division-by-zero python exception
(which gets caught by the summary provider silently). This leads
to the contents of such `std::deque&` to be printed incorrectly.

This patch dereferences the reference/pointer before calling
into the above SBAPIs.

**Testing**

- Add API test


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148531

Files:
  lldb/examples/synthetic/libcxx.py
  lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/Makefile
  lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/TestDataFormatterLibcxxDeque.py
  lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/main.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148531.514220.patch
Type: text/x-patch
Size: 5203 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230417/575dd87a/attachment.bin>


More information about the lldb-commits mailing list