From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by sourceware.org (Postfix) with ESMTPS id D3B823858C2F for ; Wed, 16 Aug 2023 21:54:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D3B823858C2F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692222852; x=1723758852; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=SXA83qwFWBfXgpXRnquD6wnCeDZGi7tPxRsR2mL0Nwo=; b=ftOTe5+rAWNAW8+K1yz/tAAeU5xpIwfwUGc6K4ffKk2ZEcV83SQqqpFP XeTCqiWIDNcNEOmobV7ZX2XYJX0KOuh2yLMNjkr/tFcgpucfNk/rRwMzg gObdC7L9pP713wZix8QXrNf2nJd2Dcpenq/dXyvl7A2w/p9ImJpIwpYUC X4PmFx1krlMt55E5TVt21/Qu9ysEj2u8PoqLerJoCEJF5f++cbfH4rU3l vW6kuWB2Usfhk9xSllIZfT7vI2ogtUl/NXv4OK8lDgiApV72GEVGm4/bz tYo5dNVu5wdJt4u/H2rOO9uVi60lO9Q8pZPItEzq4alN0PyvtuY70ro57 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10803"; a="459003116" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="459003116" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2023 14:54:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10803"; a="857966291" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="857966291" Received: from abijaz-mobl2.ger.corp.intel.com (HELO localhost) ([10.249.40.204]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2023 14:54:08 -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, blarsen@redhat.com Subject: [PATCH v5 0/4] GDB support for DW_AT_trampoline Date: Wed, 16 Aug 2023 23:53:45 +0200 Message-Id: <20230816215349.6198-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.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 List-Id: From: "Ijaz, Abdul B" 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 V4: * Fixed reverse finish for trampolines. * Elide trampoline frames in backtrace for frame-filters case. * Use target subroutine address instead of name in case of ref type trampoline target. * Fixed loops formatting and now split line where possible at ";". V4 series of patches can be found here: https://sourceware.org/pipermail/gdb-patches/2023-August/201263.html No regression seen on testing x64/native-extended-gdbserver(-m32)/x32/ native-gdbserver test configurations for these changes using Ubuntu 22. Thanks & Best Regards Abdul Basit 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 | 15 ++ gdb/doc/gdb.texinfo | 47 ++++ gdb/dwarf2/read.c | 46 +++- gdb/gdbtypes.c | 34 ++- gdb/gdbtypes.h | 113 +++++++- gdb/infcmd.c | 13 + gdb/infrun.c | 93 ++++++- gdb/infrun.h | 10 + gdb/python/py-frame.c | 15 ++ 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 +- 17 files changed, 922 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 -- 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