From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 18JWETldBWbUdhkAWB0awg (envelope-from ) for ; Thu, 28 Mar 2024 08:06:17 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Cs/w1Sai; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 3690A1E0C0; Thu, 28 Mar 2024 08:06:17 -0400 (EDT) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 AF6741E030 for ; Thu, 28 Mar 2024 08:06:14 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 550D83858420 for ; Thu, 28 Mar 2024 12:06:14 +0000 (GMT) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by sourceware.org (Postfix) with ESMTPS id ED6FF3858D1E for ; Thu, 28 Mar 2024 12:05:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED6FF3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ED6FF3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711627551; cv=none; b=ELcj8ohE3qPjr8/CPJzpDx6hwJjarZ32go2XVCX/dXhaClq4sTBTSnfPnNXNAZYEHhGCSMuAw0CmD7eA9NDFsU9q6sxPgrYnm3pvL+4iJ0xsKsisJjexW7r/XED7M/imBAdZOqWZo767lQFNsGOsHsqJzLlJuA8I0hjrHq/JFFw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711627551; c=relaxed/simple; bh=JAyVPwGr0sIsnbcXv6ILanfD+yAMVkf0dcjtJ8K/LTc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Bv1f57lOTlynRDHRP9J9u7zD8x1ttKjs9b3uqlHoWxr9GmFfEv4Rn/6hL00QbpDxtjJaynem2tuDpXJAr2g2o2QBpd1STCTR/Nd9pihPB4M9c2125MKWfbw5gMBlFCVYnS3vmrQR7qz01qK9ZbuFhpbevXqKajQ0Ri1aoksERUk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711627544; x=1743163544; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=JAyVPwGr0sIsnbcXv6ILanfD+yAMVkf0dcjtJ8K/LTc=; b=Cs/w1SaiLwDTtQIbkOXEEt4rBsbAfA3pzGzAdKFdqcjxWJUT2Gv7v/Wr jU7qwJ+LynneOaIlhUA0RxO3NnlLZ29gb4DBc85/pmvWPs3H74wjO2saf gN2Zu431T/SFnzCKMKQw5Yl+aGC2PVDkA8ZPqAPruYsY2anAqcJOyFtZX XkVhiMO3Ki2em0YJGbzQZidsjQ9pwhAIVo1670T/Iu05Vh8iWSUvv6IIe CSgO+3wBX8gPYYFVo0pj4djpGlTtLx4hhhKFytE7yIUn+SZhgR67DU1VH 0lEi/GegAubkq3SGey9qZAhQiQ0Zi60yYQW49rrryBmoDQDZ1eCokvCcl A==; X-CSE-ConnectionGUID: Lf3pkyK2Qd6HwfFqPtQ39A== X-CSE-MsgGUID: N9qYlvOjTHiWr6VHsLSykw== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="10557718" X-IronPort-AV: E=Sophos;i="6.07,161,1708416000"; d="scan'208";a="10557718" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2024 05:05:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,161,1708416000"; d="scan'208";a="21283176" Received: from abijaz-mobl2.ger.corp.intel.com (HELO localhost) ([10.246.42.1]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2024 05:05:42 -0700 From: Abdul Basit Ijaz To: gdb-patches@sourceware.org Cc: abdul.b.ijaz@intel.com, JiniSusan.George@amd.com, tom@tromey.com, eliz@gnu.org Subject: [PATCH v6 00/10] GDB support for DW_AT_trampoline Date: Thu, 28 Mar 2024 13:05:18 +0100 Message-Id: <20240328120528.30382-1-abdul.b.ijaz@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP 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.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 From: "Ijaz, Abdul B" 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. For rest of the patches as the name of the patch indicates it implements skipping of trampolines for the command mentioned in the patch name. A new setting has also been introduced in this change 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 V5: * Updated the documentation part. * Splitted the patch 4/4 for each command. * Now trampolines are skipped for these commands as well as per the feedback on V5 patch: ** backtrace -n, ** return ** mi commands -stack-list-frames and -stack-list-arguments V5 series of patches can be found here: https://sourceware.org/pipermail/gdb-patches/2023-August/201684.html No regression seen on testing x64/native-extended-gdbserver(-m32)/x32/ native-gdbserver test configurations for these changes. Thanks & Best Regards Abdul Basit Ijaz, Abdul B (7): gdb: Skip trampoline frames for the backtrace command. gdb: Skip trampoline functions for the finish and reverse-finish commands. gdb: Skip trampoline functions for the up command. gdb: Skip trampoline functions for the return command. gdb, mi: Skip trampoline functions for the -stack-list-frames command. gdb, mi: Skip trampoline functions for the -stack-list-arguments command. gdb: Filter trampoline frames in backtrace when using Python frame-filters. Nils-Christian Kempke (3): gdb, dwarf: add support for DW_AT_trampoline in DWARF reader gdb/symtab: add lookup for trampoline functions gdb: handle stepping through functions with DW_AT_trampoline gdb/NEWS | 13 + gdb/doc/gdb.texinfo | 53 +++- gdb/dwarf2/read.c | 46 +++- gdb/gdbtypes.c | 34 ++- gdb/gdbtypes.h | 113 +++++++- gdb/infcmd.c | 12 + gdb/infrun.c | 95 ++++++- gdb/infrun.h | 16 ++ gdb/mi/mi-cmd-stack.c | 14 + gdb/python/py-frame.c | 11 + gdb/stack.c | 26 ++ gdb/symtab.c | 81 ++++++ 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 | 102 ++++++++ gdb/testsuite/gdb.fortran/func-trampoline.f90 | 39 +++ .../gdb.fortran/mixed-lang-stack.exp | 10 +- gdb/testsuite/gdb.mi/mi-func-trampoline.exp | 75 ++++++ .../gdb.python/py-framefilter-trampoline.exp | 77 ++++++ .../gdb.python/py-framefilter-trampoline.py | 31 +++ .../gdb.reverse/finish-reverse-trampoline.exp | 56 ++++ 22 files changed, 1233 insertions(+), 15 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 create mode 100644 gdb/testsuite/gdb.mi/mi-func-trampoline.exp create mode 100644 gdb/testsuite/gdb.python/py-framefilter-trampoline.exp create mode 100644 gdb/testsuite/gdb.python/py-framefilter-trampoline.py create mode 100644 gdb/testsuite/gdb.reverse/finish-reverse-trampoline.exp -- 2.34.1 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928