[05/14] change how the CLI handles comments

Message ID 1400253995-12333-6-git-send-email-tromey@redhat.com
State Superseded
Headers

Commit Message

Tom Tromey May 16, 2014, 3:26 p.m. UTC
  From: Phil Muldoon <pmuldoon@redhat.com>

When using the multi-line feature, we don't want the gdb CLI to remove
comments from the command list, as this will remove things like
"#define".

This patch moves the comment feature into command_loop to avoid this
problem.

2014-05-16  Phil Muldoon  <pmuldoon@redhat.com>

	* top.c (command_loop): Handle comments here...
	(command_line_input): ... not here.
---
 gdb/ChangeLog |  5 +++++
 gdb/top.c     | 20 +++++++-------------
 2 files changed, 12 insertions(+), 13 deletions(-)
  

Comments

Doug Evans May 18, 2014, 11:26 p.m. UTC | #1
On Fri, May 16, 2014 at 8:26 AM, Tom Tromey <tromey@redhat.com> wrote:
> From: Phil Muldoon <pmuldoon@redhat.com>
>
> When using the multi-line feature, we don't want the gdb CLI to remove
> comments from the command list, as this will remove things like
> "#define".
>
> This patch moves the comment feature into command_loop to avoid this
> problem.
>
> 2014-05-16  Phil Muldoon  <pmuldoon@redhat.com>
>
>         * top.c (command_loop): Handle comments here...
>         (command_line_input): ... not here.
> ---
>  gdb/ChangeLog |  5 +++++
>  gdb/top.c     | 20 +++++++-------------
>  2 files changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/gdb/top.c b/gdb/top.c
> index fa20025..16694e6 100644
> --- a/gdb/top.c
> +++ b/gdb/top.c
> @@ -560,11 +560,14 @@ command_loop (void)
>
>        make_command_stats_cleanup (1);
>
> -      execute_command (command, instream == stdin);
> -
> -      /* Do any commands attached to breakpoint we are stopped at.  */
> -      bpstat_do_actions ();
> +      /* Do not execute commented lines.  */
> +      if (command[0] != '#')
> +       {
> +         execute_command (command, instream == stdin);
>
> +         /* Do any commands attached to breakpoint we are stopped at.  */
> +         bpstat_do_actions ();
> +       }
>        do_cleanups (old_chain);
>      }
>  }
> @@ -1057,15 +1060,6 @@ command_line_input (char *prompt_arg, int repeat, char *annotation_suffix)
>    if (*linebuffer && input_from_terminal_p ())
>      add_history (linebuffer);
>
> -  /* Note: lines consisting solely of comments are added to the command
> -     history.  This is useful when you type a command, and then
> -     realize you don't want to execute it quite yet.  You can comment
> -     out the command and then later fetch it from the value history
> -     and remove the '#'.  The kill ring is probably better, but some
> -     people are in the habit of commenting things out.  */
> -  if (*p1 == '#')
> -    *p1 = '\0';                        /* Found a comment.  */
> -
>    /* Save into global buffer if appropriate.  */
>    if (repeat)
>      {
> --
> 1.9.0
>

Hi.  I have an equivalent patch that I need for guile support.
E.g.,
guile
(foo
  #:bar 42)
end

Since this is really independent of the rest of the patch set,
can this be checked in right away?
TIA
  
Phil Muldoon May 19, 2014, 2:07 p.m. UTC | #2
On 19/05/14 00:26, Doug Evans wrote:
> On Fri, May 16, 2014 at 8:26 AM, Tom Tromey <tromey@redhat.com> wrote:
>> diff --git a/gdb/top.c b/gdb/top.c
>> index fa20025..16694e6 100644
>> --- a/gdb/top.c
>> +++ b/gdb/top.c
>> @@ -560,11 +560,14 @@ command_loop (void)
>>
>>        make_command_stats_cleanup (1);
>>
>> -      execute_command (command, instream == stdin);
>> -
>> -      /* Do any commands attached to breakpoint we are stopped at.  */
>> -      bpstat_do_actions ();
>> +      /* Do not execute commented lines.  */
>> +      if (command[0] != '#')
>> +       {
>> +         execute_command (command, instream == stdin);
>>
>> +         /* Do any commands attached to breakpoint we are stopped at.  */
>> +         bpstat_do_actions ();
>> +       }
>>        do_cleanups (old_chain);
>>      }
>>  }
>> @@ -1057,15 +1060,6 @@ command_line_input (char *prompt_arg, int repeat, char *annotation_suffix)
>>    if (*linebuffer && input_from_terminal_p ())
>>      add_history (linebuffer);
>>
>> -  /* Note: lines consisting solely of comments are added to the command
>> -     history.  This is useful when you type a command, and then
>> -     realize you don't want to execute it quite yet.  You can comment
>> -     out the command and then later fetch it from the value history
>> -     and remove the '#'.  The kill ring is probably better, but some
>> -     people are in the habit of commenting things out.  */
>> -  if (*p1 == '#')
>> -    *p1 = '\0';                        /* Found a comment.  */
>> -
>>    /* Save into global buffer if appropriate.  */
>>    if (repeat)
>>      {
>> --
>> 1.9.0
>>
>
> Hi.  I have an equivalent patch that I need for guile support.
> E.g.,
> guile
> (foo
>   #:bar 42)
> end
>
> Since this is really independent of the rest of the patch set,
> can this be checked in right away?
> TIA

I have no problems with you checking this patch in as long as nobody
else objects.  Lets give it a day or so for people to speak up.
Pending that I would say go ahead.

Cheers,

Phil
  
Doug Evans June 3, 2014, 7:03 a.m. UTC | #3
Phil Muldoon <pmuldoon@redhat.com> writes:

> On 19/05/14 00:26, Doug Evans wrote:
>> On Fri, May 16, 2014 at 8:26 AM, Tom Tromey <tromey@redhat.com> wrote:
>>> diff --git a/gdb/top.c b/gdb/top.c
>>> index fa20025..16694e6 100644
>>> --- a/gdb/top.c
>>> +++ b/gdb/top.c
>>> @@ -560,11 +560,14 @@ command_loop (void)
>>>
>>>        make_command_stats_cleanup (1);
>>>
>>> -      execute_command (command, instream == stdin);
>>> -
>>> -      /* Do any commands attached to breakpoint we are stopped at.  */
>>> -      bpstat_do_actions ();
>>> +      /* Do not execute commented lines.  */
>>> +      if (command[0] != '#')
>>> +       {
>>> +         execute_command (command, instream == stdin);
>>>
>>> +         /* Do any commands attached to breakpoint we are stopped at.  */
>>> +         bpstat_do_actions ();
>>> +       }
>>>        do_cleanups (old_chain);
>>>      }
>>>  }
>>> @@ -1057,15 +1060,6 @@ command_line_input (char *prompt_arg, int repeat, char *annotation_suffix)
>>>    if (*linebuffer && input_from_terminal_p ())
>>>      add_history (linebuffer);
>>>
>>> -  /* Note: lines consisting solely of comments are added to the command
>>> -     history.  This is useful when you type a command, and then
>>> -     realize you don't want to execute it quite yet.  You can comment
>>> -     out the command and then later fetch it from the value history
>>> -     and remove the '#'.  The kill ring is probably better, but some
>>> -     people are in the habit of commenting things out.  */
>>> -  if (*p1 == '#')
>>> -    *p1 = '\0';                        /* Found a comment.  */
>>> -
>>>    /* Save into global buffer if appropriate.  */
>>>    if (repeat)
>>>      {
>>> --
>>> 1.9.0
>>>
>>
>> Hi.  I have an equivalent patch that I need for guile support.
>> E.g.,
>> guile
>> (foo
>>   #:bar 42)
>> end
>>
>> Since this is really independent of the rest of the patch set,
>> can this be checked in right away?
>> TIA
>
> I have no problems with you checking this patch in as long as nobody
> else objects.  Lets give it a day or so for people to speak up.
> Pending that I would say go ahead.
>
> Cheers,
>
> Phil

Hi.

I have committed this.
Thanks.
  

Patch

diff --git a/gdb/top.c b/gdb/top.c
index fa20025..16694e6 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -560,11 +560,14 @@  command_loop (void)
 
       make_command_stats_cleanup (1);
 
-      execute_command (command, instream == stdin);
-
-      /* Do any commands attached to breakpoint we are stopped at.  */
-      bpstat_do_actions ();
+      /* Do not execute commented lines.  */
+      if (command[0] != '#')
+	{
+	  execute_command (command, instream == stdin);
 
+	  /* Do any commands attached to breakpoint we are stopped at.  */
+	  bpstat_do_actions ();
+	}
       do_cleanups (old_chain);
     }
 }
@@ -1057,15 +1060,6 @@  command_line_input (char *prompt_arg, int repeat, char *annotation_suffix)
   if (*linebuffer && input_from_terminal_p ())
     add_history (linebuffer);
 
-  /* Note: lines consisting solely of comments are added to the command
-     history.  This is useful when you type a command, and then
-     realize you don't want to execute it quite yet.  You can comment
-     out the command and then later fetch it from the value history
-     and remove the '#'.  The kill ring is probably better, but some
-     people are in the habit of commenting things out.  */
-  if (*p1 == '#')
-    *p1 = '\0';			/* Found a comment.  */
-
   /* Save into global buffer if appropriate.  */
   if (repeat)
     {