aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2023-08-17 10:41:34 +0200
committerTom de Vries <tdevries@suse.de>2023-08-17 10:41:34 +0200
commit9246b7bd6dfeb273f9be7648acffddfe19f966ff (patch)
tree24b121116cf815c11b51a81f5f00e878394deb3e
parent2b9ed6db3fb08feab70857dc7eb94fbe6a45e069 (diff)
downloadfsf-binutils-gdb-9246b7bd6dfeb273f9be7648acffddfe19f966ff.zip
fsf-binutils-gdb-9246b7bd6dfeb273f9be7648acffddfe19f966ff.tar.gz
fsf-binutils-gdb-9246b7bd6dfeb273f9be7648acffddfe19f966ff.tar.bz2
[gdb/build] Return const reference in target_read_auxv
In target_read_auxv we return a copy of an object: ... gdb::optional<gdb::byte_vector> target_read_auxv () { ... return info->data; } ... Return a const reference instead, saving a copy. This is exposed by using std::pmr::polymorphic_allocator instead of std::allocator in default_init_allocator. Tested on x86_64-linux.
-rw-r--r--gdb/arm-fbsd-tdep.c2
-rw-r--r--gdb/auxv.c6
-rw-r--r--gdb/auxv.h2
3 files changed, 5 insertions, 5 deletions
diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c
index acafc4a..b46fa91 100644
--- a/gdb/arm-fbsd-tdep.c
+++ b/gdb/arm-fbsd-tdep.c
@@ -244,7 +244,7 @@ arm_fbsd_read_description_auxv (const gdb::optional<gdb::byte_vector> &auxv,
const struct target_desc *
arm_fbsd_read_description_auxv (bool tls)
{
- gdb::optional<gdb::byte_vector> auxv = target_read_auxv ();
+ const gdb::optional<gdb::byte_vector> &auxv = target_read_auxv ();
return arm_fbsd_read_description_auxv (auxv,
current_inferior ()->top_target (),
current_inferior ()->gdbarch,
diff --git a/gdb/auxv.c b/gdb/auxv.c
index 812b280..3c27c1f 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -354,7 +354,7 @@ invalidate_auxv_cache (void)
/* See auxv.h. */
-gdb::optional<gdb::byte_vector>
+const gdb::optional<gdb::byte_vector> &
target_read_auxv ()
{
inferior *inf = current_inferior ();
@@ -410,7 +410,7 @@ target_auxv_search (const gdb::byte_vector &auxv, target_ops *ops,
int
target_auxv_search (CORE_ADDR match, CORE_ADDR *valp)
{
- gdb::optional<gdb::byte_vector> auxv = target_read_auxv ();
+ const gdb::optional<gdb::byte_vector> &auxv = target_read_auxv ();
if (!auxv.has_value ())
return -1;
@@ -564,7 +564,7 @@ fprint_target_auxv (struct ui_file *file)
struct gdbarch *gdbarch = target_gdbarch ();
CORE_ADDR type, val;
int ents = 0;
- gdb::optional<gdb::byte_vector> auxv = target_read_auxv ();
+ const gdb::optional<gdb::byte_vector> &auxv = target_read_auxv ();
if (!auxv.has_value ())
return -1;
diff --git a/gdb/auxv.h b/gdb/auxv.h
index 2441b6c..a920f7a 100644
--- a/gdb/auxv.h
+++ b/gdb/auxv.h
@@ -48,7 +48,7 @@ extern int svr4_auxv_parse (struct gdbarch *gdbarch, const gdb_byte **readptr,
/* Read auxv data from the current inferior's target stack. */
-extern gdb::optional<gdb::byte_vector> target_read_auxv ();
+extern const gdb::optional<gdb::byte_vector> &target_read_auxv ();
/* Read auxv data from OPS. */