From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@ericsson.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Delete program spaces directly when removing inferiors
Date: Wed, 08 Jul 2015 12:05:00 -0000 [thread overview]
Message-ID: <559D1220.1060708@redhat.com> (raw)
In-Reply-To: <1412022790-21931-1-git-send-email-simon.marchi@ericsson.com>
On 09/29/2014 09:33 PM, Simon Marchi wrote:
> -void
> -delete_inferior (int pid)
> -{
> - struct inferior *inf = find_inferior_pid (pid);
> -
> - delete_inferior_1 (inf, 0);
> -
> - if (print_inferior_events)
> - printf_unfiltered (_("[Inferior %d exited]\n"), pid);
> -}
> + /* If this program space is rendered useless, remove it. */
> + if (program_space_empty_p (inf->pspace))
> + delete_program_space (inf->pspace);
I think there's something odd with indentation here.
> - struct program_space *ss, **ss_link;
> - struct program_space *current = current_program_space;
> + gdb_assert(pspace != NULL);
> + gdb_assert(pspace != current_program_space);
>
> - ss = program_spaces;
> - ss_link = &program_spaces;
> - while (ss)
> + if (pspace == program_spaces)
> + program_spaces = pspace->next;
> + else
> {
> - if (ss == current || !pspace_empty_p (ss))
> + struct program_space *i = program_spaces;
> +
> + for (i = program_spaces; i != NULL; i = i->next)
> {
> - ss_link = &ss->next;
> - ss = *ss_link;
> - continue;
> + if (i->next == pspace)
> + {
> + i->next = i->next->next;
> + break;
> + }
> }
> -
> - *ss_link = ss->next;
> - release_program_space (ss);
> - ss = *ss_link;
> }
I don't find this conversion from while to if+else+for an
improvement. You can instead write:
ss = program_spaces;
ss_link = &program_spaces;
while (ss != NULL)
{
if (ss == pspace)
{
*ss_link = ss->next;
break;
}
ss_link = &ss->next;
ss = *ss_link;
}
release_program_space (pspace);
We use this _link pattern in several places.
OK with that change.
Thanks,
Pedro Alves
next prev parent reply other threads:[~2015-07-08 12:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-29 20:33 Simon Marchi
2014-10-20 17:46 ` Simon Marchi
2014-12-01 13:25 ` Simon Marchi
2015-07-06 17:46 ` Simon Marchi
2015-07-08 12:05 ` Pedro Alves [this message]
2015-07-08 15:34 ` Simon Marchi
2015-07-08 15:43 ` Simon Marchi
2015-07-08 15:59 ` Pedro Alves
2015-07-08 18:10 ` Simon Marchi
2015-07-08 18:17 ` Pedro Alves
2015-07-08 18:40 ` Simon Marchi
2015-07-08 18:51 ` Pedro Alves
2015-07-08 19:44 ` Simon Marchi
2015-07-08 19:49 ` 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=559D1220.1060708@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@ericsson.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).