From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2087.outbound.protection.outlook.com [40.92.91.87]) by sourceware.org (Postfix) with ESMTPS id DE1FF385DC00 for ; Sat, 4 Apr 2020 07:06:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DE1FF385DC00 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=Id6qOjfbaEoJfUU0Wc9ZrH+8Sh3ClaOANl+LWCy60B/H59u6RjB/umDB9T0HaXjZL6aoK3te0G3dcXA+68J1bh1ZGpQlIHSuvJBWWnar2gu88fN6zF0U0j8RSMkpt5nS0nrXqz2IE9ybUoKpQ2MF0xRpQohy0/x+HpurDTiPpIoZBrfAW8BHCYOEdle0oC+K0++EAD0Nkgn1Ts6DyImgOXDQrGAG1+MXLlrDBnLfJPLSaFHI4ZFkpjY7hZxaA2NtqpKFa3PHOn4yY+wB+Dn72ZrP81T5f2PWGMvsq0WnOHbmItW9z/R1Jm4qAFrAMfEwSguTQldYs0KOvZex4rz1oQ== 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=5xXOYLVlSd6ilY564K0KnnQxveWbEj0a+q7cfGHSUjU=; b=gxlnK2oxUBS2MaHWb9Xcgj3Zc55nG0mjFtOxJNqaLcMnxaIf+Z37KMmcsBD5Pg3q1/gvMKpOIZet4v/fQd5HbxhyDA9qVjeRnZvjsahAzF0l6zN9BjJkC2UNXyU4PsAPy8jqtZpkSa42IE+eMU0a06/K/ZFw92BKVDIJF2FKPXv7lZP9ETwPrzn5XW2nPFMPgsm+CuAPRINMpy/mtSGbOGGZdOx/VC5DdabAE7Lx79EHAMpNY2Wlwu8sJIpqwrLiatD01YPsumEj/ZyFxudp2x/XMGzuBxNqc0VPzgdmMnush3aCRd00/AO4SALZJyg3xKMEBc117omsE8M0N/cGVw== 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 VI1EUR05FT005.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc12::43) by VI1EUR05HT217.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc12::75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.15; Sat, 4 Apr 2020 07:06:47 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (2a01:111:e400:fc12::48) by VI1EUR05FT005.mail.protection.outlook.com (2a01:111:e400:fc12::124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.15 via Frontend Transport; Sat, 4 Apr 2020 07:06:47 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:17AA98530991EC51AB6A7D157B8D8E3FFB0F29C7323ED922C3251FDBB7ACAF57; UpperCasedChecksum:9D096C9A49CD533C5D9EF4A944DF051695F17F3A5BD864743F0BC97AFCB0C393; SizeAsReceived:8236; Count:49 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::d57:5853:a396:969d]) by AM6PR03MB5170.eurprd03.prod.outlook.com ([fe80::d57:5853:a396:969d%7]) with mapi id 15.20.2878.018; Sat, 4 Apr 2020 07:06:47 +0000 Subject: Re: [PATCH v3 2/2] Fix an undefined behavior in record_line From: Bernd Edlinger To: Luis Machado , "gdb-patches@sourceware.org" , Andrew Burgess References: Message-ID: Date: Sat, 4 Apr 2020 09:06:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 8bit X-ClientProxiedBy: AM0PR01CA0111.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::16) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) X-Microsoft-Original-Message-ID: <9b759d22-0aea-323c-172d-2ad15805817a@hotmail.de> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by AM0PR01CA0111.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.15 via Frontend Transport; Sat, 4 Apr 2020 07:06:46 +0000 X-Microsoft-Original-Message-ID: <9b759d22-0aea-323c-172d-2ad15805817a@hotmail.de> X-TMN: [DPJSJpVbpMAw3QMrpA/k/h8f/kJTy5jQ] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: d7c231e1-5b06-4597-f5da-08d7d866bd11 X-MS-TrafficTypeDiagnostic: VI1EUR05HT217: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FvFz2HbfqPOUFGZMYWcczYfQWZJ+aaNPR0CqHKtDRJJ/CBbIbGiM4TL/MsgQnYWjGvDpR5AWKlagCwelzGJjgzRyI/CMdOzOEcOAArEdAqps0J3Un5VcprMU7zG+ILz/KGu1mhJhe7XZrcea+pPSUa+ND1m0wSXiliKRXIqNl1ig/171om0uL4eJE+Xqb4Va X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:0; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR03MB5170.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:; DIR:OUT; SFP:1901; X-MS-Exchange-AntiSpam-MessageData: zBlMJA7LFUoZj8kaIpI2SzvFpukoUqwGDDP6fg7jt7QDnSyQPNOVn+EG/nVS9Dwm3IgMKqxILokqEuQfVUZcW7RtVDn2mu9Dy8XSVzGa2gQ1oiNJJpoXL4GXiYoOU0zbl8vxfgAA7fGcazZlINz0Uw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d7c231e1-5b06-4597-f5da-08d7d866bd11 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2020 07:06:47.1296 (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: VI1EUR05HT217 X-Spam-Status: No, score=-15.1 required=5.0 tests=BAYES_00, BODY_8BITS, 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: Sat, 04 Apr 2020 07:06:50 -0000 On 4/4/20 6:21 AM, Bernd Edlinger wrote: > > > On 4/4/20 12:53 AM, Luis Machado wrote: >> Hi, >> >> This seems to have caused a few regressions for aarch64-linux. I'm seeing the following: >> >> FAIL: gdb.dwarf2/dw2-ranges-func.exp: lo-cold: step-test-3: step into foo from main >> FAIL: gdb.dwarf2/dw2-ranges-func.exp: lo-cold: step-test-3: step into bar from foo >> FAIL: gdb.dwarf2/dw2-ranges-func.exp: lo-cold: step-test-3: step out of bar to foo >> FAIL: gdb.dwarf2/dw2-ranges-func.exp: lo-cold: step-test-3: step into foo_cold from foo >> FAIL: gdb.dwarf2/dw2-ranges-func.exp: lo-cold: step-test-3: step into baz from foo_cold >> FAIL: gdb.dwarf2/dw2-ranges-func.exp: lo-cold: step-test-3: step out of baz to foo_cold >> FAIL: gdb.dwarf2/dw2-ranges-func.exp: lo-cold: step-test-3: step out of foo_cold to foo >> FAIL: gdb.dwarf2/dw2-ranges-func.exp: lo-cold: step-test-3: step out of foo to main >> FAIL: gdb.dwarf2/dw2-ranges-func.exp: hi-cold: step-test-3: step into foo from main >> FAIL: gdb.dwarf2/dw2-ranges-func.exp: hi-cold: step-test-3: step into bar from foo >> FAIL: gdb.dwarf2/dw2-ranges-func.exp: hi-cold: step-test-3: step out of bar to foo >> FAIL: gdb.dwarf2/dw2-ranges-func.exp: hi-cold: step-test-3: step into foo_cold from foo >> FAIL: gdb.dwarf2/dw2-ranges-func.exp: hi-cold: step-test-3: step into baz from foo_cold >> FAIL: gdb.dwarf2/dw2-ranges-func.exp: hi-cold: step-test-3: step out of baz to foo_cold >> FAIL: gdb.dwarf2/dw2-ranges-func.exp: hi-cold: step-test-3: step out of foo_cold to foo >> FAIL: gdb.dwarf2/dw2-ranges-func.exp: hi-cold: step-test-3: step out of foo to main >> >> git bisect pointed at this commit: >> Louis, So, I cannot do much, to debug aarch64 here. I would however like to know what the output of the test result is, when it fails, that is where the step does stop when it is not where it should. And how the line table looks in the test case when it is compiled on aarch64, btw. which gcc version do you use? Thanks Bernd. > > Oh, dear. > > Andrew, please watch out, > > your other patch is also about to > change something in this area. > > I tested on x86_64 where everything looked good, > (at least for me, but sime test cases are always faling > or are unstable ...) > > It could be that your patch > > PATCH 2/2] gdb: Preserve is-stmt lines when switch between files > > I just saw in my inbox is also trying to address the same issue. > > I was not aware that you were working on the same issue. > > > Thanks > Bernd. > >> --- >> >> commit 64dc2d4bd24ff7119c913fff91184414f09b8042 >> Author: Bernd Edlinger >> Date:   Thu Mar 12 11:52:34 2020 +0100 >> >>     Fix an undefined behavior in record_line >> >>     Additionally do not completely remove symbols >>     at the same PC than the end marker, instead >>     make them non-is-stmt breakpoints. >> >>     2020-04-01  Bernd Edlinger  >> >>             * buildsym.c (record_line): Fix undefined behavior and preserve lines at eof. >> >> --- >> >> What i see in the log is stepping through lines not working as expected. >> >> >> On 3/27/20 12:50 AM, Bernd Edlinger wrote: >>> Additionally do not completely remove symbols >>> at the same PC than the end marker, instead >>> make them non-is-stmt breakpoints. >>> >>> 2020-03-27  Bernd Edlinger  >>>     * buildsym.c (record_line): Fix undefined behavior and preserve >>>     lines at eof. >>> --- >>>   gdb/buildsym.c | 34 ++++++++++++++++++---------------- >>>   1 file changed, 18 insertions(+), 16 deletions(-) >>> >>> diff --git a/gdb/buildsym.c b/gdb/buildsym.c >>> index 2d1e441..46c5bb1 100644 >>> --- a/gdb/buildsym.c >>> +++ b/gdb/buildsym.c >>> @@ -705,27 +705,29 @@ 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 since they might be at the same address >>> +     as the following function.  For instance suppose a function calls >>> +     abort there is no reason to emit a ret after that point (no joke). >>> +     So the label may be at the same address where the following >>> +     function begins.  A similar problem appears if a label is at the >>> +     same address where an inline function ends we cannot reliably tell >>> +     if this is considered part of the inline function or the calling >>> +     program or even the next inline function, so stack traces may >>> +     give surprising results.  Expect gdb.cp/step-and-next-inline.exp >>> +     to fail if these lines are not modified here.  */ >>>     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_vector->nitems++; >>>