From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1751) id 56E3A384F4AB; Mon, 21 Nov 2022 21:02:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 56E3A384F4AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669064574; bh=rt4B3WdOPsL/60N78uTQhr77/ws8QzE5xwDEEIctd2Q=; h=From:To:Subject:Date:From; b=rKU4STnxSDEMCTGeo6XRBb43oYhKCILCe1l0dD8RLJKEwKSxLmg0TsyITI//9jGur beQUD8d/Hf4Z4EWQJfxnfdHzKg7uDoOZGcvb+ucYAqFdyaLpboTIFTO3kti4DWybp1 CfTi2L1qy7Ea3272e3JlOYWN220cUterQ3axCzzA= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Philippe Waroquiers To: gdb-cvs@sourceware.org Subject: [binutils-gdb] When getting the locno of a bpstat, handle the case of bp with null locations. X-Act-Checkin: binutils-gdb X-Git-Author: Philippe Waroquiers X-Git-Refname: refs/heads/master X-Git-Oldrev: 83f350830ee561ddc799d1445c6024a84df9f161 X-Git-Newrev: 28a072f4af84ad295d37f8aa70c5fec9d36a274c Message-Id: <20221121210254.56E3A384F4AB@sourceware.org> Date: Mon, 21 Nov 2022 21:02:54 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D28a072f4af84= ad295d37f8aa70c5fec9d36a274c commit 28a072f4af84ad295d37f8aa70c5fec9d36a274c Author: Philippe Waroquiers Date: Sun Nov 20 17:42:12 2022 +0100 When getting the locno of a bpstat, handle the case of bp with null loc= ations. =20 The test py-objfile.exp unloads the current file while debugging the pr= ocess. This results in bpstat bs->b->loc to become nullptr. Handle this case in breakpoint.c:bpstat_locno. =20 Note: GDB crashes on this problem with an internal error, but the end of gdb summary shows: ... =3D=3D=3D gdb Summary =3D=3D=3D =20 # of expected passes 36 =20 The output also does not contain a 'FAIL:'. After the fix, the nr of expected passes increased. =20 In the gdb.log output, one can see: ... Fatal signal: Segmentation fault ----- Backtrace ----- 0x55698905c5b9 gdb_internal_backtrace_1 ../../binutils-gdb/gdb/bt-utils.c:122 0x55698905c5b9 _Z22gdb_internal_backtracev ... =20 ERROR: Couldn't send python print(objfile.filename) to GDB. ERROR: : spawn id exp9 not open while executing "expect { -i exp9 -timeout 10 -re ".*A problem internal to GDB has been detected" { fail "$message (GDB internal error)" gdb_internal_error..." ("uplevel" body line 1) invoked from within .... =20 Wondering if it might be possible to improve gdb_test to have gdb_test "python print(objfile.filename)" "None" \ "objfile.filename after objfile is unloaded" reporting a failed result instead of just producing the internal error. Diff: --- gdb/breakpoint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 5b691673a0e..a161b78a8aa 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -4486,7 +4486,7 @@ bpstat_locno (const bpstat *bs) =20 int locno =3D 0; =20 - if (b !=3D nullptr && b->loc->next !=3D nullptr) + if (b !=3D nullptr && b->loc !=3D nullptr && b->loc->next !=3D nullptr) { const bp_location *bl_i;