This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Delete program spaces directly when removing inferiors
- From: Pedro Alves <palves at redhat dot com>
- To: Simon Marchi <simon dot marchi at ericsson dot com>, gdb-patches at sourceware dot org
- Date: Wed, 08 Jul 2015 13:05:52 +0100
- Subject: Re: [PATCH] Delete program spaces directly when removing inferiors
- Authentication-results: sourceware.org; auth=none
- References: <1412022790-21931-1-git-send-email-simon dot marchi at ericsson dot 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