From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH 12/13] gdb: remove uses of alloca from valprint.c
Date: Mon, 27 Feb 2023 21:29:25 +0000 [thread overview]
Message-ID: <d8fd0b6e8515f87a9f4b5be58b1d3d543da1295c.1677533215.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1677533215.git.aburgess@redhat.com>
Remove the uses of alloca from valprint.c and replace them with
gdb::byte_vector.
There should be no user visible changes after this commit.
---
gdb/valprint.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 357db3815b0..63a2a4de060 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -2203,13 +2203,13 @@ generic_emit_char (int c, struct type *type, struct ui_file *stream,
{
enum bfd_endian byte_order
= type_byte_order (type);
- gdb_byte *c_buf;
bool need_escape = false;
- c_buf = (gdb_byte *) alloca (type->length ());
- pack_long (c_buf, type, c);
+ gdb::byte_vector c_buf (type->length ());
+ pack_long (c_buf.data (), type, c);
- wchar_iterator iter (c_buf, type->length (), encoding, type->length ());
+ wchar_iterator iter (c_buf.data (), type->length (), encoding,
+ type->length ());
/* This holds the printable form of the wchar_t data. */
auto_obstack wchar_buf;
@@ -2667,16 +2667,15 @@ val_print_string (struct type *elttype, const char *encoding,
width, byte_order) == 0;
if (len == -1 && !found_nul)
{
- gdb_byte *peekbuf;
-
/* We didn't find a NUL terminator we were looking for. Attempt
to peek at the next character. If not successful, or it is not
a null byte, then force ellipsis to be printed. */
- peekbuf = (gdb_byte *) alloca (width);
+ gdb::byte_vector peekbuf (width);
- if (target_read_memory (addr, peekbuf, width) == 0
- && extract_unsigned_integer (peekbuf, width, byte_order) != 0)
+ if (target_read_memory (addr, peekbuf.data (), width) == 0
+ && extract_unsigned_integer (peekbuf.data (),
+ width, byte_order) != 0)
force_ellipsis = 1;
}
else if ((len >= 0 && err != 0) || (len > bytes_read / width))
--
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 ` [PATCH 01/13] gdb: remove uses of alloca from arch-utils.c Andrew Burgess
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 ` Andrew Burgess [this message]
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=d8fd0b6e8515f87a9f4b5be58b1d3d543da1295c.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).