[Lldb-commits] [PATCH] D124155: [lldb] Add tests which simulate the various std::string layouts

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 21 02:22:41 PDT 2022


labath created this revision.
labath added reviewers: shafik, philnik.
Herald added a project: All.
labath requested review of this revision.
Herald added a project: LLDB.

Checking whether a formatter change does not break some of the supported
string layouts is difficult because it requires tracking down and/or
building different versions and build configurations of the library.

The purpose of this patch is to avoid that by providing an in-tree
simulation of the string class. It is a reduced version of the real
string class, obtained by elimitating all non-trivial code, leaving
just the internal data structures used by the data formatter. Different
versions of the class can be simulated through preprocessor defines.

The test (ab)uses the fact that our formatters kick in for any
double-underscore sub-namespace of `std`, so it avoids colliding with
the real string class by declaring the test class in the std::__lldb
namespace.

I do not consider this to be a replacement for the existing data
formatter tests, as producing this kind of a test is not trivial, and it
is easy to make a mistake in the process. However, it's also not
realistic to expect that every person changing the data formatter will
test it against all versions of the real class, so I think it can be
useful as a first line of defence.

Adding support for new layouts can become particularly unwieldy, but
this complexity will also be reflected in the actual code, so if we find
ourselves needing to support too many variants, we may need to start
dropping support for old ones, or come up with a completely different
strategy.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124155

Files:
  lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/simulator/Makefile
  lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/simulator/TestDataFormatterLibcxxStringSimulator.py
  lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/simulator/a.out
  lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/simulator/main.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124155.424130.patch
Type: text/x-patch
Size: 8085 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220421/c4da94b4/attachment-0001.bin>


More information about the lldb-commits mailing list