From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Ufe5Ohe31WjCcxMAWB0awg (envelope-from ) for ; Thu, 25 Sep 2025 17:41:43 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gC5z0dUn; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id EAC4E1E04C; Thu, 25 Sep 2025 17:41:43 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,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 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 2BB661E04C for ; Thu, 25 Sep 2025 17:41:43 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C3A493858415 for ; Thu, 25 Sep 2025 21:41:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C3A493858415 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gC5z0dUn Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id F09DB3858C98 for ; Thu, 25 Sep 2025 21:41:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F09DB3858C98 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F09DB3858C98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1758836464; cv=none; b=XXnnreWW7N9uiuB1sLpx+mwH1DNYO1muErVx1WzTb1BQe4NmysyOx/YnEE8h2+h/1nDtUwrHKNcNcCehTGo7o12uEe4M0di3wvD2iVPlEYW01KAqLMQV3owNymC0FFzUj24yXX9WPS0cKD4+8C5mb/G0geZ31YEIofRiM0pSuuA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1758836464; c=relaxed/simple; bh=qR1V2uaNNAm+m1AaWSFt7mM+TVmLONTZAqlo7081DKI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=aN1LTgZLvM+qj4YNnAL56XFyunTnXgmTnYOUcideATQHUL9hw0cZoMMOZgIWuP1w9JaCMt9UGgtOWKiGITlVsrAIRRoXaOYkYk4UIK2C4mndPRV+5wRhs7o+h1nydNV4XulN4n3soD7HPtvWc76FJwbbsPsAgHsfo4RLK/L4RO0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F09DB3858C98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1758836463; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=CFjDBTMP2B8EGY23tHeHRA6HA2bX9cRyemDys8G6ieo=; b=gC5z0dUnUMk7ieqb2+Yf7NWsr2RSp9zQae7STht1Fw3wI2w/pR3+ecg1FuLq2e5s1Whsji Ta0knaZSTXDLuizIml0P3Ckp6ErpCM/jg95vHF6jYXNZQxJIdL7a8Yw6gbuM38hPszPEy7 3eFeMvE/So49crf+fFcI+DGyaOuJn4w= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-36-uN-uMirENPGrAP7kHyeCvA-1; Thu, 25 Sep 2025 17:41:02 -0400 X-MC-Unique: uN-uMirENPGrAP7kHyeCvA-1 X-Mimecast-MFC-AGG-ID: uN-uMirENPGrAP7kHyeCvA_1758836461 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3ef9218daf5so1090558f8f.1 for ; Thu, 25 Sep 2025 14:41:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758836460; x=1759441260; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CFjDBTMP2B8EGY23tHeHRA6HA2bX9cRyemDys8G6ieo=; b=sK+xbJ8796Yo7zukn+1M4MSmo/KMrEa9ZfkFC8nHvEMaeqzgdl0/+Nnvp0IE5EyvHW YhRL8hJR8SyBVibCjuGCqTl/QXCQWbUzlSyTDZmbUWTuAGUSqJeRvo0WhCJO8ZuwDIsM /sWxzQ+M08/cOrE4kIo+VxCDESGZ51RMJge7ONoV4cnq5RL2FTHXgmitdBnSEOPNBBMJ uasMA9faetDfTnfR6VEJ1BM5M0c99lXjhVIl034lPs6wCmzhdiYeHDeu/adseZAZX2ex IYP4ACKQicRHDLuNkC1ESiHdtxSrvegxYkH44OIWp8sWIqiszN8bPV6jfADDk3f9TT9p ASmw== X-Gm-Message-State: AOJu0Yz1NTJuvnCZPujL4hS8RbI9kn7IN5KdAgH0tTj27K/lcw/EXU+6 n4Kv+HgiG3Ywx9u/z5Iwj9D41HXD+VWQpWAPgTR2XHQfH028kGBxfXATRumw6jvWCXyzBROdEns 4o4XaR5du4GGMHYyn+wjCrmNLHwgEwWARu4v7TGc7yxGJr7nEek9I3k9wXV8u/qEkx1b4GwY= X-Gm-Gg: ASbGncsp4e4VpuRgKasmbXez2PbzmsZI9Vh1t47GPGeeL+oQklT7YFdmfWu9ulCHLNi BvCHOa1+s5s1QiGhEYQ4H4PSZ1jeUnDXdBJfqWKA/Vhib2JC76d5+5AsNSMZk/atwSkrqke7aaB t5EZeGSrT1GOQygU+7ymFVJfWo15WczLkm8jJwYYDQHThu9c0qF1QdVwRY+Apd42WNVP+e28yqq GX5ni8cqdoNIOk0HPGkP9leo25i/pmHhiKM2RR6x/8QxCuzVoh7HOfYW8EcKIKxmQTsA0QJzT3e C1/a1IZjAzMPzIFphvi1c3azUdxu3CO6uVA= X-Received: by 2002:a05:6000:1847:b0:3ee:1233:4681 with SMTP id ffacd0b85a97d-40e4745e98bmr5192065f8f.23.1758836460563; Thu, 25 Sep 2025 14:41:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFIxlt9Ircgz20auf/CIQ/BMxbyx48Dy8/mp6PwCCBmXrxgoEJtkmuIUVxiH6ovSShJwG/u7A== X-Received: by 2002:a05:6000:1847:b0:3ee:1233:4681 with SMTP id ffacd0b85a97d-40e4745e98bmr5192056f8f.23.1758836460104; Thu, 25 Sep 2025 14:41:00 -0700 (PDT) Received: from localhost ([31.111.84.207]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-40fb89065b5sm4419704f8f.17.2025.09.25.14.40.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Sep 2025 14:40:59 -0700 (PDT) From: Andrew Burgess To: Simon Marchi , =?utf-8?Q?S=C3=A9bastien?= Darche Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] gdb: ensure bp_location::section is set correct to avoid an assert In-Reply-To: References: <7febb0c1-7bbd-45d5-8ebe-91c34bb4a6ce@efficios.com> <87tt0qe7qf.fsf@redhat.com> Date: Thu, 25 Sep 2025 22:40:58 +0100 Message-ID: <87ldm2dxcl.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: AJkOcY3pRmQyl6n1A-Pf9n1DcNKnlywkds9gLfhhbuE_1758836461 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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 Simon Marchi writes: > 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. That sounds reasonable enough. But the original code was still wrong I think. I don't have time right now to reexamine the code I'm afraid, so I'm going from memory a bit here. But in the ifunc case, I think MSYMBOL is the symbol from the resolver, not the actual function where the breakpoint is being placed. Maybe the answer is as simple as moving the .section assignment into the earlier if block, something like: if (is_function && want_start_sal) { sal = find_function_start_sal (func_addr, NULL, self->funfirstline); /* This breakpoint is for the ifunc case, FUNC_ADDR is can be anywhere, in a completely different section to MSYMBOL, or even in a different objfile! TODO: I haven't checked, maybe find_function_start_sal already fills this stuff in for us? Or maybe it could be made too? For now I'm assuming all we have is an address, but this needs checking. */ sal.section = find_pc_overlay (func_addr); if (sal.section == nullptr) sal.section = find_pc_section (func_addr); } else { sal.objfile = objfile; sal.msymbol = msymbol; /* Store func_addr, not the minsym's address in case this was an ifunc that hasn't been resolved yet. */ if (is_function) sal.pc = func_addr; else sal.pc = msymbol->value_address (objfile); sal.pspace = current_program_space; /* We can assign the section based on MSYMBOL here because the breakpoint is actually being placed at (or near) MSYMBOL. */ sal.section = msymbol->obj_section (objfile); } Now we retain the use of MSYMBOL where we can, which addresses the valid issues you identify above. But we no longer use MSYMBOL when it's the wrong thing to do, which addresses the problem I was trying to fix. Does this look like a valid path forward maybe? FYI: I'm off work for a couple of days now, but will catch up when I return. There was a test with my original change, so as long as that's still passing I'm happy with whatever you think best. Thanks, Andrew