diff options
author | Tom de Vries <tdevries@suse.de> | 2023-08-17 10:41:34 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2023-08-17 10:41:34 +0200 |
commit | 9246b7bd6dfeb273f9be7648acffddfe19f966ff (patch) | |
tree | 24b121116cf815c11b51a81f5f00e878394deb3e | |
parent | 2b9ed6db3fb08feab70857dc7eb94fbe6a45e069 (diff) | |
download | binutils-9246b7bd6dfeb273f9be7648acffddfe19f966ff.zip binutils-9246b7bd6dfeb273f9be7648acffddfe19f966ff.tar.gz binutils-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.c | 2 | ||||
-rw-r--r-- | gdb/auxv.c | 6 | ||||
-rw-r--r-- | gdb/auxv.h | 2 |
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, @@ -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; @@ -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. */ |