From: Simon Marchi <simark@simark.ca>
To: Simon Marchi <simon.marchi@efficios.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] gdb: cleanup of displaced_step_inferior_state::reset/displaced_step_clear
Date: Thu, 13 Feb 2020 22:52:00 -0000 [thread overview]
Message-ID: <627719a0-6ae6-40b9-a6c4-6123dca89dc7@simark.ca> (raw)
In-Reply-To: <20200122151410.30012-1-simon.marchi@efficios.com>
On 2020-01-22 10:14 a.m., Simon Marchi wrote:
> displaced_step_inferior_state::reset and displaced_step_clear appear to
> have the same goal, but they don't do the same thing.
> displaced_step_inferior_state::reset clears more things than
> displaced_step_clear, but it misses free'ing the closure, which
> displaced_step_clear does.
>
> This patch replaces displaced_step_clear's implementation with just a call to
> displaced_step_inferior_state::reset. It then changes
> displaced_step_inferior_state::step_closure to be a unique_ptr, to indicate the
> fact that displaced_step_inferior_state owns the closure (and so that it is
> automatically freed when the field is reset).
>
> It should be possible to get rid of displaced_step_clear entirely, but I'm not
> sure what the best way, give that it's used in scope exit macros.
>
> The test gdb.base/step-over-syscall.exp caught a problem when doing this, which
> I consider to be a latent bug which my cleanup exposes. In
> handle_inferior_event, in the TARGET_WAITKIND_FORKED case, if we displaced-step
> over a fork syscall, we make sure to restore the memory that we used as a
> displaced-stepping buffer in the child. We do so using the
> displaced_step_inferior_state of the parent. However, we do it after calling
> displaced_step_fixup for the parent, which clears the information in the
> parent's displaced_step_inferior_state. It worked fine before, because
> displaced_step_clear didn't completely clear the displaced_step_inferior_state
> structure, so the required information (in this case the gdbarch) was
> still available after clearing.
>
> I fixed it by making GDB restore the child's memory before calling the
> displaced_step_fixup on the parent. This way, the data in the
> displaced_step_inferior_state structure is still valid when we use it for the
> child. This is the error you would get in
> gdb.base/step-over-syscall.exp without this fix:
>
> /home/smarchi/src/binutils-gdb/gdb/gdbarch.c:3911: internal-error: ULONGEST gdbarch_max_insn_length(gdbarch*): Assertion `gdbarch != NULL' failed.
If there's no objection, I would push these two patches next week.
Simon
next prev parent reply other threads:[~2020-02-13 22:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-22 15:14 Simon Marchi
2020-01-22 15:20 ` [PATCH 2/2] gdb: make gdbarch_displaced_step_copy_insn return an std::unique_ptr Simon Marchi
2020-02-14 19:47 ` Pedro Alves
2020-02-14 19:48 ` Pedro Alves
2020-02-14 20:31 ` Simon Marchi
2020-02-13 22:52 ` Simon Marchi [this message]
2020-02-14 19:39 ` [PATCH 1/2] gdb: cleanup of displaced_step_inferior_state::reset/displaced_step_clear Pedro Alves
2020-02-14 20:11 ` Simon Marchi
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=627719a0-6ae6-40b9-a6c4-6123dca89dc7@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@efficios.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).