]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: Use std::string_view instead of gdb::string_view
authorLancelot Six <lancelot.six@amd.com>
Fri, 13 Oct 2023 10:17:02 +0000 (10:17 +0000)
committerLancelot Six <lancelot.six@amd.com>
Tue, 21 Nov 2023 11:52:36 +0000 (11:52 +0000)
Given that GDB now requires a C++17, replace all uses of
gdb::string_view with std::string_view.

This change has mostly been done automatically:
- gdb::string_view -> std::string_view
- #include "gdbsupport/gdb_string_view.h" -> #include <string_view>

One things which got brought up during review is that gdb::stging_view
does support being built from "nullptr" while std::sting_view does not.
Two places are manually adjusted to account for this difference:
gdb/tui/tui-io.c:tui_getc_1 and
gdbsupport/format.h:format_piece::format_piece.

The above automatic change transformed
"gdb::to_string (const gdb::string_view &)" into
"gdb::to_string (const std::string_view &)".  The various direct users
of this function are now explicitly including
"gdbsupport/gdb_string_view.h".  A later patch will remove the users of
gdb::to_string.

The implementation and tests of gdb::string_view are unchanged, they will
be removed in a following patch.

Change-Id: Ibb806a7e9c79eb16a55c87c6e41ad396fecf0207
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
31 files changed:
gdb/ada-lang.c
gdb/amdgpu-tdep.c
gdb/cli/cli-script.c
gdb/dbxread.c
gdb/debuginfod-support.c
gdb/dwarf2/cooked-index.c
gdb/dwarf2/cooked-index.h
gdb/dwarf2/index-common.c
gdb/dwarf2/index-common.h
gdb/dwarf2/read.c
gdb/elfread.c
gdb/eval.c
gdb/language.c
gdb/linux-tdep.c
gdb/mdebugread.c
gdb/minsyms.c
gdb/minsyms.h
gdb/psymtab.c
gdb/psymtab.h
gdb/solib-rocm.c
gdb/split-name.c
gdb/split-name.h
gdb/stabsread.c
gdb/symtab.c
gdb/symtab.h
gdb/tui/tui-io.c
gdb/tui/tui-win.c
gdb/xcoffread.c
gdbsupport/common-utils.h
gdbsupport/format.h
gdbsupport/gdb_string_view.h

index 58c70160d313035fb08493d7abc7b2e42507b692..843583ecb4079aa9bb274da26db0cfa319d1ad8d 100644 (file)
@@ -58,6 +58,7 @@
 #include "gdbsupport/function-view.h"
 #include "gdbsupport/byte-vector.h"
 #include "gdbsupport/selftest.h"
+#include "gdbsupport/gdb_string_view.h"
 #include <algorithm>
 #include "ada-exp.h"
 #include "charset.h"
@@ -1035,7 +1036,7 @@ find_case_fold_entry (uint32_t c)
    rather than emitting a warning.  Result good to next call.  */
 
 static const char *
-ada_fold_name (gdb::string_view name, bool throw_on_error = false)
+ada_fold_name (std::string_view name, bool throw_on_error = false)
 {
   static std::string fold_storage;
 
@@ -13250,7 +13251,7 @@ do_exact_match (const char *symbol_search_name,
 
 ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
 {
-  gdb::string_view user_name = lookup_name.name ();
+  std::string_view user_name = lookup_name.name ();
 
   if (!user_name.empty () && user_name[0] == '<')
     {
@@ -13269,7 +13270,7 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
     {
       m_verbatim_p = false;
 
-      m_encoded_p = user_name.find ("__") != gdb::string_view::npos;
+      m_encoded_p = user_name.find ("__") != std::string_view::npos;
 
       if (!m_encoded_p)
        {
@@ -13326,7 +13327,7 @@ literal_symbol_name_matcher (const char *symbol_search_name,
                             const lookup_name_info &lookup_name,
                             completion_match_result *comp_match_res)
 {
-  gdb::string_view name_view = lookup_name.name ();
+  std::string_view name_view = lookup_name.name ();
 
   if (lookup_name.completion_mode ()
       ? (strncmp (symbol_search_name, name_view.data (),
index 3a521a43977cdbc3d91e95107dd88ad5383c1ac3..58d26fc0b6bba3dca694f81337b17968a93ce1ac 100644 (file)
@@ -27,6 +27,7 @@
 #include "frame-unwind.h"
 #include "gdbarch.h"
 #include "gdbsupport/selftest.h"
+#include "gdbsupport/gdb_string_view.h"
 #include "gdbtypes.h"
 #include "inferior.h"
 #include "objfiles.h"
@@ -237,7 +238,7 @@ struct amd_dbgapi_register_type_flags : public amd_dbgapi_register_type
   using container_type = std::vector<field>;
   using const_iterator_type = container_type::const_iterator;
 
-  amd_dbgapi_register_type_flags (unsigned int bit_size, gdb::string_view name)
+  amd_dbgapi_register_type_flags (unsigned int bit_size, std::string_view name)
     : amd_dbgapi_register_type (kind::FLAGS,
                                make_lookup_name (bit_size, name)),
       m_bit_size (bit_size),
@@ -270,7 +271,7 @@ struct amd_dbgapi_register_type_flags : public amd_dbgapi_register_type
   const std::string &name () const
   { return m_name; }
 
-  static std::string make_lookup_name (int bits, gdb::string_view name)
+  static std::string make_lookup_name (int bits, std::string_view name)
   {
     std::string res = string_printf ("flags%d_t ", bits);
     res.append (name.data (), name.size ());
@@ -297,7 +298,7 @@ struct amd_dbgapi_register_type_enum : public amd_dbgapi_register_type
   using container_type = std::vector<enumerator>;
   using const_iterator_type = container_type::const_iterator;
 
-  amd_dbgapi_register_type_enum (gdb::string_view name)
+  amd_dbgapi_register_type_enum (std::string_view name)
     : amd_dbgapi_register_type (kind::ENUM, make_lookup_name (name)),
       m_name (name.data (), name.length ())
   {}
@@ -326,7 +327,7 @@ struct amd_dbgapi_register_type_enum : public amd_dbgapi_register_type
   const std::string &name () const
   { return m_name; }
 
-  static std::string make_lookup_name (gdb::string_view name)
+  static std::string make_lookup_name (std::string_view name)
   {
     std::string res = "enum ";
     res.append (name.data (), name.length ());
@@ -349,7 +350,7 @@ using amd_dbgapi_register_type_map
 /* Parse S as a ULONGEST, raise an error on overflow.  */
 
 static ULONGEST
-try_strtoulst (gdb::string_view s)
+try_strtoulst (std::string_view s)
 {
   errno = 0;
   ULONGEST value = strtoulst (s.data (), nullptr, 0);
@@ -365,7 +366,7 @@ try_strtoulst (gdb::string_view s)
 #define WSOPT "[ \t]*"
 
 static const amd_dbgapi_register_type &
-parse_amd_dbgapi_register_type (gdb::string_view type_name,
+parse_amd_dbgapi_register_type (std::string_view type_name,
                                amd_dbgapi_register_type_map &type_map);
 
 
@@ -373,7 +374,7 @@ parse_amd_dbgapi_register_type (gdb::string_view type_name,
 
 static void
 parse_amd_dbgapi_register_type_enum_fields
-  (amd_dbgapi_register_type_enum &enum_type, gdb::string_view fields)
+  (amd_dbgapi_register_type_enum &enum_type, std::string_view fields)
 {
   compiled_regex regex (/* name */
                        "^(" IDENTIFIER ")"
@@ -394,8 +395,8 @@ parse_amd_dbgapi_register_type_enum_fields
       auto sv_from_match = [fields] (const regmatch_t &m)
        { return fields.substr (m.rm_so, m.rm_eo - m.rm_so); };
 
-      gdb::string_view name = sv_from_match (matches[1]);
-      gdb::string_view value_str = sv_from_match (matches[2]);
+      std::string_view name = sv_from_match (matches[1]);
+      std::string_view value_str = sv_from_match (matches[2]);
       ULONGEST value = try_strtoulst (value_str);
 
       if (value > std::numeric_limits<uint32_t>::max ())
@@ -412,7 +413,7 @@ parse_amd_dbgapi_register_type_enum_fields
 static void
 parse_amd_dbgapi_register_type_flags_fields
   (amd_dbgapi_register_type_flags &flags_type,
-   int bits, gdb::string_view name, gdb::string_view fields,
+   int bits, std::string_view name, std::string_view fields,
    amd_dbgapi_register_type_map &type_map)
 {
   gdb_assert (bits == 32 || bits == 64);
@@ -439,9 +440,9 @@ parse_amd_dbgapi_register_type_flags_fields
       auto sv_from_match = [fields] (const regmatch_t &m)
        { return fields.substr (m.rm_so, m.rm_eo - m.rm_so); };
 
-      gdb::string_view field_type_str = sv_from_match (matches[1]);
-      gdb::string_view field_name = sv_from_match (matches[3]);
-      gdb::string_view pos_begin_str = sv_from_match (matches[4]);
+      std::string_view field_type_str = sv_from_match (matches[1]);
+      std::string_view field_name = sv_from_match (matches[3]);
+      std::string_view pos_begin_str = sv_from_match (matches[4]);
       ULONGEST pos_begin = try_strtoulst (pos_begin_str);
 
       if (field_type_str == "bool")
@@ -452,7 +453,7 @@ parse_amd_dbgapi_register_type_flags_fields
          if (matches[5].rm_so == -1)
            error (_("Missing end bit position"));
 
-         gdb::string_view pos_end_str = sv_from_match (matches[5]);
+         std::string_view pos_end_str = sv_from_match (matches[5]);
          ULONGEST pos_end = try_strtoulst (pos_end_str.substr (1));
          const amd_dbgapi_register_type &field_type
            = parse_amd_dbgapi_register_type (field_type_str, type_map);
@@ -467,7 +468,7 @@ parse_amd_dbgapi_register_type_flags_fields
 /* parse_amd_dbgapi_register_type helper for scalars.  */
 
 static const amd_dbgapi_register_type &
-parse_amd_dbgapi_register_type_scalar (gdb::string_view name,
+parse_amd_dbgapi_register_type_scalar (std::string_view name,
                                       amd_dbgapi_register_type_map &type_map)
 {
   std::string name_str = gdb::to_string (name);
@@ -513,24 +514,24 @@ parse_amd_dbgapi_register_type_scalar (gdb::string_view name,
    details about the format.  */
 
 static const amd_dbgapi_register_type &
-parse_amd_dbgapi_register_type (gdb::string_view type_str,
+parse_amd_dbgapi_register_type (std::string_view type_str,
                                amd_dbgapi_register_type_map &type_map)
 {
   size_t pos_open_bracket = type_str.find_last_of ('[');
   auto sv_from_match = [type_str] (const regmatch_t &m)
     { return type_str.substr (m.rm_so, m.rm_eo - m.rm_so); };
 
-  if (pos_open_bracket != gdb::string_view::npos)
+  if (pos_open_bracket != std::string_view::npos)
     {
       /* Vector types.  */
-      gdb::string_view element_type_str
+      std::string_view element_type_str
        = type_str.substr (0, pos_open_bracket);
       const amd_dbgapi_register_type &element_type
        = parse_amd_dbgapi_register_type (element_type_str, type_map);
 
       size_t pos_close_bracket = type_str.find_last_of (']');
-      gdb_assert (pos_close_bracket != gdb::string_view::npos);
-      gdb::string_view count_str_view
+      gdb_assert (pos_close_bracket != std::string_view::npos);
+      std::string_view count_str_view
        = type_str.substr (pos_open_bracket + 1,
                            pos_close_bracket - pos_open_bracket);
       std::string count_str = gdb::to_string (count_str_view);
@@ -567,9 +568,9 @@ parse_amd_dbgapi_register_type (gdb::string_view type_str,
       if (res == REG_NOMATCH)
        error (_("Failed to parse flags type string"));
 
-      gdb::string_view flags_keyword = sv_from_match (matches[1]);
+      std::string_view flags_keyword = sv_from_match (matches[1]);
       unsigned int bit_size = flags_keyword == "flags32_t" ? 32 : 64;
-      gdb::string_view name = sv_from_match (matches[2]);
+      std::string_view name = sv_from_match (matches[2]);
       std::string lookup_name
        = amd_dbgapi_register_type_flags::make_lookup_name (bit_size, name);
       auto existing_type_it = type_map.find (lookup_name);
@@ -596,7 +597,7 @@ parse_amd_dbgapi_register_type (gdb::string_view type_str,
 
          amd_dbgapi_register_type_flags_up flags_type
            (new amd_dbgapi_register_type_flags (bit_size, name));
-         gdb::string_view fields_without_braces = sv_from_match (matches[4]);
+         std::string_view fields_without_braces = sv_from_match (matches[4]);
 
          parse_amd_dbgapi_register_type_flags_fields
            (*flags_type, bit_size, name, fields_without_braces, type_map);
@@ -620,7 +621,7 @@ parse_amd_dbgapi_register_type (gdb::string_view type_str,
       if (res == REG_NOMATCH)
        error (_("Failed to parse flags type string"));
 
-      gdb::string_view name = sv_from_match (matches[1]);
+      std::string_view name = sv_from_match (matches[1]);
 
       std::string lookup_name
        = amd_dbgapi_register_type_enum::make_lookup_name (name);
@@ -648,7 +649,7 @@ parse_amd_dbgapi_register_type (gdb::string_view type_str,
 
          amd_dbgapi_register_type_enum_up enum_type
            (new amd_dbgapi_register_type_enum (name));
-         gdb::string_view fields_without_braces = sv_from_match (matches[3]);
+         std::string_view fields_without_braces = sv_from_match (matches[3]);
 
          parse_amd_dbgapi_register_type_enum_fields
            (*enum_type, fields_without_braces);
index 8ec5689ebcfdda09f592cd8172a39a69d3c4e921..b355a6dc81ed82e0cfad940bbe709ef58bb852f8 100644 (file)
@@ -35,7 +35,7 @@
 #include "extension.h"
 #include "interps.h"
 #include "compile/compile.h"
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 #include "python/python.h"
 #include "guile/guile.h"
 
@@ -103,7 +103,7 @@ private:
   std::string m_command_line;
 
   /* The arguments.  Each element points inside M_COMMAND_LINE.  */
-  std::vector<gdb::string_view> m_args;
+  std::vector<std::string_view> m_args;
 };
 
 /* The stack of arguments passed to user defined functions.  We need a
index 3afafa77fb49fa929474f962170717fb2ad75c5c..b92193bdadd7996a827cbdedf5a2e0d79bceb390 100644 (file)
@@ -1483,7 +1483,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
            {
            case 'S':
              if (pst != nullptr)
-               pst->add_psymbol (gdb::string_view (sym_name, sym_len), true,
+               pst->add_psymbol (std::string_view (sym_name, sym_len), true,
                                  VAR_DOMAIN, LOC_STATIC,
                                  data_sect_index,
                                  psymbol_placement::STATIC,
@@ -1500,7 +1500,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
              /* The addresses in these entries are reported to be
                 wrong.  See the code that reads 'G's for symtabs.  */
              if (pst != nullptr)
-               pst->add_psymbol (gdb::string_view (sym_name, sym_len), true,
+               pst->add_psymbol (std::string_view (sym_name, sym_len), true,
                                  VAR_DOMAIN, LOC_STATIC,
                                  data_sect_index,
                                  psymbol_placement::GLOBAL,
@@ -1525,7 +1525,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
                      && namestring[0] != ' '))
                {
                  if (pst != nullptr)
-                   pst->add_psymbol (gdb::string_view (sym_name, sym_len),
+                   pst->add_psymbol (std::string_view (sym_name, sym_len),
                                      true, STRUCT_DOMAIN, LOC_TYPEDEF, -1,
                                      psymbol_placement::STATIC,
                                      unrelocated_addr (0),
@@ -1540,7 +1540,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
                    {
                      /* Also a typedef with the same name.  */
                      if (pst != nullptr)
-                       pst->add_psymbol (gdb::string_view (sym_name, sym_len),
+                       pst->add_psymbol (std::string_view (sym_name, sym_len),
                                          true, VAR_DOMAIN, LOC_TYPEDEF, -1,
                                          psymbol_placement::STATIC,
                                          unrelocated_addr (0),
@@ -1559,7 +1559,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
              if (p != namestring)      /* a name is there, not just :T...  */
                {
                  if (pst != nullptr)
-                   pst->add_psymbol (gdb::string_view (sym_name, sym_len),
+                   pst->add_psymbol (std::string_view (sym_name, sym_len),
                                      true, VAR_DOMAIN, LOC_TYPEDEF, -1,
                                      psymbol_placement::STATIC,
                                      unrelocated_addr (0),
@@ -1627,7 +1627,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
                      /* Note that the value doesn't matter for
                         enum constants in psymtabs, just in symtabs.  */
                      if (pst != nullptr)
-                       pst->add_psymbol (gdb::string_view (p, q - p), true,
+                       pst->add_psymbol (std::string_view (p, q - p), true,
                                          VAR_DOMAIN, LOC_CONST, -1,
                                          psymbol_placement::STATIC,
                                          unrelocated_addr (0),
@@ -1652,7 +1652,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
            case 'c':
              /* Constant, e.g. from "const" in Pascal.  */
              if (pst != nullptr)
-               pst->add_psymbol (gdb::string_view (sym_name, sym_len), true,
+               pst->add_psymbol (std::string_view (sym_name, sym_len), true,
                                  VAR_DOMAIN, LOC_CONST, -1,
                                  psymbol_placement::STATIC,
                                  unrelocated_addr (0),
@@ -1712,7 +1712,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
                  textlow_not_set = 0;
                }
              if (pst != nullptr)
-               pst->add_psymbol (gdb::string_view (sym_name, sym_len), true,
+               pst->add_psymbol (std::string_view (sym_name, sym_len), true,
                                  VAR_DOMAIN, LOC_BLOCK,
                                  SECT_OFF_TEXT (objfile),
                                  psymbol_placement::STATIC,
@@ -1771,7 +1771,7 @@ read_dbx_symtab (minimal_symbol_reader &reader,
                  textlow_not_set = 0;
                }
              if (pst != nullptr)
-               pst->add_psymbol (gdb::string_view (sym_name, sym_len), true,
+               pst->add_psymbol (std::string_view (sym_name, sym_len), true,
                                  VAR_DOMAIN, LOC_BLOCK,
                                  SECT_OFF_TEXT (objfile),
                                  psymbol_placement::GLOBAL,
index 1ebd98ca705e96a64995fab3c66c25ab9b71f8f9..a989eb9cb977343c833afbf88b87b9cef7870cba 100644 (file)
@@ -20,6 +20,7 @@
 #include "diagnostics.h"
 #include <errno.h>
 #include "gdbsupport/scoped_fd.h"
+#include "gdbsupport/gdb_string_view.h"
 #include "debuginfod-support.h"
 #include <optional>
 #include "cli/cli-cmds.h"
@@ -246,11 +247,11 @@ debuginfod_is_enabled ()
       gdb_printf (_("\nThis GDB supports auto-downloading debuginfo " \
                    "from the following URLs:\n"));
 
-      gdb::string_view url_view (urls);
+      std::string_view url_view (urls);
       while (true)
        {
          size_t off = url_view.find_first_not_of (' ');
-         if (off == gdb::string_view::npos)
+         if (off == std::string_view::npos)
            break;
          url_view = url_view.substr (off);
          /* g++ 11.2.1 on s390x, g++ 11.3.1 on ppc64le and g++ 11 on
@@ -266,7 +267,7 @@ debuginfod_is_enabled ()
             styled_string (file_name_style.style (),
                            gdb::to_string (url_view.substr (0,
                                                             off)).c_str ()));
-         if (off == gdb::string_view::npos)
+         if (off == std::string_view::npos)
            break;
          url_view = url_view.substr (off);
        }
index 58ea541a5c93abfc22f65e83d1abac0d9d949244..7c4af3a168186cd957c848eae1e4309504403343 100644 (file)
@@ -266,9 +266,9 @@ cooked_index_shard::handle_gnat_encoded_entry (cooked_index_entry *entry,
   std::string canonical = ada_decode (entry->name, false, false);
   if (canonical.empty ())
     return {};
-  std::vector<gdb::string_view> names = split_name (canonical.c_str (),
+  std::vector<std::string_view> names = split_name (canonical.c_str (),
                                                    split_style::DOT_STYLE);
-  gdb::string_view tail = names.back ();
+  std::string_view tail = names.back ();
   names.pop_back ();
 
   const cooked_index_entry *parent = nullptr;
@@ -333,7 +333,7 @@ cooked_index_shard::do_finalize ()
   auto eq_entry = [] (const void *a, const void *b) -> int
     {
       const cooked_index_entry *ae = (const cooked_index_entry *) a;
-      const gdb::string_view *sv = (const gdb::string_view *) b;
+      const std::string_view *sv = (const std::string_view *) b;
       return (strlen (ae->canonical) == sv->length ()
              && strncasecmp (ae->canonical, sv->data (), sv->length ()) == 0);
     };
index 5aacb321c9199b5f64e118c5300f4f5a42a4754b..5675ea68bb8d7e6fcaa21e47051c77c3c9cacf39 100644 (file)
@@ -25,7 +25,7 @@
 #include "symtab.h"
 #include "hashtab.h"
 #include "dwarf2/index-common.h"
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 #include "quick-symbol.h"
 #include "gdbsupport/gdb_obstack.h"
 #include "addrmap.h"
index 07330a86da1daea55e5c1121951b2812b63bbd03..04b04f93a61bc21fb277fd1fa6f2077cd6b83702 100644 (file)
@@ -58,7 +58,7 @@ dwarf5_djb_hash (const char *str_)
 /* See dwarf-index-common.h.  */
 
 uint32_t
-dwarf5_djb_hash (gdb::string_view str)
+dwarf5_djb_hash (std::string_view str)
 {
   /* Note: tolower here ignores UTF-8, which isn't fully compliant.
      See http://dwarfstd.org/ShowIssue.php?issue=161027.1.  */
index 23e814a240bf9cfee5fec71a35606a2e7c8cccb5..79d3a59220e1892beb24dc4df5795cb270848ae9 100644 (file)
@@ -54,6 +54,6 @@ uint32_t dwarf5_djb_hash (const char *str_);
 
 /* Symbol name hashing function as specified by DWARF-5.  */
 
-uint32_t dwarf5_djb_hash (gdb::string_view str_);
+uint32_t dwarf5_djb_hash (std::string_view str_);
 
 #endif /* DWARF_INDEX_COMMON_H */
index 6d86d28d8c038a0bf5dac4ee50e5f52b0b54d7d4..a16139dad1e41e33ef3288592bdc88f19d31e254 100644 (file)
@@ -96,6 +96,7 @@
 #include "split-name.h"
 #include "gdbsupport/parallel-for.h"
 #include "gdbsupport/thread-pool.h"
+#include "gdbsupport/gdb_string_view.h"
 
 /* When == 1, print basic high level tracing messages.
    When > 1, be more verbose.
@@ -16767,7 +16768,7 @@ cooked_index_functions::expand_symtabs_matching
 
   for (enum language lang : unique_styles)
     {
-      std::vector<gdb::string_view> name_vec
+      std::vector<std::string_view> name_vec
        = lookup_name_without_params.split_name (lang);
       std::string last_name = gdb::to_string (name_vec.back ());
 
index 86e7f61586e85ef4901d1e47306ece9f375424d9..5dc8f21d7c78a093d42f27c5085a008fe07a7374 100644 (file)
@@ -45,7 +45,7 @@
 #include "auxv.h"
 #include "mdebugread.h"
 #include "ctfread.h"
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 #include "gdbsupport/scoped_fd.h"
 #include "dwarf2/public.h"
 #include "cli/cli-cmds.h"
@@ -195,7 +195,7 @@ elf_locate_sections (asection *sectp, struct elfinfo *ei)
 
 static struct minimal_symbol *
 record_minimal_symbol (minimal_symbol_reader &reader,
-                      gdb::string_view name, bool copy_name,
+                      std::string_view name, bool copy_name,
                       unrelocated_addr address,
                       enum minimal_symbol_type ms_type,
                       asection *bfd_section, struct objfile *objfile)
@@ -503,7 +503,7 @@ elf_symtab_read (minimal_symbol_reader &reader,
                  && !is_plt
                  && (elf_sym->version & VERSYM_HIDDEN) == 0)
                record_minimal_symbol (reader,
-                                      gdb::string_view (sym->name, len),
+                                      std::string_view (sym->name, len),
                                       true, unrelocated_addr (symaddr),
                                       ms_type, sym->section, objfile);
              else if (is_plt)
@@ -517,7 +517,7 @@ elf_symtab_read (minimal_symbol_reader &reader,
                      struct minimal_symbol *mtramp;
 
                      mtramp = record_minimal_symbol
-                       (reader, gdb::string_view (sym->name, len), true,
+                       (reader, std::string_view (sym->name, len), true,
                         unrelocated_addr (symaddr),
                         mst_solib_trampoline, sym->section, objfile);
                      if (mtramp)
index 3358b0d8d32a29e1f89e9daa2138c6d4494f78ef..8664d4980b710605a9d8821882748e24e6d4c1e3 100644 (file)
@@ -37,6 +37,7 @@
 #include "user-regs.h"
 #include "valprint.h"
 #include "gdbsupport/gdb_obstack.h"
+#include "gdbsupport/gdb_string_view.h"
 #include "objfiles.h"
 #include "typeprint.h"
 #include <ctype.h>
index c768971be422760e949fd84b3495cba2d04e5a02..cfd4a621e6be758d493c3f23f10a6b1dc4ca6dc3 100644 (file)
@@ -641,7 +641,7 @@ default_symbol_name_matcher (const char *symbol_search_name,
                             const lookup_name_info &lookup_name,
                             completion_match_result *comp_match_res)
 {
-  gdb::string_view name = lookup_name.name ();
+  std::string_view name = lookup_name.name ();
   completion_match_for_lcd *match_for_lcd
     = (comp_match_res != NULL ? &comp_match_res->match_for_lcd : NULL);
   strncmp_iw_mode mode = (lookup_name.completion_mode ()
index db29b0320189e3e07a9b2fd6c67b13cd1c20bb32..26cf483b04a9e21e166bfe7c7fc08a38dcddc180 100644 (file)
@@ -457,13 +457,13 @@ struct mapping
 {
   ULONGEST addr;
   ULONGEST endaddr;
-  gdb::string_view permissions;
+  std::string_view permissions;
   ULONGEST offset;
-  gdb::string_view device;
+  std::string_view device;
   ULONGEST inode;
 
   /* This field is guaranteed to be NULL-terminated, hence it is not a
-     gdb::string_view.  */
+     std::string_view.  */
   const char *filename;
 };
 
@@ -1384,7 +1384,7 @@ parse_smaps_data (const char *data,
 
       /* Decode permissions.  */
       auto has_perm = [&m] (char c)
-       { return m.permissions.find (c) != gdb::string_view::npos; };
+       { return m.permissions.find (c) != std::string_view::npos; };
       read = has_perm ('r');
       write = has_perm ('w');
       exec = has_perm ('x');
index cd6638224e74e2ccd7b888bb7f872b8baa17ab92..fc731605991f2179351f0c8d6efa202934aff21c 100644 (file)
@@ -3050,7 +3050,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                    switch (p[1])
                      {
                      case 'S':
-                       pst->add_psymbol (gdb::string_view (namestring,
+                       pst->add_psymbol (std::string_view (namestring,
                                                            p - namestring),
                                          true, VAR_DOMAIN, LOC_STATIC,
                                          SECT_OFF_DATA (objfile),
@@ -3063,7 +3063,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                        /* The addresses in these entries are reported
                           to be wrong.  See the code that reads 'G's
                           for symtabs.  */
-                       pst->add_psymbol (gdb::string_view (namestring,
+                       pst->add_psymbol (std::string_view (namestring,
                                                            p - namestring),
                                          true, VAR_DOMAIN, LOC_STATIC,
                                          SECT_OFF_DATA (objfile),
@@ -3085,7 +3085,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                                && namestring[0] != ' '))
                          {
                            pst->add_psymbol
-                             (gdb::string_view (namestring, p - namestring),
+                             (std::string_view (namestring, p - namestring),
                               true, STRUCT_DOMAIN, LOC_TYPEDEF, -1,
                               psymbol_placement::STATIC,
                               unrelocated_addr (0),
@@ -3095,7 +3095,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                              {
                                /* Also a typedef with the same name.  */
                                pst->add_psymbol
-                                 (gdb::string_view (namestring,
+                                 (std::string_view (namestring,
                                                     p - namestring),
                                   true, VAR_DOMAIN, LOC_TYPEDEF, -1,
                                   psymbol_placement::STATIC,
@@ -3111,7 +3111,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                                                   just :T...  */
                          {
                            pst->add_psymbol
-                             (gdb::string_view (namestring,
+                             (std::string_view (namestring,
                                                 p - namestring),
                               true, VAR_DOMAIN, LOC_TYPEDEF, -1,
                               psymbol_placement::STATIC,
@@ -3178,7 +3178,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                                /* Note that the value doesn't matter for
                                   enum constants in psymtabs, just in
                                   symtabs.  */
-                               pst->add_psymbol (gdb::string_view (p,
+                               pst->add_psymbol (std::string_view (p,
                                                                    q - p),
                                                  true, VAR_DOMAIN,
                                                  LOC_CONST, -1,
@@ -3199,7 +3199,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                        continue;
                      case 'c':
                        /* Constant, e.g. from "const" in Pascal.  */
-                       pst->add_psymbol (gdb::string_view (namestring,
+                       pst->add_psymbol (std::string_view (namestring,
                                                            p - namestring),
                                          true, VAR_DOMAIN, LOC_CONST, -1,
                                          psymbol_placement::STATIC,
@@ -3215,7 +3215,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                            function_outside_compilation_unit_complaint
                              (copy.c_str ());
                          }
-                       pst->add_psymbol (gdb::string_view (namestring,
+                       pst->add_psymbol (std::string_view (namestring,
                                                            p - namestring),
                                          true, VAR_DOMAIN, LOC_BLOCK,
                                          SECT_OFF_TEXT (objfile),
@@ -3236,7 +3236,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
                            function_outside_compilation_unit_complaint
                              (copy.c_str ());
                          }
-                       pst->add_psymbol (gdb::string_view (namestring,
+                       pst->add_psymbol (std::string_view (namestring,
                                                            p - namestring),
                                          true, VAR_DOMAIN, LOC_BLOCK,
                                          SECT_OFF_TEXT (objfile),
index 1d77882285881733a0ccd5c5758e8da2c7ab0026..72e500be9597584ebb908ea773bd243ef1ed12b9 100644 (file)
@@ -1170,7 +1170,7 @@ mst_str (minimal_symbol_type t)
 /* See minsyms.h.  */
 
 struct minimal_symbol *
-minimal_symbol_reader::record_full (gdb::string_view name,
+minimal_symbol_reader::record_full (std::string_view name,
                                    bool copy_name, unrelocated_addr address,
                                    enum minimal_symbol_type ms_type,
                                    int section)
@@ -1510,7 +1510,7 @@ minimal_symbol_reader::install ()
               {
                 size_t idx = msym - msymbols;
                 msym->compute_and_set_names
-                  (gdb::string_view (msym->linkage_name (),
+                  (std::string_view (msym->linkage_name (),
                                      hash_values[idx].name_length),
                    false,
                    m_objfile->per_bfd,
index f3a2474c79633498b309e4ddf217f9c8d9af6dc8..ee415c4db41d73b0d1d4bda7f58902e987341d61 100644 (file)
@@ -118,7 +118,7 @@ class minimal_symbol_reader
      SECTION - the symbol's section
   */
 
-  struct minimal_symbol *record_full (gdb::string_view name,
+  struct minimal_symbol *record_full (std::string_view name,
                                      bool copy_name,
                                      unrelocated_addr address,
                                      enum minimal_symbol_type ms_type,
index 484d4eaa651a93b596054764c652ec4f27247e93..d4cd5810c209ffbcc3a7b03234f4f8cd86561640 100644 (file)
@@ -1208,7 +1208,7 @@ partial_symtab::add_psymbol (const partial_symbol &psymbol,
 /* See psymtab.h.  */
 
 void
-partial_symtab::add_psymbol (gdb::string_view name, bool copy_name,
+partial_symtab::add_psymbol (std::string_view name, bool copy_name,
                             domain_enum domain,
                             enum address_class theclass,
                             short section,
index 4bafc6e998e6cf797c3104fdc2cb2d22d5de9e7f..005a63cbba86263e53d639fe7d3309b4fda260ad 100644 (file)
@@ -21,7 +21,7 @@
 #define PSYMTAB_H
 
 #include "objfiles.h"
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 #include "gdbsupport/gdb_obstack.h"
 #include "symfile.h"
 #include "gdbsupport/next-iterator.h"
@@ -346,7 +346,7 @@ struct partial_symtab
      LANGUAGE is the language from which the symbol originates.  This will
      influence, amongst other things, how the symbol name is demangled. */
 
-  void add_psymbol (gdb::string_view name,
+  void add_psymbol (std::string_view name,
                    bool copy_name, domain_enum domain,
                    enum address_class theclass,
                    short section,
index cf56a81a2eef55620d2a3feb4b6d1a2d8ea8929e..9ceb7a922e3c45208d137250bb8522a973242d6b 100644 (file)
@@ -31,6 +31,7 @@
 #include "solib-svr4.h"
 #include "solist.h"
 #include "symfile.h"
+#include "gdbsupport/gdb_string_view.h"
 
 #include <unordered_map>
 
@@ -436,8 +437,8 @@ rocm_code_object_stream_memory::read (bfd *, void *buf, file_ptr size,
 static gdb_bfd_iovec_base *
 rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
 {
-  gdb::string_view uri (bfd_get_filename (abfd));
-  gdb::string_view protocol_delim = "://";
+  std::string_view uri (bfd_get_filename (abfd));
+  std::string_view protocol_delim = "://";
   size_t protocol_end = uri.find (protocol_delim);
   std::string protocol = gdb::to_string (uri.substr (0, protocol_end));
   protocol_end += protocol_delim.length ();
@@ -445,7 +446,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
   std::transform (protocol.begin (), protocol.end (), protocol.begin (),
                  [] (unsigned char c) { return std::tolower (c); });
 
-  gdb::string_view path;
+  std::string_view path;
   size_t path_end = uri.find_first_of ("#?", protocol_end);
   if (path_end != std::string::npos)
     path = uri.substr (protocol_end, path_end++ - protocol_end);
@@ -461,7 +462,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
        && std::isxdigit (path[i + 1])
        && std::isxdigit (path[i + 2]))
       {
-       gdb::string_view hex_digits = path.substr (i + 1, 2);
+       std::string_view hex_digits = path.substr (i + 1, 2);
        decoded_path += std::stoi (gdb::to_string (hex_digits), 0, 16);
        i += 2;
       }
@@ -469,7 +470,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
       decoded_path += path[i];
 
   /* Tokenize the query/fragment.  */
-  std::vector<gdb::string_view> tokens;
+  std::vector<std::string_view> tokens;
   size_t pos, last = path_end;
   while ((pos = uri.find ('&', last)) != std::string::npos)
     {
@@ -481,15 +482,15 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
     tokens.emplace_back (uri.substr (last));
 
   /* Create a tag-value map from the tokenized query/fragment.  */
-  std::unordered_map<gdb::string_view, gdb::string_view,
+  std::unordered_map<std::string_view, std::string_view,
                     gdb::string_view_hash> params;
-  for (gdb::string_view token : tokens)
+  for (std::string_view token : tokens)
     {
       size_t delim = token.find ('=');
       if (delim != std::string::npos)
        {
-         gdb::string_view tag = token.substr (0, delim);
-         gdb::string_view val = token.substr (delim + 1);
+         std::string_view tag = token.substr (0, delim);
+         std::string_view val = token.substr (delim + 1);
          params.emplace (tag, val);
        }
     }
@@ -499,7 +500,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
       ULONGEST offset = 0;
       ULONGEST size = 0;
 
-      auto try_strtoulst = [] (gdb::string_view v)
+      auto try_strtoulst = [] (std::string_view v)
        {
          errno = 0;
          ULONGEST value = strtoulst (v.data (), nullptr, 0);
index 0253b3cf675ef925a5d612b379b7cab8bac3afdf..0805cb82700fb1af390ebeab14efd8d12c258bd4 100644 (file)
 
 /* See split-name.h.  */
 
-std::vector<gdb::string_view>
+std::vector<std::string_view>
 split_name (const char *name, split_style style)
 {
-  std::vector<gdb::string_view> result;
+  std::vector<std::string_view> result;
   unsigned int previous_len = 0;
 
   switch (style)
index 7648cf9b90085bf446e9b164d0042bec9ee4dc4f..ad2862e222d7d7bf295407136da03b645776ceb7 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef GDB_SPLIT_NAME_H
 #define GDB_SPLIT_NAME_H
 
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 
 /* The available styles of name splitting.  */
 
@@ -40,7 +40,7 @@ enum class split_style
 /* Split NAME into components at module boundaries.  STYLE indicates
    which style of splitting to use.  */
 
-extern std::vector<gdb::string_view> split_name (const char *name,
+extern std::vector<std::string_view> split_name (const char *name,
                                                 split_style style);
 
 #endif /* GDB_SPLIT_NAME_H */
index 7402a26a401f6c059de1cfa020c84fd095893048..4011475f7aca802e35bf87ecfdcec6fff4be414d 100644 (file)
@@ -748,7 +748,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       if (new_name != nullptr)
        sym->compute_and_set_names (new_name.get (), true, objfile->per_bfd);
       else
-       sym->compute_and_set_names (gdb::string_view (string, p - string), true,
+       sym->compute_and_set_names (std::string_view (string, p - string), true,
                                    objfile->per_bfd);
 
       if (sym->language () == language_cplus)
index 17d1987608f502138dd33559bc5ad1eab8972444..15471554f32618fd355e00af408a6d585be3d504 100644 (file)
@@ -70,7 +70,7 @@
 #include "filename-seen-cache.h"
 #include "arch-utils.h"
 #include <algorithm>
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 #include "gdbsupport/pathstuff.h"
 #include "gdbsupport/common-utils.h"
 
@@ -828,10 +828,10 @@ general_symbol_info::set_language (enum language language,
 /* Objects of this type are stored in the demangled name hash table.  */
 struct demangled_name_entry
 {
-  demangled_name_entry (gdb::string_view mangled_name)
+  demangled_name_entry (std::string_view mangled_name)
     : mangled (mangled_name) {}
 
-  gdb::string_view mangled;
+  std::string_view mangled;
   enum language language;
   gdb::unique_xmalloc_ptr<char> demangled;
 };
@@ -940,7 +940,7 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
    so the pointer can be discarded after calling this function.  */
 
 void
-general_symbol_info::compute_and_set_names (gdb::string_view linkage_name,
+general_symbol_info::compute_and_set_names (std::string_view linkage_name,
                                            bool copy_name,
                                            objfile_per_bfd_storage *per_bfd,
                                            std::optional<hashval_t> hash)
@@ -991,14 +991,14 @@ general_symbol_info::compute_and_set_names (gdb::string_view linkage_name,
       /* A 0-terminated copy of the linkage name.  Callers must set COPY_NAME
         to true if the string might not be nullterminated.  We have to make
         this copy because demangling needs a nullterminated string.  */
-      gdb::string_view linkage_name_copy;
+      std::string_view linkage_name_copy;
       if (copy_name)
        {
          char *alloc_name = (char *) alloca (linkage_name.length () + 1);
          memcpy (alloc_name, linkage_name.data (), linkage_name.length ());
          alloc_name[linkage_name.length ()] = '\0';
 
-         linkage_name_copy = gdb::string_view (alloc_name,
+         linkage_name_copy = std::string_view (alloc_name,
                                                linkage_name.length ());
        }
       else
@@ -1038,7 +1038,7 @@ general_symbol_info::compute_and_set_names (gdb::string_view linkage_name,
          memcpy (mangled_ptr, linkage_name.data (), linkage_name.length ());
          mangled_ptr [linkage_name.length ()] = '\0';
          new (*slot) demangled_name_entry
-           (gdb::string_view (mangled_ptr, linkage_name.length ()));
+           (std::string_view (mangled_ptr, linkage_name.length ()));
        }
       (*slot)->demangled = std::move (demangled_name);
       (*slot)->language = language ();
index 0fb0c8683cbe0d6f505e2125b1d83d43e5b425d1..ec2ac4942d3f1cdcfa467d3b59e91bae5a3ebfb3 100644 (file)
@@ -31,7 +31,7 @@
 #include "gdbsupport/enum-flags.h"
 #include "gdbsupport/function-view.h"
 #include <optional>
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 #include "gdbsupport/next-iterator.h"
 #include "gdbsupport/iterator-range.h"
 #include "completer.h"
@@ -126,11 +126,11 @@ class ada_lookup_name_info final
 
   /* A wrapper for ::split_name that handles some Ada-specific
      peculiarities.  */
-  std::vector<gdb::string_view> split_name () const
+  std::vector<std::string_view> split_name () const
   {
     if (m_verbatim_p || m_standard_p)
       {
-       std::vector<gdb::string_view> result;
+       std::vector<std::string_view> result;
        if (m_standard_p)
          result.emplace_back ("standard");
        result.emplace_back (m_encoded_name);
@@ -238,7 +238,7 @@ class lookup_name_info final
   /* Getters.  See description of each corresponding field.  */
   symbol_name_match_type match_type () const { return m_match_type; }
   bool completion_mode () const { return m_completion_mode; }
-  gdb::string_view name () const { return m_name; }
+  std::string_view name () const { return m_name; }
   const bool ignore_parameters () const { return m_ignore_parameters; }
 
   /* Like the "name" method but guarantees that the returned string is
@@ -292,7 +292,7 @@ class lookup_name_info final
 
   /* A wrapper for ::split_name (see split-name.h) that splits this
      name, and that handles any language-specific peculiarities.  */  
-  std::vector<gdb::string_view> split_name (language lang) const
+  std::vector<std::string_view> split_name (language lang) const
   {
     if (lang == language_ada)
       return ada ().split_name ();
@@ -356,7 +356,7 @@ private:
   symbol_name_match_type m_match_type;
   bool m_completion_mode;
   bool m_ignore_parameters;
-  gdb::string_view m_name;
+  std::string_view m_name;
 
   /* Language-specific info.  These fields are filled lazily the first
      time a lookup is done in the corresponding language.  They're
@@ -509,7 +509,7 @@ struct general_symbol_info
   /* Set the linkage and natural names of a symbol, by demangling
      the linkage name.  If linkage_name may not be nullterminated,
      copy_name must be set to true.  */
-  void compute_and_set_names (gdb::string_view linkage_name, bool copy_name,
+  void compute_and_set_names (std::string_view linkage_name, bool copy_name,
                              struct objfile_per_bfd_storage *per_bfd,
                              std::optional<hashval_t> hash
                                = std::optional<hashval_t> ());
index b8954af36e2a743e64b06756a274dfb89773ee88..84724643fd56489fce8138e76b828b6279b132e3 100644 (file)
@@ -1197,7 +1197,10 @@ tui_getc_1 (FILE *fp)
         Compare keyname instead.  */
       if (ch >= KEY_MAX)
        {
-         auto name = gdb::string_view (keyname (ch));
+         std::string_view name;
+         const char *name_str = keyname (ch);
+         if (name_str != nullptr)
+           name = std::string_view (name_str);
 
          /* The following sequences are hardcoded in readline as
             well.  */
index a0a123340e3ed257e888530130f2e8ec392100ea..9219c1f01844f231a621bfec7de6ac1b10a094c5 100644 (file)
@@ -54,7 +54,7 @@
 #include "gdb_curses.h"
 #include <ctype.h>
 #include "readline/readline.h"
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 
 #include <signal.h>
 
@@ -663,7 +663,7 @@ tui_scroll_right_command (const char *arg, int from_tty)
 
 /* Answer the window represented by name.  */
 static struct tui_win_info *
-tui_partial_win_by_name (gdb::string_view name)
+tui_partial_win_by_name (std::string_view name)
 {
   struct tui_win_info *best = nullptr;
 
@@ -935,7 +935,7 @@ tui_set_win_size (const char *arg, bool set_width_p)
   buf_ptr = skip_to_space (buf_ptr);
 
   /* Validate the window name.  */
-  gdb::string_view wname (buf, buf_ptr - buf);
+  std::string_view wname (buf, buf_ptr - buf);
   win_info = tui_partial_win_by_name (wname);
 
   if (win_info == NULL)
index e6ecf2a6de57d83455307b0e028c54cc87b7185e..829fc1f09c7e81348e4b310314979d7896aef72e 100644 (file)
@@ -2500,7 +2500,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
            switch (p[1])
              {
              case 'S':
-               pst->add_psymbol (gdb::string_view (namestring,
+               pst->add_psymbol (std::string_view (namestring,
                                                    p - namestring),
                                  true, VAR_DOMAIN, LOC_STATIC,
                                  SECT_OFF_DATA (objfile),
@@ -2513,7 +2513,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
              case 'G':
                /* The addresses in these entries are reported to be
                   wrong.  See the code that reads 'G's for symtabs.  */
-               pst->add_psymbol (gdb::string_view (namestring,
+               pst->add_psymbol (std::string_view (namestring,
                                                    p - namestring),
                                  true, VAR_DOMAIN, LOC_STATIC,
                                  SECT_OFF_DATA (objfile),
@@ -2534,7 +2534,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                    || (p == namestring + 1
                        && namestring[0] != ' '))
                  {
-                   pst->add_psymbol (gdb::string_view (namestring,
+                   pst->add_psymbol (std::string_view (namestring,
                                                        p - namestring),
                                      true, STRUCT_DOMAIN, LOC_TYPEDEF, -1,
                                      psymbol_placement::STATIC,
@@ -2544,7 +2544,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                    if (p[2] == 't')
                      {
                        /* Also a typedef with the same name.  */
-                       pst->add_psymbol (gdb::string_view (namestring,
+                       pst->add_psymbol (std::string_view (namestring,
                                                            p - namestring),
                                          true, VAR_DOMAIN, LOC_TYPEDEF, -1,
                                          psymbol_placement::STATIC,
@@ -2559,7 +2559,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
              case 't':
                if (p != namestring)    /* a name is there, not just :T...  */
                  {
-                   pst->add_psymbol (gdb::string_view (namestring,
+                   pst->add_psymbol (std::string_view (namestring,
                                                        p - namestring),
                                      true, VAR_DOMAIN, LOC_TYPEDEF, -1,
                                      psymbol_placement::STATIC,
@@ -2624,7 +2624,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                          ;
                        /* Note that the value doesn't matter for
                           enum constants in psymtabs, just in symtabs.  */
-                       pst->add_psymbol (gdb::string_view (p, q - p), true,
+                       pst->add_psymbol (std::string_view (p, q - p), true,
                                          VAR_DOMAIN, LOC_CONST, -1,
                                          psymbol_placement::STATIC,
                                          unrelocated_addr (0),
@@ -2644,7 +2644,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 
              case 'c':
                /* Constant, e.g. from "const" in Pascal.  */
-               pst->add_psymbol (gdb::string_view (namestring,
+               pst->add_psymbol (std::string_view (namestring,
                                                    p - namestring),
                                  true, VAR_DOMAIN, LOC_CONST, -1,
                                  psymbol_placement::STATIC,
@@ -2659,7 +2659,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                    std::string name (namestring, (p - namestring));
                    function_outside_compilation_unit_complaint (name.c_str ());
                  }
-               pst->add_psymbol (gdb::string_view (namestring,
+               pst->add_psymbol (std::string_view (namestring,
                                                    p - namestring),
                                  true, VAR_DOMAIN, LOC_BLOCK,
                                  SECT_OFF_TEXT (objfile),
@@ -2686,7 +2686,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
                if (startswith (namestring, "@FIX"))
                  continue;
 
-               pst->add_psymbol (gdb::string_view (namestring,
+               pst->add_psymbol (std::string_view (namestring,
                                                    p - namestring),
                                  true, VAR_DOMAIN, LOC_BLOCK,
                                  SECT_OFF_TEXT (objfile),
index 4ceb44d88b88bf5f6ee0cc5a263f71afe2ab88d9..1efc5bbf45983704fb01d2dfe990b6388ef49d05 100644 (file)
@@ -26,7 +26,7 @@
 #include "gdbsupport/gdb_unique_ptr.h"
 #include "gdbsupport/array-view.h"
 #include "poison.h"
-#include "gdb_string_view.h"
+#include <string_view>
 
 #if defined HAVE_LIBXXHASH
 #  include <xxhash.h>
@@ -94,7 +94,7 @@ extern const char *safe_strerror (int);
    true if the start of STRING matches PATTERN, false otherwise.  */
 
 static inline bool
-startswith (gdb::string_view string, gdb::string_view pattern)
+startswith (std::string_view string, std::string_view pattern)
 {
   return (string.length () >= pattern.length ()
          && strncmp (string.data (), pattern.data (), pattern.length ()) == 0);
@@ -228,7 +228,7 @@ fast_hash (const void *ptr, size_t len, unsigned int start_value = 0)
 namespace gdb
 {
 
-/* Hash type for gdb::string_view.
+/* Hash type for std::string_view.
 
    Even after we switch to C++17 and dump our string_view implementation, we
    might want to keep this hash implementation if it's faster than std::hash
@@ -236,7 +236,7 @@ namespace gdb
 
 struct string_view_hash
 {
-  std::size_t operator() (gdb::string_view view) const
+  std::size_t operator() (std::string_view view) const
   {  return fast_hash (view.data (), view.length ()); }
 };
 
index 2af34ab9450fcf8e2adb39044e195ec490bdb139..26e327a60e80009f4a78a55b7a9aad35ca9dc345 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef COMMON_FORMAT_H
 #define COMMON_FORMAT_H
 
-#include "gdbsupport/gdb_string_view.h"
+#include <string_view>
 
 #if defined(__MINGW32__) && !defined(PRINTF_HAS_LONG_LONG)
 # define USE_PRINTF_I64 1
@@ -56,12 +56,13 @@ struct format_piece
       argclass (argc),
       n_int_args (n)
   {
+    gdb_assert (str != nullptr);
   }
 
   bool operator== (const format_piece &other) const
   {
     return (this->argclass == other.argclass
-           && gdb::string_view (this->string) == other.string);
+           && std::string_view (this->string) == other.string);
   }
 
   const char *string;
index 26a3a9f091074b673ecc521c5e3a45a841bb40b4..cf7af62332765fbabab55e6527cfc51160e12a63 100644 (file)
@@ -556,7 +556,7 @@ namespace gdb {
 namespace gdb {
 
 static inline std::string
-to_string(const gdb::string_view &view)
+to_string(const std::string_view &view)
 {
   return { view.data (), view.size () };
 }