public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r8-10721] libstdc++: Fix filesystem::path pretty printer test failure
@ 2021-01-11 17:44 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2021-01-11 17:44 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:6d1d6f7a4f3847615a2c2ad309ffa88145d9ffab
commit r8-10721-g6d1d6f7a4f3847615a2c2ad309ffa88145d9ffab
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Dec 2 00:39:21 2020 +0000
libstdc++: Fix filesystem::path pretty printer test failure
On some systems libstdc++-prettyprinters/cxx17.cc FAILs with this error:
skipping: Python Exception <type 'exceptions.AttributeError'> 'gdb.Type' object has no attribute 'name': ^M
got: $27 = filesystem::path "/dir/."^M
FAIL: libstdc++-prettyprinters/cxx17.cc print path2
The gdb.Type.name attribute isn't present in GDB 7.6, so we get an
exception from StdPathPrinter._iterator.__next__ trying to use it.
The StdPathPrinter._iterator is already passed the type's name in its
constructor, so we can just store that and use it instead of
gdb.Type.name.
libstdc++-v3/ChangeLog:
* python/libstdcxx/v6/printers.py (StdExpPathPrinter): Store the
name of the type and pass it to the iterator.
* testsuite/libstdc++-prettyprinters/filesystem-ts.cc: New test.
(cherry picked from commit a70384f94c83895f97179b45c1a8d66202132af8)
Diff:
---
libstdc++-v3/python/libstdcxx/v6/printers.py | 10 +++---
.../libstdc++-prettyprinters/filesystem-ts.cc | 39 ++++++++++++++++++++++
2 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index a476561b32e..ba9bbc096a0 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -1216,10 +1216,11 @@ class StdExpStringViewPrinter:
return 'string'
class StdExpPathPrinter:
- "Print a std::experimental::filesystem::path"
+ "Print a std::experimental::filesystem::path or std::filesystem::path"
def __init__ (self, typename, val):
self.val = val
+ self.typename = typename
start = self.val['_M_cmpts']['_M_impl']['_M_start']
finish = self.val['_M_cmpts']['_M_impl']['_M_finish']
self.num_cmpts = int (finish - start)
@@ -1241,7 +1242,8 @@ class StdExpPathPrinter:
return "filesystem::path %s" % path
class _iterator(Iterator):
- def __init__(self, cmpts):
+ def __init__(self, cmpts, pathtype):
+ self.pathtype = pathtype
self.item = cmpts['_M_impl']['_M_start']
self.finish = cmpts['_M_impl']['_M_finish']
self.count = 0
@@ -1257,13 +1259,13 @@ class StdExpPathPrinter:
self.count = self.count + 1
self.item = self.item + 1
path = item['_M_pathname']
- t = StdExpPathPrinter(item.type.name, item)._path_type()
+ t = StdExpPathPrinter(self.pathtype, item)._path_type()
if not t:
t = count
return ('[%s]' % t, path)
def children(self):
- return self._iterator(self.val['_M_cmpts'])
+ return self._iterator(self.val['_M_cmpts'], self.typename)
class StdPairPrinter:
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/filesystem-ts.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/filesystem-ts.cc
new file mode 100644
index 00000000000..8a1398f6c85
--- /dev/null
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/filesystem-ts.cc
@@ -0,0 +1,39 @@
+// { dg-options "-g -O0 -lstdc++fs" }
+// { dg-do run { target c++11 } }
+// { dg-require-filesystem-ts "" }
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/filesystem>
+#include <iostream>
+
+int
+main()
+{
+ std::experimental::filesystem::path path0;
+// { dg-final { note-test path0 {filesystem::path ""} } }
+ std::experimental::filesystem::path path1("filename");
+// { dg-final { note-test path1 {filesystem::path "filename"} } }
+ std::experimental::filesystem::path path2("/dir/.");
+// { dg-final { note-test path2 {filesystem::path "/dir/." = {[root-directory] = "/", [1] = "dir", [2] = "."}} } }
+
+ std::cout << "\n";
+ return 0; // Mark SPOT
+}
+
+// { dg-final { gdb-test SPOT } }
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-01-11 17:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-11 17:44 [gcc r8-10721] libstdc++: Fix filesystem::path pretty printer test failure Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).