* [PATCH] gdb: add -a option for remove-inferior
@ 2016-12-29 17:45 sbaugh
2016-12-29 18:13 ` Luis Machado
0 siblings, 1 reply; 2+ messages in thread
From: sbaugh @ 2016-12-29 17:45 UTC (permalink / raw)
To: gdb-patches
I find myself frequently wanting to wipe out the current set of
inferiors: detaching from all of them, or killing them all, and then
starting anew. A -a flag to the various inferior commands which currently
just take ranges of ids would make this a lot easier. Does that sound
like a reasonable enhancement?
If this patch is acceptable I'll go ahead and add -a flags like this to
all the inferior commands where it makes sense, and add docs, and
resubmit.
This adds a -a option for remove-inferior; when passed, all inferiors
will be removed.
---
gdb/inferior.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/gdb/inferior.c b/gdb/inferior.c
index 32b6db2..f4cd062 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -775,13 +775,25 @@ info_inferiors_command (char *args, int from_tty)
print_inferior (current_uiout, args);
}
-/* remove-inferior ID */
+/* remove-inferior [-a] ID */
static void
remove_inferior_command (char *args, int from_tty)
{
if (args == NULL || *args == '\0')
- error (_("Requires an argument (inferior id(s) to remove)"));
+ error (_("Requires an argument (inferior id(s) to remove or -a)"));
+
+ if (startswith (args, "-a"))
+ {
+ struct inferior *inf, *cur;
+ cur = current_inferior();
+ ALL_INFERIORS(inf)
+ {
+ if (inf != cur)
+ delete_inferior (inf);
+ }
+ return;
+ }
number_or_range_parser parser (args);
while (!parser.finished ())
@@ -1056,7 +1068,7 @@ as main program."));
add_com ("remove-inferiors", no_class, remove_inferior_command, _("\
Remove inferior ID (or list of IDs).\n\
-Usage: remove-inferiors ID..."));
+Usage: remove-inferiors [-a] ID..."));
add_com ("clone-inferior", no_class, clone_inferior_command, _("\
Clone inferior ID.\n\
--
2.10.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] gdb: add -a option for remove-inferior
2016-12-29 17:45 [PATCH] gdb: add -a option for remove-inferior sbaugh
@ 2016-12-29 18:13 ` Luis Machado
0 siblings, 0 replies; 2+ messages in thread
From: Luis Machado @ 2016-12-29 18:13 UTC (permalink / raw)
To: sbaugh, gdb-patches
On 12/29/2016 11:13 AM, sbaugh@catern.com wrote:
>
> I find myself frequently wanting to wipe out the current set of
> inferiors: detaching from all of them, or killing them all, and then
> starting anew. A -a flag to the various inferior commands which currently
> just take ranges of ids would make this a lot easier. Does that sound
> like a reasonable enhancement?
>
> If this patch is acceptable I'll go ahead and add -a flags like this to
> all the inferior commands where it makes sense, and add docs, and
> resubmit.
>
>
> This adds a -a option for remove-inferior; when passed, all inferiors
> will be removed.
>
> ---
> gdb/inferior.c | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/gdb/inferior.c b/gdb/inferior.c
> index 32b6db2..f4cd062 100644
> --- a/gdb/inferior.c
> +++ b/gdb/inferior.c
> @@ -775,13 +775,25 @@ info_inferiors_command (char *args, int from_tty)
> print_inferior (current_uiout, args);
> }
>
> -/* remove-inferior ID */
> +/* remove-inferior [-a] ID */
>
> static void
> remove_inferior_command (char *args, int from_tty)
> {
> if (args == NULL || *args == '\0')
> - error (_("Requires an argument (inferior id(s) to remove)"));
> + error (_("Requires an argument (inferior id(s) to remove or -a)"));
> +
> + if (startswith (args, "-a"))
> + {
> + struct inferior *inf, *cur;
> + cur = current_inferior();
> + ALL_INFERIORS(inf)
> + {
> + if (inf != cur)
> + delete_inferior (inf);
> + }
> + return;
> + }
>
> number_or_range_parser parser (args);
> while (!parser.finished ())
> @@ -1056,7 +1068,7 @@ as main program."));
>
> add_com ("remove-inferiors", no_class, remove_inferior_command, _("\
> Remove inferior ID (or list of IDs).\n\
> -Usage: remove-inferiors ID..."));
> +Usage: remove-inferiors [-a] ID..."));
>
> add_com ("clone-inferior", no_class, clone_inferior_command, _("\
> Clone inferior ID.\n\
>
It sounds like a reasonable option to me. I wonder if a regular
expression would be better than -a? So, it would be easier to say
"remove-inferior *". It may be a bit more complicated to address though.
In any case, -a seems to be a good addition.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-12-29 18:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-29 17:45 [PATCH] gdb: add -a option for remove-inferior sbaugh
2016-12-29 18:13 ` Luis Machado
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox