diff options
author | Andrew Burgess <aburgess@redhat.com> | 2023-02-17 10:48:06 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2023-02-28 10:56:28 +0000 |
commit | 2fd9a436c8d24eb0af85ccb3a2fbdf9a9c679a6c (patch) | |
tree | fdc033bff0e854d5f105863def0f591f5d614609 /gdb/testsuite/gdb.mi | |
parent | 02aadca4fbeadbab6584222ca78dbc24c79f5229 (diff) | |
download | gdb-2fd9a436c8d24eb0af85ccb3a2fbdf9a9c679a6c.zip gdb-2fd9a436c8d24eb0af85ccb3a2fbdf9a9c679a6c.tar.gz gdb-2fd9a436c8d24eb0af85ccb3a2fbdf9a9c679a6c.tar.bz2 |
gdb: don't duplicate 'thread' field in MI breakpoint output
When creating a thread-specific breakpoint with a single location, the
'thread' field would be repeated in the MI output. This can be seen
in two existing tests gdb.mi/mi-nsmoribund.exp and
gdb.mi/mi-pending.exp, e.g.:
(gdb)
-break-insert -p 1 bar
^done,bkpt={number="1",type="breakpoint",disp="keep",
enabled="y",
addr="0x000000000040110a",func="bar",
file="/tmp/mi-thread-specific-bp.c",
fullname="/tmp/mi-thread-specific-bp.c",
line="32",thread-groups=["i1"],
thread="1",thread="1", <================ DUPLICATION!
times="0",original-location="bar"}
I know we need to be careful when adjusting MI output, but I'm hopeful
in this case, as the field is duplicated, and the field contents are
always identical, that we might get away with removing one of the
duplicates.
The change in GDB is a fairly trivial condition change.
We did have a couple of tests that contained the duplicate fields in
their expected output, but given there was no comment pointing out
this oddity either in the GDB code, or in the test, I suspect this was
more a case of copying whatever output GDB produced and using that as
the expected results. I've updated these tests to remove the
duplication.
I've update lib/mi-support.exp to provide support for building
breakpoint patterns that contain the thread field, and I've made use
of this in a new test I've added that is just about creating
thread-specific breakpoints and checking the results. The two tests I
mentioned above as being updated could also use the new
lib/mi-support.exp functionality, but I'm going to do that in a later
patch, this way it is clear what changes I'm actually proposing to
make to the expected output.
As I said, I hope that frontends will be able to handle this change,
but I still think its worth adding a NEWS entry, that way, if someone
runs into problems, there's a chance they can figure out what's going
on.
This should not impact CLI output at all.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Pedro Alves <pedro@palves.net>
Diffstat (limited to 'gdb/testsuite/gdb.mi')
-rw-r--r-- | gdb/testsuite/gdb.mi/mi-nsmoribund.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi-pending.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi-thread-specific-bp.c | 44 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp | 49 |
4 files changed, 95 insertions, 2 deletions
diff --git a/gdb/testsuite/gdb.mi/mi-nsmoribund.exp b/gdb/testsuite/gdb.mi/mi-nsmoribund.exp index 103aa45..55450e4 100644 --- a/gdb/testsuite/gdb.mi/mi-nsmoribund.exp +++ b/gdb/testsuite/gdb.mi/mi-nsmoribund.exp @@ -74,7 +74,7 @@ mi_delete_breakpoints # Recreate the same breakpoint, but this time, specific to thread 5. mi_gdb_test "234-break-insert -p 5 $srcfile:$bkpt_line" \ - "234\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\".*\",func=\"thread_function\",file=\".*\",fullname=\".*\",line=\".*\",thread-groups=\\\[\".*\"\\\],thread=\"5\",thread=\"5\",times=\"0\",original-location=\".*\"\}" \ + "234\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\".*\",func=\"thread_function\",file=\".*\",fullname=\".*\",line=\".*\",thread-groups=\\\[\".*\"\\\],thread=\"5\",times=\"0\",original-location=\".*\"\}" \ "thread specific breakpoint at thread_function" # Resume all threads. Only thread 5 should report a stop. diff --git a/gdb/testsuite/gdb.mi/mi-pending.exp b/gdb/testsuite/gdb.mi/mi-pending.exp index 153efdf..cd1301c 100644 --- a/gdb/testsuite/gdb.mi/mi-pending.exp +++ b/gdb/testsuite/gdb.mi/mi-pending.exp @@ -98,7 +98,7 @@ mi_gdb_test "-break-delete 3" "\\^done" "delete breakpoint 3" # Set pending breakpoint with a thread via MI. mi_gdb_test "-break-insert -p 2 -f pendfunc3" \ - ".*\\^done,bkpt=\{number=\"4\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"<PENDING>\",pending=\"pendfunc3\",thread=\"2\",thread=\"2\",times=\"0\",original-location=\"pendfunc3\"\}"\ + ".*\\^done,bkpt=\{number=\"4\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"<PENDING>\",pending=\"pendfunc3\",thread=\"2\",times=\"0\",original-location=\"pendfunc3\"\}"\ "MI pending breakpoint on pendfunc3" mi_send_resuming_command "exec-continue" "continuing execution to thread condition" diff --git a/gdb/testsuite/gdb.mi/mi-thread-specific-bp.c b/gdb/testsuite/gdb.mi/mi-thread-specific-bp.c new file mode 100644 index 0000000..8c87f01 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-thread-specific-bp.c @@ -0,0 +1,44 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2022-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 <http://www.gnu.org/licenses/>. */ + +volatile int global_var = 0; + +__attribute__((__always_inline__)) static inline void +foo (void) +{ + int i; + + for (i = 0; i < 10; ++i) + global_var = i; +} + +__attribute__((__noinline__)) static void +bar (void) +{ + global_var = 0; + foo (); +} + +int +main (void) +{ + global_var = 0; + foo (); + bar (); + foo (); + return 0; +} diff --git a/gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp b/gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp new file mode 100644 index 0000000..4586fa4 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp @@ -0,0 +1,49 @@ +# Copyright 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 <http://www.gnu.org/licenses/>. + +# This test is for creating thread-specific breakpoint using the MI, +# and checking the results from GDB. + +load_lib mi-support.exp +set MIFLAGS "-i=mi" + +if {[mi_clean_restart]} { + return +} + +standard_testfile + +if [build_executable ${testfile}.exp ${binfile} ${srcfile}] { + return -1 +} + +if {[mi_clean_restart $binfile]} { + return -1 +} + +mi_create_breakpoint "-p 1 bar" "thread-specific b/p on bar" \ + -thread "1" + +proc make_loc {num} { + return [mi_make_breakpoint_loc -thread "1" -number "$::decimal\\.$num"] +} + +set loc1 [make_loc 1] +set loc2 [make_loc 2] +set loc3 [make_loc 3] + +mi_create_breakpoint_multi "-p 1 foo" "thread-specific b/p on foo" \ + -thread "1" \ + -locations "\\\[$loc1,$loc2,$loc3\\\]" |