• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisão5ac588997c3c2d032d5d5145d9245eb37354c23b (tree)
Hora2020-06-30 22:53:03
AutorTom Tromey <tromey@adac...>
CommiterTom Tromey

Mensagem de Log

Do not define basic_string_view::to_string

gdb's copy of basic_string_view includes a to_string method. However,
according to cppreference, this is not a method on the real
std::basic_string_view:

https://en.cppreference.com/w/cpp/string/basic_string_view

This difference matters because gdb_string_view.h will use the
standard implementation when built with a C++17 or later. This caused
PR build/26183.

This patch fixes the problem by changing the method to be a standalone
helper function, and then rewriting the uses. Tested by rebuilding
with a version of GCC that defaults to C++17.

(Note that the build still is not clean; and also I noticed that the
libstdc++ string_view forbids the use of nullptr ... I wonder if gdb
violates that.)

gdb/ChangeLog
2020-06-30 Tom Tromey <tromey@adacore.com>

PR build/26183:
* ada-lang.c (ada_lookup_name_info::ada_lookup_name_info): Use
gdb::to_string.

gdbsupport/ChangeLog
2020-06-30 Tom Tromey <tromey@adacore.com>

PR build/26183:
* gdb_string_view.h (basic_string_view::to_string): Remove.
(gdb::to_string): New function.

Mudança Sumário

Diff

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
1+2020-06-30 Tom Tromey <tromey@adacore.com>
2+
3+ PR build/26183:
4+ * ada-lang.c (ada_lookup_name_info::ada_lookup_name_info): Use
5+ gdb::to_string.
6+
17 2020-06-29 Simon Marchi <simon.marchi@efficios.com>
28
39 * gdbarch.sh (displaced_step_copy_insn): Update doc.
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13553,10 +13553,10 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
1355313553 {
1355413554 if (user_name.back () == '>')
1355513555 m_encoded_name
13556- = user_name.substr (1, user_name.size () - 2).to_string ();
13556+ = gdb::to_string (user_name.substr (1, user_name.size () - 2));
1355713557 else
1355813558 m_encoded_name
13559- = user_name.substr (1, user_name.size () - 1).to_string ();
13559+ = gdb::to_string (user_name.substr (1, user_name.size () - 1));
1356013560 m_encoded_p = true;
1356113561 m_verbatim_p = true;
1356213562 m_wild_match_p = false;
@@ -13575,10 +13575,10 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
1357513575 if (encoded != NULL)
1357613576 m_encoded_name = encoded;
1357713577 else
13578- m_encoded_name = user_name.to_string ();
13578+ m_encoded_name = gdb::to_string (user_name);
1357913579 }
1358013580 else
13581- m_encoded_name = user_name.to_string ();
13581+ m_encoded_name = gdb::to_string (user_name);
1358213582
1358313583 /* Handle the 'package Standard' special case. See description
1358413584 of m_standard_p. */
--- a/gdbsupport/ChangeLog
+++ b/gdbsupport/ChangeLog
@@ -1,3 +1,9 @@
1+2020-06-30 Tom Tromey <tromey@adacore.com>
2+
3+ PR build/26183:
4+ * gdb_string_view.h (basic_string_view::to_string): Remove.
5+ (gdb::to_string): New function.
6+
17 2020-06-27 Simon Marchi <simon.marchi@efficios.com>
28
39 * tdesc.h (class print_xml_feature) <add_line>: Add
--- a/gdbsupport/gdb_string_view.h
+++ b/gdbsupport/gdb_string_view.h
@@ -245,13 +245,6 @@ namespace gdb {
245245 return { this->_M_str, this->_M_len };
246246 }
247247
248- template<typename _Allocator = std::allocator<_CharT>>
249- std::basic_string<_CharT, _Traits, _Allocator>
250- to_string(const _Allocator& __alloc = _Allocator()) const
251- {
252- return { this->_M_str, this->_M_len, __alloc };
253- }
254-
255248 size_type
256249 copy(_CharT* __str, size_type __n, size_type __pos = 0) const
257250 {
@@ -560,4 +553,14 @@ namespace gdb {
560553
561554 #endif // __cplusplus < 201703L
562555
556+namespace gdb {
557+
558+static inline std::string
559+to_string(const gdb::string_view &view)
560+{
561+ return { view.data (), view.size () };
562+}
563+
564+}
565+
563566 #endif /* COMMON_GDB_STRING_VIEW_H */