From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ZLJiLyOjvGpMoRwAWB0awg (envelope-from ) for ; Wed, 30 Sep 2026 01:50:27 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=outlook.com header.i=@outlook.com header.a=rsa-sha256 header.s=selector1 header.b=QGJkbcFR; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id AD07B1E033; Wed, 30 Sep 2026 01:50:27 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C91791E033 for ; Wed, 30 Sep 2026 01:50:24 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DDF304BB24CC for ; Wed, 30 Sep 2026 05:50:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DDF304BB24CC Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=outlook.com header.i=@outlook.com header.a=rsa-sha256 header.s=selector1 header.b=QGJkbcFR Received: from SY8PR01CU002.outbound.protection.outlook.com (mail-australiaeastazolkn190100000.outbound.protection.outlook.com [IPv6:2a01:111:f403:d40d::]) by sourceware.org (Postfix) with ESMTPS id E3AD04BB1C2A for ; Wed, 30 Sep 2026 05:49:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E3AD04BB1C2A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=outlook.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=outlook.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E3AD04BB1C2A Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:d40d:: ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1790747396; cv=pass; b=s0mr88Xf2yDlJpkQ8dq0W5vcGgTcbSkvgN1vilyBaGvv3vlFJk8jA7YB2Pmr/ENj6r9cJCNmG4BNPlf+RkaV1Gg04Vc7I6CB7LDQZGDsBYvvjOGLZ+DjETS2BFJgjC0FBqPS1DBDFZyAyi5FieUNaIfn8gCMmZs78rKgYl4OFOw= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1790747396; c=relaxed/simple; bh=RqnDjTt90GOkB29kJ0vbfFeekswUFAXEMsgq8+w8Dkg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=prw90e9Snq5G/2FMZcupDeU+oyqW4jb7m0gnvQt0MiAatJUiPQuQyDj7Ut6lAVETNjCBY96hmPgVZraFg/QJ27VIForYXWHrGT16XQfUkEOIsYEoSENYEs+4yrfqZ4fcA5Xl1YU2Y0yWnPBUcyQja3E8TZsNjgLDwtoVd4HPE7U= ARC-Authentication-Results: i=2; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=outlook.com header.i=@outlook.com header.a=rsa-sha256 header.s=selector1 header.b=QGJkbcFR DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E3AD04BB1C2A ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YgYaGn+PVyk2Tl2hxVp9iur4JPCminUtV9VBbEoK3obVFUd3NpDR5JPWCspMFIMRUhp+j8PrLoGYbmYHnd3IgLxbW20ndJhDoPHW/Mnj3qx/LSzoitw/s14RpbePxZivVDAtB2GvjmuQPw5ZriuBDDMj0chxgv09XyT6Cb/zphxSHJNEywu6/jtKLp4RLChyZFqbsvFWLrMHqsIWqrWBdq1a4/M+4BlNsDDty2g/4SDo1pc+hSuL99yh0KSYUB3d0B8498FuTMFeeK/xOw6bqK70/93Ehe6GS/RYxLBYr4Iuwx2aOzW58MoyaNNXDGthfNgy2SdBRPFZ695Ym69Aog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=ngZ0e6YuE6LSSuaIKRuTcw8cuC6Y7FMdExsaBvHek84=; b=Hibaknv4cSqQTpr/CfwKtXVv0dLBFnGcgd/9OFrIs5I0uPaoM+CU+LVRnLMRPLpMYCxYL5IVFoPxLlJeyeywroY4hoNahA9++FSIHYPJ3ZCHFdfVL5SAgMIV2SwOrz7qeuUIeDxopwboPw8pbdWOQBW1xueky412w0uA71judSgDfmFV17QSjYPdxGeMaFPjHGH/dfJ3KA/qRvScbaWusDqCTyecRX3oKsWVEzVzZnpnbVRFW7psEjs8sjbsmAiKh4JQ5nHBcFY0S1XoUCQWZZpYNU+2Uk1aYnvOtC6GCMDp/+VaHsCKXMnltsIcsNOlgjOvATCfF1NQuitmP0+aRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ngZ0e6YuE6LSSuaIKRuTcw8cuC6Y7FMdExsaBvHek84=; b=QGJkbcFRWbJH3uNgUOnMEW4RRYKF64H+k/YFQRHu66kk1AdrnsieHuLosFXS0YHEi+kTYdjnjT/81eLh3KtjVtQQrPnfFjs1jtxByde77hw58jdrTFXPMYt1uNRRd75gS49X5AYYskYoro1rexea97dB2ynegbJXX3VSAeDa/eWvcCA7V08LjIFHoyqA+HnEcP5qYpvEK8r27X4esaRPL6NzOTaWwGR0IJxL9Yj03q1MMLOQd1i479KOOMKfAx2DB4ZjKR8RUdaf3nCYQGJ7792eCLALfFzq7SuZ8ejzubGxPms5L2U9UQDR75u5lT2VohSdXDlaG7bm5gLtnb4Cjg== Received: from SY7P300MB0131.AUSP300.PROD.OUTLOOK.COM (2603:10c6:10:23a::11) by SY7P300MB1513.AUSP300.PROD.OUTLOOK.COM (2603:10c6:10:2c6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.26; Wed, 30 Sep 2026 05:49:48 +0000 Received: from SY7P300MB0131.AUSP300.PROD.OUTLOOK.COM ([fe80::8f2d:9505:409a:9c61]) by SY7P300MB0131.AUSP300.PROD.OUTLOOK.COM ([fe80::8f2d:9505:409a:9c61%6]) with mapi id 15.21.0472.015; Wed, 30 Sep 2026 05:49:48 +0000 From: cocolato To: gdb-patches@sourceware.org Subject: [PATCH] gdb/aarch64: Step through GNU ld's erratum 843419 veneers Date: Wed, 30 Sep 2026 13:49:30 +0800 Message-ID: X-Mailer: git-send-email 2.54.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: TPYP295CA0054.TWNP295.PROD.OUTLOOK.COM (2603:1096:7d0:8::6) To SY7P300MB0131.AUSP300.PROD.OUTLOOK.COM (2603:10c6:10:23a::11) X-Microsoft-Original-Message-ID: <20260930054930.43711-1-haiizhu@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SY7P300MB0131:EE_|SY7P300MB1513:EE_ X-MS-Office365-Filtering-Correlation-Id: 35e72ecf-d265-4bc6-17c4-08df1eb6a342 X-Microsoft-Antispam: BCL:0; ARA:14566002|6090799003|5072599009|23021999003|41001999006|15080799012|260925184616899003|20031999006|24021099003|4140399003|25010399006|12121999013|24071999003|8060799015|39105399006|19110799012|25031999004|3412199025|440099028|12091999003|40105399003|2607281247196008|10035399007; X-Microsoft-Antispam-Message-Info: =?utf-8?B?NjdhalpvUFlza3NoM2ZyT00ySS94K2lZL0NNK1hQNVB1M09FbG92c3JtYmN1?= =?utf-8?B?ZlFZS0NaQTFjVmx0a21Uak5CcW1KU2RWZEJhVSs1d3Y3aHgvbVlNNVQvTVhT?= =?utf-8?B?WUh1eWJuMmY3bUFxUmdtT0xtYXpIU3VPOHJKdE9wcThTci95K1BTL0NDYUpZ?= =?utf-8?B?anRVZ0tyUHVtYjVWaWswaFpjSnVHdTh0M3dPakZhdXNjS1lINTZQQVFrSEY2?= =?utf-8?B?aktaSmxHeDhEaWJlRHhGUDBXc0tYbW12ekg1ejBZZGJBOXEvRWg2Wjh1VXRR?= =?utf-8?B?ZGFJNTYxamN5MTNCVSsxRFpGY2FSSk1XVndhK21TZ0JXSE1sN2pHU1A3eXZa?= =?utf-8?B?bmhmNnFmUTRWQ3NSWHVwalozSWNFVm1NdUJjRHBQZ24vclVpT0tMYVJEc0dw?= =?utf-8?B?eEJUV3ZkVVRvaCtHdDRpd0QySW9RR1lyZTBEQlY3ZHpodE9SUFFJelhCc0dM?= =?utf-8?B?Z1I0S0gwb0J2S2ZaUGlkUm1HbXIwd054MGthOFBFaGZoRmlZSEphTEZXenBt?= =?utf-8?B?SlZBOC9hK3NDa1I3cGlGa1J5ZW94QzhyazZGVDFWWTZpWkN1ZEdsdHRUdSt2?= =?utf-8?B?SHlLWU5xV3VkRUlGaStFellucnlVRFBIZzdNVTNybmNSUEc1YmNxdDJ6dlpo?= =?utf-8?B?ZHNZOWx2ZG0xNUlib2kwWUJ6RTV5ZndramhUNUtSZnlZSWRwRmFnQ1VoNks5?= =?utf-8?B?U2hIS0JLVWdYU0w2ajFabmZWQURlazhlY0xwamZpN3M0bEFkcHNrTDRUQ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?= =?utf-8?B?NHZIbnBiOHZuUDZCNHF5aE5VbzNrRG9NenJzTlVXZ1NHUGFoRGhyaXZwQnYz?= =?utf-8?Q?0Z2U0aqQfRO60?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35e72ecf-d265-4bc6-17c4-08df1eb6a342 X-MS-Exchange-CrossTenant-AuthSource: SY7P300MB0131.AUSP300.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2026 05:49:48.5757 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SY7P300MB1513 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org GNU ld's Cortex-A53 erratum 843419 workaround can move an instruction into an e843419@ veneer. A plain branch replaces the original instruction; the veneer executes it and branches back to the next instruction in the same function. Neither branch updates the link register. When next or finish from an inline frame enters the veneer, GDB can mistake it for a function call. With no veneer unwind information, GDB can use an earlier call's return address from the link register for a step-resume breakpoint, running the inferior to completion instead of stopping after the inline function. Recognize GNU ld's named e843419@ veneers through the existing in_indirect_branch_thunk hook, before subroutine-entry handling. Recognize both veneer instructions; minimal-symbol lookup already checks the bounds of GNU ld's sized symbols. Stripped veneer symbols remain unsupported. skip_trampoline_code is too late on the forward STEP_OVER_ALL path: GDB has already set the caller-return breakpoint and returned. The existing hook needs no generic stepping changes or instruction decoding. The assembly and DWARF regression test exercises next and inline finish using explicitly defined veneer instructions and symbols. It reproduces the GDB stepping bug without a Cortex-A53 CPU or the hardware erratum, independent of compiler optimization and linker sequence detection. A call to helper leaves a stale link register before entering the veneer, which has no debug or unwind information. The assertions check the initial inline backtrace, returned source line, and exact stop address. To reproduce on a native AArch64 ELF target: 1. Build GDB at the base commit below and retain its executable and data-directory. Apply this patch and build the patched GDB. 2. From the patched build's gdb/testsuite directory, run the same test with each GDB. Use absolute executable and data-directory paths: make check \ RUNTESTFLAGS="GDB=/path/to/gdb \ GDBFLAGS=--data-directory=/path/to/data-directory \ gdb.arch/aarch64-erratum-843419-veneer.exp" Save gdb.sum and gdb.log after each run; the next run overwrites them. Recorded next sessions (patched source path shortened): Before: (gdb) next [Inferior 1 (process 46367) exited normally] (gdb) p $pc == (void *) &inline_high No registers. After: (gdb) next outer () at .../aarch64-erratum-843419-veneer.S:58 58 /* Outer after inline. */ (gdb) p $pc == (void *) &inline_high $1 = 1 finish likewise changes from normal inferior exit to stopping at inline_high in outer. The new test changes from 4 PASS and 4 FAIL to 8 PASS and no FAIL. Tested on native aarch64-unknown-linux-gnu in an Ubuntu 26.04 container, with GCC 15.2.0, GNU ld 2.46, and GDB 19.0.50.20260929-git. Base commit: 4ba6bd8393418b63dc3efa0ec6f934903a10f140. These eight existing test files stayed at 241 PASS and no FAIL in both runs: gdb.arch/aarch64-prologue.exp gdb.arch/aarch64-unwind-pc.exp gdb.opt/inline-cmds.exp gdb.opt/inline-bt.exp gdb.dwarf2/dw2-inline-stepping.exp gdb.base/finish.exp gdb.base/step-over-no-symbols.exp gdb.base/step-line.exp A rerun after comment-only cleanup also gave 8 PASS and no FAIL. The full GDB testsuite and other targets were not tested. CPython issue #157965 reports layout-sensitive failures in test_bt_unwinds_from_inside_jit_executor on AArch64 release builds. Later main builds did not consistently reproduce them, so the standalone fixture is the regression test. A separate check used a preserved CPython binary with a GNU ld-generated e843419@ veneer and PYTHON_JIT=0. Before the fix, finish ran the inferior to exit and bt reported "No stack." With the fix, it stopped in mro_invoke with a valid backtrace. This used an existing binary; current CPython main was not rebuilt and the issue's JIT test was not rerun. Related report: https://github.com/python/cpython/issues/157965 --- This is my first contribution to GDB. I have not completed an FSF copyright assignment. Could you please point me to the appropriate form? gdb/aarch64-tdep.c | 16 +++ .../gdb.arch/aarch64-erratum-843419-veneer.S | 84 +++++++++++++ .../aarch64-erratum-843419-veneer.exp | 111 ++++++++++++++++++ 3 files changed, 211 insertions(+) create mode 100644 gdb/testsuite/gdb.arch/aarch64-erratum-843419-veneer.S create mode 100644 gdb/testsuite/gdb.arch/aarch64-erratum-843419-veneer.exp diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 950ad4f6..9e1b5612 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -34,6 +34,7 @@ #include "frame-base.h" #include "trad-frame.h" #include "objfiles.h" +#include "symtab.h" #include "dwarf2.h" #include "dwarf2/frame.h" #include "gdbtypes.h" @@ -4158,6 +4159,19 @@ aarch64_cannot_store_register (struct gdbarch *gdbarch, int regnum) && regnum < tdep->pauth_reg_base + tdep->pauth_reg_count); } +/* Implement the in_indirect_branch_thunk gdbarch method. GNU ld's + Cortex-A53 erratum 843419 veneers branch back into the same function, + so step through them rather than treating them as function calls. */ + +static bool +aarch64_in_indirect_branch_thunk (gdbarch *, CORE_ADDR pc) +{ + bound_minimal_symbol minsym = lookup_minimal_symbol_by_pc (pc); + + return (minsym.minsym != nullptr + && startswith (minsym.minsym->linkage_name (), "e843419@")); +} + /* Implement the stack_frame_destroyed_p gdbarch method. */ static bool @@ -4788,6 +4802,8 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) aarch64_breakpoint::bp_from_kind); set_gdbarch_have_nonsteppable_watchpoint (gdbarch, true); set_gdbarch_get_next_pcs (gdbarch, aarch64_software_single_step); + set_gdbarch_in_indirect_branch_thunk (gdbarch, + aarch64_in_indirect_branch_thunk); /* Information about registers, etc. */ set_gdbarch_sp_regnum (gdbarch, AARCH64_SP_REGNUM); diff --git a/gdb/testsuite/gdb.arch/aarch64-erratum-843419-veneer.S b/gdb/testsuite/gdb.arch/aarch64-erratum-843419-veneer.S new file mode 100644 index 00000000..e14a0d14 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-erratum-843419-veneer.S @@ -0,0 +1,84 @@ +/* Copyright 2026 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 . */ + +/* Calling helper leaves a stale link register. The veneer has no debug + or unwind information. */ + .text + .global main + .type main, %function +main: + .cfi_startproc + stp x29, x30, [sp, -16]! + .cfi_def_cfa_offset 16 + .cfi_offset x29, -16 + .cfi_offset x30, -8 + mov x29, sp + bl outer + mov w0, 0 + ldp x29, x30, [sp], 16 + .cfi_def_cfa_offset 0 + .cfi_restore x29 + .cfi_restore x30 + ret + .cfi_endproc + .size main, .-main + + .global outer + .type outer, %function +outer: + .cfi_startproc + stp x29, x30, [sp, -16]! + .cfi_def_cfa_offset 16 + .cfi_offset x29, -16 + .cfi_offset x30, -8 + mov x29, sp + mov x0, sp + + /* Outer call line. */ + /* Inline body line. */ + .global inline_low +inline_low: + bl helper + b .Lveneer + + /* Outer after inline. */ + .global inline_high +inline_high: + ldp x29, x30, [sp], 16 + .cfi_def_cfa_offset 0 + .cfi_restore x29 + .cfi_restore x30 + ret + .cfi_endproc + .global outer_end +outer_end: + .size outer, .-outer + +helper: + ret + + .type "e843419@0000_00000000_0000", %function +"e843419@0000_00000000_0000": +.Lveneer: + ldr x2, [x0] + b inline_high + .size "e843419@0000_00000000_0000", .-.Lveneer + + .global program_end +program_end: + + .section .note.GNU-stack,"",%progbits diff --git a/gdb/testsuite/gdb.arch/aarch64-erratum-843419-veneer.exp b/gdb/testsuite/gdb.arch/aarch64-erratum-843419-veneer.exp new file mode 100644 index 00000000..67a76052 --- /dev/null +++ b/gdb/testsuite/gdb.arch/aarch64-erratum-843419-veneer.exp @@ -0,0 +1,111 @@ +# Copyright 2026 Free Software Foundation, Inc. + +# This file is part of GDB. + +# 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 . + +# Test stepping over a Cortex-A53 erratum 843419 veneer in an inline function. +# Fixed instructions and debug information avoid dependence on compiler +# optimizations or linker layout. + +load_lib dwarf.exp + +require is_aarch64_target +require is_elf_target +require dwarf2_support + +standard_testfile .S -dw.S + +set outer_call_line [gdb_get_line_number "Outer call line"] +set inline_line [gdb_get_line_number "Inline body line"] +set outer_after_line [gdb_get_line_number "Outer after inline"] + +set dwarf_asm [standard_output_file $srcfile2] +Dwarf::assemble $dwarf_asm { + global srcdir subdir srcfile + global outer_call_line inline_line outer_after_line + + declare_labels lines_label inline_subprogram + + cu {} { + compile_unit { + DW_AT_language @DW_LANG_C + DW_AT_name $srcfile + DW_AT_stmt_list $lines_label DW_FORM_sec_offset + DW_AT_low_pc main addr + DW_AT_high_pc program_end addr + } { + inline_subprogram: subprogram { + DW_AT_name inline_func + DW_AT_inline 3 data1 + } + subprogram { + DW_AT_name outer + DW_AT_low_pc outer addr + DW_AT_high_pc outer_end addr + } { + inlined_subroutine { + DW_AT_abstract_origin %$inline_subprogram + DW_AT_low_pc inline_low addr + DW_AT_high_pc inline_high addr + DW_AT_call_file 1 data1 + DW_AT_call_line $outer_call_line data1 + } + } + } + } + + lines {version 2} lines_label { + include_dir "$srcdir/$subdir" + file_name "$srcfile" 1 + + program { + DW_LNE_set_address outer + line $outer_call_line + DW_LNS_copy + # Describe the inline call site before the inline function's body. + DW_LNE_set_address inline_low + line $outer_call_line + DW_LNS_copy + DW_LNE_set_address inline_low + line $inline_line + DW_LNS_copy + DW_LNE_set_address inline_high + line $outer_after_line + DW_LNS_copy + DW_LNE_set_address outer_end + DW_LNE_end_sequence + } + } +} + +if { [prepare_for_testing "failed to prepare" $testfile \ + [list $srcfile $dwarf_asm] {nodebug nopie}] } { + return +} + +foreach_with_prefix command {next finish} { + if { ![runto_main] } { + return + } + + gdb_breakpoint "*inline_low" + gdb_continue_to_breakpoint "inline function" + + gdb_test "bt" "#0 inline_func.*#1 outer.*#2 .*main.*" \ + "backtrace in inline function" + gdb_test $command "Outer after inline.*" "step through erratum veneer" + gdb_test {p $pc == (void *) &inline_high} " = 1" \ + "stopped after inline function" +} base-commit: 4ba6bd8393418b63dc3efa0ec6f934903a10f140 -- 2.54.0 (Apple Git-157)