[PATCH 2/2] gdb/testsuite: Add gdb.base/memops-watchpoint.exp

Kevin Buettner kevinb@redhat.com
Sun Apr 21 21:20:19 GMT 2024


On Sat, 20 Apr 2024 18:33:07 -0300
Thiago Jung Bauermann <thiago.bauermann@linaro.org> wrote:

> diff --git a/gdb/testsuite/gdb.base/memops-watchpoint.exp b/gdb/testsuite/gdb.base/memops-watchpoint.exp
> new file mode 100644
> index 000000000000..6fc84eb469c4
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/memops-watchpoint.exp
> @@ -0,0 +1,83 @@
> +# Copyright 2024 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/>.
> +
> +# Test a binary that uses standard libc memory operation functions.  They are
> +# frequently optimized with specialized instructions, so make sure GDB behaves
> +# correctly in their presence.
> +
> +# It's not possible to check in which libc function the watchpoint triggers
> +# without its debug info.
> +require libc_has_debug_info

I'm wondering about the need for this requirement.  When I comment it
out and run it on a machine without libc debuginfo, I do see 3 FAILs,
but it seems to me that those could be turned into PASSes by changing
the regular expressions for the "continue until..." tests.

E.g. for the first one, with libc debuginfo, I see:

continue
Continuing.

Hardware watchpoint 2: -location a[31]

Old value = 101 'e'
New value = 0 '\000'
__memset_avx2_unaligned () at ../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S:146
146		VMOVU	%VMM(0), (%rdi)
(gdb) PASS: gdb.base/memops-watchpoint.exp: continue until memset watchpoint hits

But, without libc debuginfo, the watchpoint still works:

continue
Continuing.

Hardware watchpoint 2: -location a[31]

Old value = 101 'e'
New value = 0 '\000'
0x00007ffff7e3553a in __memset_avx2_unaligned () from /lib64/libc.so.6
(gdb) FAIL: gdb.base/memops-watchpoint.exp: continue until memset watchpoint hits

As stated earlier, this could be turned into a PASS by tweaking the RE.

In both cases, we know that it's in a "memset" function.  (The presence
of minimal symbols provides GDB with this information.)

Kevin



More information about the Gdb-patches mailing list