From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 6/7] [gdb/build] Return reference in target_read_auxv
Date: Tue, 15 Aug 2023 20:13:08 +0200 [thread overview]
Message-ID: <20230815181309.8595-7-tdevries@suse.de> (raw)
In-Reply-To: <20230815181309.8595-1-tdevries@suse.de>
In target_read_auxv we return a copy of an object:
...
gdb::optional<gdb::byte_vector>
target_read_auxv ()
{
...
return info->data;
}
...
Return a 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.
---
gdb/arm-fbsd-tdep.c | 2 +-
gdb/auxv.c | 6 +++---
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 acafc4a8bcd..fe1c7f453c9 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 ();
+ 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 812b2807554..02b4ab4cdd0 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>
+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 ();
+ 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 ();
+ 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 2441b6c02ab..f42efa4fa7b 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 gdb::optional<gdb::byte_vector> &target_read_auxv ();
/* Read auxv data from OPS. */
--
2.35.3
next prev parent reply other threads:[~2023-08-15 18:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-15 18:13 [PATCH 0/7] [gdb/build] Fix -std=c++20 issues Tom de Vries
2023-08-15 18:13 ` [PATCH 1/7] [gdb/build, c++20] Fix Wdeprecated-enum-enum-conversion Tom de Vries
2023-08-15 18:13 ` [PATCH 2/7] [gdb/build, c++20] Stop using deprecated is_pod Tom de Vries
2023-08-15 18:13 ` [PATCH 3/7] [gdb/build, c++20] Fix DISABLE_COPY_AND_ASSIGN use in ui_out_emit_type Tom de Vries
2023-08-15 18:13 ` [PATCH 4/7] [gdb/build, c++20] Fix deprecated implicit capture of this Tom de Vries
2023-08-15 18:13 ` [PATCH 5/7] [gdb/build, c++20] Fix invalid conversion in test_symbols Tom de Vries
2023-08-15 18:13 ` Tom de Vries [this message]
2023-08-16 18:23 ` [PATCH 6/7] [gdb/build] Return reference in target_read_auxv Tom Tromey
2023-08-15 18:13 ` [PATCH 7/7] [gdb/build, c++20] Handle deprecated std::allocator::construct Tom de Vries
2023-08-16 18:27 ` [PATCH 0/7] [gdb/build] Fix -std=c++20 issues Tom Tromey
2023-08-21 11:04 ` Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230815181309.8595-7-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).