* [PATCH] Don't prune program spaces when doing "maintenance info program-spaces"
@ 2014-09-24 18:11 Simon Marchi
2014-09-24 18:53 ` Sergio Durigan Junior
2014-09-24 22:48 ` Doug Evans
0 siblings, 2 replies; 9+ messages in thread
From: Simon Marchi @ 2014-09-24 18:11 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
While debugging a program spaces issue, I found that "maintenance info
program-spaces" pruned the program spaces prior to printing them. I
don't think a command to inspect the state of the program (especially
a maintenance one) should modify the state. All it can do is potentially
hide bugs.
gdb/Changelog:
* progspace.c (print_program_space): Add "prune" parameter.
(maintenance_info_program_spaces_command): Update call to
print_program_space with new parameter.
---
gdb/progspace.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/gdb/progspace.c b/gdb/progspace.c
index a74b6ab..aef2d4e 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -272,18 +272,19 @@ prune_program_spaces (void)
/* Prints the list of program spaces and their details on UIOUT. If
REQUESTED is not -1, it's the ID of the pspace that should be
- printed. Otherwise, all spaces are printed. */
+ printed. Otherwise, all spaces are printed. If PRUNE is true,
+ prune the unused program spaces prior to printing them, so they
+ won't be displayed. */
static void
-print_program_space (struct ui_out *uiout, int requested)
+print_program_space (struct ui_out *uiout, int requested, int prune)
{
struct program_space *pspace;
int count = 0;
struct cleanup *old_chain;
- /* Might as well prune away unneeded ones, so the user doesn't even
- seem them. */
- prune_program_spaces ();
+ if (prune)
+ prune_program_spaces ();
/* Compute number of pspaces we will print. */
ALL_PSPACES (pspace)
@@ -385,7 +386,7 @@ maintenance_info_program_spaces_command (char *args, int from_tty)
error (_("program space ID %d not known."), requested);
}
- print_program_space (current_uiout, requested);
+ print_program_space (current_uiout, requested, 0 /* prune */);
}
/* Simply returns the count of program spaces. */
--
2.1.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Don't prune program spaces when doing "maintenance info program-spaces"
2014-09-24 18:11 [PATCH] Don't prune program spaces when doing "maintenance info program-spaces" Simon Marchi
@ 2014-09-24 18:53 ` Sergio Durigan Junior
2014-09-24 19:31 ` Simon Marchi
2014-09-24 22:48 ` Doug Evans
1 sibling, 1 reply; 9+ messages in thread
From: Sergio Durigan Junior @ 2014-09-24 18:53 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
On Wednesday, September 24 2014, Simon Marchi wrote:
> While debugging a program spaces issue, I found that "maintenance info
> program-spaces" pruned the program spaces prior to printing them. I
> don't think a command to inspect the state of the program (especially
> a maintenance one) should modify the state. All it can do is potentially
> hide bugs.
Hi Simon,
Thanks for the patch. I agree with your rationale, and just have one
comment.
> ---
> gdb/progspace.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/gdb/progspace.c b/gdb/progspace.c
> index a74b6ab..aef2d4e 100644
> --- a/gdb/progspace.c
> +++ b/gdb/progspace.c
> @@ -272,18 +272,19 @@ prune_program_spaces (void)
>
> /* Prints the list of program spaces and their details on UIOUT. If
> REQUESTED is not -1, it's the ID of the pspace that should be
> - printed. Otherwise, all spaces are printed. */
> + printed. Otherwise, all spaces are printed. If PRUNE is true,
> + prune the unused program spaces prior to printing them, so they
> + won't be displayed. */
>
> static void
> -print_program_space (struct ui_out *uiout, int requested)
> +print_program_space (struct ui_out *uiout, int requested, int prune)
> {
> struct program_space *pspace;
> int count = 0;
> struct cleanup *old_chain;
>
> - /* Might as well prune away unneeded ones, so the user doesn't even
> - seem them. */
> - prune_program_spaces ();
> + if (prune)
> + prune_program_spaces ();
>
> /* Compute number of pspaces we will print. */
> ALL_PSPACES (pspace)
> @@ -385,7 +386,7 @@ maintenance_info_program_spaces_command (char *args, int from_tty)
> error (_("program space ID %d not known."), requested);
> }
>
> - print_program_space (current_uiout, requested);
> + print_program_space (current_uiout, requested, 0 /* prune */);
Just like we had a comment explaining why we were pruning progspaces, I
think a small comment here explaining why we are *not* pruning them
would be neat.
Otherwise, looks good to me (this is not an approval).
Thanks,
--
Sergio
GPG key ID: 0x65FC5E36
Please send encrypted e-mail if possible
http://sergiodj.net/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Don't prune program spaces when doing "maintenance info program-spaces"
2014-09-24 18:53 ` Sergio Durigan Junior
@ 2014-09-24 19:31 ` Simon Marchi
2014-09-24 19:34 ` Sergio Durigan Junior
0 siblings, 1 reply; 9+ messages in thread
From: Simon Marchi @ 2014-09-24 19:31 UTC (permalink / raw)
To: Sergio Durigan Junior; +Cc: gdb-patches
On 2014-09-24 02:53 PM, Sergio Durigan Junior wrote:
>> @@ -385,7 +386,7 @@ maintenance_info_program_spaces_command (char *args, int from_tty)
>> error (_("program space ID %d not known."), requested);
>> }
>>
>> - print_program_space (current_uiout, requested);
>> + print_program_space (current_uiout, requested, 0 /* prune */);
>
> Just like we had a comment explaining why we were pruning progspaces, I
> think a small comment here explaining why we are *not* pruning them
> would be neat.
Sure, I could add to the current patch, above the call to print_program_space:
/* Since this is an "info" command, we want to avoid modifying
the state of the debugger. Therefore, don't prune unused
program spaces. */
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Don't prune program spaces when doing "maintenance info program-spaces"
2014-09-24 19:31 ` Simon Marchi
@ 2014-09-24 19:34 ` Sergio Durigan Junior
0 siblings, 0 replies; 9+ messages in thread
From: Sergio Durigan Junior @ 2014-09-24 19:34 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
On Wednesday, September 24 2014, Simon Marchi wrote:
> Sure, I could add to the current patch, above the call to print_program_space:
>
> /* Since this is an "info" command, we want to avoid modifying
> the state of the debugger. Therefore, don't prune unused
> program spaces. */
Nice, thanks Simon.
--
Sergio
GPG key ID: 0x65FC5E36
Please send encrypted e-mail if possible
http://sergiodj.net/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Don't prune program spaces when doing "maintenance info program-spaces"
2014-09-24 18:11 [PATCH] Don't prune program spaces when doing "maintenance info program-spaces" Simon Marchi
2014-09-24 18:53 ` Sergio Durigan Junior
@ 2014-09-24 22:48 ` Doug Evans
2014-09-25 2:31 ` Sergio Durigan Junior
1 sibling, 1 reply; 9+ messages in thread
From: Doug Evans @ 2014-09-24 22:48 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches
On Wed, Sep 24, 2014 at 11:11 AM, Simon Marchi
<simon.marchi@ericsson.com> wrote:
> While debugging a program spaces issue, I found that "maintenance info
> program-spaces" pruned the program spaces prior to printing them. I
> don't think a command to inspect the state of the program (especially
> a maintenance one) should modify the state. All it can do is potentially
> hide bugs.
>
> gdb/Changelog:
>
> * progspace.c (print_program_space): Add "prune" parameter.
> (maintenance_info_program_spaces_command): Update call to
> print_program_space with new parameter.
> ---
> gdb/progspace.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/gdb/progspace.c b/gdb/progspace.c
> index a74b6ab..aef2d4e 100644
> --- a/gdb/progspace.c
> +++ b/gdb/progspace.c
> @@ -272,18 +272,19 @@ prune_program_spaces (void)
>
> /* Prints the list of program spaces and their details on UIOUT. If
> REQUESTED is not -1, it's the ID of the pspace that should be
> - printed. Otherwise, all spaces are printed. */
> + printed. Otherwise, all spaces are printed. If PRUNE is true,
> + prune the unused program spaces prior to printing them, so they
> + won't be displayed. */
>
> static void
> -print_program_space (struct ui_out *uiout, int requested)
> +print_program_space (struct ui_out *uiout, int requested, int prune)
> {
> struct program_space *pspace;
> int count = 0;
> struct cleanup *old_chain;
>
> - /* Might as well prune away unneeded ones, so the user doesn't even
> - seem them. */
> - prune_program_spaces ();
> + if (prune)
> + prune_program_spaces ();
>
> /* Compute number of pspaces we will print. */
> ALL_PSPACES (pspace)
> @@ -385,7 +386,7 @@ maintenance_info_program_spaces_command (char *args, int from_tty)
> error (_("program space ID %d not known."), requested);
> }
>
> - print_program_space (current_uiout, requested);
> + print_program_space (current_uiout, requested, 0 /* prune */);
> }
>
> /* Simply returns the count of program spaces. */
Hi.
I agree we want to, in general, avoid side-effects in info commands
(even more so in maint info commands).
OTOH, as a reader of this code I wouldn't expect a print routine to
have side-effects either.
IOW, how about move the call to prune_program_spaces to whatever
caller wants it.
btw, is part of this patch missing?
Is there intended to be another caller of print_program_spaces that
passes prune = 1?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Don't prune program spaces when doing "maintenance info program-spaces"
2014-09-24 22:48 ` Doug Evans
@ 2014-09-25 2:31 ` Sergio Durigan Junior
2014-09-25 14:44 ` Simon Marchi
0 siblings, 1 reply; 9+ messages in thread
From: Sergio Durigan Junior @ 2014-09-25 2:31 UTC (permalink / raw)
To: Doug Evans; +Cc: Simon Marchi, gdb-patches
On Wednesday, September 24 2014, Doug Evans wrote:
> IOW, how about move the call to prune_program_spaces to whatever
> caller wants it.
As a note, after I commented on the patch, I noticed that the "prune"
argument may be unecessary indeed (and the "prunning" logic"), because
we are not prunning anything anymore.
Anyway, I just wanted to say that I agree with removing this part of the
code, and moving it to more suitable parts.
--
Sergio
GPG key ID: 0x65FC5E36
Please send encrypted e-mail if possible
http://sergiodj.net/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Don't prune program spaces when doing "maintenance info program-spaces"
2014-09-25 2:31 ` Sergio Durigan Junior
@ 2014-09-25 14:44 ` Simon Marchi
2014-09-25 19:13 ` Doug Evans
0 siblings, 1 reply; 9+ messages in thread
From: Simon Marchi @ 2014-09-25 14:44 UTC (permalink / raw)
To: Sergio Durigan Junior, Doug Evans; +Cc: gdb-patches
On 2014-09-24 10:30 PM, Sergio Durigan Junior wrote:
> On Wednesday, September 24 2014, Doug Evans wrote:
>
>> IOW, how about move the call to prune_program_spaces to whatever
>> caller wants it.
>
> As a note, after I commented on the patch, I noticed that the "prune"
> argument may be unecessary indeed (and the "prunning" logic"), because
> we are not prunning anything anymore.
>
> Anyway, I just wanted to say that I agree with removing this part of the
> code, and moving it to more suitable parts.
Fine with me. Here is the updated patch, much simpler now.
gdb/Changelog:
* progspace.c (print_program_space): Don't prune program spaces
before printing them.
---
gdb/progspace.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/gdb/progspace.c b/gdb/progspace.c
index a74b6ab..b111a50 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -281,10 +281,6 @@ print_program_space (struct ui_out *uiout, int requested)
int count = 0;
struct cleanup *old_chain;
- /* Might as well prune away unneeded ones, so the user doesn't even
- seem them. */
- prune_program_spaces ();
-
/* Compute number of pspaces we will print. */
ALL_PSPACES (pspace)
{
--
2.1.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Don't prune program spaces when doing "maintenance info program-spaces"
2014-09-25 14:44 ` Simon Marchi
@ 2014-09-25 19:13 ` Doug Evans
2014-09-26 14:37 ` Simon Marchi
0 siblings, 1 reply; 9+ messages in thread
From: Doug Evans @ 2014-09-25 19:13 UTC (permalink / raw)
To: Simon Marchi; +Cc: Sergio Durigan Junior, gdb-patches
On Thu, Sep 25, 2014 at 8:44 AM, Simon Marchi <simon.marchi@ericsson.com> wrote:
> On 2014-09-24 10:30 PM, Sergio Durigan Junior wrote:
>> On Wednesday, September 24 2014, Doug Evans wrote:
>>
>>> IOW, how about move the call to prune_program_spaces to whatever
>>> caller wants it.
>>
>> As a note, after I commented on the patch, I noticed that the "prune"
>> argument may be unecessary indeed (and the "prunning" logic"), because
>> we are not prunning anything anymore.
>>
>> Anyway, I just wanted to say that I agree with removing this part of the
>> code, and moving it to more suitable parts.
>
> Fine with me. Here is the updated patch, much simpler now.
>
> gdb/Changelog:
>
> * progspace.c (print_program_space): Don't prune program spaces
> before printing them.
LGTM
In the commit log I would add a note that this was removed so that the
print routine didn't have (unwanted) side-effects.
Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Don't prune program spaces when doing "maintenance info program-spaces"
2014-09-25 19:13 ` Doug Evans
@ 2014-09-26 14:37 ` Simon Marchi
0 siblings, 0 replies; 9+ messages in thread
From: Simon Marchi @ 2014-09-26 14:37 UTC (permalink / raw)
To: Doug Evans; +Cc: Sergio Durigan Junior, gdb-patches
On 2014-09-25 03:13 PM, Doug Evans wrote:
> On Thu, Sep 25, 2014 at 8:44 AM, Simon Marchi <simon.marchi@ericsson.com> wrote:
>> On 2014-09-24 10:30 PM, Sergio Durigan Junior wrote:
>>> On Wednesday, September 24 2014, Doug Evans wrote:
>>>
>>>> IOW, how about move the call to prune_program_spaces to whatever
>>>> caller wants it.
>>>
>>> As a note, after I commented on the patch, I noticed that the "prune"
>>> argument may be unecessary indeed (and the "prunning" logic"), because
>>> we are not prunning anything anymore.
>>>
>>> Anyway, I just wanted to say that I agree with removing this part of the
>>> code, and moving it to more suitable parts.
>>
>> Fine with me. Here is the updated patch, much simpler now.
>>
>> gdb/Changelog:
>>
>> * progspace.c (print_program_space): Don't prune program spaces
>> before printing them.
>
> LGTM
>
> In the commit log I would add a note that this was removed so that the
> print routine didn't have (unwanted) side-effects.
>
> Thanks.
Pushed, thanks!
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-09-26 14:37 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-24 18:11 [PATCH] Don't prune program spaces when doing "maintenance info program-spaces" Simon Marchi
2014-09-24 18:53 ` Sergio Durigan Junior
2014-09-24 19:31 ` Simon Marchi
2014-09-24 19:34 ` Sergio Durigan Junior
2014-09-24 22:48 ` Doug Evans
2014-09-25 2:31 ` Sergio Durigan Junior
2014-09-25 14:44 ` Simon Marchi
2014-09-25 19:13 ` Doug Evans
2014-09-26 14:37 ` Simon Marchi
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).