From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id KIL5AQBQ0GefMAwAWB0awg (envelope-from ) for ; Tue, 11 Mar 2025 11:00:16 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=CHeoHgYL; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 03F531E105; Tue, 11 Mar 2025 11:00:16 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.0 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 5B12C1E08E for ; Tue, 11 Mar 2025 11:00:15 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F3536385770D for ; Tue, 11 Mar 2025 15:00:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F3536385770D 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=CHeoHgYL Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id A2087385840D for ; Tue, 11 Mar 2025 14:57:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A2087385840D 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 A2087385840D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::630 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741705052; cv=none; b=nGTpZr/2BVHpFruWUGUQ6dvIPYIe27Mk7Bl7zx9xqYiAsrBLWukheYiEas+eudsZSOlqhXlzIIk5xH8AYWZwH5JnD0CGz5SQTfdcEsTPbKxjQZuE9y8PKe7xi33Qf0Kh3SqS8YQnwMF47VR3zlvZT+JRlKn6BuO0pRR5gm3QWNY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741705052; c=relaxed/simple; bh=Zzk+HS+6H7orPIqbejove/J1NKJr/qf+0GJezsTBWUM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ce1BMHiCu9B+9Ou+Gt9Wk45I0Rihn7FIhdqAcuksDlsUCNuS+QVo/eu+8WJTJfXwJxgjWgOOfJ3jmiDoNz44Mmp7YTsV1+EmTUlshNPHRPZj79ZFCD9Iz8kmz+DuaLW5pVVoqddJDgxAqpuDV0CACvnhVeRbykVRPxJS8Ocd+SQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2087385840D Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-aaecf50578eso990360066b.2 for ; Tue, 11 Mar 2025 07:57:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741705051; x=1742309851; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=92oyP1FP9mrDB7wfOzbrHjA+gwInowm/nf4UHLE2M7w=; b=CHeoHgYLZVaEJfm+5Vc1py1SIngaGZiR4DxDPySHE683KGGexdsTM0n1Ue9+wkbaV4 EuozK3HTgpQ6BxVvzdbNqGxJvR29ITjT2ihlxtySehpil36uVrRGuDjL5cszCspQhREW uzNFJqle8rPAQSSvUEr/8PLM1u/ivhWdR3GNwynw2ILvrv2wVxv/Dk32AUkHzFkq98ZG FMkjeMhFgg2i1Op9aOdmS6w48j8bcgTZW9cpV8+zT+cS1Awwe+4KwTJiOGhx65k+GxXn 3l/h2uUQzOrbFAqqgvZP9YaiBzbhNV1Q427Q29TVMf8SA4mXwUbQMuzvXfkH8KHn70KG EHig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741705051; x=1742309851; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=92oyP1FP9mrDB7wfOzbrHjA+gwInowm/nf4UHLE2M7w=; b=QeOOzapT6hens64nO+QFyWtMnZyJBbXhesy0f6eWgf+0cVI7H2HK6subpqACwagv1p LHYavPDkWxbHtYzXGvJeuz/NODSW3JaTSozIMdzC2uVo+6mbuus8EwIpyn53DF07FCke pDP2e1NvtSOEiTKMqdm9zwZy+l/KSwE7/livI0VpRavvzhJXuEHa3EcuBxOXdQ2ApQNo 1c4DPpu+a8GgEWXWZCbu2rad5UbdWL8L01oZoaIcQRd0nXrWmPTioR5yCC3JkAVN0zH2 iBcZq1V/jwbLrZqnqg6g03tGwqKvgoacwTNNiLj/lp8IERetbEIZ8JoBNhTznOJ27sHg gp7g== X-Gm-Message-State: AOJu0YySLsTFZ/rrWCx3efvfKJ4mv4FhgshzAPLzWEikE8H6ejkErs7P GxFON2sxsD12/uM7avGpoPNwLpcGECIarCm7qLVsMgzKG8tX5MhuLBBFEA== X-Gm-Gg: ASbGnctCiRJboALSP3Ps7/LK0ky9W4c6rTwOAIL5WYePWx+4DeE0ud1HgnKssHmvEvm V5ISuFXEglhVZwGV7zCQfycAyc6p6XgD14Ub0wGhTvcucw4HWITfIOZd+2F+R08h/5nTLVaXgZj F1mX1L28NOPg+GjvLrfyfXJF6MzJXum8zn/Fo6vX2wrqOLjVqbf9C3Nkc3syCe64bWp4YnAFhX4 KOeTcwJon/QGD/aTbYrITNavQC5KBgQfMUoql9SQWiUMdqMznrOGBTvtfpTBAIHE4bQGldV7U1Z Bj71h+NSmkYKMU1bpvYDqoZO/NHhRgVFWNDlZtO23kiTNTLbk9vhVQjNQHR/zyr0ZMMr X-Google-Smtp-Source: AGHT+IENTMIvk/Nd3UK3RnlZoTJdXGDfSwhHfiC+Oo0cumaIwj9jTe/vK0AvA8JDgNCeYNG+3ts1nA== X-Received: by 2002:a17:907:c91f:b0:ac2:c1e:dff0 with SMTP id a640c23a62f3a-ac252a88554mr1326204966b.19.1741705050696; Tue, 11 Mar 2025 07:57:30 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Mar 2025 07:57:30 -0700 (PDT) From: dominikmascherbauer X-Google-Original-From: dominikmascherbauer To: gdb-patches@sourceware.org Cc: dominikmascherbauer Subject: [PATCH 1/3] Add new commands for controlling type signature fallback. Date: Tue, 11 Mar 2025 15:57:18 +0100 Message-Id: <9c04ac7d791b96d90c624fba5333f2e9009393a3.1741701275.git.dominik.mascherbauer@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 'set dwarf-type-signature-fallback (off|main|full)': Enable type signature fallback. If a type signature is not found in the current objfile, either looks up the 'main' objfile or all objfiles in a progspace to find the type signature. Usually a type signature is unique, ther should only be one type unit for each type signature. Therefore, it should be okay to check other objfile for a type signature. However, whether this is really the case depends on the debug info producer. This is why its disabled by default. 'set dwarf-type-signature-fallback-jit': Whether the type signature fallback is enabled for only JIT objfiles. JIT objfiles are self-contained, but usually share most debug info with some already loaded objfile. This is why JIT objfiles are a major use case for the type signature fallback. This option is added to restrict the type signature fallback to match this exact use-case and provides a more granular use of the type signature fallback. --- gdb/NEWS | 14 +++++++++ gdb/doc/gdb.texinfo | 26 +++++++++++++++++ gdb/dwarf2/read.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+) diff --git a/gdb/NEWS b/gdb/NEWS index 2c504a9b603..53368d7463c 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -261,6 +261,20 @@ disable missing-objfile-handler LOCUS HANDLER or can be a regular expression which is matched against the filename of the primary executable in each program space. +set dwarf-type-signature-fallback (off|main|full) + New command which enables a type signature lookup fallback, if a + dwarf objfile from a JIT compilation does not provide its own type + units, but relies on type units from other objfiles. The 'main' + setting allows to limit the scope of the lookup to just the main + symfile objfile, 'full' uses all objfiles in a progspace. + The default value is 'off'. + +set dwarf-type-signature-fallback-jit on|off + New command that is used in combination with type-signature-fallback + and is on by default. If type signature fallback is enabled, + this restricts the fallback to objfiles that were loaded with the + JIT debug interface. + * Changed commands remove-symbol-file diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 04719bf65e6..901152dd15e 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -42325,6 +42325,32 @@ Symbol "argc" is a complex DWARF expression: For more information on these expressions, see @uref{http://www.dwarfstd.org/, the DWARF standard}. +@kindex set dwarf-type-signature-fallback +@kindex show dwarf-type-signature-fallback +@item set dwarf-type-signature-fallback @samp{full|main|off} +@itemx show dwarf-type-signature-fallback +Control the behavior of the type signature lookup for type units if a +type signature is undefined within an objfile. + +The default is @code{off}, which means @value{GDBN} will not use other +objfiles in the progspace to lookup missing type signatures. When +@code{main}, @value{GDBN} will check the current main objfile for a +missing signatured type. When @code{full}, all objfiles in the current +progspace will be searched for the missing signatured type. + +@kindex set dwarf-type-signature-fallback-jit +@kindex show dwarf-type-signature-fallback-jit +@item set dwarf-type-signature-fallback-jit +@itemx show dwarf-type-signature-fallback-jit + +Control whether @code{dwarf type-signature-fallback} is limited to +objfiles originated from the JIT interface (@pxref{JIT Interface}) +or all objfiles with a missing signatured type. + +The default is @code{on}, which limits the type signature fallback to +only objfiles from the JIT interface. When @code{off}, the type signature +fallback will look for missing signatured types for all objfiles. + @kindex maint set dwarf max-cache-age @kindex maint show dwarf max-cache-age @item maint set dwarf max-cache-age diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index c5375b68567..dc8cc7652d9 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -737,6 +737,49 @@ show_dwarf_max_cache_age (struct ui_file *file, int from_tty, value); } +/* If the type for a type signature is not found in the CUs objfile + fallback to other objfiles for type signature resolution */ +const char type_signature_fallback_off[] = "off"; +const char type_signature_fallback_main[] = "main"; +const char type_signature_fallback_full[] = "full"; +static const char *type_signature_fallback_enums[] = + { + type_signature_fallback_off, + type_signature_fallback_main, + type_signature_fallback_full, + nullptr + }; +static const char *type_signature_fallback = type_signature_fallback_off; + +static void +show_type_signature_fallback (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + gdb_printf (file, _ ("Resolution of type signatures with " + "fallback objfiles is %s.\n"), + value); +} + +/* Type signature fallback is by default restricted to only jit objfiles. */ +static bool type_signature_fallback_jit = true; + +static void +show_type_signature_fallback_jit (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + gdb_printf (file, _ ("Whether type signature resolution with " + "fallback objfiles is restricted to jit objfiles is %s.\n"), + value); +} + +/* Check if type signature fallback applies to OBJFILE. */ +static bool +use_type_signature_fallback (struct objfile *objfile) +{ + return type_signature_fallback != type_signature_fallback_off && + (!type_signature_fallback_jit || objfile->flags & OBJF_JIT); +} + /* When true, wait for DWARF reading to be complete. */ static bool dwarf_synchronous = false; @@ -20103,6 +20146,33 @@ caching, which can slow down startup."), &set_dwarf_cmdlist, &show_dwarf_cmdlist); + add_setshow_enum_cmd ("dwarf-type-signature-fallback", class_support, + type_signature_fallback_enums, &type_signature_fallback, + _ ("\ +Set resolution of type signatures with other objfiles as fallback."), _ ("\ +Show resolution of type signatures with other objfiles as fallback."), _ ("\ +This option will only take effect if set before loading symbols.\n\ +off == turn type signature fallback off\n\ +main == use the main symbolfile as fallback objfile\n\ + for type signature resolution\n\ +full == use all objfiles with type units in the current progspace\n\ + as fallback objfiles for type signature resolution."), + NULL, show_type_signature_fallback, &setlist, + &showlist); + + add_setshow_boolean_cmd ("dwarf-type-signature-fallback-jit", class_support, + &type_signature_fallback_jit, + _ ("\ +Set wether resolution of type signatures with other objfiles as fallback\n\ +is restricted to jit objfiles."), _ ("\ +Show resolution of type signatures with other objfiles as fallback\n\ +is restricted to jit objfiles."), _ ("\ +By default, type signature resolution with fallback objfiles is restricted\n\ +to jit objfiles.\n\ +This option will only take effect if type-signature-fallback is enabled."), + NULL, show_type_signature_fallback_jit, &setlist, + &showlist); + add_setshow_boolean_cmd ("synchronous", class_obscure, &dwarf_synchronous, _("\ Set whether DWARF is read synchronously."), _("\ -- 2.34.1