From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 5A34B3858D20 for ; Tue, 11 Jul 2023 11:22:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5A34B3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJBQj-0004iJ-Os; Tue, 11 Jul 2023 07:21:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=QpQrKhHDZY7Jqgxu7lkWzJCLIQ82Y23uyQMMCYnrRd0=; b=IlmChUAKTbgc EWVhYESKkJIxlD51AOP/aMb1umCEiTyQ9vB4jv0u/M7uEXirJqnhCKA3VImpClsB8qGLtG0PBRcd8 gdpWKQTR0Z0c5qSlnMZA1Wxf3kK4x03Vv8MTB/dkJ6T8rr5eNoEKz/hbbQJvXg6fGfO02VPOEjRz/ LO3CO7PqFShJVSfhcwir4YxprLIZPUN12JX9NIGvUbkNdrlsGiCjUqNYBWGAJ33kcGVJCVAn8m21L QxwJCRMaEMHSGdnABNX6S+7cxke2AhMY9a+1PzvrhC/z2F4ZWnwSBeH8hDCdpUVW7x1cnkaJg0BSI AzvaZu0v7HIhsVNldBng+Q==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJBQj-0006wI-8U; Tue, 11 Jul 2023 07:21:17 -0400 Date: Tue, 11 Jul 2023 14:21:28 +0300 Message-Id: <837cr68zif.fsf@gnu.org> From: Eli Zaretskii To: Abdul Basit Ijaz Cc: gdb-patches@sourceware.org, JiniSusan.George@amd.com, tom@tromey.com, nils-christian.kempke@intel.com In-Reply-To: <20230710225643.32280-4-abdul.b.ijaz@intel.com> (message from Abdul Basit Ijaz on Tue, 11 Jul 2023 00:56:42 +0200) Subject: Re: [PATCH v3 3/4] gdb/infrun: handle stepping through functions with DW_AT_trampoline References: <20230710225643.32280-1-abdul.b.ijaz@intel.com> <20230710225643.32280-4-abdul.b.ijaz@intel.com> X-Spam-Status: No, score=1.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_BARRACUDACENTRAL,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > From: Abdul Basit Ijaz > Cc: abdul.b.ijaz@intel.com, > JiniSusan.George@amd.com, > tom@tromey.com, > eliz@gnu.org, > Nils-Christian Kempke > Date: Tue, 11 Jul 2023 00:56:42 +0200 > > From: Nils-Christian Kempke > > This patch makes infrun continue stepping into and through trampoline > functions marked via the DW_AT_trampoline in DWARF. The attribute can > be emitted by the compiler for certain subroutines/inlined subroutines > that are compiler generated and should be hidden from a user. > > Mainly, infrun is modified in 3 ways. > > First, GDB will now attempt to step through trampoline functions. > Whenever we issued a step command that would make GDB step into a > function that is marked trampoline, GDB will try to step directly towards > the trampoline's 'target' instead and, e.g., not stop at the first > instruction of the trampoline. > The target can be specified by the compiler by the value of > DW_AT_trampoline if its form is either an address, a name, or a DIE > reference. DW_AT_trampoline is also allowed to be specified as a flag > (containing true or false), in which case the target is assumed to be > unknown. If GDB successfully finds a target, so if the value of > DW_AT_trampoline was not a flag and could be resolved successfully, GDB > steps directly towards the target and through the trampoline, hiding > the trampoline from the user. If GDB cannot, however deduce a target, > most likely because the DW_AT_trampoline was given as a flag or because > of broken debug info, it will instead continue inside execution in the > trampoline function until it reaches an instruction that is not > associated with a trampoline function, which is usually the target > function. It will then stop and give control back to the user. > It should be noted, that there might be the cases, where trampolines > call functions other than the target before the actual target call. If, > in such a situation, GDB fails to resolve the target, it would resume > execution until stepping into this other function call, and hand back > control to the user, without actually having reached the target. A > second step would have to be issued by the user to arrive a the target > (by resuming in the trampoline and then until leaving it a second time). > As this is a rather pathological case and no real instance of this is > known, I think the current behavior here is good enough and seems to be > the best GDB can do in such a situation. > > Secondly, as trampoline functions normally do not have any real source > code correlation, it is likely that they mostly appear without line > info. > Normally, GDB would skip completely over a function call to a function > that has no source line information, so we would never get to the > aforementioned stepping through a trampoline and target resolution. To > remedy this, for debug info trampolines, GDB now attempts to step through > them regardless of them having source line information or not. So > issuing a step at a function call wrapped by a trampoline without source > line information will no longer skip the whole function call, but now > step through the trampoline and attempt to resolve the trampoline target > as described above (so usually, a single step at the call site will step > through the trampoline and towards the target, even if the trampoline had > not source line info). > > Last, in all other cases when GDB is about to stop at a location that is > included in a trampoline region (e.g. after a step from the target back > into the trampoline) GDB will instead continue until the trampoline > region is left again and only then give control back to the user. This > change serves the purpose of allowing stepping back from a target call > through the trampoline without the user noticing the artificial function > call inbetween call site and target. > > Together, these changes attempt to hide the trampoline function from the > user while stepping. Additionally, the skip-trampoline-functions option > has been introduced in infrun. It is set by default, and, when turned > off, GDB will return to its 'normal' stepping behavior and ignore any > possible DW_AT_trampoline. > > As currently only ifx emits the DW_AT_trampoline tag, a test has been > added to gdb.dwarf2 that artificially creates a set of trampoline > functions. > > 2023-07-10 Nils-Christian Kempke > --- > gdb/NEWS | 15 ++ > gdb/doc/gdb.texinfo | 36 +++ > gdb/infrun.c | 81 +++++- > gdb/infrun.h | 4 + > .../gdb.dwarf2/dw2-function-trampolines.c | 80 ++++++ > .../gdb.dwarf2/dw2-function-trampolines.exp | 245 ++++++++++++++++++ > 6 files changed, 457 insertions(+), 4 deletions(-) > create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-function-trampolines.c > create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-function-trampolines.exp Thanks, the documentation parts are okay. Reviewed-By: Eli Zaretskii