From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074013.outbound.protection.outlook.com [40.92.74.13]) by sourceware.org (Postfix) with ESMTPS id 411F8385E010 for ; Fri, 27 Mar 2020 03:09:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 411F8385E010 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bernd.edlinger@hotmail.de ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hj05GL7EG/3XpfW/bMNvZnxZbWG+Or0XdIYWZ/KC15NZZ8pCNXXY7+nBteunrXwr6ob9HjFZdoYabwmr36oGE4Y9J+XRqn+yC4hQivlCyeb+TSIHA/Bkh8O+fFTkflHK3MCXjstJGAP+ctttvbQjJ6NcVrFXXIy4n8iu27K2ObwKWgPC4H3pgR5YPTiYMXUzWNLdF82cKRp90fgTrPx4+zV8UUZ3I3USZsge3hyhx1uL8jekiIVnUL1iHV9nToqRJjb5CVP/HXGs/1eK8JnsaGb9b6blKVN2M0D3PDzj3Vnk1WI8FjVGkkwUYiY5ATNg0a8USxSUHw8pkyR/vrVFgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=beylWHBlxQYlbO67C6/gGiEHDFLo6pcyprSRTEFLq/s=; b=JyQPXKwaB6Rb7/HDI6e+fE/qRG1IclrWrDXL/Hq1E2X1LBhOxsyMrXkoRuEB7r1dPrMPfRHVVgnA8iAf7Ft8BJxP4ejwQalUdaBSZYQiG9jLb7M1CXHE8LwTDc3RqnqYMyQqvPdV9r6nQG4Gp4UQHCz8lyk7Y8U2LQbYV3cpdgSFDlnsypnh6LGhv6jlL4zUgX/b0mEOwV+d608j33T5cI/1JHCdI0ArGbHyy1dI6DJZkeLoR1nycbk0FV4qkrAopiQFeYP21PJIjliha8SPY0gCoFqmtumPFNWOKUPepDvNrM+jxQmM6Yht2SpZYRtcrZXKxKHuOFqHT5AeuHGajA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hotmail.de; dmarc=pass action=none header.from=hotmail.de; dkim=pass header.d=hotmail.de; arc=none Received: from HE1EUR04FT047.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::46) by HE1EUR04HT159.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.17; Fri, 27 Mar 2020 03:09:16 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (10.152.26.54) by HE1EUR04FT047.mail.protection.outlook.com (10.152.26.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.17 via Frontend Transport; Fri, 27 Mar 2020 03:09:16 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:35F3BA8AAD7BB25AB5A58FA2FAF2D01AAD3BD9E1920B8FA9745C83A15FCC481D; UpperCasedChecksum:EEBEE29ABCB2125F5F0EAE12EB1BF5A10D852088EC750A4214C6E8CB461DA021; SizeAsReceived:8194; Count:50 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd]) by AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::1956:d274:cab3:b4dd%6]) with mapi id 15.20.2835.025; Fri, 27 Mar 2020 03:09:16 +0000 Subject: Re: [PATCHv2] Fix an undefined behavior in record_line To: Andrew Burgess Cc: "gdb-patches@sourceware.org" References: <20200324091013.GT3317@embecosm.com> From: Bernd Edlinger Message-ID: Date: Fri, 27 Mar 2020 04:09:13 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: <20200324091013.GT3317@embecosm.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: ZR0P278CA0038.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::7) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) X-Microsoft-Original-Message-ID: <95c383d8-e749-05d1-d57a-1d57f62d94c1@hotmail.de> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by ZR0P278CA0038.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.19 via Frontend Transport; Fri, 27 Mar 2020 03:09:15 +0000 X-Microsoft-Original-Message-ID: <95c383d8-e749-05d1-d57a-1d57f62d94c1@hotmail.de> X-TMN: [MP5PSubJzu8x7DDGRVnP3vcuvABE/MMI] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 1a43672a-fa6d-421a-5d03-08d7d1fc3b58 X-MS-TrafficTypeDiagnostic: HE1EUR04HT159: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VcsJjYt7pwdiTsgbUJ102J04mvr9781jOG5OPkJcQAEqKxeV+5ibyTCRwKNkg2/mrjk9td9Lh3+wmerMov3Ax9rvwvL1//MPsfUlQ1gfXDR09MmFhfrXcCotR+cWSV68nls6s/SMMmgWbiUOTgNrpDpt7z4j40QVtqszWf8EWXvsiUm6UWSXfjR229L2kTJH X-MS-Exchange-AntiSpam-MessageData: me9uujsihrAyGOVHUo4aEm9JYdv8GsY9WmhGeRIcEioQoZ+At1fiB5Pu5eCBJTC3rhhWLQ5O+/uXZhNzHnFRqzIkz1DJMOYmUCJZ1UeAB9LHwLa/ATKUXhZZjnzsGPH80vuXnAgGlNjokR12wvEX8Q== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a43672a-fa6d-421a-5d03-08d7d1fc3b58 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Mar 2020 03:09:16.0031 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR04HT159 X-Spam-Status: No, score=-18.7 required=5.0 tests=BAYES_00, FORGED_MUA_MOZILLA, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, MSGID_FROM_MTA_HEADER, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Mar 2020 03:09:20 -0000 Am 24.03.20 um 10:10 schrieb Andrew Burgess: > * Bernd Edlinger [2020-03-23 22:25:42 +0100]: > >> 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. > > I suspect this commit message has evolved overtime - having the first > word be "additionally" seems a little strange. > >>>> >>>> 2020-03-10 Bernd Edlinger >>>> * buildsym.c (record_line): Fix ub and preserve lines at eof. > > Typo: ub -> up > Ah, I just realized this is a GCC-slang word for undefined behavior we always just say "ub" when we mean the code has undefined behavior. Will change to "undefined behavior" and have two lines in commit message instead. >>>> --- >>>> 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)))); >>>> } > > This part seems separate to what comes below I think. This should be > a separate commit. > >>>> >>>> - /* 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. */ > > You need to expand on what "problems" means here. Someone coming back > to this code in the future will have no idea why we're making this > change, and with no tests for this commit they can't even try to > figure out the "problems" by looking at a test. > >>>> 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. > > I'm super uncomfortable with any code that changes is-stmt to > !is-stmt, as I worry about what we might be giving up. You say "All > we lose is the ability to set breakpoints at some lines which contain > no instructions anyway.", but I'll need to work through some examples > to see what this actually means in practice before I can be happy with > this change. > > Thanks, > Andrew >