From: Bernd Edlinger <bernd.edlinger@hotmail.de>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
Andrew Burgess <andrew.burgess@embecosm.com>
Subject: Re: [PATCHv2] Fix an undefined behavior in record_line
Date: Mon, 23 Mar 2020 22:25:42 +0100 [thread overview]
Message-ID: <AM6PR03MB5170C913A281DD3D1C128F97E4F00@AM6PR03MB5170.eurprd03.prod.outlook.com> (raw)
In-Reply-To: <AM6PR03MB51706F5467EBFE2345E48E3CE4F30@AM6PR03MB5170.eurprd03.prod.outlook.com>
On 3/22/20 4:25 AM, Bernd Edlinger wrote:
> On 3/13/20 12:55 PM, Bernd Edlinger wrote:
>> Additionally do not completely remove symbols
>> at the same PC than the end marker, instead
>> make them non-is-stmt breakpoints.
>>
>> Also fix the condition when the line table need to be resized,
>> that was wasting one element.
>>
>> 2020-03-10 Bernd Edlinger <bernd.edlinger@hotmail.de>
>> * buildsym.c (record_line): Fix ub and preserve lines at eof.
>> ---
>> gdb/buildsym.c | 28 +++++++++++-----------------
>> 1 file changed, 11 insertions(+), 17 deletions(-)
>>
>> diff --git a/gdb/buildsym.c b/gdb/buildsym.c
>> index 7155db3..960a36c 100644
>> --- a/gdb/buildsym.c
>> +++ b/gdb/buildsym.c
>> @@ -695,7 +695,7 @@ struct blockvector *
>> }
>> }
>>
>> - if (subfile->line_vector->nitems + 1 >= subfile->line_vector_length)
>> + if (subfile->line_vector->nitems >= subfile->line_vector_length)
>> {
>> subfile->line_vector_length *= 2;
>> subfile->line_vector = (struct linetable *)
>> @@ -705,27 +705,21 @@ struct blockvector *
>> * sizeof (struct linetable_entry))));
>> }
>>
>> - /* Normally, we treat lines as unsorted. But the end of sequence
>> - marker is special. We sort line markers at the same PC by line
>> - number, so end of sequence markers (which have line == 0) appear
>> - first. This is right if the marker ends the previous function,
>> - and there is no padding before the next function. But it is
>> - wrong if the previous line was empty and we are now marking a
>> - switch to a different subfile. We must leave the end of sequence
>> - marker at the end of this group of lines, not sort the empty line
>> - to after the marker. The easiest way to accomplish this is to
>> - delete any empty lines from our table, if they are followed by
>> - end of sequence markers. All we lose is the ability to set
>> - breakpoints at some lines which contain no instructions
>> - anyway. */
>> + /* The end of sequence marker is special. We need to reset the
>> + is_stmt flag on previous lines at the same PC, otherwise these
>> + lines may cause problems. All we lose is the ability to set
>> + breakpoints at some lines which contain no instructions anyway. */
>> if (line == 0 && subfile->line_vector->nitems > 0)
>> {
>> - e = subfile->line_vector->item + subfile->line_vector->nitems - 1;
>> - while (subfile->line_vector->nitems > 0 && e->pc == pc)
>> + e = subfile->line_vector->item + subfile->line_vector->nitems;
>> + do
>> {
>> e--;
>> - subfile->line_vector->nitems--;
>> + if (e->pc != pc || e->line == 0)
>> + break;
>> + e->is_stmt = 0;
>> }
>> + while (e > subfile->line_vector->item);
>> }
>>
>> e = subfile->line_vector->item + subfile->line_vectoms++;
>>
Andrew, this is the place where currently the is-stmt entries
are deleted. With your is-stmt patch this code is executed in more
cases than before. Therefore I would suggest to convert them
to !is_stmt lines for now, but maybe in the long run add a new flag
that allows them to be used in the file:line case, but make these
lines behave differently when stepping, I am only trying to fix
the case where you step out of the subroutine.
Bernd.
next prev parent reply other threads:[~2020-03-23 21:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-13 11:55 Bernd Edlinger
2020-03-22 3:25 ` Bernd Edlinger
2020-03-23 21:25 ` Bernd Edlinger [this message]
2020-03-24 9:10 ` Andrew Burgess
2020-03-24 10:20 ` Bernd Edlinger
2020-03-25 11:08 ` Andrew Burgess
2020-03-25 11:50 ` Bernd Edlinger
2020-03-27 3:09 ` Bernd Edlinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AM6PR03MB5170C913A281DD3D1C128F97E4F00@AM6PR03MB5170.eurprd03.prod.outlook.com \
--to=bernd.edlinger@hotmail.de \
--cc=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox