From: Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
To: gdb-patches@sourceware.org
Cc: uweigand@de.ibm.com, edjunior@gmail.com
Subject: [PATCH v5 01/12] Zero-initialize linux note sections
Date: Mon, 22 Oct 2018 22:33:00 -0000 [thread overview]
Message-ID: <20181022223242.7858-2-pedromfc@linux.ibm.com> (raw)
In-Reply-To: <20181022223242.7858-1-pedromfc@linux.ibm.com>
This patches changes linux-tdep.c so that the buffer used to write
note sections when generating a core file is zero-initialized. This
way, bytes that are not collected won't contain random
data (e.g. padding bytes).
gdb/ChangeLog:
YYYY-MM-DD Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* linux-tdep.c (linux_collect_regset_section_cb): Use
std::vector<gdb_byte> instead of char * and malloc for buf.
Remove xfree.
---
gdb/linux-tdep.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 352114943f..c958c0dfe9 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -1584,7 +1584,6 @@ linux_collect_regset_section_cb (const char *sect_name, int supply_size,
int collect_size, const struct regset *regset,
const char *human_name, void *cb_data)
{
- char *buf;
struct linux_collect_regset_section_cb_data *data
= (struct linux_collect_regset_section_cb_data *) cb_data;
bool variable_size_section = (regset != NULL
@@ -1598,19 +1597,22 @@ linux_collect_regset_section_cb (const char *sect_name, int supply_size,
gdb_assert (regset && regset->collect_regset);
- buf = (char *) xmalloc (collect_size);
- regset->collect_regset (regset, data->regcache, -1, buf, collect_size);
+ /* This is intentionally zero-initialized by using std::vector, so
+ that any padding bytes in the core file will show as 0. */
+ std::vector<gdb_byte> buf (collect_size);
+
+ regset->collect_regset (regset, data->regcache, -1, buf.data (),
+ collect_size);
/* PRSTATUS still needs to be treated specially. */
if (strcmp (sect_name, ".reg") == 0)
data->note_data = (char *) elfcore_write_prstatus
(data->obfd, data->note_data, data->note_size, data->lwp,
- gdb_signal_to_host (data->stop_signal), buf);
+ gdb_signal_to_host (data->stop_signal), buf.data ());
else
data->note_data = (char *) elfcore_write_register_note
(data->obfd, data->note_data, data->note_size,
- sect_name, buf, collect_size);
- xfree (buf);
+ sect_name, buf.data (), collect_size);
if (data->note_data == NULL)
data->abort_iteration = 1;
--
2.13.6
next prev parent reply other threads:[~2018-10-22 22:33 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-22 22:33 [PATCH v5 00/12] GDB support for more powerpc registers on linux Pedro Franco de Carvalho
2018-10-22 22:33 ` [PATCH v5 06/12] [PowerPC] Fix indentation in arch/ppc-linux-common.c Pedro Franco de Carvalho
2018-10-22 22:33 ` [PATCH v5 07/12] [PowerPC] Refactor have_ initializers in rs6000-tdep.c Pedro Franco de Carvalho
2018-10-22 22:33 ` [PATCH v5 05/12] [PowerPC] Fix two if statements in gdb/ppc-linux-nat.c Pedro Franco de Carvalho
2018-10-22 22:33 ` [PATCH v5 02/12] [PowerPC] Don't zero-initialize vector register buffers Pedro Franco de Carvalho
2018-10-22 22:33 ` Pedro Franco de Carvalho [this message]
2018-10-22 22:33 ` [PATCH v5 03/12] Add decfloat registers to float reggroup Pedro Franco de Carvalho
2018-10-22 22:33 ` [PATCH v5 04/12] [PowerPC] Remove rs6000_pseudo_register_reggroup_p Pedro Franco de Carvalho
2018-10-22 22:54 ` [PATCH v5 10/12] [PowerPC] Add support for EBB and PMU registers Pedro Franco de Carvalho
2018-10-22 22:56 ` [PATCH v5 11/12] [PowerPC] Reject tdescs with VSX and no FPU or Altivec Pedro Franco de Carvalho
2018-10-23 16:05 ` Pedro Alves
2018-10-23 18:46 ` Pedro Franco de Carvalho
2018-10-25 15:45 ` Pedro Alves
2018-10-22 22:58 ` [PATCH v5 09/12] [PowerPC] Add support for TAR Pedro Franco de Carvalho
2018-10-23 2:34 ` Eli Zaretskii
2018-10-23 18:50 ` Pedro Franco de Carvalho
2018-10-22 23:05 ` [PATCH v5 12/12] [PowerPC] Add support for HTM registers Pedro Franco de Carvalho
2019-02-09 5:51 ` Simon Marchi
2019-02-11 19:10 ` Pedro Franco de Carvalho
2018-10-22 23:16 ` [PATCH v5 08/12] [PowerPC] Add support for PPR and DSCR Pedro Franco de Carvalho
2018-10-23 15:37 ` [PATCH v5 00/12] GDB support for more powerpc registers on linux Pedro Alves
2018-10-23 18:42 ` Pedro Franco de Carvalho
2018-10-24 17:59 ` Ulrich Weigand
2018-10-25 20:05 ` Pedro Franco de Carvalho
2018-10-26 11:01 ` Ulrich Weigand
2018-10-26 10:57 ` Pedro Alves
2018-10-26 11:00 ` Ulrich Weigand
2018-10-26 15:16 ` Pedro Franco de Carvalho
2018-10-29 14:20 ` Regression on old kernels (Re: [PATCH v5 00/12] GDB support for more powerpc registers on linux) Ulrich Weigand
2018-10-29 19:50 ` Pedro Franco de Carvalho
2018-10-30 9:44 ` Ulrich Weigand
2018-10-31 13:05 ` Pedro Franco de Carvalho
2018-10-31 13:14 ` Ulrich Weigand
2018-10-31 14:06 ` Pedro Franco de Carvalho
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=20181022223242.7858-2-pedromfc@linux.ibm.com \
--to=pedromfc@linux.ibm.com \
--cc=edjunior@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=uweigand@de.ibm.com \
/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).