This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA 1/2] Fix regressions for multi breakpoints command line setting/clearing


>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

>>> if (repeat && *p1 == '\0')
>>> -    return saved_command_line;
>>> +    {
>>> +      xfree (buffer_finish (cmd_line_buffer));
>>> +      buffer_grow_str0 (cmd_line_buffer, saved_command_line);
>>> +      cmd_line_buffer->used_size = 0;

Philippe> I was somewhat surprised by used_size being set to 0.
Philippe> I am not sure to understand in which case it is supposed to be
Philippe> set to 0 : it is set to 0 in the first few lines of handle_line_of_input
Philippe> with a comment explaining why.
Philippe> I however do not understand why it is set to the string length in
Philippe> the 'Do history expansion' case, and not to 0 : as far as I can see,
Philippe> cmd will be returned as a full line in case of expansion ?

Tom> Thanks for noticing this.

Tom> I suspect the history case (which doesn't seem to be tested...) is just
Tom> wrong and should also set the used size to 0.

I think we both misread this, because the history expansion case does:

	  xfree (buffer_finish (cmd_line_buffer));
	  cmd_line_buffer->buffer = history_value;
	  cmd_line_buffer->buffer_size = len + 1;

... which does not change used_size.

So, I think all the cases are behaving properly.

Tom> I'll see if I can come up with a test case here.

I'm still going to write a history expansion test, because there should
be at least one.

Philippe> So, I am wondering what kind of usage of this function
Philippe> will make the buffer bigger. Maybe worth pointing at the
Philippe> above risk then ?

Tom> I can add a comment somewhere.

Actually I don't think there is a problem here.
The growing case, I think, can only happen with continuation lines.
Otherwise the buffer is stable -- I think, provided we don't reenter the
command loop -- for the duration of the command.

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]