From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH 01/13] gdb: remove uses of alloca from arch-utils.c
Date: Mon, 27 Feb 2023 21:29:14 +0000 [thread overview]
Message-ID: <15cec6aaaad2f1147323b4dc5e13be69135d6889.1677533215.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1677533215.git.aburgess@redhat.com>
Remove the two uses of alloca from arch-utils.c, replace them both
with gdb::byte_vector instead.
There should be no user visible changes after this commit.
---
gdb/arch-utils.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index e3af9ce2dbc..be90d0ed89c 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -933,7 +933,7 @@ default_program_breakpoint_here_p (struct gdbarch *gdbarch,
if (bpoint == nullptr)
return false;
- gdb_byte *target_mem = (gdb_byte *) alloca (len);
+ gdb::byte_vector target_mem (len);
/* Enable the automatic memory restoration from breakpoints while
we read the memory. Otherwise we may find temporary breakpoints, ones
@@ -941,11 +941,11 @@ default_program_breakpoint_here_p (struct gdbarch *gdbarch,
scoped_restore restore_memory
= make_scoped_restore_show_memory_breakpoints (0);
- if (target_read_memory (address, target_mem, len) == 0)
+ if (target_read_memory (address, target_mem.data (), len) == 0)
{
/* Check if this is a breakpoint instruction for this architecture,
including ones used by GDB. */
- if (memcmp (target_mem, bpoint, len) == 0)
+ if (memcmp (target_mem.data (), bpoint, len) == 0)
return true;
}
@@ -1012,7 +1012,6 @@ default_guess_tracepoint_registers (struct gdbarch *gdbarch,
CORE_ADDR addr)
{
int pc_regno = gdbarch_pc_regnum (gdbarch);
- gdb_byte *regs;
/* This guessing code below only works if the PC register isn't
a pseudo-register. The value of a pseudo-register isn't stored
@@ -1023,10 +1022,10 @@ default_guess_tracepoint_registers (struct gdbarch *gdbarch,
if (pc_regno < 0 || pc_regno >= gdbarch_num_regs (gdbarch))
return;
- regs = (gdb_byte *) alloca (register_size (gdbarch, pc_regno));
- store_unsigned_integer (regs, register_size (gdbarch, pc_regno),
+ gdb::byte_vector regs (register_size (gdbarch, pc_regno));
+ store_unsigned_integer (regs.data (), register_size (gdbarch, pc_regno),
gdbarch_byte_order (gdbarch), addr);
- regcache->raw_supply (pc_regno, regs);
+ regcache->raw_supply (pc_regno, regs.data ());
}
int
--
2.25.4
next prev parent reply other threads:[~2023-02-27 21:29 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-27 21:29 [PATCH 00/13] Remove a bunch of alloca uses Andrew Burgess
2023-02-27 21:29 ` Andrew Burgess [this message]
2023-02-27 21:29 ` [PATCH 02/13] gdb: remove use of alloca from auxv.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 03/13] gdb: remove use of alloca from c-lang.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 04/13] gdb: remove use of alloca from corefile.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 05/13] gdb: remove uses of alloca from dwarf2/expr.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 06/13] gdb: remove a use of alloca from elfread.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 07/13] gdb: remove use of alloca from findvar.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 08/13] gdb: remove use of alloca from linux-nat-trad.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 09/13] gdb: remove use of alloca from mem-break.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 10/13] gdb: remove some uses of alloca from printcmd.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 11/13] gdb: remove some uses of alloca from remote.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 12/13] gdb: remove uses of alloca from valprint.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 13/13] gdb: remove a use of alloca from symfile.c Andrew Burgess
2023-02-28 2:47 ` [PATCH 00/13] Remove a bunch of alloca uses Simon Marchi
2023-03-07 21:57 ` Tom Tromey
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=15cec6aaaad2f1147323b4dc5e13be69135d6889.1677533215.git.aburgess@redhat.com \
--to=aburgess@redhat.com \
--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).