From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2070.outbound.protection.outlook.com [40.107.6.70]) by sourceware.org (Postfix) with ESMTPS id AADFB3858C52 for ; Tue, 17 Jan 2023 11:14:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AADFB3858C52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bjoAW/n1WoyITVw1Ah2ebA8zd1Qd+eaK7NjJKVuwn+M=; b=Wu7I7pSXbgZwlAQWR11U4cytswkhrzjnXslvLXC2gkAkWluxZCdpwzHbjfTlMLJx37ANm2hs+edDk6j5rdhC9JLQmRpJaoV2B1buxwPU/iMxIEdOFCIlh0qm6NZnRGOxiNo5qKZP93aiLzAS+pI/mbFgyNLtPD1nM6MizpAmaMQ= Received: from AS9P251CA0023.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:50f::19) by AM7PR08MB5366.eurprd08.prod.outlook.com (2603:10a6:20b:10b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.23; Tue, 17 Jan 2023 11:14:17 +0000 Received: from AM7EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:50f:cafe::be) by AS9P251CA0023.outlook.office365.com (2603:10a6:20b:50f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.19 via Frontend Transport; Tue, 17 Jan 2023 11:14:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT032.mail.protection.outlook.com (100.127.140.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13 via Frontend Transport; Tue, 17 Jan 2023 11:14:16 +0000 Received: ("Tessian outbound b1d3ffe56e73:v132"); Tue, 17 Jan 2023 11:14:16 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d654e08433de869a X-CR-MTA-TID: 64aa7808 Received: from ffd42ebaa75e.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 068CC450-8DC1-46B6-AB51-8B23F06EFAEC.1; Tue, 17 Jan 2023 11:14:04 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ffd42ebaa75e.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 17 Jan 2023 11:14:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LYfEqlhegeIxpEQFo5jAaEX/bQiseV7QhVsqu8W2gvO9DIv5IrTCIBTPHxh+y0iJMLGgiGmlvsqk888n43XCaDiMJ/xKlMN0J2LFBPYDOziqDKFhIkGZMjH+7bQ5R/Y+rYY7kRb22q15J7wtYDcsoeeJc+6j+SPPPqt6C9yveP0VWzPfZZoVHb5qeKZFmpv39RGPhrSoulqZbPlw3F2ZQfq/v/eiCPF5hOJ5jaM0GuFBXr6t/mJz5XERjJMYqIqrBq+4TN0ng7krpcc+wrfv53ZYFWiUMYuJMTNyQWugU/Mad45/3JPzJs7UkdJO5lpuFZO6vtlluJCU+Q4dsZyK3w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bjoAW/n1WoyITVw1Ah2ebA8zd1Qd+eaK7NjJKVuwn+M=; b=J1fDiTxFMQSwbl+a5JU8X0YIyJnThsm6stcPRT7mOI/ImtIWpJ5v4yfg60C6modKfK9ofjdYsTZCPLRLrpvUyMqg6EueOzd4GpNqGZyFItN7ysqw9IIzq2Zj/j6nbl4QlcoPjm9BK7MlaEf+xkTg/jyIOMYeMpm+nUfOa4v5fU/eGiIGg2yCEmWZMgZocu9TdQujBwbZXpsi6rx0/nDXdLLRZrTB4NBhpV7DZUi24XF5aHhT9G7NVaZWMpWX7aesKz7hATqO1gny/zo8OzDQfvyScDu78Gh+9JDNGB47172exPQU/PVIY1bsgXtVxbBP+q0N7HjyslvFIMHO0ebbYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bjoAW/n1WoyITVw1Ah2ebA8zd1Qd+eaK7NjJKVuwn+M=; b=Wu7I7pSXbgZwlAQWR11U4cytswkhrzjnXslvLXC2gkAkWluxZCdpwzHbjfTlMLJx37ANm2hs+edDk6j5rdhC9JLQmRpJaoV2B1buxwPU/iMxIEdOFCIlh0qm6NZnRGOxiNo5qKZP93aiLzAS+pI/mbFgyNLtPD1nM6MizpAmaMQ= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) by PA4PR08MB6016.eurprd08.prod.outlook.com (2603:10a6:102:e3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.12; Tue, 17 Jan 2023 11:14:01 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::eed7:25a3:e4ea:187a]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::eed7:25a3:e4ea:187a%6]) with mapi id 15.20.5986.023; Tue, 17 Jan 2023 11:14:01 +0000 Message-ID: <8bcfa5a5-ed74-db8c-ce4b-0fad472cb486@arm.com> Date: Tue, 17 Jan 2023 11:14:01 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PING] [PATCH] gdb/arm: Fix backtrace for pthread_cond_timedwait Content-Language: en-US To: Jan Kratochvil , gdb-patches@sourceware.org Cc: Alan Hayward References: From: Luis Machado In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P302CA0013.GBRP302.PROD.OUTLOOK.COM (2603:10a6:600:2c2::20) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|PA4PR08MB6016:EE_|AM7EUR03FT032:EE_|AM7PR08MB5366:EE_ X-MS-Office365-Filtering-Correlation-Id: 46cd497a-5895-4fad-9915-08daf87bf919 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: da5Rk5+Iig81iH51tDl06cp6WgP1GovdGmf9LQMkAEIpAwkJzg+1NExlaNfCgpq2YajB8q36/EDlahiqiImC1q5nYpdpNQvcj+yz4zhSV7EShcgk4vthTShqv/yu7hlB4xwjUBMLGa5M9mxxeQnuFJnLmTjJu/quOLH0eWOffPgHdgEyOR1C6U18R1XVPPVj+6Ba9YfE0yZ+QxIq2LMUOs/4+lqZmP8NrqxO7+BQ/wwvmfo/alnDPHwvIicJLjxWVgM9xkIXZpdu5ybeF8hu6Bw+f19wUrsBushjB9QUfFmm6YlxktfPffI27VdoUM9sOipZDEWXcfr61XutSD82w5MUzlQe77U7PCuZs+/iHCOkAtdV/EbCmVS6T6eqnTxoZVekKZ7gIeiYG+/w9t6o6K7QNSUFnaGIjq0eFQZJxCMDhYwzd1zbt5Cnb5IQmlDviONB9S6p23kSb/pLHgl2zHNVQRrZO85vaxOuM87V/QcqwoqE1D0NE0grrgAMTTxSVislTp+Mlp9MgwyGIYWuhzMZg6q/3SmRE5t6OAVskUlPBWXfBk/YnrP8UfVHl3+cmSkXJizYAKgcRz7XNPhWapyHIRADNnGZoW4DOb3APLh9ILEKFxLv3fchQx3v677KWyBCjYWbQssxMoS9hMwQe9eGdzRd455q/EdGr1QGri4kwdAWePzAkPQzeJ7icsUiv8neO03E7zMwGMYycPY8MvhGJ4Zvd3Qxgje+wjAqbZHL4orvvdJ93NQxUYx/+bv1tqh3j02RxVa1MIV+CE8oqt2KbNojGhNKY/eUtUUlDzEzSdkhCWihg8KUPfgTV2T5 X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR08MB3919.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(39860400002)(376002)(136003)(346002)(366004)(451199015)(26005)(2906002)(83380400001)(86362001)(44832011)(53546011)(6486002)(6506007)(31696002)(36756003)(41300700001)(2616005)(478600001)(6512007)(4326008)(186003)(8936002)(66946007)(66556008)(316002)(38100700002)(8676002)(30864003)(66476007)(31686004)(84970400001)(5660300002)(2004002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6016 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: a616d496-91a9-4e2f-9b9d-08daf87befb7 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5hWNXY+DrPV6BNysgF6R+PdxH4gFhTtVuYdN92kN2EYLb6rGq8P2B9HUZ/Ddq9+qtpXynv4EsUiW3eUFqPAYVYc4oWsFWve6wtccFWQo9RUFjzhVpROjDAmRx/4UVL1L9fkQuUSvHQTBjOsMZV+Zl3abZisGcyaNkbALmF5nxSfbhjeJyKGp9iMJqn+61teG8Wd/q1bGMTS++xVqRIbG7KrKZOY9qiLLSMdcxO5rkm2b5VjbXy4wC7ZLDBXSQiSpJ4rEdrpMKfmd8Ad4/XeVTl1XKOATJ9wisfinzzaWUWXi5JnsSf7ZtGuB3hRfOvGuIM//MeCS6ttbLIhGWZTZt4dD8W5uwGXUG1De7NbAFK5a7165Tcy2TGgkupY4EOW6tF5g1NqtCid68Hf0NX0Cvq2f+Vj+aHlPXVcfJEopfcsQnAUcesZbnRMFmuymwg2H6R6WYWWK88VU0LnaVp9ge9F1t6TKeLo1KjJA1Z94t641NWl9Hw6Jza9zZydqjbDu5DuNkaVMfEBw//DquM8ObdqV1qy2JNFboDVPxs0jt2LqN6dTcclxMgnj0IF02remYxb7jfmhKr3w2fRzH8M7KfAmi6WDm4wB1nb1RXnTuvPUgeXO8dKcYNz2tqz342pUn7iWZbgDI0ImaGLmhca0snYN2gDm++HLsQ5s1Q0Qy+tzXbMBPbI1kq73cd5HGeqmJlnn5YH4mRTsNcT+7fcM8yUq2Upkj/jvfIRrFcGLTnwjSlVOjie401GZQTeaFOvQOGWoMTiF56Z0mMqSembgnu8SiWcxCzL2I7KPd9HWY1IfSAVPBKGxy/xjRut+FRm3 X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(396003)(376002)(136003)(346002)(451199015)(46966006)(40470700004)(36840700001)(84970400001)(82740400003)(31696002)(356005)(2906002)(36860700001)(81166007)(31686004)(86362001)(36756003)(47076005)(40460700003)(40480700001)(82310400005)(316002)(2616005)(30864003)(8676002)(70206006)(41300700001)(70586007)(44832011)(4326008)(5660300002)(6506007)(53546011)(6486002)(186003)(8936002)(336012)(26005)(6512007)(478600001)(83380400001)(2004002)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2023 11:14:16.9279 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 46cd497a-5895-4fad-9915-08daf87bf919 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5366 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Jan, Sorry, I didn't spot the patch on the list. On 1/16/23 16:10, Jan Kratochvil wrote: > GDB expected PC should point right after the SVC instruction when the > syscall is active. But some active syscalls keep PC pointing to the SVC > instruction itself. > > This leads to a broken backtrace like: > Backtrace stopped: previous frame identical to this frame (corrupt stack?) > #0 0xb6f8681c in pthread_cond_timedwait@@GLIBC_2.4 () from /lib/arm-linux-gnueabihf/libpthread.so.0 > #1 0xb6e21f80 in ?? () > > The reason is that .ARM.exidx unwinder gives up if PC does not point > right after the SVC (syscall) instruction. I did not investigate why but > some syscalls will point PC to the SVC instruction itself. This happens > for the "futex" syscall used by pthread_cond_timedwait. > > That normally does not matter as ARM prologue unwinder gets called > instead of the .ARM.exidx one. Unfortunately some glibc calls have more > complicated prologue where the GDB unwinder fails to properly determine > the return address (that is in fact an orthogonal GDB bug). I expect it > is due to the "vpush" there in this case but I did not investigate it more: > > Dump of assembler code for function pthread_cond_timedwait@@GLIBC_2.4: > 0xb6f8757c <+0>: push {r4, r5, r6, r7, r8, r9, r10, r11, lr} > 0xb6f87580 <+4>: mov r10, r2 > 0xb6f87584 <+8>: vpush {d8} > > Regression tested on armv7l kernel 5.15.32-v7l+ (Raspbian 11). > --- > gdb/arm-tdep.c | 42 ++++--- > .../gdb.arch/arm-pthread_cond_timedwait-bt.c | 62 +++++++++++ > .../arm-pthread_cond_timedwait-bt.exp | 105 ++++++++++++++++++ > 3 files changed, 192 insertions(+), 17 deletions(-) > create mode 100644 gdb/testsuite/gdb.arch/arm-pthread_cond_timedwait-bt.c > create mode 100644 gdb/testsuite/gdb.arch/arm-pthread_cond_timedwait-bt.exp > > diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c > index 78a2fe2ade5..328eb17f419 100644 > --- a/gdb/arm-tdep.c > +++ b/gdb/arm-tdep.c > @@ -3116,26 +3116,34 @@ arm_exidx_unwind_sniffer (const struct frame_unwind *self, > && get_frame_type (get_next_frame (this_frame)) == NORMAL_FRAME) > exc_valid = 1; > > - /* We also assume exception information is valid if we're currently > - blocked in a system call. The system library is supposed to > - ensure this, so that e.g. pthread cancellation works. */ > - if (arm_frame_is_thumb (this_frame)) > + /* Some syscalls keep PC pointing to the SVC instruction itself. */ > + for (int shift = 0; shift <= 1 && !exc_valid; ++shift) > { > - ULONGEST insn; > + /* We also assume exception information is valid if we're currently > + blocked in a system call. The system library is supposed to > + ensure this, so that e.g. pthread cancellation works. */ > + if (arm_frame_is_thumb (this_frame)) > + { > + ULONGEST insn; > > - if (safe_read_memory_unsigned_integer (get_frame_pc (this_frame) - 2, > - 2, byte_order_for_code, &insn) > - && (insn & 0xff00) == 0xdf00 /* svc */) > - exc_valid = 1; > - } > - else > - { > - ULONGEST insn; > + if (safe_read_memory_unsigned_integer ((get_frame_pc (this_frame) > + - (shift ? 2 : 0)), > + 2, byte_order_for_code, > + &insn) > + && (insn & 0xff00) == 0xdf00 /* svc */) > + exc_valid = 1; > + } > + else > + { > + ULONGEST insn; > > - if (safe_read_memory_unsigned_integer (get_frame_pc (this_frame) - 4, > - 4, byte_order_for_code, &insn) > - && (insn & 0x0f000000) == 0x0f000000 /* svc */) > - exc_valid = 1; > + if (safe_read_memory_unsigned_integer ((get_frame_pc (this_frame) > + - (shift ? 4 : 0)), > + 4, byte_order_for_code, > + &insn) > + && (insn & 0x0f000000) == 0x0f000000 /* svc */) > + exc_valid = 1; > + } > } The changes and reasoning sound good to me, though the test doesn't seem to be doing much on my setup. I see the same results with a patched and unpatched gdb: PASS: gdb.arch/arm-pthread_cond_timedwait-bt.exp: successfully compiled posix threads test case PASS: gdb.arch/arm-pthread_cond_timedwait-bt.exp: advance to break-line PASS: gdb.arch/arm-pthread_cond_timedwait-bt.exp: thread 2 for svc check UNTESTED: gdb.arch/arm-pthread_cond_timedwait-bt.exp: pc points to svc Do you see something different? > > /* Bail out if we don't know that exception information is valid. */ > diff --git a/gdb/testsuite/gdb.arch/arm-pthread_cond_timedwait-bt.c b/gdb/testsuite/gdb.arch/arm-pthread_cond_timedwait-bt.c > new file mode 100644 > index 00000000000..c382a100afd > --- /dev/null > +++ b/gdb/testsuite/gdb.arch/arm-pthread_cond_timedwait-bt.c > @@ -0,0 +1,62 @@ > +/* This testcase is part of GDB, the GNU debugger. > + > + Copyright 2022 Free Software Foundation, Inc. > + > + This program is free software; you can redistribute it and/or modify > + it under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + This program is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + GNU General Public License for more details. > + > + You should have received a copy of the GNU General Public License > + along with this program. If not, see . */ > + > +#include > +#include > +#include > +#include > + > +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; > +static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; > + > +static void *fun(void *arg) > +{ > + struct timeval now; > + struct timespec until; > + int err; > + > + err = gettimeofday(&now, NULL); > + assert(!err); > + > + until.tv_sec = now.tv_sec + 60; > + until.tv_nsec = now.tv_usec * 1000UL; > + > + pthread_cond_timedwait(&cond, &mutex, &until); > + assert(0); > + err = pthread_mutex_unlock(&mutex); > + assert(!err); > + > + return arg; > +} > + > +int main() > +{ > + pthread_t thread; > + void *ret; > + int err; > + > + err = pthread_mutex_lock(&mutex); > + assert(!err); > + err = pthread_create(&thread, NULL, fun, NULL); > + assert(!err); > + err = pthread_mutex_lock(&mutex); > + assert(!err); > + err = pthread_join(thread, &ret); // break-line > + assert(0); > + > + return 0; > +} > diff --git a/gdb/testsuite/gdb.arch/arm-pthread_cond_timedwait-bt.exp b/gdb/testsuite/gdb.arch/arm-pthread_cond_timedwait-bt.exp > new file mode 100644 > index 00000000000..d5e594c73d5 > --- /dev/null > +++ b/gdb/testsuite/gdb.arch/arm-pthread_cond_timedwait-bt.exp > @@ -0,0 +1,105 @@ > +# Copyright 2022 Free Software Foundation, Inc. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > + > +# This serves as a template for writing new test cases. Replace this with > +# a description of what this test case tests. > + > +standard_testfile > + > +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ > + {debug pthreads}] } { > + return > +} > + > +if { ![runto_main] } { > + return > +} > + > +gdb_test "advance [gdb_get_line_number "break-line"]" "break-line.*" \ > + "advance to break-line" > + > +gdb_test "thread 2" "Switching to thread 2 .*" "thread 2 for svc check" > + > +# GDB expected PC should point right after the SVC instruction when the syscall is active. > +# But some active syscalls keep PC pointing to the SVC instruction itself. > +set test "pc points to svc" > +gdb_test_multiple {x/i $pc} $test { > + -re ":\tsvc\t0x00000000\r\n$gdb_prompt $" { > + pass $test > + } > + -re "\r\n$gdb_prompt $" { > + untested $test > + return > + } > +} > + > +gdb_test "thread 1" "Switching to thread 1 .*" > +gdb_test_no_output "set debug frame 1" > + > +# PASS: > +# [frame] frame_unwind_try_unwinder: trying unwinder "arm exidx" > +# [frame] frame_unwind_register_value: enter > +#... > +# [frame] frame_unwind_register_value: exit > +# [frame] frame_unwind_try_unwinder: yes > +#... > +# [frame] get_prev_frame_always_1: -> {level=0,type=NORMAL_FRAME,unwinder="arm exidx",pc=0xb6f8681c,id=,func=} // cached > + > +# FAIL: > +# [frame] frame_unwind_try_unwinder: trying unwinder "arm exidx" > +# [frame] frame_unwind_register_value: enter > +#... > +# [frame] frame_unwind_register_value: exit > +# [frame] frame_unwind_try_unwinder: no > +# [frame] frame_unwind_try_unwinder: trying unwinder "arm epilogue" > +# [frame] frame_unwind_register_value: enter > +#... > +# [frame] frame_unwind_register_value: exit > +# [frame] frame_unwind_try_unwinder: no > +# [frame] frame_unwind_try_unwinder: trying unwinder "arm prologue" > +# [frame] frame_unwind_try_unwinder: yes > +#... > +# [frame] get_prev_frame_always_1: -> {level=0,type=NORMAL_FRAME,unwinder="arm prologue",pc=0xb6f8681c,id=,func=} // cached > + > +set test "unwinder is arm exidx" > +# Switch the threads to reset frame cache. > +gdb_test_multiple {thread 2} $test { > + -re "\{level=0,type=NORMAL_FRAME,unwinder=\"arm exidx\",pc=.*\r\n$gdb_prompt $" { > + pass $test > + } > + -re "\{level=0,type=NORMAL_FRAME,unwinder=\"arm prologue\",pc=.*\r\n$gdb_prompt $" { > + fail $test > + } > + -re "\r\n$gdb_prompt $" { > + untested $test > + return > + } > +} > + > +gdb_test "thread 2" "Switching to thread 2 .*" "thread 2 for debug frame check" > + > +gdb_test_no_output "set debug frame 0" > + > +# PASS: > +# #0 0xb6f8681c in pthread_cond_timedwait@@GLIBC_2.4 () from /lib/arm-linux-gnueabihf/libpthread.so.0 > +# #1 0x00010648 in fun (arg=0x0) at .../gdb/testsuite/gdb.arch/arm-pthread_cond_timedwait-bt.c:38 > +# ... > + > +# FAIL: > +# #0 0xb6f8681c in pthread_cond_timedwait@@GLIBC_2.4 () from /lib/arm-linux-gnueabihf/libpthread.so.0 > +# #1 0xb6e21f80 in ?? () > +# Backtrace stopped: previous frame identical to this frame (corrupt stack?) > + > +gdb_test "bt" { in fun \(arg=.*} "unwind of pthread_cond_timedwait"