From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id cSHyCOuu1Wj+ZhMAWB0awg (envelope-from ) for ; Thu, 25 Sep 2025 17:06:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1758834411; bh=Gh54M1jkWAcM9ZnnMoluIMibPE9khi0VxIM0yMikXNs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=aKvG1pZqDm5HUx+G0ejMM+doHso+bQsBCO65TuBEZe/7W+/5+MnFt1Icn5xpz8Sx3 kxbUDSn7Gcg10vBiBDyXzDEa+jo9TwN606Ynzg1Ul5KFquTqC+LcvK7r3sOvOPv+qI gA9Hj4B7sL2cFeEdzF/ptXownNt/FOQKiAqkxiKM= Received: by simark.ca (Postfix, from userid 112) id 1CC1A1E0BA; Thu, 25 Sep 2025 17:06:51 -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=RwAg8IW6; dkim-atps=neutral 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 D6A1F1E04C for ; Thu, 25 Sep 2025 17:06:49 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4BF3D385842D for ; Thu, 25 Sep 2025 21:06:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4BF3D385842D 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=RwAg8IW6 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 38E973858291 for ; Thu, 25 Sep 2025 21:05:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 38E973858291 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 38E973858291 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=1758834349; cv=none; b=mj6NRe3R7E/HIqAL5/imD4pe71pvmNTx+VIzJUJsap8vqOGI4B+f0F0/KU0rut2IV3/QXXxn7Lu+5fckPgP67yGAlPxeRs6Hm86wgWRnLTM1u1Qv+gqxtVJvzm/Ysdis/Tyak9CH7PH26n6XtWnfgB1W6+yKLu4ql58hriOG1mc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1758834349; c=relaxed/simple; bh=Gh54M1jkWAcM9ZnnMoluIMibPE9khi0VxIM0yMikXNs=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=WJ0oIQIwYj4O88fTk3QTGlxQknII/JJkCqTAKyu3EZnskDSqTUqBPCYi2S5Xebz7zqI+rAFg5cPJCutYO4RKmJKsZveKR3tXPNOq0I0wSVBR3z+8/fOaxhCoDWQYB5ZHOskQ/Oqr3xZP1Je3IhPJFJuNqDosUCeq5T2ujyGkO6c= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 38E973858291 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1758834348; bh=Gh54M1jkWAcM9ZnnMoluIMibPE9khi0VxIM0yMikXNs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=RwAg8IW6ffl3IGLqKhGY7M8hS/SC2qDSLlSCa5i4iYkOMtuFQB2eEKfdTfwqFj58v aW+fw1szoQSZmjlSbQAwE6LWgdac/s9+203tM10pwPVKz/HOYGjtNZOw3G5WjRTYdD UA873REG+xmuXH2ydV6PUbl2z6j8OonOv5bp5CoE= Received: by simark.ca (Postfix) id A95481E04C; Thu, 25 Sep 2025 17:05:48 -0400 (EDT) Message-ID: Date: Thu, 25 Sep 2025 17:05:48 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] gdb: ensure bp_location::section is set correct to avoid an assert To: Andrew Burgess , =?UTF-8?Q?S=C3=A9bastien_Darche?= Cc: gdb-patches@sourceware.org References: <7febb0c1-7bbd-45d5-8ebe-91c34bb4a6ce@efficios.com> <87tt0qe7qf.fsf@redhat.com> Content-Language: fr From: Simon Marchi In-Reply-To: <87tt0qe7qf.fsf@redhat.com> 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 9/25/25 1:56 PM, Andrew Burgess wrote: > Part of the reason I'd push for a wider fix is that there are lots > different linespec formats, and I don't think they all pass through > minsym_found (or maybe they do?). It's certainly possble to create SALs without going through minsym_found. > If they don't then it feels like you should be able to adjust your > original test such that minsym_found isn't called, and you'll have the > same incorrect gdbarch problem. So then you'll have to add a > find_pc_section in _another_ place.... If the test was compiled with DWARF info, the SAL would be created from a full (DWARF) symbol, and we'd go through another path that would cause the section field to be set. I think find_function_start_sal -> find_function_start_sal_1. In this case the section would be known from the struct symbol. I went a bit down the overlay rabbit hole, and I think that your change might have broken that (but... I don't know how to test that). Here's the summary of my findings (I'm perhaps completely wrong). Two ELF sections overlay each other if they have the same VMA but different LMA. - LMA is the address where the code is permanently stored (e.g. large flash memory, non-executable). Unique for each section. - VMA is the address where the code gets copied when executed (e.g. small RAM, executable). An overlay manager in the program takes care of copying the right section from its LMA to its VMA before executing it. My understanding is that the ELF symbols for the various functions in these overlaying region have VMA region of memory. So, you would have overlapping ELF symbols, but you can know which ELF symbol is part of which section, because ELF symbols have a "section index" property. We record that in minimal_symbol::m_section. Before your patch, when seting a breakpoint by minimal symbol in an overlay situation, this: sal.section = msymbol->obj_section (objfile); would return the right section based on the minimal symbol you specified. I guess this is important later. To know if it should insert the breakpoint location, GDB must decide if the breakpoint location is in the section currently mapped at the VMA or not. For that, it needs to know in which section you intended to put the breakpoint. However, the new line: sal.section = find_pc_overlay (sal.pc); would return one of the multiple sections in which sal.pc (a VMA) appears, possibly the wrong one. This would mess up the "should we insert this location" logic later. This is what I gathered from an hour of reading the code, it's perhaps wrong. I need to go for now, but I thought I'd share these findings. Simon