From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id b5M2Bj2O7WnKqTsAWB0awg (envelope-from ) for ; Sun, 26 Apr 2026 00:02:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1777176125; bh=I0GKkyvhdS98nHOPPZU5RpzDjIGj/CkNjbQ1NC1C1hE=; h=Date:Subject:To:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=K/HslgO0XjElI59ccF7A3NQB6Kww9RfTWx8htX+eirDIOgZi5YFWFxRC4yZTav31K VwLeMDhZKIsDe++Oew8M1y2sZOruXWFCIeDrlLN5tNTou1EBj2WTn4sO887aBkeEwJ CZjZraYH9wFb0RoA1cWCFSWuiLPOZeULLd96g4Cw= Received: by simark.ca (Postfix, from userid 112) id 0123A1E093; Sun, 26 Apr 2026 00:02:04 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=O6MxdTRA; dkim-atps=neutral Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (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 3262B1E093 for ; Sun, 26 Apr 2026 00:02:04 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id A0C4B4BB5887 for ; Sun, 26 Apr 2026 04:02:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0C4B4BB5887 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=O6MxdTRA Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id B17FF4BB3BFC for ; Sun, 26 Apr 2026 04:01:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B17FF4BB3BFC Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B17FF4BB3BFC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777176098; cv=none; b=AGSEdCOAehqg2XBAWYPiaK+JTcmYxJYeTPnlhsMyVTTgrBSYXhdjx4ELhYWm0R1qOpYz/gei79V88DLK+c042kVkDtImx0/PEf18A1G7GeHIDuhe9x9slBr+Q+fSnovYi2zqLwyY0u7OxPDcQyz+uD0qptD2cIsO3sCKHcTXCqY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777176098; c=relaxed/simple; bh=I0GKkyvhdS98nHOPPZU5RpzDjIGj/CkNjbQ1NC1C1hE=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=DNrYNTXRboIwAE6dGVvpN2Q2yP36xx3G0rf/oB6QhDTUIQy1dskIfy1NTXc9JgoOAP1VNWxskSiKd6OyLZtDG6WFqCn5xuDplMf1nwPxFiwDkI8yJh3bKR5SJxCLgbAq2S1BoNapDQdPOWa1RA195cNCQfMJvN8f5whbSU0oqnE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B17FF4BB3BFC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1777176097; bh=I0GKkyvhdS98nHOPPZU5RpzDjIGj/CkNjbQ1NC1C1hE=; h=Date:Subject:To:References:From:In-Reply-To:From; b=O6MxdTRA5Vugi0ysg5qeqsoDSTphACvDWZL2rwAugYeyov8LwJBnlx2u/w/ijOdAl oQ+rJS9plVQfMnJFv2fTiilwGAq2KG2P0OoHQ4g5zEeuaRQmxCsfFtZoawJ89Rghrx 7pVo+5RKisYsCdcS1X9fpnZpz/GqJ/pHS5S6RXUc= Received: by simark.ca (Postfix) id 622A31E093; Sun, 26 Apr 2026 00:01:37 -0400 (EDT) Message-ID: Date: Sun, 26 Apr 2026 00:01:37 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [gdb] Support default locations in DWARF5 loclists To: Gregori Mignerot , gdb-patches@sourceware.org References: <20260425073939.84434-1-gregori.mignerot@laposte.net> Content-Language: en-US From: Simon Marchi In-Reply-To: <20260425073939.84434-1-gregori.mignerot@laposte.net> 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 On 2026-04-25 03:39, Gregori Mignerot wrote: > @@ -4031,6 +4052,18 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr, > &low, &high, byte_order, > addr_size, signed_addr_p); > loc_ptr = new_ptr; > + if (dlbaton->dwarf_version < 5) > + { > + length = extract_unsigned_integer (loc_ptr, 2, byte_order); > + loc_ptr += 2; > + } > + else > + { > + unsigned int bytes_read; > + length = read_unsigned_leb128 (NULL, loc_ptr, &bytes_read); > + loc_ptr += bytes_read; > + } > + This change doesn't seem right. It will make it so that we'll read a length even if the "kind" doesn't imply a length. That is, when kind is DEBUG_LOC_END_OF_LIST or DEBUG_LOC_BASE_ADDRESS (or DEBUG_LOC_BUFFER_OVERFLOW / DEBUG_LOC_INVALID_ENTRY). > diff --git a/gdb/testsuite/gdb.dwarf2/loclists-default-location.c b/gdb/testsuite/gdb.dwarf2/loclists-default-location.c > new file mode 100644 > index 00000000000..fc388dcb106 > --- /dev/null > +++ b/gdb/testsuite/gdb.dwarf2/loclists-default-location.c > @@ -0,0 +1,37 @@ > +/* Copyright (C) 2026 Free Software Foundation, Inc. > + * > + * This file is part of GDB. > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 3 of the License, or > + * (at your option) any later version. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with this program. If not, see . */ This copyright header is not formatted correctly (there shouldn't be the leading asterisks. Copy it from another existing source file in this directory. > + loclists {is-64 $is_64} { > + # The lists in this table are accessed by index (DW_FORM_loclistx). > + table {post-header-label cu_table} { > + # With the default location first in the list (default_first) > + list_ { > + # Applies by default in func2 > + default_location { > + DW_OP_constu 0x2222 > + DW_OP_stack_value > + } > + > + # When in func1. > + start_end $func1_addr "$func1_addr + $func1_len" { > + DW_OP_constu 0x1111 > + DW_OP_stack_value > + } > + } Just wondering, is this valid DWARF? The spec implies that the default location has the be last (if present): A location list consists of a sequence of zero or more bounded location description or base address entries, optionally followed by a default location entry, and terminated by an end-of-list entry. I'm not sure why DWARF 5 requires that, it seems to me like it would work just as well if the default location was allowed to be anywhere in the list. Do you know about producers that do this? Also, could you add somme checks in the test to exercise loclist_describe_location? Simon