From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id xFcZFCJQ0WfqDQ0AWB0awg (envelope-from ) for ; Wed, 12 Mar 2025 05:13:06 -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=jnIjZBSZ; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4189F1E105; Wed, 12 Mar 2025 05:13:06 -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 5218F1E08E for ; Wed, 12 Mar 2025 05:13:05 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 922BE385842A for ; Wed, 12 Mar 2025 09:13:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 922BE385842A 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=jnIjZBSZ Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id 2FED23858C31 for ; Wed, 12 Mar 2025 09:12:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2FED23858C31 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 2FED23858C31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741770747; cv=none; b=KAjyZBZ/K35wWlhAhy7NZpCqB81BInn8oHFrqVj3N93NX9dhum3OXmNDdPYFeopUtzGgwG4cFKkZuRxMp3JudZW6VIU1ARryNrH9tJ0TUv5XN40PERuwmYJtS/O2WEz1/lOQu97wRRrk106dHmThqUae/kwie1OwwZIPSGogx9M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741770747; c=relaxed/simple; bh=LkaFAkTOqxLr0PwjgTzk9akunajPj0ZOq6k9SeJkN0I=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=qTHa2hVsZKSmkLAeFvpaat9bv37uNGPZfNh8YmjBfpvsuBbsd5P1ojM3KNf/N8VIPDEnM11NxotJrUR127eflwoErqg9YKm59GiXvEQiyGjkajG9tdMLM14wGS9RU6UuiDFkWT5FHfvQhKibabrjcNqGTIGjDB8clizKcaNRiBE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2FED23858C31 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-5e5e7fd051bso6649891a12.0 for ; Wed, 12 Mar 2025 02:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741770746; x=1742375546; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=SPNYTRCBq5/K/++Tm7LgG3F7OEuel8qZ9FdFesheoFY=; b=jnIjZBSZ8k2qxk4QebYvWoQ3PkzHkzReNTYWEr4fnxgvnEMzkH7mLUimi48C1mPjyE kCxGv0nTmVEJarQE8h4VmNh2P2GQglpM0QWXlyYBHOj5nk3N0U47asPR3mEL5O9SUPdf R22drZzloNGPt9qgUHRjcLVsrfrMgX7LNQWSBG57fWAUE+AFbCg8ogHide7E61BS7WSj /srsTFD7nAIIF8s8Cl1MheOOnE8v3divcKf3k1tPE+Ovmcpck5x5neqtgb5qAwy0+8eK Pvd+aYI/sm4oe8wFApx/JZfeIOsGrWVa7h8YUUMbOCpLnp4NUkB7yyyBtSsHUZOPg3Aq AEGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741770746; x=1742375546; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SPNYTRCBq5/K/++Tm7LgG3F7OEuel8qZ9FdFesheoFY=; b=E78TOI9SQDM5jecR97kfYgJAzluz4URXoDro1H3p81JQe/b6LaEjqPczZyvMCMcLes hkPv4/xYX8KNTYU5fMV3U9YB5K8PoOd7tVuX3wRBKeiDkLiqyRyBDNOTC21fSOFgmsrS xwGC4/8TDaWegeU4EV9l04y0qwuZHGg9EDWlN/TLOpnsrqhgbNDF3kMvCpTgZOd7NO5n TFqn4bsIDDK7IpJLvZcRDLL8OWsPK0U4KaPhoMeSc/Vf4x2d4zsgHMcHvVkWYmSPH+0i w7gGIc0iNifOOkj2mcC8xhEf20wORcJYHMzVcmBiIrFRO9RJW8UxBCZ0FMXsSaeJBAk2 uu3w== X-Gm-Message-State: AOJu0Yz327RhuSS7/5YTgvFVLw7p7jJ0eyq6hP0hnfPHNwvYsVSlZ95J WDv/zkntZY3GzCKW0c4RXMSSDhAQe0idoB2+o8BBPW2uWX+kzwBHfkPy+4q4BPI= X-Gm-Gg: ASbGncvFu/csYn4/XcYs1JRSUo1mJonMaeh3NfajPfX4ZOEMJKxBhQoSdqB+KMEdIK/ 0iFm6qnlzEFcOuPzX5EUYc2ybiRomRRUkWElJVV2E54a3AszNscGkfpmRhdXE8q1BWEFOWc4AJW /V9OIgbwc2Tv4eKO1mklytEdO8B176KPZIE8lYe/RssdDQK5Hr8fqF3gdx4A4PlzYWBXrXXqQ+L xKvn5MgT/AvpdgxtQBgODlhFxIkzD41yoyuko9n7jv9pgykFRKRDQAOsbRfsNPqrETxGBVHro3a PJbnSTqqib2qnlBqo4XJP0rV0uMkepX+sy4JzLbyjyR3bcP2iHF+k7JKiStnr2AH1w== X-Google-Smtp-Source: AGHT+IGG7QYn5GFYOX7C+ia8QDCB06cpPSzmyGBwlBPpKngEwFPjuHBLvKG6feALVZ/ekwZuwM8zzQ== X-Received: by 2002:a17:907:2ce5:b0:abf:7af6:ea64 with SMTP id a640c23a62f3a-ac2b9ea1881mr961384066b.45.1741770745429; Wed, 12 Mar 2025 02:12:25 -0700 (PDT) Received: from [140.78.145.202] ([140.78.145.202]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac27e11c457sm671144966b.126.2025.03.12.02.12.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Mar 2025 02:12:24 -0700 (PDT) Message-ID: <3237e31f-16f6-4337-8c09-0d26aee35fc9@gmail.com> Date: Wed, 12 Mar 2025 10:12:23 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/3] Add new commands for controlling type signature fallback. To: Eli Zaretskii Cc: gdb-patches@sourceware.org References: <9c04ac7d791b96d90c624fba5333f2e9009393a3.1741701275.git.dominik.mascherbauer@oracle.com> <865xkfbhfv.fsf@gnu.org> Content-Language: en-US From: Dominik Mascherbauer In-Reply-To: <865xkfbhfv.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 Thanks for the review. >> From: dominikmascherbauer >> Cc: dominikmascherbauer >> Date: Tue, 11 Mar 2025 15:57:18 +0100 >> >> '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(+) > > Thanks. > >> 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. > > Please leave two spaces between sentences, otherwise the printed > version will be typeset sub-optimally. > > More generally, I think both NEWS and the text for the manual doesn't > tell what this means in practical terms and when it would be useful to > fiddle with these options. I find myself wondering why and when would > I need to help GDB look up type signature, and even what is a "type > signature" (it is used in the manual only once, without any > explanations). I think at least the manual should answer these > questions. > Would this be enough, or does it need to be more detailed: diff --git a/gdb/NEWS b/gdb/NEWS index 53368d7463c..5274c84f168 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -262,18 +262,25 @@ disable missing-objfile-handler LOCUS HANDLER 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. + New command which enables a type signature look up fallback for DWARF objfiles. + If type signatures in DWARF objfile are unique, enabling this option to look + up type signatures from fallback DWARF objfiles. Reusing type units from + fallback objfiles can be used to avoid duplicating those type units. + + The 'main' setting allows to limit the scope of the lookup to just the main + symfile objfile to reduce the overhead of type signature lookup. The 'full' + setting uses all objfiles in a progspace to find as many type signatures as + possible. The default value is 'off'. set dwarf-type-signature-fallback-jit on|off - New command that is used in combination with type-signature-fallback + New command that is used in combination with dwarf-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. + JIT objfiles are produced at run-time and often rely on already available + type information. This allows the debug info producer to skip generating type + units that are known to be present in other objfiles. * Changed commands diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 901152dd15e..9581ea915e4 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -42329,27 +42329,35 @@ For more information on these expressions, see @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. +Control the behavior of the type signature look up in DWARF objfiles. Type +Signatures in DWARF uniquely identify a type unit. A type unit contains debug +info for a type and can b referenced by its type signature. Type signature +look up allows @value{GDBN} to look up type signatures not only in objfile +containing the refererence to a type signature, but also other type signatures +in the progspace. This allows to avoid duplicating type units, by looking them +up from other DWARF objfiles. 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 +objfiles in the progspace to look up missing type signatures. When +@code{main}, @value{GDBN} will check the current main symfile objfile for a +missing signatured type. If the main symfile objfile contains most of the +debug info required for debugging, this setting reduces the impact of type +signature look up. When @code{full}, all DWARF 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 +Control whether @code{dwarf-type-signature-fallback} is limited to DWARF objfiles originated from the JIT interface (@pxref{JIT Interface}) -or all objfiles with a missing signatured type. +or all DWARF objfiles with a missing signatured type. If only objfiles loaded +through the JIT interface rely on existing types and type units this +setting allows to limit type signature look up to avoid undesired behavior. 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. +only DWARF objfiles from the JIT interface. When @code{off}, type signature +look up is performed for missing signatured types in all DWARF objfiles. @kindex maint set dwarf max-cache-age @kindex maint show dwarf max-cache-age >> + 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."), > > The list of possible values should probably start with "main" or > "full", as otherwise the reference to "fallback" in "off" will not be > understood. > > Also note that you use "resolution" in the above doc strings, but > "look up" in the manual and NEWS. I think it's better to use the same > terminology; "look up" sounds more accurate to me. > Ok, I will change that. > Reviewed-By: Eli Zaretskii