From: Simon Marchi <simark@simark.ca>
To: Shahab Vahedi <shahab.vahedi@gmail.com>, gdb-patches@sourceware.org
Cc: Anton Kolesov <Anton.Kolesov@synopsys.com>,
Shahab Vahedi <shahab@synopsys.com>,
Francois Bedard <fbedard@synopsys.com>
Subject: Re: [PATCH v2] arc: Add support for Linux coredump files
Date: Sun, 4 Oct 2020 22:13:49 -0400 [thread overview]
Message-ID: <7e10e689-2de3-c9cc-6552-495510bd37c6@simark.ca> (raw)
In-Reply-To: <20200929161547.19168-1-shahab.vahedi@gmail.com>
Hi Shahab,
The patch LGTM with the nits below fixed.
On 2020-09-29 12:15 p.m., Shahab Vahedi wrote:
> +/* arc_linux_core_reg_offsets[i] is the offset in the .reg section of GDB
> + regnum i. Array index is an internal GDB register number, as defined in
> + arc-tdep.h:arc_regnum.
> +
> + From include/uapi/asm/ptrace.h in the ARC Linux sources. */
Thanks for this, I _love_ it when people point to references that help
make sense of the code.
> +void
> +arc_linux_supply_gregset (const struct regset *regset,
> + struct regcache *regcache,
> + int regnum, const void *gregs, size_t size)
> +{
> + gdb_static_assert (ARC_LAST_REGNUM
> + < ARRAY_SIZE (arc_linux_core_reg_offsets));
> +
> + const bfd_byte *buf = (const bfd_byte *) gregs;
> +
> + for (int reg = 0; reg <= ARC_LAST_REGNUM; reg++)
> + {
> + if (arc_linux_core_reg_offsets[reg] != ARC_OFFSET_NO_REGISTER)
> + regcache->raw_supply (reg, buf + arc_linux_core_reg_offsets[reg]);
> + }
I might have mislead you in the past by telling you to use curly braces
in this situation before. I recently learned that it's not necessary.
You can do:
for (...)
if (...)
something ();
It's only needed for nested ifs:
if (...)
{
if (...)
something ();
}
to avoid the problem of the dangling else.
> +void
> +arc_linux_collect_gregset (const struct regset *regset,
> + const struct regcache *regcache,
> + int regnum, void *gregs, size_t size)
> +{
> + gdb_static_assert (ARC_LAST_REGNUM
> + < ARRAY_SIZE (arc_linux_core_reg_offsets));
> +
> + gdb_byte *buf = (gdb_byte *) gregs;
> + struct gdbarch *gdbarch = regcache->arch ();
> +
> + /* regnum == -1 means writing all the registers. */
> + if (regnum == -1)
> + for (int reg = 0; reg <= ARC_LAST_REGNUM; reg++)
> + collect_register (regcache, gdbarch, reg, buf);
> + else if (regnum <= ARC_LAST_REGNUM)
> + collect_register (regcache, gdbarch, regnum, buf);
> + else
> + gdb_assert (!"Invalid regnum in arc_linux_collect_gregset.");
You can use gdb_assert_not_reached exactly for this.
Simon
next prev parent reply other threads:[~2020-10-05 2:13 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-27 11:27 [PATCH] " Shahab Vahedi
2020-09-07 9:14 ` Shahab Vahedi
2020-09-16 2:31 ` [PING^2][PATCH] " Shahab Vahedi
2020-09-16 20:21 ` [PATCH] " Simon Marchi
2020-09-17 11:55 ` Aktemur, Tankut Baris
2020-09-28 13:47 ` Shahab Vahedi via Gdb-patches
2020-09-28 14:08 ` Aktemur, Tankut Baris via Gdb-patches
2020-09-28 19:10 ` Simon Marchi
2020-09-29 8:24 ` Shahab Vahedi via Gdb-patches
2020-09-29 9:02 ` Shahab Vahedi via Gdb-patches
2020-09-29 14:22 ` Simon Marchi
2020-09-29 15:42 ` Shahab Vahedi via Gdb-patches
2020-10-01 13:30 ` Shahab Vahedi via Gdb-patches
2020-09-29 16:15 ` [PATCH v2] " Shahab Vahedi via Gdb-patches
2020-10-05 2:13 ` Simon Marchi [this message]
2020-10-07 16:11 ` [PUSHED master] " Shahab Vahedi via Gdb-patches
2020-10-07 16:32 ` [PUSHED gdb-10-branch] " Shahab Vahedi via Gdb-patches
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=7e10e689-2de3-c9cc-6552-495510bd37c6@simark.ca \
--to=simark@simark.ca \
--cc=Anton.Kolesov@synopsys.com \
--cc=fbedard@synopsys.com \
--cc=gdb-patches@sourceware.org \
--cc=shahab.vahedi@gmail.com \
--cc=shahab@synopsys.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