From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075049.outbound.protection.outlook.com [40.92.75.49]) by sourceware.org (Postfix) with ESMTPS id 79328385E006 for ; Fri, 27 Mar 2020 03:50:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 79328385E006 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=mD7xaojBrYbt/ROOD0QHHL1axrSsiSH+rx4wKD92VHvB+XyU5Ukfx0dvhT29xEb8U/yxLbj+2LNOAJgRuhNE6L6VKNiVpdA9ThUFrOai6HjKMzjgaWsWYjBiKv7q3FcXRQ8U9qCa6/aZHOjnORuUQXzAy5+gUHroPfGi0wvRUwTAvyMFN3Plxq1h5GdU9ggdlRXQBIswRMvNPUE5vJ8tQm8xnELe1PYzdvKdbibiIt8nhGP5fGTSSax7ijuSk5gf0IDP52WA8ZmYBrdKXuDVvDRnGIQ6w13a0RBolDnGknUSZHOrzj8vp6OMsWFQPbtBrxgUGqh022zQnzd8hYa34Q== 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=+CHMH/YneZOOiR0Nm/pq4uMmOGYwssBi0ZwhQn4SsEU=; b=IaR1YhjzOdi6F/L6b11tSCsen/CWa6L34Q8WsIL5LXir7VMB4QAixRYSm27ytdQqKZJi11XplwJ26cAn1SugS3ar1Jh+VhtpmE6njlXnFMDwJqdfUTbmSZnK/mSbO2sOsgnwjynWejfyQtBPgyWFXEWcVYqOwkyITgULIFvQEvPWX59VZMIEanmZWVNC7tTyvLgr0BgDUuaFbSn7BnHimC09zNj3jDemq9txPy5I6C6R5+GJV4v+PI036er5ghmDZrX0azprsPm1E+66Joplh1ssci8R5L1+oBCDzmSp5y8oF4L8uMminLii3smnnuhR3cMMYaACFo7CFON/KzpkEQ== 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 DB3EUR04FT020.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::50) by DB3EUR04HT212.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::419) 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:50:31 +0000 Received: from AM6PR03MB5170.eurprd03.prod.outlook.com (10.152.24.54) by DB3EUR04FT020.mail.protection.outlook.com (10.152.25.27) 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:50:31 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:6934A43F9320BE3760CFA32016C67CBF9F9873E6F8AE94EDE10FC9FA73E11B03; UpperCasedChecksum:744AF702F80FD6901CED4C43F309381AC3F3D16C7CC4D021C8EB47757C629DC7; SizeAsReceived:7848; Count:47 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:50:31 +0000 From: Bernd Edlinger Subject: [PATCH v3 2/2] Fix an undefined behavior in record_line To: "gdb-patches@sourceware.org" , Andrew Burgess Message-ID: Date: Fri, 27 Mar 2020 04:50:29 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: ZRAP278CA0009.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:10::19) To AM6PR03MB5170.eurprd03.prod.outlook.com (2603:10a6:20b:ca::23) X-Microsoft-Original-Message-ID: <5b0b942d-ff99-858c-f056-a52e14bfe4fa@hotmail.de> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (92.77.140.102) by ZRAP278CA0009.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:10::19) 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:50:30 +0000 X-Microsoft-Original-Message-ID: <5b0b942d-ff99-858c-f056-a52e14bfe4fa@hotmail.de> X-TMN: [ZDvkK530+t13JlnnJYQCWXQwtavApVMW] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 4dd3c54f-87db-4313-9a38-08d7d201fed8 X-MS-TrafficTypeDiagnostic: DB3EUR04HT212: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8DPoaCPx4oCELZVGQsB0RXmnSctVGHGAnwz+J0bShp9smK0G06VbgkWIKLMucnPpD2bsimJ4NC0uY3g3V9xZTp/Q1DSpm/1vZyHbqmK80hGrq69cWXablP4h8LxNui5c2/YoXcWob9jBQ98QGTdZkjiTXdFJRqFb8lySyFj++PAu1t1LozzPB6tLG1KRah0K X-MS-Exchange-AntiSpam-MessageData: HR4/e6W6VM0MsDsizgbt+glG5gPnt2K6QCvwueNbUhME+cI3FK6or6hpWZiShO54r/cIOnbcPleVlsvwVKXJTRyfPpq9NX8wu2O/3KSLwc5epfXP9UreRiJo/FbEvxx0wPESMa+rfeKDCppUbUNEFA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4dd3c54f-87db-4313-9a38-08d7d201fed8 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Mar 2020 03:50:31.1461 (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: DB3EUR04HT212 X-Spam-Status: No, score=-19.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:50:34 -0000 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++; -- 1.9.1