From patchwork Mon Jun 5 11:04:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ijaz, Abdul B" X-Patchwork-Id: 55815 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4E78F385084A for ; Mon, 5 Jun 2023 11:04:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E78F385084A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685963098; bh=p8DRvPzAl23yNBADuf07ATIIB7HvjqDyO39pnIJ/xIo=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ynZWOLasbj2jlnuRu6vyVofdMPnqBsFtx93BW1EEFgEBN/xjvsGCQe4HQPlXHbjh/ dUAF9QaibVBlf3Nalj3CPpMXAbaNmy2UDT3V0Yv2U0u627RpHWh8TommShHJHpcITU sfW4MOdhX/LkTEJYuims0Rkc747IrBQmW0oTzl4A= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by sourceware.org (Postfix) with ESMTPS id 222DA3854E47 for ; Mon, 5 Jun 2023 11:04:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 222DA3854E47 X-IronPort-AV: E=McAfee;i="6600,9927,10731"; a="345933346" X-IronPort-AV: E=Sophos;i="6.00,217,1681196400"; d="scan'208";a="345933346" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2023 04:04:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10731"; a="1038735960" X-IronPort-AV: E=Sophos;i="6.00,217,1681196400"; d="scan'208";a="1038735960" Received: from labpc2030.iul.intel.com (HELO localhost) ([172.28.48.46]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jun 2023 04:04:26 -0700 To: gdb-patches@sourceware.org Cc: abdul.b.ijaz@intel.com, JiniSusan.George@amd.com, tom@tromey.com Subject: [PATCH v2 0/4] GDB support for DW_AT_trampoline Date: Mon, 5 Jun 2023 13:04:06 +0200 Message-Id: <20230605110410.3078-1-abdul.b.ijaz@intel.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Abdul Basit Ijaz via Gdb-patches From: "Ijaz, Abdul B" Reply-To: Abdul Basit Ijaz Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Hi, please find attached a series of patches that attempts to enable GDB to handle the DW_AT_trampoline attribute on functions and inlined functions. DW_AT_trampoline can be emitted by the compiler for functions that are compiler generated trampolines (e.g. wrapping other function calls). In doing so, the compiler can specify a target as the value of DW_AT_trampoline which the trampoline is wrapping. This series enables GDB to recognize the DW_AT_trampoline and store the target for a given function. Patch 3 adapts GDB's stepping behavior when dealing with trampolines and attempts to - by default - hide these trampolines from the user. When about to step into a trampoline, instead, GDB will try and step through the trampoline and directly towards the target. Patch 4 in V2 now skip trampoline frames in the stack for printing or finish command. A new setting has been introduced to turn off this modified stepping behavior or printing of stack for trampolines. The motivation for these patches comes from ifx which emits the attribute for some of its compiler generated functions. As I do not know of any other compiler (especially gcc/gfortran) emitting DW_AT_trampoline, I added a gdb.dwarf2 test to this series in order to test the trampoline handling within GDB. Changes since V1: * Skip trampoline frames in the stack for printing or finish command. * Code reviews related changes: - Removed Changelog entries in commit messages. - Removed minimum symbol address search and addtional section offset for trampolines during symbol read. - Fix typo and improve description for option "skip-trampoline-functions". - Handling of data offset for trampoline target address is removed from dwarf reader. - Update trampoline function type bitfield handling in func_type structure. V1 series of patches can be found here: https://sourceware.org/pipermail/gdb-patches/2022-July/190566.html No regression seen on testing unix/unix32/gdbserver/gdbserver-extended test configurations for these changes using Ubuntu 18. Thanks & Best Regards, Abdul Basit Ijaz Abdul Basit Ijaz (1): gdb: Skip trampoline frames in the stack for printing or finish command. Nils-Christian Kempke (3): gdb, dwarf: add support for DW_AT_trampoline in DWARF reader gdb/symtab: add lookup for trampoline functions gdb/infrun: handle stepping through functions with DW_AT_trampoline gdb/NEWS | 14 + gdb/doc/gdb.texinfo | 46 ++++ gdb/dwarf2/read.c | 43 ++- gdb/gdbtypes.c | 35 ++- gdb/gdbtypes.h | 103 +++++++- gdb/infcmd.c | 14 + gdb/infrun.c | 81 +++++- gdb/infrun.h | 10 + gdb/stack.c | 8 + gdb/symtab.c | 80 ++++++ gdb/symtab.h | 19 ++ .../gdb.dwarf2/dw2-function-trampolines.c | 80 ++++++ .../gdb.dwarf2/dw2-function-trampolines.exp | 245 ++++++++++++++++++ gdb/testsuite/gdb.fortran/func-trampoline.exp | 69 +++++ gdb/testsuite/gdb.fortran/func-trampoline.f90 | 39 +++ .../gdb.fortran/mixed-lang-stack.exp | 10 +- 16 files changed, 882 insertions(+), 14 deletions(-) create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-function-trampolines.c create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-function-trampolines.exp create mode 100644 gdb/testsuite/gdb.fortran/func-trampoline.exp create mode 100644 gdb/testsuite/gdb.fortran/func-trampoline.f90