From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 9UqUCci0GWq5NCcAWB0awg (envelope-from ) for ; Fri, 29 May 2026 11:46:16 -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=XdIi4hn1; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 192BB1E0A3; Fri, 29 May 2026 11:46:16 -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 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 241221E062 for ; Fri, 29 May 2026 11:46:15 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 83E204BA23E6 for ; Fri, 29 May 2026 15:46:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 83E204BA23E6 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=XdIi4hn1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id AA85B4BA2E35 for ; Fri, 29 May 2026 15:45:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AA85B4BA2E35 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 AA85B4BA2E35 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780069545; cv=none; b=ETPJjHk/TgHfKoHCY6OnMOmuVhhO18sQ0mnOGFDLEIsoaCCQx3PDRHwsv8SMbn1MewkurkPNtvN0oF1uSsjR3MTaS2jzluYMWbMJgxhcilg764nMXeKjm4OLwyjh9WkUtKzNkXLqKJtgNgq2BB9wzEZIKsU16WWLum28AT9aEIY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1780069545; c=relaxed/simple; bh=bcN5J7c9TX3Ytbqu0xw0eHCIepc3sGFF7TLlqZCIIV4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=EDeFrVItbuaEA69vqJrP/LeEYRx3AblyN2cKCUf/e8sEXe9FwGa52wkPxiSg3OkevDhh+GrfNL8a66cWdbuSr0GEXnuHCzzS8WNEk/sStL8bFxuNXhUbPwdsGeKGr/hmM+jY4hLjrrjDVb6ID0zN/KauErg0UgEqrwK2Z0fxRF8= ARC-Authentication-Results: i=1; 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=XdIi4hn1 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA85B4BA2E35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780069545; 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=+3Un4eJqOBMlRiiEcfeYAxL/Bq5WSDZqIOH9h1//b7E=; b=XdIi4hn1dNdQY3xQDTX+SqS70IDja1E+8wVfA7LNZ9bOYhzvKyLVwp+pSGFjGSn74TSjPH jE0rrWh6NTTEbM25qJLEsWn6BG7PrYGceiZT/MZjbztXIaWcf2tLl8ZlkWm12vQeYP0PXb sPWH5Rhdjr2hfXTe9/FyAH4ZkrclvCU= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-9-Fq-SFmA5PsuzPvMj-ittbw-1; Fri, 29 May 2026 11:45:43 -0400 X-MC-Unique: Fq-SFmA5PsuzPvMj-ittbw-1 X-Mimecast-MFC-AGG-ID: Fq-SFmA5PsuzPvMj-ittbw_1780069542 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-45ef3c7073eso498432f8f.2 for ; Fri, 29 May 2026 08:45:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780069542; x=1780674342; 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=YtZfRv/Gbwv/jpUMPFdrDANWMqtBmovU8vcdyYTA0CI=; b=EzEE0+VYS/gpWVMxYE0tpYaaSuRXqfiiIPU4jMpFpPphvf2MQuOD1edmhVd9WfT3cT eamYkd8LdbHhwR9pbIFTNhhKeFzCst9QxsgFrgSkujwyFk8DHutardd1KuYpLBh/5KyA RvzuQdJSTLSqnnDsMBcxiEyqlf3Cko2kDfI+y5YRz9x6cRktDQCAxuLiWjfvKSLINbCJ 6Gn93dlMI3L1JqbNy6S6ktwJzt7Bp63EwxYrvV0W6WyPPxFXqAPkJldUTSufnFMR5j8w WxzvCJoGi+MJV0FjBOh8cCh95u+kOnE1wpi3wb8ekJGvIpOQwVkg/ZnX2SfgT7D9wyzy oJVQ== X-Forwarded-Encrypted: i=1; AFNElJ/JIBG3Pg8tONZa62vpFDebEWNBdS3rPjWiQaQZ1ZDXe1WTTnAcS5izZWvV/8czbMP6rcDcSSuQM/KIaQ==@sourceware.org X-Gm-Message-State: AOJu0Yz5k5kt0vEHmFfM5KLKbiQpI9w/CYUmeQuv3CSQiUW9K8/IjS0o DxWXt0JKflv5zwb2w+2IxROsDhssBsJlasgVTzYpayxjRQFJkK5DNwklszPzVpY53t53wnuSKSw yjLm103Vlkq4A069YtDHlWt4qe7S5MVtFzBrmQ6klDDHm5the6M+gYoLLp4r3DOKqjPMylCs= X-Gm-Gg: Acq92OG0kBVg33ovrRYPYVU9IQRdyyNzQB+x6mU3YB/FLaESIc5gbW/ozggH1C6aCtu 7181ZjyGfLmXi2+pLHTjva/FmC3gHFSQzXt0Or+VXUhXZt6UFWgvQ4EkVLNJEjxs2wt13l+3xR4 qGRO7qzV+6GhXTFDiAPq9Ie1sQgOSsud7YtGP9Q9qNaTQA+jmeqppxTxpJannzUrR4WC4DW31pL VQy10GBnQnX9l/Ys5WT9FM2/v7EE3SgmmyM2bTGmp2oe86Jk/eWxZGu3TgX6TqMXxmcHYoUXCkL 67TYEVNTtRfBQtCKqBsRe4VWJmxUwl5fZLd4dGEy8ZojN5yFkUonri6tPY+QZb5L7g5w7Ptj8bQ ndo2dfnkJSo0WVYI3+2jnnkJtGw== X-Received: by 2002:a05:6000:2892:b0:45e:eaed:afd2 with SMTP id ffacd0b85a97d-45ef6a94af8mr850831f8f.0.1780069542084; Fri, 29 May 2026 08:45:42 -0700 (PDT) X-Received: by 2002:a05:6000:2892:b0:45e:eaed:afd2 with SMTP id ffacd0b85a97d-45ef6a94af8mr850769f8f.0.1780069541546; Fri, 29 May 2026 08:45:41 -0700 (PDT) Received: from localhost ([213.31.44.43]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45ef34bcc30sm4412286f8f.12.2026.05.29.08.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2026 08:45:41 -0700 (PDT) From: Andrew Burgess To: =?utf-8?Q?S=C3=A9bastien?= Darche , gdb-patches@sourceware.org Cc: =?utf-8?Q?S=C3=A9bastien?= Darche Subject: Re: [PATCH] gdb/breakpoint: remove assertion when printing internal breakpoints without locspecs In-Reply-To: <20260526145701.41678-1-sdarche@efficios.com> References: <20260526145701.41678-1-sdarche@efficios.com> Date: Fri, 29 May 2026 16:45:40 +0100 Message-ID: <87tsrqxlqz.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: oFmZFsCjD1mbF0VL9qQbF_hQrnzq7IFmEEFAHG969-Y_1780069542 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 Hi S=C3=A9bastien, Thanks for looking at this. I think this looks good, I have a couple of minor nits to feedback, see inline below. S=C3=A9bastien Darche writes: > When debugging gdb with `set debug breakpoint on`, gdb would crash if > the inferior happened to unload (through dlclose ()) a shared library > that contains jit debugging symbols: > > =09../../gdb/breakpoint.c:6473: internal-error: print_breakpoint_location= : > =09Assertion `b->locspec !=3D nullptr || (!user_breakpoint_p (b) && (b->t= ype > =09=3D=3D bp_shlib_event || b->type =3D=3D bp_thread_event))' failed. > =09A problem internal to GDB has been detected [...] > > This assertion was added in commit 5770f68 ("gdb: handle empty locspec > when printing breakpoints"). The assumption for this assert is that the > user may not call any (gdb-)debugging command between the time a shared > library is marked (bp_location->shlib_disabled is set) and the > breakpoint is actually removed. This would be true if the user called > `maint info breakpoints` as explained in the original commit message. > > However, if `set debug breakpoint on` is called, gdb prints debugging > info as the shared library is being unloaded. The ~jiter_objfile_data > dtor deletes the breakpoint, which calls remove_breakpoint_1 on the > bp_location in the recently unloaded shared object. Since `debug > breakpoint` is enabled, we go through print_breakpoint_location with the > bp_location's shlib_disabled flag set.. which results in the assert > above. I think the ".. " should be replace with ", ". > > This commit removes the assertion as it is not true in all cases. I've > also included a minimal test case that loads a shared library with a > __jit_debug_register_code symbol. The test fails with the assert. > > Change-Id: Ia19c84f194a6f0c10315548c7f423bfd86ef0266 > --- > gdb/breakpoint.c | 17 --------- > gdb/testsuite/gdb.base/jit-unload-solib.c | 21 +++++++++++ > gdb/testsuite/gdb.base/jit-unload.c | 45 +++++++++++++++++++++++ > gdb/testsuite/gdb.base/jit-unload.exp | 44 ++++++++++++++++++++++ > 4 files changed, 110 insertions(+), 17 deletions(-) > create mode 100644 gdb/testsuite/gdb.base/jit-unload-solib.c > create mode 100644 gdb/testsuite/gdb.base/jit-unload.c > create mode 100644 gdb/testsuite/gdb.base/jit-unload.exp > > diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c > index 101dc57ee6b..85c4ffc3171 100644 > --- a/gdb/breakpoint.c > +++ b/gdb/breakpoint.c > @@ -6457,23 +6457,6 @@ print_breakpoint_location (const breakpoint *b, co= nst bp_location *loc) > } > else > { > - /* Internal breakpoints don't have a locspec string, but can becom= e > -=09 pending if the shared library the breakpoint is in is unloaded. > -=09 For most internal breakpoint types though, after unloading the > -=09 shared library, the breakpoint will be deleted and never recreated > -=09 (see internal_breakpoint::re_set). But for two internal > -=09 breakpoint types bp_shlib_event and bp_thread_event this is not > -=09 true. Usually we don't expect the libraries that contain these > -=09 breakpoints to ever be unloaded, but a buggy inferior might do > -=09 such a thing, in which case GDB should be prepared to handle this > -=09 case. > - > -=09 If these two breakpoint types become pending then there will be no > -=09 locspec string. */ > - gdb_assert (b->locspec !=3D nullptr > -=09=09 || (!user_breakpoint_p (b) > -=09=09 && (b->type =3D=3D bp_shlib_event > -=09=09=09 || b->type =3D=3D bp_thread_event))); > const char *locspec_str > =09=3D (b->locspec !=3D nullptr ? b->locspec->to_string () : ""); > uiout->field_string ("pending", locspec_str); > diff --git a/gdb/testsuite/gdb.base/jit-unload-solib.c b/gdb/testsuite/gd= b.base/jit-unload-solib.c > new file mode 100644 > index 00000000000..3cf2c580320 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/jit-unload-solib.c > @@ -0,0 +1,21 @@ > +/* This test program is part of GDB, the GNU debugger. > + > + Copyright 2026 Free Software Foundation, Inc. > + > + 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 simulates a JIT library. */ > + > + > +#include "jit-protocol.h" > diff --git a/gdb/testsuite/gdb.base/jit-unload.c b/gdb/testsuite/gdb.base= /jit-unload.c > new file mode 100644 > index 00000000000..def66b53861 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/jit-unload.c > @@ -0,0 +1,45 @@ > +/* This test program is part of GDB, the GNU debugger. > + > + Copyright 2026 Free Software Foundation, Inc. > + > + 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 .= */ > + > +/* Simulate loading of a library JIT code. */ > + > +#include > +#include > + > +#ifdef __WIN32__ > +#include > +#define dlopen(name, mode) LoadLibrary (TEXT (name)) > +#define dlclose(handle) FreeLibrary (handle) > +#else > +#include > +#endif > + > + > +int > +main() Missing space after 'main'. Also, for C code I think 'main (void)' is what we should be writing, though we do have a lot of 'main ()' already. > +{ > + void *handle =3D dlopen (SHLIB_NAME, RTLD_NOW); > + > + if (handle =3D=3D nullptr) The 'nullptr' is a C23 feature. To allow this test to compile with older compilers it would be better to use 'NULL'. > + { > + fprintf (stderr, "%s\n", dlerror ()); > + exit (1); > + } > + > + dlclose (handle); > + return 0; > +} > diff --git a/gdb/testsuite/gdb.base/jit-unload.exp b/gdb/testsuite/gdb.ba= se/jit-unload.exp > new file mode 100644 > index 00000000000..0bf9c59385d > --- /dev/null > +++ b/gdb/testsuite/gdb.base/jit-unload.exp > @@ -0,0 +1,44 @@ > +# Copyright 2026 Free Software Foundation, Inc. > + > +# 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 test checks that gdb does not assert when unloading a shared libr= ary > +# that defines a __jit_debug_register_code if `set debug breakpoint on` = is set. > + > +require allow_shlib_tests > + > +standard_testfile .c -solib.c > +set libfile ${testfile}-lib > + > +set options [list \ > +=09=09 debug \ > +=09=09 shlib_load \ > +=09=09 additional_flags=3D-DSHLIB_NAME=3D\"${libfile}\"] > + > +if { [build_executable "build main file" $testfile $srcfile $options] = =3D=3D -1 } { > + return > +} > + > +if { [build_executable "build shlib" $libfile $srcfile2 {debug shlib}] = =3D=3D -1 } { > + return > +} This isn't going to work for remote target boards as the shlib will still be on the build machine. If you rewrite like this to make use of gdb_download_shlib then things will be better. I tested this using 'make check-all-boards', which is described in gdb/testsuite/README: require allow_shlib_tests =20 standard_testfile .c -solib.c =20 set lib_testfile ${testfile}-lib set lib_binfile [standard_output_file $lib_testfile] =20 if { [build_executable "build shlib" $lib_testfile $srcfile2 \ =09 {debug shlib}] =3D=3D -1 } { return } =20 set lib_testfile_on_target [gdb_download_shlib $lib_binfile] =20 set options [list \ =09=09 debug \ =09=09 shlib_load \ =09=09 additional_flags=3D-DSHLIB_NAME=3D\"${lib_testfile_on_target}\"] =20 if { [prepare_for_testing "build main file" $testfile $srcfile \ =09 $options] =3D=3D -1 } { return } > + > +clean_restart $::testfile I propose using prepare_for_testing above, so this line will no longer be needed. > + > +if { ![runto_main] } { > + return > +} > + > +gdb_test_no_output "set debug breakpoint on" > +gdb_continue_to_end "unload" continue 1 I worry about trying to handle all of the possible debug breakpoint output using gdb_continue_to_end, which matches all the output with a ".*" pattern; there's a risk of buffer overflow in the future. I'd prefer to see this handled with something like: set saw_exit false gdb_test_multiple "continue" unload { -re "^\\\[Inferior $decimal \[^\r\n\]+ exited normally\\\]\r\n" { =09set saw_exit true =09exp_continue } =20 -re "^$gdb_prompt $" { =09gdb_assert ${saw_exit} $gdb_test_name } =20 -re "^\[^\r\n\]*\r\n" { =09exp_continue } } which handles the output line by line, and so will be happy with any volume of debug output. Thanks, Andrew