Test "set multiple-symbols on" creating multiple breakpoints
authorPedro Alves <pedro@palves.net>
Mon, 16 May 2022 11:48:51 +0000 (12:48 +0100)
committerPedro Alves <pedro@palves.net>
Fri, 20 May 2022 19:41:02 +0000 (20:41 +0100)
commit46f0aab14350e9e380c6bbe7bf0539932241fb5b
tree3d23c184fe940f729257f0f23b9a1aba9f0dd403
parent7ab979957c6dd6fddd86b396e9e885ec09002e8e
Test "set multiple-symbols on" creating multiple breakpoints

To look for code paths that lead to create_breakpoints_sal creating
multiple breakpoints, I ran the whole testsuite with this hack:

  --- a/gdb/breakpoint.c
  +++ b/gdb/breakpoint.c
  @@ -8377,8 +8377,7 @@ create_breakpoints_sal (struct gdbarch *gdbarch,
  int from_tty,
  int enabled, int internal, unsigned flags)
   {
  -  if (canonical->pre_expanded)
  -    gdb_assert (canonical->lsals.size () == 1);
  +  gdb_assert (canonical->lsals.size () == 1);

surprisingly, the assert never failed...

The way to get to create_breakpoints_sal with multiple lsals is to use
"set multiple-symbols ask" and then select multiple options from the
menu, like so:

 (gdb) set multiple-symbols ask
 (gdb) b overload1arg
 [0] cancel
 [1] all
 [2] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg()
 [3] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(char)
 [4] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(double)
 [5] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(float)
 [6] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(int)
 [7] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(long)
 [8] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(short)
 [9] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(signed char)
 [10] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(unsigned char)
 [11] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(unsigned int)
 [12] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(unsigned long)
 [13] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(unsigned short)
 > 2-3
 Breakpoint 2 at 0x1532: file /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc, line 107.
 Breakpoint 3 at 0x154b: file /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc, line 110.
 warning: Multiple breakpoints were set.
 Use the "delete" command to delete unwanted breakpoints.

... which would trigger the assert.

This commit makes gdb.cp/ovldbreak.exp test this scenario.  It does
that by making set_bp_overloaded take a list of expected created
breakpoints rather than just one breakpoint.  It converts the
procedure to use gdb_test_multiple instead of send_gdb/gdb_expect
along the way.

Change-Id: Id87d1e08feb6670440d926f5344e5081f5e37c8e
gdb/testsuite/gdb.cp/ovldbreak.exp