]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[libstdc++] [prettyprint] add local std::string use to more tests
authorAlexandre Oliva <oliva@adacore.com>
Fri, 3 Mar 2023 18:59:33 +0000 (15:59 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Fri, 3 Mar 2023 19:06:46 +0000 (16:06 -0300)
We're getting regressions after ugprading to GDB 13 in a few of the
libstdc++ pretty-printing tests.  It might seem like a GDB regression,
but that update has a new symbol reader, and Tom Tromey says it
exposes a latent problem in the pretty-printer, namely, when a name is
not defined locally in the local translation unit, GDB will look for
it in other units, and if multiple different definitions are
available, there are no guarantees as to which one it will find.

Since libstdc++ contains units in which std::string maps to different
types, in order to ensure the tests get the std::string definition we
expect, we need std::string to be present in the debug information for
the test itself, as we already do in other tests.

for  libstdc++-v3/ChangeLog

* testsuite/libstdc++-prettyprinters/80276.cc: Add
std::string to debug info.
* testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise.

libstdc++-v3/testsuite/libstdc++-prettyprinters/80276.cc
libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc

index db4de593808e3ac370cbb1e372a1427ee790887a..1d6b0207106a6f7d5dae0d7f9f8bb27190998705 100644 (file)
@@ -36,6 +36,11 @@ int
 main()
 {
   using namespace std;
+  // Ensure debug info for std::string is issued in the local
+  // translation unit, so that GDB won't pick up any alternate
+  // std::string notion that might be present in libstdc++.so.
+  string bah = "hi";
+  (void)bah;
   unique_ptr<vector<unique_ptr<vector<int>*>>> p1;
   unique_ptr<vector<unique_ptr<set<int>*>>[]> p2;
   unique_ptr<set<unique_ptr<vector<int>*>>[10]> p3;
index b1c91033cc8e6b5f29fc8522498db4c90d30909f..29e8bc8f194e316e46113b3c61a8b3eec52a7cc0 100644 (file)
@@ -32,6 +32,12 @@ using std::experimental::string_view;
 int
 main()
 {
+  // Ensure debug info for std::string is issued in the local
+  // translation unit, so that GDB won't pick up any alternate
+  // std::string notion that might be present in libstdc++.so.
+  std::string bah = "hi";
+  (void)bah;
+
   string_view str = "string";
 // { dg-final { note-test str "\"string\"" } }