From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 27EFE3858C74 for ; Wed, 23 Aug 2023 08:06:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 27EFE3858C74 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692777988; 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=3iDrh3fw4yBIOazmH2V3q62SRkNzijZCxRnVI7q+EJI=; b=Xho9kAXP6dpdQmlJPrUGdljiGQQBybTY4+kEHh2gq5IGHki1Uv111GkAZ8zF6zybWpSwkZ 8el8uCm0Txpdhtu2rf+QeWc1/APtUt1m/PW9NQhgatbKrLO2/Y+R5/JqRMfucaMbw6NBP0 vdss40GYEJ14ymuzo9w9twPkDKGFE50= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-178-TuEdnparPy--OEU1l15zcQ-1; Wed, 23 Aug 2023 04:06:27 -0400 X-MC-Unique: TuEdnparPy--OEU1l15zcQ-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-9a198d4d98aso222655366b.1 for ; Wed, 23 Aug 2023 01:06:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692777986; x=1693382786; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3iDrh3fw4yBIOazmH2V3q62SRkNzijZCxRnVI7q+EJI=; b=PwQgSr1xCSf/wfHNVB9z7w2eBso62yEwKoFH94PsLVd9ZB+3lZigCU25m//r7ivAAI NiJ1rn4TXzu2Cs8xJd5a+uBLuMuFSUYWrBJlztUob/PBICbG1ezX+Qz/8mX/FJorL1q0 gytkVIyO7rbzOmu+LB58+gGk4Va46uyh5XMVGV1IkaU64W+kvf6qEhhYnrhW+OZm+RiP yi7BLtazfstGfNTzizkJCzaT8WS/L4hEmHaS+a/FyoJyRaB8u13CLnZiBcqrw1ABxd7l G0oqLFVo07zQQ9REqIR8GkRKMdESVSYnFASH2fAkqP672Mu0cigUUNyE2crX+fCm+oqd yNvA== X-Gm-Message-State: AOJu0YzZ8vw6lMSw1ejjdd7B8FOctkhpA2TRfg9qlNb4znoIZBV75++Q uOfk09MT+T61uNC5rSTGiVzzDI3LL2NzUkwYGB7fumEZgdeLDZtDugLPwFD7HE+DE0cUU0v4Rqh lRVB0Fcpqo1IUPuE2gM0B6YxPp7AukwIzts02mU2xIXUETLK4uuX3HqiSps4YiCdWE2OV+ma5nk PI3GSeOA== X-Received: by 2002:a17:907:77d3:b0:9a1:c447:3c60 with SMTP id kz19-20020a17090777d300b009a1c4473c60mr2463906ejc.47.1692777985918; Wed, 23 Aug 2023 01:06:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFghdT1ho0/ql3TcY8sPHrSgrchH1h/E+811y9WZJscuxcz53RWIT3gd5Ba15ey6gLaCFTs8Q== X-Received: by 2002:a17:907:77d3:b0:9a1:c447:3c60 with SMTP id kz19-20020a17090777d300b009a1c4473c60mr2463885ejc.47.1692777985508; Wed, 23 Aug 2023 01:06:25 -0700 (PDT) Received: from localhost ([31.111.84.232]) by smtp.gmail.com with ESMTPSA id g24-20020a1709063b1800b0098f99048053sm9573283ejf.148.2023.08.23.01.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 01:06:24 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PUSHED] gdb: add missing notify_breakpoint_modified call Date: Wed, 23 Aug 2023 09:06:22 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The commit: commit b080fe54fb3414b488b8ef323c6c50def061f918 Date: Tue Nov 8 12:32:51 2022 +0000 gdb: add inferior-specific breakpoints introduced a bug in the function breakpoint_set_inferior. The above commit includes this line: gdb::observers::breakpoint_modified.notify (b); when it should have instead used this line: notify_breakpoint_modified (b); The change to use notify_breakpoint_modified was introduced to GDB after commit b080fe54fb34 was written, but before it was merged, and I failed to update this part of the code during the rebase. The consequence of this error is that the MI interpreter will not emit breakpoint-modified notifications when breakpoint_set_inferior is called. In this commit I update the code to call notify_breakpoint_modified, and add a test that checks the MI events are being emitted correctly in this case. --- gdb/breakpoint.c | 2 +- gdb/testsuite/gdb.mi/mi-py-modify-bp.c | 28 +++++++++++ gdb/testsuite/gdb.mi/mi-py-modify-bp.exp | 61 ++++++++++++++++++++++++ gdb/testsuite/gdb.mi/mi-py-modify-bp.py | 25 ++++++++++ 4 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 gdb/testsuite/gdb.mi/mi-py-modify-bp.c create mode 100644 gdb/testsuite/gdb.mi/mi-py-modify-bp.exp create mode 100644 gdb/testsuite/gdb.mi/mi-py-modify-bp.py diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index f88ca1c9b65..f0f5328fb5e 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1574,7 +1574,7 @@ breakpoint_set_inferior (struct breakpoint *b, int inferior) int old_inferior = b->inferior; b->inferior = inferior; if (old_inferior != inferior) - gdb::observers::breakpoint_modified.notify (b); + notify_breakpoint_modified (b); } /* See breakpoint.h. */ diff --git a/gdb/testsuite/gdb.mi/mi-py-modify-bp.c b/gdb/testsuite/gdb.mi/mi-py-modify-bp.c new file mode 100644 index 00000000000..58546b33387 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-py-modify-bp.c @@ -0,0 +1,28 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright (C) 2023 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 . */ + +int +foo () +{ + return 0; +} + +int +main () +{ + return foo (); +} diff --git a/gdb/testsuite/gdb.mi/mi-py-modify-bp.exp b/gdb/testsuite/gdb.mi/mi-py-modify-bp.exp new file mode 100644 index 00000000000..95a26eab672 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-py-modify-bp.exp @@ -0,0 +1,61 @@ +# Copyright (C) 2023 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 . + +# Check that the MI interpreter correctly emits breakpoint-modified +# notifications when a breakpoint's thread or inferior is set from +# Python code. + +load_lib mi-support.exp +set MIFLAGS "-i=mi" + +standard_testfile + +require allow_python_tests + +if {[build_executable $testfile.exp $testfile $srcfile] == -1} { + return -1 +} + +set remote_python_file [gdb_remote_download host \ + ${srcdir}/${subdir}/${testfile}.py] + +mi_clean_restart $binfile +mi_runto_main + +# Delete all breakpoints. +mi_delete_breakpoints + +# Create a breakpoint. At this point the breakpoint is global, but +# this will be adjusted from Python code. +mi_create_breakpoint "foo" "break in foo" -disp keep -func foo +set bpnum [mi_get_valueof "/d" "\$bpnum" "INVALID" \ + "get number for thread-specific breakpoint"] + +# Some patterns used in the expected output below. +set thr_group_re [string_to_regexp {thread-groups=["i1"]}] +set times_re [string_to_regexp {times="0"}] + +# Source the Python script, the script changes the thread then +# inferior field of the first breakpoint, we expect to see the +# breakpoint modified four times. +mi_gdb_test "source $remote_python_file" \ + [multi_line \ + "&\"source \[^\r\n\]+\"" \ + "=breakpoint-modified,bkpt=\\{number=\"$bpnum\",\[^\r\n\]+\\,$thr_group_re,thread=\"1\",$times_re,\[^\r\n\]+}" \ + "=breakpoint-modified,bkpt=\\{number=\"$bpnum\",\[^\r\n\]+\\,$thr_group_re,$times_re,\[^\r\n\]+}" \ + "=breakpoint-modified,bkpt=\\{number=\"$bpnum\",\[^\r\n\]+\\,$thr_group_re,inferior=\"1\",$times_re,\[^\r\n\]+}" \ + "=breakpoint-modified,bkpt=\\{number=\"$bpnum\",\[^\r\n\]+\\,$thr_group_re,$times_re,\[^\r\n\]+}" \ + "\\^done"] \ + "source python script" diff --git a/gdb/testsuite/gdb.mi/mi-py-modify-bp.py b/gdb/testsuite/gdb.mi/mi-py-modify-bp.py new file mode 100644 index 00000000000..6e1034c38bd --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-py-modify-bp.py @@ -0,0 +1,25 @@ +# Copyright (C) 2023 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 . + +import gdb + +bps = gdb.breakpoints() +bp = bps[0] + +bp.thread = 1 +bp.thread = None + +bp.inferior = 1 +bp.inferior = None base-commit: 835f16daa77952015d1a97ae6eab48cc2ea14fb8 -- 2.25.4