| Message ID | cover.1741701275.git.dominik.mascherbauer@oracle.com |
|---|---|
| Headers |
Return-Path: <gdb-patches-bounces~patchwork=sourceware.org@sourceware.org> 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 78ABF3857BA7 for <patchwork@sourceware.org>; Tue, 11 Mar 2025 14:58:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 78ABF3857BA7 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=ElRT4S35 X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id 012613858C48 for <gdb-patches@sourceware.org>; Tue, 11 Mar 2025 14:57:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 012613858C48 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 012613858C48 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741705052; cv=none; b=ZwUTCBEBg4oSWmxzhazt9f5x9PKAOQtK9uHUdZ1ciur8DWmP3gqWWJ/+H74NMTYUPN9I5O6WryKJROxnVyxLFIYqaYFFKw4w7MeUDUt7lLwERqr8D8l4vx8y/F5GSv5TMFPBCLTDvdKEbkB96+EJ7TmLk/iNglYg3BeI3jfdk5M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741705052; c=relaxed/simple; bh=HFRgkCQJddKx4MJokjrWlOm5pqan0VJUA/af0aLI48s=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=HyOH9Uj5Mg7SRaISSoRCUuGioiq/HnwMjhO6gCvsiukNN0mNv5lnMCZ2uQN3NutkKEbxj56rsf/Nd3aXkmGJCiw3Hnj3yQc0AXdnka55BCD+ujv3W4ZMNcoF2hw4rvkmM/Yu93uwBNPGXdzLc4dHA5sOv5XyZDGBsX91+WhhZXM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 012613858C48 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5e5bc066283so8693400a12.0 for <gdb-patches@sourceware.org>; Tue, 11 Mar 2025 07:57:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741705050; x=1742309850; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=2OVzfmjptrXS/uPqlCF33Nl784NxXwsIYGAHe/ihFuc=; b=ElRT4S35h9hboMdt6zRQT2aIkzT2rSn+z4z0EK7NAOAJ+BGUTmRgHSvFR3ypCg+YB5 WtPkfirA+QA/xhYE7+SetpphXf6bDUvpCSOWXDPgCRYjv2T32O/5iAh0ykSvWC9REODd PDwY25jnSTfRbLDb4SisLdMAiVO7YszuRw634bBZfGnRjie/cGuSHTcMJYleyDcemnXh LbqurFwBg9vO+/DwZiImFsQo2yHE0vAUy+Oo9EqlP0tXpoP6j2QvbVTlpECg0+em6lYX AZeUKzFBUZEsMOuXNAxvUjUT1PnYW2zIIF4G9Io8FUB5cyPWOKuJdf6CTF70Jvm8X9nd npeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741705050; x=1742309850; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2OVzfmjptrXS/uPqlCF33Nl784NxXwsIYGAHe/ihFuc=; b=Iq6L0s699HP8LLdUJNXhNSocSNcd6qVx8FFamRYf6lJF2rxZQOOAIPhjo6K8210Hnj +Qhjq+8i8jrAQxxoSf8QDlOjF+ZGgSAXEO+0Dxu+XMrRwtX0RRaES0KNXHjWC6ySirZN XxJ5y+qkRwfQ9KUyVuaMyG+HiAqspu5iGqSxaaxO1WNvGGhPDB8L7Nlp5GmRxxeIzf8K 3N75WWj26gEDqNc62BqlRaqfqVRl0MrxqrlBviXlYS7jcBeQdj82MVtojMMlwIilNoxU iCV54/luCS5gbukY1eiu0uE9gc35smuyYA77sL68Xx3Qm6ghvR40CfBYKZMOEBVpqLbL O2EA== X-Gm-Message-State: AOJu0YzPbgUr3pPduS3BcAeXWn7/HHYWpn/nnvDDiIiwlX6X8OIHj0oX p0hCbCODTIlMrI557zozogJaQLxbgetKWGd1GiELhEgy/rFSFf9ilCzVjg== X-Gm-Gg: ASbGncvRc5igvgbSFCFnbkqgYrMhaUj/EBEqWps1Ed7hJPwrMSVWA9LcOgzwy62a2KJ tHOJcHxPQ5viIc7MQkvlltwwcRIIlXnrTHH1S5Aq/MfSLAcgLA3/Yy6apCPyhg5Asic4VacwfFb P2WrMBqUNT8r2HqCWI/XXa6YpIa7Ztw96uj1A6YUNj05fkHS+H0uDoyh0H6RHMDr0uaAwBp7BHp R6rRbvvMnuf+ejSrgusbMK7lUePoqK0lgZpVAo7otcaw7SYMZuvbaYA0ma7SpqsDqqc9WTSMXzO pJOrp8TfHi6Vn/dMyrfEsGPDpzIwAXCBecDP0lOK33WwO4Oy5GBVY1GJngLNsscVcznF X-Google-Smtp-Source: AGHT+IE7NkIg2uQNBxgMBf5DqJsR4a1nydFRYPNmX231vNWHbBEvg2Z1XhaK6LuhefFZV9AG45J1dQ== X-Received: by 2002:a17:907:c0d:b0:ac2:892f:439 with SMTP id a640c23a62f3a-ac2892f132emr1357510266b.37.1741705049957; Tue, 11 Mar 2025 07:57:29 -0700 (PDT) Received: from pop-os.ssw.jku.at ([140.78.145.202]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac239439074sm945195866b.10.2025.03.11.07.57.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Mar 2025 07:57:29 -0700 (PDT) From: dominikmascherbauer <dominik.mascherbauer@gmail.com> X-Google-Original-From: dominikmascherbauer <dominik.mascherbauer@oracle.com> To: gdb-patches@sourceware.org Cc: dominikmascherbauer <dominik.mascherbauer@oracle.com> Subject: [PATCH 0/3] DWARF type signature lookup fallback. Date: Tue, 11 Mar 2025 15:57:17 +0100 Message-Id: <cover.1741701275.git.dominik.mascherbauer@oracle.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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 <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
DWARF type signature lookup fallback.
|
|
Message
Dominik Mascherbauer
March 11, 2025, 2:57 p.m. UTC
I am working on a patch that adds parameters to allow type signature fallback for DWARF type units to fallback to other objfiles. This allows to only create type units once and reuse them by their type signature, reducing duplication of type units. It builds on the uniqueness of type signatures, so a type signature always references the same type unit. This is my first time using a mailing list, so please remind me of any formatting errors or other mistakes. Thanks, Dominik dominikmascherbauer (3): Add new commands for controlling type signature fallback. Add type signature fallback and JIT objfile restriction. Add testing for type signature fallback. gdb/NEWS | 14 + gdb/doc/gdb.texinfo | 26 ++ gdb/dwarf2/read.c | 254 ++++++++++++++++-- gdb/jit.c | 6 +- gdb/objfile-flags.h | 3 + .../gdb.dwarf2/sig-type-fallback-jit.c | 62 +++++ .../gdb.dwarf2/sig-type-fallback-jit.exp | 75 ++++++ 7 files changed, 409 insertions(+), 31 deletions(-) create mode 100644 gdb/testsuite/gdb.dwarf2/sig-type-fallback-jit.c create mode 100644 gdb/testsuite/gdb.dwarf2/sig-type-fallback-jit.exp base-commit: 512316811d47d689d75d25aa9d5b98bdafd64df6
Comments
>>>>> dominikmascherbauer <dominik.mascherbauer@gmail.com> writes: > I am working on a patch that adds parameters to allow type signature > fallback for DWARF type units to fallback to other objfiles. This > allows to only create type units once and reuse them by their type > signature, reducing duplication of type units. It builds on the > uniqueness of type signatures, so a type signature always references > the same type unit. I am not sure this can really work due to lifetime constraints. GDB has some rules about type ownership: 1. Arch-owned types must only refer to other arch-owned types 2. Objfile-owned types must only refer to other types coming from the same objfile, or to arch-owned types These rules exist so that if an objfile is removed, there will not be any dangling pointers. I think this series violates rule 2. There's a follow-on rule to this that isn't as frequently discussed, but a symbol in an objfile has to follow rule 2 as well: it can't refer to types from another objfile. And I think this series also violates this. I think you can see this in action for opaque types, where the lookup is done over and over, because caching the result would violate the rules. (This brings up the question of why you want this feature at all as opposed to just using opaque type resolution.) Anyway, this can't be easily remedied. One idea we have discussed in the past is to have a "type GC". What this would mean is removing type ownership -- just allocate all types globally. Then, have a garbage collector that removes type objects when things change, for instance after an objfile is destroyed. This is difficult to implement though. For one thing types can refer back to symbols. Though perhaps this particular special case could be handled by the GC. Maybe other approaches are possible too, I don't know. Tom
>>>>>> dominikmascherbauer <dominik.mascherbauer@gmail.com> writes: > >> I am working on a patch that adds parameters to allow type signature >> fallback for DWARF type units to fallback to other objfiles. This >> allows to only create type units once and reuse them by their type >> signature, reducing duplication of type units. It builds on the >> uniqueness of type signatures, so a type signature always references >> the same type unit. > > I am not sure this can really work due to lifetime constraints. > > GDB has some rules about type ownership: > > 1. Arch-owned types must only refer to other arch-owned types > > 2. Objfile-owned types must only refer to other types coming from the > same objfile, or to arch-owned types > > These rules exist so that if an objfile is removed, there will not be > any dangling pointers. > > I think this series violates rule 2. > > There's a follow-on rule to this that isn't as frequently discussed, but > a symbol in an objfile has to follow rule 2 as well: it can't refer to > types from another objfile. And I think this series also violates this. > > I think you can see this in action for opaque types, where the lookup is > done over and over, because caching the result would violate the rules. > (This brings up the question of why you want this feature at all as > opposed to just using opaque type resolution.) > > > Anyway, this can't be easily remedied. One idea we have discussed in > the past is to have a "type GC". What this would mean is removing type > ownership -- just allocate all types globally. Then, have a garbage > collector that removes type objects when things change, for instance > after an objfile is destroyed. > > This is difficult to implement though. For one thing types can refer > back to symbols. Though perhaps this particular special case could be > handled by the GC. > > Maybe other approaches are possible too, I don't know. > > Tom Thanks for the response. I agree that this series violates rule 2 as you mentioned. I was not aware of those rules at the time of implementing this patch. Thank you very much for pointing out opaque types. I did not come across those when trying to figure out how to reference existing types from other objfiles. For checking available options I mainly used the DWARF specification which does not mention them. My initial idea was to use type signatures as they should be unique even across multiple objfiles. Based on that I thought it would be possible to use type signatures for finding type units in other not linked objfiles such as objfiles coming from the JIT compilation interface. I tested opaque types for my use-case, and it did work out. So, I guess the best option for me is to adapt the generated debug info for opaque types. Thanks again, Dominik
>>>>> "Dominik" == Dominik Mascherbauer <dominik.mascherbauer@gmail.com> writes:
Dominik> Thanks for the response. I agree that this series violates rule 2 as you
Dominik> mentioned. I was not aware of those rules at the time of implementing
Dominik> this patch.
Totally understandable, since if they are written down anywhere, it's in
some comment "somewhere".
Dominik> My initial idea was to use type signatures as they should be unique even
Dominik> across multiple objfiles. Based on that I thought it would be possible
Dominik> to use type signatures for finding type units in other not linked
Dominik> objfiles such as objfiles coming from the JIT compilation interface.
FWIW I think your insight here is correct.
Dominik> I tested opaque types for my use-case, and it did work out. So, I guess the
Dominik> best option for me is to adapt the generated debug info for opaque types.
I wonder if integrating type signatures into 'struct type' would be
possible. That is, an opaque type could store its signature. Then
there'd be a new "quick" API method to look up a full type (which gdb
confusingly calls "transparent") by signature.
This might solve your problem without violating the lifetime rules and
without requiring type GC.
thanks,
Tom