From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id sQGfIt5Cg2nTFCgAWB0awg (envelope-from ) for ; Wed, 04 Feb 2026 08:00:14 -0500 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=LYw0QWxo; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 8AA371E08D; Wed, 04 Feb 2026 08:00:14 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.6 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,RDNS_NONE autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (unknown [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 903D41E08D for ; Wed, 04 Feb 2026 08:00:13 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 1D6324BA2E0A for ; Wed, 4 Feb 2026 13:00:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D6324BA2E0A 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=LYw0QWxo 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 E779D4BA2E08 for ; Wed, 4 Feb 2026 12:59:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E779D4BA2E08 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 E779D4BA2E08 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=1770209985; cv=none; b=qjz6+ISzUdKNWBHEN48y7Rk5HjLhsu86YzzJovYJZ5xxQ15Ugo/K98Ma0aguGSIG9+2WAVdqSoyj3zE/cG6NEGrLWiUteH45vZwcIhwDUF3c/Qn7GFX2Xp+5XgiZAZ1SKiaV9pDsG3R5CVDxPVRL/lXq26itiWqycEHhCWwVjxo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770209985; c=relaxed/simple; bh=Yc875oA0P1FC/s01xHO0Z3rWYDH6PcZGDOpvA6pCDNs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=MrXmwKvUoy45ejC3mUZM6lzIF1dnmp2C7kZvLdKue1PeyZD2ckQnOfxEkZpKWyOPRKFXaNylt8VxPq5pu92KDe2J1lga0MKSch6ypGthlhnM7FUtDIR6r4u/AEK+ZVd0rXHxizhgNazDjEbKArDcZpE5kTQU7IRDxdOa2AjY1gQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E779D4BA2E08 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770209984; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D0WgBr4HLlYjUgrx/3ubSMj76MAnB4837MtM8Nv/BRo=; b=LYw0QWxoAgq46rZGb7UKF0xnzhr/qvTUuOmSiM944d+ieVzhmhiBp1ogwDd9ZTiotscSN9 DWm679kqd0NUE2QdS/zmc/iI4YsAGvjtD3mi+aMy/jS55z6DkI90iADRBzNOYxQrtvKwUx iaAKXlgGYaY4ulKkARylkToUzockZ7U= 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-602-SxQalMykORKwSLGeonsZzw-1; Wed, 04 Feb 2026 07:59:43 -0500 X-MC-Unique: SxQalMykORKwSLGeonsZzw-1 X-Mimecast-MFC-AGG-ID: SxQalMykORKwSLGeonsZzw_1770209982 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-42fdbba545fso810589f8f.0 for ; Wed, 04 Feb 2026 04:59:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770209982; x=1770814782; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=bDUhmiDDonHmxkdp5VTn6+7i1XXinneNheuNm5hlccY=; b=VxgjI6eb8cNXHFNhzEGdboBfajUceUMQLiVyMyjaiGx8EotCS5ayCa3agXTGVDZbO4 9zNWkWamsgIDXXpqH88SJTed+BkCfb28BO4PY/NgzKiRH5+5I8LmBDmOvdDPVX9ET65u hSdMg/xlFNjBx/6NqGuY/ExRBewSjMQypC1v4Q0FF9syBR7lfaWe1qIKCa1OJpMu1zDi 5IWcXeA6eSfbVgPihitGATltRNybB+ad9OMxMLQoPsjS6I/1HRzjlZ0JxjfMPprCysmC 8edyZ4quJcR/pbSv/Lj+zhMKb39PN+1QRRrpQ8nE2OwKR6N6DAqq2qys8l3TCXsvaKLC Nl/g== X-Gm-Message-State: AOJu0YydFX0lfZFJA9ra9s7D1uygi8Qbeare3ozimUf6cmh5R1zs1iaP H3uHKkbOCVBYSi8xgBeXz/OCOPASQIhfhWgivoJWxmWnbg377FBuv2OEklMJ5ecjxXJ6W6acWvs dikJHxOTl+yPaDRgKjXyow0NG+R7g6CF3Tnz7NGLP4N2d7sLpt9iTSn11upgCs6J66MqM7/c= X-Gm-Gg: AZuq6aIrFxakNy99Wv3iUFeC+j8SbFHmJczxXd6GbtADepTvmE0mUJZk+CDyJBCWQhn R9g2MPvr5cW6h48sKAO0mYlKP2Vstps4KvAFDmg/HLqHw9519rcWhqZ5TZ/PUriQppRKXS853Ia Rszvl7ebOzY0M2TTX1GMUClHcGmzsfqiLUd5/KawOWbpdNB4Q9ZMddGv8LAESbX56tuMMiLw5TE nyv3bNGn56DSIBkqJv2GlV/h8TamqEupOhgnp/vs/wIAJQrq4NlfGqdcdEk4jHEE+QLxZbAtw1i SBeBWcAO/XjlwYTQiud6ECfMbTV+mNlKpmRt1pYOCzR3gWAFCdyLxCVFZO+lYqwVqPPpa6GGBPL Lc8he X-Received: by 2002:adf:f44a:0:b0:436:14fa:a3fd with SMTP id ffacd0b85a97d-43614faa4c4mr5826848f8f.24.1770209981789; Wed, 04 Feb 2026 04:59:41 -0800 (PST) X-Received: by 2002:adf:f44a:0:b0:436:14fa:a3fd with SMTP id ffacd0b85a97d-43614faa4c4mr5826816f8f.24.1770209981331; Wed, 04 Feb 2026 04:59:41 -0800 (PST) Received: from localhost ([31.111.84.232]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43617e263b9sm6059964f8f.4.2026.02.04.04.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Feb 2026 04:59:40 -0800 (PST) From: Andrew Burgess To: "Rohr, Stephan" Cc: "gdb-patches@sourceware.org" , =?utf-8?Q?S?= =?utf-8?Q?=C3=A9bastien?= Darche , "simark@simark.ca" 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> <87ldm2dxcl.fsf@redhat.com> <6c31b667-db2d-453e-9597-9fe011c4766e@efficios.com> <87jz186xhv.fsf@redhat.com> Date: Wed, 04 Feb 2026 12:59:40 +0000 Message-ID: <87o6m4ekar.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: _kedVJLtab7wZtuIrlNK_zRgW-HvOLnKKFsX1V9ySBg_1770209982 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 "Rohr, Stephan" writes: >> -----Original Message----- >> From: Andrew Burgess >> Sent: Monday, 6 October 2025 14:11 >> To: S=C3=A9bastien Darche ; simark@simark.ca >> Cc: gdb-patches@sourceware.org >> Subject: Re: [PATCH] gdb: ensure bp_location::section is set correct to = avoid an >> assert >>=20 >> S=C3=A9bastien Darche writes: >>=20 >> > On 9/25/25 17:40, Andrew Burgess wrote: >> >> 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 =3D find_function_start_sal (func_addr, NULL, self->funfir= stline); >> >> >> >> /* 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 alre= ady >> >> 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 ne= eds >> >> checking. */ >> >> sal.section =3D find_pc_overlay (func_addr); >> >> if (sal.section =3D=3D nullptr) >> >> sal.section =3D find_pc_section (func_addr); >> >> } >> >> else >> >> { >> >> sal.objfile =3D objfile; >> >> sal.msymbol =3D msymbol; >> >> /* Store func_addr, not the minsym's address in case this was = an >> >> =09 ifunc that hasn't been resolved yet. */ >> >> if (is_function) >> >> =09sal.pc =3D func_addr; >> >> else >> >> =09sal.pc =3D msymbol->value_address (objfile); >> >> sal.pspace =3D 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 =3D msymbol->obj_section (objfile); >> >> } >> >> >> > >> > To answer your question on whether find_function_start_sal does fill >> > this for us : it depends. It manages to do it on amd64 but not on amdg= pu. >> > >> > By default, the sal does not contain a valid section. It's only when w= e >> > try to adjust the pc past the prologue (skip_prologue_sal) that a >> > section is computed for the pc at the start of the function. If we do >> > have a prologue, then we assign that section (symtab.c:3914). If not >> > (and that is the case on amdgpu), then we're left with an empty >> > sal.section. I would say the behavior is not really consistent. >> > >> > I would agree it could be made to. >> >> Does this look like a valid path forward maybe? >> > >> > Your solution seems to work for the gnu-ifunc test and fixes the >> > regression for gdb.rocm/displaced-stepping.exp - so I'd say it's a goo= d >> > aproach. I am not familiar with overlays, so I can't really judge if t= he >> > change would impact how they are handled. >> > >> > I think it would be best to ensure find_function_start_sal has a >> > consistent behavior across architectures. I'll submit a small patch >> > which should address this. This would also at least reduce the chance >> > for another bug like this to appear somewhere else : >> > >>=20 >> Hi, >>=20 >> I'm proposing the patch below. You should double check that this still >> addresses the issue you're seeing with the amdgpu target. Given Simon's >> concerns, I do wonder if there might still be some issues with this >> related to overlay debugging, but without any way to test it, and no >> known overlay users, I think we can probably just ignore that for now. >>=20 >> If this fixes your regression, then maybe we should merge this, and >> figure any other issues out later? >>=20 >> Thanks, >> Andrew >>=20 >> --- >>=20 >> commit 6ffea587445eeacf8b2962de6d3b00d6efa98213 >> Author: Andrew Burgess >> Date: Mon Oct 6 10:27:08 2025 +0100 >>=20 >> gdb: fixes for setting the section in minsym_found >>=20 >> After this commit: >>=20 >> commit 6f7ad2381ae72aa592ada4a0921265aa3292b1fa >> Date: Wed Sep 3 19:57:42 2025 +0100 >>=20 >> gdb: ensure bp_location::section is set correct to avoid an as= sert >>=20 >> Some issues were reported as a result of the bp_location::section >> being left as NULL by the call to find_pc_overlay that was >> introduced. See this thread: >>=20 >> https://inbox.sourceware.org/gdb-patches/7febb0c1-7bbd-45d5-8ebe- >> 91c34bb4a6ce@efficios.com >>=20 >> The problem was that code_breakpoint::add_location relies on the >> section being set in order to deduce the gdbarch. If the section is >> not set then the gdbarch is deduced using the breakpoint's gdbarch. >>=20 >> The bug was reported by the ROCm engineers, who have inferiors runni= ng >> mixed host and GPU code, and so rely on the section being set in ord= er >> to establish the correct architecture for a specific address. >>=20 >> During discussion in the above thread Simon pointed out that the >> change made in the above commit might not be correct anyway for >> overlay debugging (does that even work, or is it used any more?), as >> the commit relies on establishing a section by calling >> find_pc_overlay. However, when presented with multiple possible >> sections, find_pc_overlay cannot know which section to select, and s= o >> just picks one. This could be different from the section of the >> minimal_symbol we already had to hand. >>=20 >> This patch I think should (at least) resolve the issues the ROCm >> engineers are seeing. >>=20 >> Instead of always calling find_pc_overlay I have moved the section >> assignment inside the if/then/else blocks with the following >> reasoning. >>=20 >> In the 'else' block, this is the non-function or non-ifunc case, the >> address used is based on the msymbol's address, and so should be in >> the same section. In this case we can use the msymbol's section. >>=20 >> In the 'if' block things are more complicated. This could be the >> ifunc case, in which case func_addr could have been adjusted to a >> different section, or even different objfile. >>=20 >> Further, when we call find_function_start_sal, we pass in just an >> address, so the SAL being returned isn't going to consider which >> overlay section the original msymbol was from, which could cause >> problems for overlay debugging maybe? >>=20 >> Anyway, I'm ignoring that for now, as fixing that would be a whole b= ig >> thing. So I'm proposing that, if find_function_start_sal returns a >> symtab_and_line with a section set, then we use that section. >> Otherwise, we can try to figure out a section. >>=20 >> diff --git a/gdb/linespec.c b/gdb/linespec.c >> index 2ddc495babf..4d9c5ac26f3 100644 >> --- a/gdb/linespec.c >> +++ b/gdb/linespec.c >> @@ -4083,13 +4083,16 @@ minsym_found (struct linespec_state *self, >> struct objfile *objfile, >>=20 >> CORE_ADDR func_addr; >> bool is_function =3D msymbol_is_function (objfile, msymbol, &func_add= r); >> + bool is_ifunc =3D false; >>=20 >> if (is_function) >> { >> const char *msym_name =3D msymbol->linkage_name (); >>=20 >> - if (msymbol->type () =3D=3D mst_text_gnu_ifunc >> -=09 || msymbol->type () =3D=3D mst_data_gnu_ifunc) >> + is_ifunc =3D (msymbol->type () =3D=3D mst_text_gnu_ifunc >> +=09=09 || msymbol->type () =3D=3D mst_data_gnu_ifunc); >> + >> + if (is_ifunc) >> =09want_start_sal =3D gnu_ifunc_resolve_name (msym_name, >> &func_addr); >> else >> =09want_start_sal =3D true; >> @@ -4098,7 +4101,32 @@ minsym_found (struct linespec_state *self, struct >> objfile *objfile, >> symtab_and_line sal; >>=20 >> if (is_function && want_start_sal) >> - sal =3D find_function_start_sal (func_addr, NULL, self->funfirstlin= e); >> + { >> + sal =3D find_function_start_sal (func_addr, NULL, self->funfirstl= ine); >> + >> + /* If SAL already has a section then we'll use that. If not, the= n we >> +=09 can try to find a section. >> + >> +=09 In the ifunc case though we cannot rely on the section of MSYMBOL, >> +=09 the ifunc target could be in a different section, or even a >> +=09 different objfile, from the original MSYMBOL. For this case, we >> +=09 fall back to looking up a section based on FUNC_ADDR. >> + >> +=09 For the non-ifunc case, we can use the section of MSYMBOL, as >> +=09 that's how we filled in FUNC_ADDR, so they should be in the same >> +=09 section. */ >> + if (sal.section =3D=3D nullptr) >> +=09{ >> +=09 if (!is_ifunc) >> +=09 sal.section =3D msymbol->obj_section (objfile); >> +=09 else >> +=09 { >> +=09 sal.section =3D find_pc_overlay (func_addr); >> +=09 if (sal.section =3D=3D nullptr) >> +=09=09sal.section =3D find_pc_section (func_addr); >> +=09 } >> +=09} >> + } >> else >> { >> sal.objfile =3D objfile; >> @@ -4110,14 +4138,13 @@ minsym_found (struct linespec_state *self, >> struct objfile *objfile, >> else >> =09sal.pc =3D msymbol->value_address (objfile); >> sal.pspace =3D current_program_space; >> - } >>=20 >> - /* Don't use the section from the msymbol, the code above might have >> - adjusted FUNC_ADDR, in which case the msymbol's section might not = be >> - the section containing FUNC_ADDR. It might not even be in the sam= e >> - objfile. As the section is primarily to assist with overlay >> - debugging, it should reflect the SAL's pc value. */ >> - sal.section =3D find_pc_overlay (sal.pc); >> + /* We can assign the section based on MSYMBOL here because the >> +=09 breakpoint is actually being placed at (or near) MSYMBOL. Note, >> +=09 this is not a path where ifunc resolution can have occurred, which >> +=09 could adjust FUNC_ADDR significantly. */ >> + sal.section =3D msymbol->obj_section (objfile); >> + } >>=20 >> if (self->maybe_add_address (objfile->pspace (), sal.pc)) >> add_sal_to_sals (self, result, &sal, msymbol->natural_name (), fals= e); > > Hi all, > > I came across the same issue when debugging a remote inferior that is com= piled w/o debug symbols and a > breakpoint is inserted based on the function name that is called in the i= nferior.=20 > > Our test started to regress with the introduction of patch > "gdb: ensure bp_location::section is set correct to avoid an assert". As= mentioned in the patch above, > GDB uses the default gdbarch to insert the breakpoint if the section is N= ULL. This causes issues later.=20 > > I applied the patch; our breakpoint insertion issue is fixed with this pa= tch. I reviewed the patch, it is > reasonable to me. Only thing I wonder is the usage of 'find_pc_ovelay'; = this always returns NULL if > overlay debugging is not used? But I guess that's fixed by using 'find_pc= _section' in this case. Hey Stephan, Could you confirm if you were testing against master, or against a release branch? If you're using a release branch, could you check if the issue is still present on master. I'm surprised that commit 539fc2164f44a doesn't fix the issue you're seeing, but this is only available on master right now. If you are testing on master, and you still applied my patch then you must have resolved the merge conflicts, could you post your diff so I can see how you resolved things. Thanks, Andrew