From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: jan.kratochvil@redhat.com
Cc: gdb-patches@sourceware.org
Subject: Re: [patch 2/4] hw watchpoints across fork()
Date: Mon, 06 Dec 2010 13:05:00 -0000 [thread overview]
Message-ID: <201012061305.oB6D5NMi021251@glazunov.sibelius.xs4all.nl> (raw)
In-Reply-To: <20101206111300.GC27176@host0.dyn.jankratochvil.net> (message from Jan Kratochvil on Mon, 6 Dec 2010 12:13:01 +0100)
> Date: Mon, 6 Dec 2010 12:13:01 +0100
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
>
> --- a/gdb/i386-nat.c
> +++ b/gdb/i386-nat.c
> @@ -220,16 +220,50 @@ static int i386_handle_nonaligned_watchpoint (i386_wp_op_t what,
>
> /* Implementation. */
>
> +/* Per-inferior data key. */
> +static const struct inferior_data *i386_inferior_data;
> +
> +struct i386_inferior_data
> + {
> + /* Copy of i386 hardware debug registers for performance reasons. */
> + struct dr_mirror dr_mirror;
> + };
> +
> +static struct i386_inferior_data *
> +i386_inferior_data_get (void)
> +{
> + static struct i386_inferior_data inf_data_local;
> + struct inferior *inf = current_inferior ();
> + struct i386_inferior_data *inf_data = &inf_data_local;
> + static struct i386_inferior_data *detached_inf_data;
> + static int detached_inf_pid = -1;
The whole dance with inf_data seems unecessarily complicated to me.
Why not...
> +
> + if (inf->pid != ptid_get_pid (inferior_ptid))
> + {
> + if (detached_inf_pid != ptid_get_pid (inferior_ptid))
> + {
> + xfree (detached_inf_data);
> + detached_inf_pid = ptid_get_pid (inferior_ptid);
> + detached_inf_data = xmalloc (sizeof (*detached_inf_data));
Huh, free and immediately malloc?
> +
> + /* Forked processes get a copy of the debug registers. */
> + memcpy (detached_inf_data, inf_data, sizeof (*detached_inf_data));
> + }
> +
> + gdb_assert (detached_inf_data != NULL);
> + inf_data = detached_inf_data;
Simply return detached_inf_data here.
> + }
> +
> + return inf_data;
And return &inf_data_local here? But why are you returning pointers
to static storage in the first place? I'm abviously missing the point
of this function. Can you explain?
next prev parent reply other threads:[~2010-12-06 13:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-06 11:13 Jan Kratochvil
2010-12-06 13:05 ` Mark Kettenis [this message]
2010-12-11 5:15 ` Jan Kratochvil
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=201012061305.oB6D5NMi021251@glazunov.sibelius.xs4all.nl \
--to=mark.kettenis@xs4all.nl \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.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