aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
diff options
context:
space:
mode:
authorLancelot Six <lancelot.six@amd.com>2023-10-13 10:17:02 +0000
committerLancelot Six <lancelot.six@amd.com>2023-11-21 11:52:36 +0000
commit8082468ffe65095cdd640fb081b9d3d28dd7add4 (patch)
tree4e9ab5a6ad254f77e96e295d873a1d5b31cf44fa /gdb/dwarf2
parent42742fc5817a8f2e47c711880501073a9ad86cfc (diff)
downloadgdb-8082468ffe65095cdd640fb081b9d3d28dd7add4.zip
gdb-8082468ffe65095cdd640fb081b9d3d28dd7add4.tar.gz
gdb-8082468ffe65095cdd640fb081b9d3d28dd7add4.tar.bz2
gdb: Use std::string_view instead of gdb::string_view
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>
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r--gdb/dwarf2/cooked-index.c6
-rw-r--r--gdb/dwarf2/cooked-index.h2
-rw-r--r--gdb/dwarf2/index-common.c2
-rw-r--r--gdb/dwarf2/index-common.h2
-rw-r--r--gdb/dwarf2/read.c3
5 files changed, 8 insertions, 7 deletions
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
index 58ea541..7c4af3a 100644
--- a/gdb/dwarf2/cooked-index.c
+++ b/gdb/dwarf2/cooked-index.c
@@ -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);
};
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
index 5aacb32..5675ea6 100644
--- a/gdb/dwarf2/cooked-index.h
+++ b/gdb/dwarf2/cooked-index.h
@@ -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"
diff --git a/gdb/dwarf2/index-common.c b/gdb/dwarf2/index-common.c
index 07330a8..04b04f9 100644
--- a/gdb/dwarf2/index-common.c
+++ b/gdb/dwarf2/index-common.c
@@ -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. */
diff --git a/gdb/dwarf2/index-common.h b/gdb/dwarf2/index-common.h
index 23e814a..79d3a59 100644
--- a/gdb/dwarf2/index-common.h
+++ b/gdb/dwarf2/index-common.h
@@ -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 */
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 6d86d28..a16139d 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -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 ());