]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
5 months agoNew Romanian translation for ld
Nick Clifton [Tue, 28 Nov 2023 10:16:05 +0000 (10:16 +0000)] 
New Romanian translation for ld

5 months ago[gdb] Fix segfault in for_each_block, part 2
Tom de Vries [Tue, 28 Nov 2023 09:31:25 +0000 (10:31 +0100)] 
[gdb] Fix segfault in for_each_block, part 2

The previous commit describes PR gdb/30547, a segfault when running test-case
gdb.base/vfork-follow-parent.exp on powerpc64 (likewise on s390x).

The root cause for the segmentation fault is that linux_is_uclinux gives an
incorrect result: it returns true instead of false.

So, why does linux_is_uclinux:
...
int
linux_is_uclinux (void)
{
  CORE_ADDR dummy;

  return (target_auxv_search (AT_NULL, &dummy) > 0
  && target_auxv_search (AT_PAGESZ, &dummy) == 0);
...
return true?

This is because ppc_linux_target_wordsize returns 4 instead of 8, causing
ppc_linux_nat_target::auxv_parse to misinterpret the auxv vector.

So, why does ppc_linux_target_wordsize:
...
int
ppc_linux_target_wordsize (int tid)
{
  int wordsize = 4;

  /* Check for 64-bit inferior process.  This is the case when the host is
     64-bit, and in addition the top bit of the MSR register is set.  */
  long msr;

  errno = 0;
  msr = (long) ptrace (PTRACE_PEEKUSER, tid, PT_MSR * 8, 0);
  if (errno == 0 && ppc64_64bit_inferior_p (msr))
    wordsize = 8;

  return wordsize;
}
...
return 4?

Specifically, we get this result because because tid == 0, so we get
errno == ESRCH.

The tid == 0 is caused by the switch_to_no_thread in
handle_vfork_child_exec_or_exit:
...
  /* Switch to no-thread while running clone_program_space, so
     that clone_program_space doesn't want to read the
     selected frame of a dead process.  */
  scoped_restore_current_thread restore_thread;
  switch_to_no_thread ();

  inf->pspace = new program_space (maybe_new_address_space ());
...
but moving the maybe_new_address_space call to before that gives us the
same result.  The tid is no longer 0, but we still get ESRCH because the
thread has exited.

Fix this in handle_vfork_child_exec_or_exit by doing the
maybe_new_address_space call in the context of the vfork parent.

Tested on top of trunk on x86_64-linux and ppc64le-linux.
Tested on top of gdb-14-branch on ppc64-linux.

Co-Authored-By: Simon Marchi <simon.marchi@polymtl.ca>
PR gdb/30547
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30547

5 months ago[gdb] Fix segfault in for_each_block, part 1
Tom de Vries [Tue, 28 Nov 2023 09:31:25 +0000 (10:31 +0100)] 
[gdb] Fix segfault in for_each_block, part 1

When running test-case gdb.base/vfork-follow-parent.exp on powerpc64 (likewise
on s390x), I run into:
...
(gdb) PASS: gdb.base/vfork-follow-parent.exp: \
  exec_file=vfork-follow-parent-exit: target-non-stop=on: non-stop=off: \
  resolution_method=schedule-multiple: print unblock_parent = 1
continue^M
Continuing.^M
Reading symbols from vfork-follow-parent-exit...^M
^M
^M
Fatal signal: Segmentation fault^M
----- Backtrace -----^M
0x1027d3e7 gdb_internal_backtrace_1^M
        src/gdb/bt-utils.c:122^M
0x1027d54f _Z22gdb_internal_backtracev^M
        src/gdb/bt-utils.c:168^M
0x1057643f handle_fatal_signal^M
        src/gdb/event-top.c:889^M
0x10576677 handle_sigsegv^M
        src/gdb/event-top.c:962^M
0x3fffa7610477 ???^M
0x103f2144 for_each_block^M
        src/gdb/dcache.c:199^M
0x103f235b _Z17dcache_invalidateP13dcache_struct^M
        src/gdb/dcache.c:251^M
0x10bde8c7 _Z24target_dcache_invalidatev^M
        src/gdb/target-dcache.c:50^M
...
or similar.

The root cause for the segmentation fault is that linux_is_uclinux gives an
incorrect result: it should always return false, given that we're running on a
regular linux system, but instead it returns first true, then false.

In more detail, the segmentation fault happens as follows:
- a program space with an address space is created
- a second program space is about to be created. maybe_new_address_space
  is called, and because linux_is_uclinux returns true, maybe_new_address_space
  returns false, and no new address space is created
- a second program space with the same address space is created
- a program space is deleted. Because linux_is_uclinux now returns false,
  gdbarch_has_shared_address_space (current_inferior ()->arch ()) returns
  false, and the address space is deleted
- when gdb uses the address space of the remaining program space, we run into
  the segfault, because the address space is deleted.

Hardcoding linux_is_uclinux to false makes the test-case pass.

We leave addressing the root cause for the following commit in this series.

For now, prevent the segmentation fault by making the address space a refcounted
object.

This was already suggested here [1]:
...
A better solution might be to have the address spaces be reference counted
...

Tested on top of trunk on x86_64-linux and ppc64le-linux.
Tested on top of gdb-14-branch on ppc64-linux.

Co-Authored-By: Simon Marchi <simon.marchi@polymtl.ca>
PR gdb/30547
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30547

[1] https://sourceware.org/pipermail/gdb-patches/2023-October/202928.html

5 months agotestsuite: Clean up .allow_index_reg in i386 tests
Haochen Jiang [Tue, 28 Nov 2023 05:29:01 +0000 (13:29 +0800)] 
testsuite: Clean up .allow_index_reg in i386 tests

gas/ChangeLog:

* testsuite/gas/i386/adx.s: Remove .allow_index_reg.
* testsuite/gas/i386/amx-complex-inval.l: Ditto.
* testsuite/gas/i386/amx-complex-inval.s: Ditto.
* testsuite/gas/i386/avx-ifma.s: Ditto.
* testsuite/gas/i386/avx-ne-convert.s: Ditto.
* testsuite/gas/i386/avx-scalar-2.s: Ditto.
* testsuite/gas/i386/avx-vnni-int8.s: Ditto.
* testsuite/gas/i386/avx-vnni.s: Ditto.
* testsuite/gas/i386/avx-wig.s: Ditto.
* testsuite/gas/i386/avx2-wig.s: Ditto.
* testsuite/gas/i386/avx2.s: Ditto.
* testsuite/gas/i386/avx256int.s: Ditto.
* testsuite/gas/i386/avx512_4fmaps.s: Ditto.
* testsuite/gas/i386/avx512_4vnniw.s: Ditto.
* testsuite/gas/i386/avx512_bf16.s: Ditto.
* testsuite/gas/i386/avx512_bf16_vl-inval.l: Ditto.
* testsuite/gas/i386/avx512_bf16_vl-inval.s: Ditto.
* testsuite/gas/i386/avx512_bf16_vl.s: Ditto.
* testsuite/gas/i386/avx512_fp16-inval-bcast.l: Ditto.
* testsuite/gas/i386/avx512_fp16-inval-bcast.s: Ditto.
* testsuite/gas/i386/avx512_fp16.s: Ditto.
* testsuite/gas/i386/avx512_fp16_pseudo_ops.s: Ditto.
* testsuite/gas/i386/avx512_fp16_vl.s: Ditto.
* testsuite/gas/i386/avx512_vpopcntdq.s: Ditto.
* testsuite/gas/i386/avx512bitalg.s: Ditto.
* testsuite/gas/i386/avx512bitalg_vl.s: Ditto.
* testsuite/gas/i386/avx512bw-opts.s: Ditto.
* testsuite/gas/i386/avx512bw-wig.s: Ditto.
* testsuite/gas/i386/avx512bw.s: Ditto.
* testsuite/gas/i386/avx512bw_vl-opts.s: Ditto.
* testsuite/gas/i386/avx512bw_vl-wig.s: Ditto.
* testsuite/gas/i386/avx512bw_vl.s: Ditto.
* testsuite/gas/i386/avx512cd.s: Ditto.
* testsuite/gas/i386/avx512cd_vl.s: Ditto.
* testsuite/gas/i386/avx512dq-rcig.s: Ditto.
* testsuite/gas/i386/avx512dq.s: Ditto.
* testsuite/gas/i386/avx512dq_vl.s: Ditto.
* testsuite/gas/i386/avx512er-rcig.s: Ditto.
* testsuite/gas/i386/avx512er.s: Ditto.
* testsuite/gas/i386/avx512f-opts.s: Ditto.
* testsuite/gas/i386/avx512f-rcig.s: Ditto.
* testsuite/gas/i386/avx512f.s: Ditto.
* testsuite/gas/i386/avx512f_gfni.s: Ditto.
* testsuite/gas/i386/avx512f_vaes.s: Ditto.
* testsuite/gas/i386/avx512f_vl-opts.s: Ditto.
* testsuite/gas/i386/avx512f_vl-wig.s: Ditto.
* testsuite/gas/i386/avx512f_vl.s: Ditto.
* testsuite/gas/i386/avx512f_vpclmulqdq.s: Ditto.
* testsuite/gas/i386/avx512ifma.s: Ditto.
* testsuite/gas/i386/avx512ifma_vl.s: Ditto.
* testsuite/gas/i386/avx512pf.s: Ditto.
* testsuite/gas/i386/avx512vbmi.s: Ditto.
* testsuite/gas/i386/avx512vbmi2.s: Ditto.
* testsuite/gas/i386/avx512vbmi2_vl.s: Ditto.
* testsuite/gas/i386/avx512vbmi_vl.s: Ditto.
* testsuite/gas/i386/avx512vl_gfni.s: Ditto.
* testsuite/gas/i386/avx512vl_vaes.s: Ditto.
* testsuite/gas/i386/avx512vl_vpclmulqdq.s: Ditto.
* testsuite/gas/i386/avx512vnni.s: Ditto.
* testsuite/gas/i386/avx512vnni_vl.s: Ditto.
* testsuite/gas/i386/bmi.s: Ditto.
* testsuite/gas/i386/bmi2.s: Ditto.
* testsuite/gas/i386/cldemote.s: Ditto.
* testsuite/gas/i386/clflushopt.s: Ditto.
* testsuite/gas/i386/clwb.s: Ditto.
* testsuite/gas/i386/cmpccxadd-inval.l: Ditto.
* testsuite/gas/i386/cmpccxadd-inval.s: Ditto.
* testsuite/gas/i386/enqcmd-inval.l: Ditto.
* testsuite/gas/i386/enqcmd-inval.s: Ditto.
* testsuite/gas/i386/enqcmd.s: Ditto.
* testsuite/gas/i386/evex-lig-2.s: Ditto.
* testsuite/gas/i386/evex-lig.s: Ditto.
* testsuite/gas/i386/evex-wig.s: Ditto.
* testsuite/gas/i386/evex.s: Ditto.
* testsuite/gas/i386/fma-scalar.s: Ditto.
* testsuite/gas/i386/fma.s: Ditto.
* testsuite/gas/i386/fma4.s: Ditto.
* testsuite/gas/i386/gfni.s: Ditto.
* testsuite/gas/i386/hle.s: Ditto.
* testsuite/gas/i386/ilp32/enqcmd.s: Ditto.
* testsuite/gas/i386/ilp32/movdir.s: Ditto.
* testsuite/gas/i386/lwp.s: Ditto.
* testsuite/gas/i386/movdir.s: Ditto.
* testsuite/gas/i386/movdir64b-reg.l: Ditto.
* testsuite/gas/i386/movdir64b-reg.s: Ditto.
* testsuite/gas/i386/mpx-inval-1.l: Ditto.
* testsuite/gas/i386/mpx-inval-1.s: Ditto.
* testsuite/gas/i386/mpx.s: Ditto.
* testsuite/gas/i386/msrlist-inval.l: Ditto.
* testsuite/gas/i386/msrlist-inval.s: Ditto.
* testsuite/gas/i386/notrack.s: Ditto.
* testsuite/gas/i386/notrackbad.l: Ditto.
* testsuite/gas/i386/notrackbad.s: Ditto.
* testsuite/gas/i386/optimize-1.s: Ditto.
* testsuite/gas/i386/optimize-2.s: Ditto.
* testsuite/gas/i386/optimize-3.s: Ditto.
* testsuite/gas/i386/optimize-6.s: Ditto.
* testsuite/gas/i386/optimize-6a.l: Ditto.
* testsuite/gas/i386/optimize-7.l: Ditto.
* testsuite/gas/i386/optimize-7.s: Ditto.
* testsuite/gas/i386/opts.s: Ditto.
* testsuite/gas/i386/prefetchwt1.s: Ditto.
* testsuite/gas/i386/raoint.s: Ditto.
* testsuite/gas/i386/sha.s: Ditto.
* testsuite/gas/i386/sse2avx.s: Ditto.
* testsuite/gas/i386/tbm.s: Ditto.
* testsuite/gas/i386/vaes.s: Ditto.
* testsuite/gas/i386/vex-lig-2.s: Ditto.
* testsuite/gas/i386/vp2intersect-inval-bcast.l: Ditto.
* testsuite/gas/i386/vp2intersect-inval-bcast.s: Ditto.
* testsuite/gas/i386/vpclmulqdq.s: Ditto.
* testsuite/gas/i386/x86-64-adx.s: Ditto.
* testsuite/gas/i386/x86-64-amx-complex.s: Ditto.
* testsuite/gas/i386/x86-64-amx-fp16.s: Ditto.
* testsuite/gas/i386/x86-64-avx-ifma.s: Ditto.
* testsuite/gas/i386/x86-64-avx-ne-convert.s: Ditto.
* testsuite/gas/i386/x86-64-avx-scalar-2.s: Ditto.
* testsuite/gas/i386/x86-64-avx-swap.s: Ditto.
* testsuite/gas/i386/x86-64-avx-vnni-int8.s: Ditto.
* testsuite/gas/i386/x86-64-avx-vnni.s: Ditto.
* testsuite/gas/i386/x86-64-avx-wig.s: Ditto.
* testsuite/gas/i386/x86-64-avx2-wig.s: Ditto.
* testsuite/gas/i386/x86-64-avx2.s: Ditto.
* testsuite/gas/i386/x86-64-avx256int.s: Ditto.
* testsuite/gas/i386/x86-64-avx512_4fmaps.s: Ditto.
* testsuite/gas/i386/x86-64-avx512_4vnniw.s: Ditto.
* testsuite/gas/i386/x86-64-avx512_bf16.s: Ditto.
* testsuite/gas/i386/x86-64-avx512_bf16_vl-inval.l: Ditto.
* testsuite/gas/i386/x86-64-avx512_bf16_vl-inval.s: Ditto.
* testsuite/gas/i386/x86-64-avx512_bf16_vl.s: Ditto.
* testsuite/gas/i386/x86-64-avx512_fp16-inval-bcast.l: Ditto.
* testsuite/gas/i386/x86-64-avx512_fp16-inval-bcast.s: Ditto.
* testsuite/gas/i386/x86-64-avx512_fp16-inval-register.l: Ditto.
* testsuite/gas/i386/x86-64-avx512_fp16-inval-register.s: Ditto.
* testsuite/gas/i386/x86-64-avx512_fp16.s: Ditto.
* testsuite/gas/i386/x86-64-avx512_fp16_pseudo_ops.s: Ditto.
* testsuite/gas/i386/x86-64-avx512_fp16_vl.s: Ditto.
* testsuite/gas/i386/x86-64-avx512_vpopcntdq.s: Ditto.
* testsuite/gas/i386/x86-64-avx512bitalg.s: Ditto.
* testsuite/gas/i386/x86-64-avx512bitalg_vl.s: Ditto.
* testsuite/gas/i386/x86-64-avx512bw-opts.s: Ditto.
* testsuite/gas/i386/x86-64-avx512bw-wig.s: Ditto.
* testsuite/gas/i386/x86-64-avx512bw.s: Ditto.
* testsuite/gas/i386/x86-64-avx512bw_vl-opts.s: Ditto.
* testsuite/gas/i386/x86-64-avx512bw_vl-wig.s: Ditto.
* testsuite/gas/i386/x86-64-avx512bw_vl.s: Ditto.
* testsuite/gas/i386/x86-64-avx512cd.s: Ditto.
* testsuite/gas/i386/x86-64-avx512cd_vl.s: Ditto.
* testsuite/gas/i386/x86-64-avx512dq-rcig.s: Ditto.
* testsuite/gas/i386/x86-64-avx512dq.s: Ditto.
* testsuite/gas/i386/x86-64-avx512dq_vl.s: Ditto.
* testsuite/gas/i386/x86-64-avx512er-rcig.s: Ditto.
* testsuite/gas/i386/x86-64-avx512er.s: Ditto.
* testsuite/gas/i386/x86-64-avx512f-opts.s: Ditto.
* testsuite/gas/i386/x86-64-avx512f-rcig.s: Ditto.
* testsuite/gas/i386/x86-64-avx512f.s: Ditto.
* testsuite/gas/i386/x86-64-avx512f_gfni.s: Ditto.
* testsuite/gas/i386/x86-64-avx512f_vaes.s: Ditto.
* testsuite/gas/i386/x86-64-avx512f_vl-opts.s: Ditto.
* testsuite/gas/i386/x86-64-avx512f_vl-wig.s: Ditto.
* testsuite/gas/i386/x86-64-avx512f_vl.s: Ditto.
* testsuite/gas/i386/x86-64-avx512f_vpclmulqdq.s: Ditto.
* testsuite/gas/i386/x86-64-avx512ifma.s: Ditto.
* testsuite/gas/i386/x86-64-avx512ifma_vl.s: Ditto.
* testsuite/gas/i386/x86-64-avx512pf.s: Ditto.
* testsuite/gas/i386/x86-64-avx512vbmi.s: Ditto.
* testsuite/gas/i386/x86-64-avx512vbmi2.s: Ditto.
* testsuite/gas/i386/x86-64-avx512vbmi2_vl.s: Ditto.
* testsuite/gas/i386/x86-64-avx512vbmi_vl.s: Ditto.
* testsuite/gas/i386/x86-64-avx512vl_gfni.s: Ditto.
* testsuite/gas/i386/x86-64-avx512vl_vaes.s: Ditto.
* testsuite/gas/i386/x86-64-avx512vl_vpclmulqdq.s: Ditto.
* testsuite/gas/i386/x86-64-avx512vnni.s: Ditto.
* testsuite/gas/i386/x86-64-avx512vnni_vl.s: Ditto.
* testsuite/gas/i386/x86-64-avx_gfni.s: Ditto.
* testsuite/gas/i386/x86-64-bmi.s: Ditto.
* testsuite/gas/i386/x86-64-bmi2.s: Ditto.
* testsuite/gas/i386/x86-64-cldemote.s: Ditto.
* testsuite/gas/i386/x86-64-clflushopt.s: Ditto.
* testsuite/gas/i386/x86-64-clwb.s: Ditto.
* testsuite/gas/i386/x86-64-cmpccxadd.s: Ditto.
* testsuite/gas/i386/x86-64-enqcmd-inval.l: Ditto.
* testsuite/gas/i386/x86-64-enqcmd-inval.s: Ditto.
* testsuite/gas/i386/x86-64-enqcmd.s: Ditto.
* testsuite/gas/i386/x86-64-evex-lig-2.s: Ditto.
* testsuite/gas/i386/x86-64-evex-lig.s: Ditto.
* testsuite/gas/i386/x86-64-evex-wig.s: Ditto.
* testsuite/gas/i386/x86-64-evex-wig2.s: Ditto.
* testsuite/gas/i386/x86-64-fma-scalar.s: Ditto.
* testsuite/gas/i386/x86-64-fma.s: Ditto.
* testsuite/gas/i386/x86-64-fma4.s: Ditto.
* testsuite/gas/i386/x86-64-fred.s: Ditto.
* testsuite/gas/i386/x86-64-gfni.s: Ditto.
* testsuite/gas/i386/x86-64-hle.s: Ditto.
* testsuite/gas/i386/x86-64-lkgs.s: Ditto.
* testsuite/gas/i386/x86-64-lwp.s: Ditto.
* testsuite/gas/i386/x86-64-movdir.s: Ditto.
* testsuite/gas/i386/x86-64-movdir64b-reg.l: Ditto.
* testsuite/gas/i386/x86-64-movdir64b-reg.s: Ditto.
* testsuite/gas/i386/x86-64-mpx-inval-1.l: Ditto.
* testsuite/gas/i386/x86-64-mpx-inval-1.s: Ditto.
* testsuite/gas/i386/x86-64-mpx-inval-2.l: Ditto.
* testsuite/gas/i386/x86-64-mpx-inval-2.s: Ditto.
* testsuite/gas/i386/x86-64-mpx.s: Ditto.
* testsuite/gas/i386/x86-64-notrack.s: Ditto.
* testsuite/gas/i386/x86-64-notrackbad.l: Ditto.
* testsuite/gas/i386/x86-64-notrackbad.s: Ditto.
* testsuite/gas/i386/x86-64-optimize-1.s: Ditto.
* testsuite/gas/i386/x86-64-optimize-2.s: Ditto.
* testsuite/gas/i386/x86-64-optimize-3.s: Ditto.
* testsuite/gas/i386/x86-64-optimize-4.s: Ditto.
* testsuite/gas/i386/x86-64-optimize-7.s: Ditto.
* testsuite/gas/i386/x86-64-optimize-7a.l: Ditto.
* testsuite/gas/i386/x86-64-optimize-8.l: Ditto.
* testsuite/gas/i386/x86-64-optimize-8.s: Ditto.
* testsuite/gas/i386/x86-64-opts.s: Ditto.
* testsuite/gas/i386/x86-64-prefetchi-warn.s: Ditto.
* testsuite/gas/i386/x86-64-prefetchi.s: Ditto.
* testsuite/gas/i386/x86-64-prefetchwt1.s: Ditto.
* testsuite/gas/i386/x86-64-raoint.s: Ditto.
* testsuite/gas/i386/x86-64-sha.s: Ditto.
* testsuite/gas/i386/x86-64-sse2avx.s: Ditto.
* testsuite/gas/i386/x86-64-tbm.s: Ditto.
* testsuite/gas/i386/x86-64-vaes.s: Ditto.
* testsuite/gas/i386/x86-64-vex-lig-2.s: Ditto.
* testsuite/gas/i386/x86-64-vp2intersect-inval-bcast.l: Ditto.
* testsuite/gas/i386/x86-64-vp2intersect-inval-bcast.s: Ditto.
* testsuite/gas/i386/x86-64-vpclmulqdq.s: Ditto.
* testsuite/gas/i386/x86-64-xop.s: Ditto.
* testsuite/gas/i386/x86-64-xsavec.s: Ditto.
* testsuite/gas/i386/x86-64-xsaves.s: Ditto.
* testsuite/gas/i386/xop.s: Ditto.
* testsuite/gas/i386/xsavec.s: Ditto.
* testsuite/gas/i386/xsaves.s: Ditto.

5 months agotestsuite: Clean up #as in dump file for i386 tests
Haochen Jiang [Tue, 28 Nov 2023 05:28:45 +0000 (13:28 +0800)] 
testsuite: Clean up #as in dump file for i386 tests

gas/ChangeLog:

* testsuite/gas/i386/avx-gather-intel.d: Remove unused #as.
* testsuite/gas/i386/avx-gather.d: Ditto.
* testsuite/gas/i386/avx-ifma-intel.d: Ditto.
* testsuite/gas/i386/avx-ifma.d: Ditto.
* testsuite/gas/i386/avx-ne-convert-intel.d: Ditto.
* testsuite/gas/i386/avx-ne-convert.d: Ditto.
* testsuite/gas/i386/avx-vnni-int8-intel.d: Ditto.
* testsuite/gas/i386/avx-vnni-int8.d: Ditto.
* testsuite/gas/i386/avx512_bf16.d: Ditto.
* testsuite/gas/i386/avx512_bf16_vl.d: Ditto.
* testsuite/gas/i386/avx512_fp16-intel.d: Ditto.
* testsuite/gas/i386/avx512_fp16.d: Ditto.
* testsuite/gas/i386/avx512_fp16_pseudo_ops.d: Ditto.
* testsuite/gas/i386/avx512_fp16_vl-intel.d: Ditto.
* testsuite/gas/i386/avx512_fp16_vl.d: Ditto.
* testsuite/gas/i386/avx512_vpopcntdq-intel.d: Ditto.
* testsuite/gas/i386/avx512_vpopcntdq.d: Ditto.
* testsuite/gas/i386/avx512bitalg-intel.d: Ditto.
* testsuite/gas/i386/avx512bitalg.d: Ditto.
* testsuite/gas/i386/avx512bitalg_vl-intel.d: Ditto.
* testsuite/gas/i386/avx512bitalg_vl.d: Ditto.
* testsuite/gas/i386/avx512bw-opts-intel.d: Ditto.
* testsuite/gas/i386/avx512bw-opts.d: Ditto.
* testsuite/gas/i386/avx512bw_vl-intel.d: Ditto.
* testsuite/gas/i386/avx512bw_vl-opts-intel.d: Ditto.
* testsuite/gas/i386/avx512bw_vl-opts.d: Ditto.
* testsuite/gas/i386/avx512bw_vl.d: Ditto.
* testsuite/gas/i386/avx512cd-intel.d: Ditto.
* testsuite/gas/i386/avx512cd.d: Ditto.
* testsuite/gas/i386/avx512cd_vl-intel.d: Ditto.
* testsuite/gas/i386/avx512cd_vl.d: Ditto.
* testsuite/gas/i386/avx512dq-intel.d: Ditto.
* testsuite/gas/i386/avx512dq.d: Ditto.
* testsuite/gas/i386/avx512dq_vl-intel.d: Ditto.
* testsuite/gas/i386/avx512dq_vl.d: Ditto.
* testsuite/gas/i386/avx512er-intel.d: Ditto.
* testsuite/gas/i386/avx512er.d: Ditto.
* testsuite/gas/i386/avx512f-nondef.d: Ditto.
* testsuite/gas/i386/avx512f-opts-intel.d: Ditto.
* testsuite/gas/i386/avx512f-opts.d: Ditto.
* testsuite/gas/i386/avx512f_gfni-intel.d: Ditto.
* testsuite/gas/i386/avx512f_gfni.d: Ditto.
* testsuite/gas/i386/avx512f_vaes-intel.d: Ditto.
* testsuite/gas/i386/avx512f_vaes.d: Ditto.
* testsuite/gas/i386/avx512f_vl-intel.d: Ditto.
* testsuite/gas/i386/avx512f_vl-opts-intel.d: Ditto.
* testsuite/gas/i386/avx512f_vl-opts.d: Ditto.
* testsuite/gas/i386/avx512f_vl.d: Ditto.
* testsuite/gas/i386/avx512f_vpclmulqdq-intel.d: Ditto.
* testsuite/gas/i386/avx512f_vpclmulqdq.d: Ditto.
* testsuite/gas/i386/avx512ifma-intel.d: Ditto.
* testsuite/gas/i386/avx512ifma.d: Ditto.
* testsuite/gas/i386/avx512ifma_vl-intel.d: Ditto.
* testsuite/gas/i386/avx512ifma_vl.d: Ditto.
* testsuite/gas/i386/avx512pf-intel.d: Ditto.
* testsuite/gas/i386/avx512pf.d: Ditto.
* testsuite/gas/i386/avx512vbmi-intel.d: Ditto.
* testsuite/gas/i386/avx512vbmi.d: Ditto.
* testsuite/gas/i386/avx512vbmi2-intel.d: Ditto.
* testsuite/gas/i386/avx512vbmi2.d: Ditto.
* testsuite/gas/i386/avx512vbmi2_vl-intel.d: Ditto.
* testsuite/gas/i386/avx512vbmi2_vl.d: Ditto.
* testsuite/gas/i386/avx512vbmi_vl-intel.d: Ditto.
* testsuite/gas/i386/avx512vbmi_vl.d: Ditto.
* testsuite/gas/i386/avx512vl_gfni-intel.d: Ditto.
* testsuite/gas/i386/avx512vl_gfni.d: Ditto.
* testsuite/gas/i386/avx512vl_vaes-intel.d: Ditto.
* testsuite/gas/i386/avx512vl_vaes.d: Ditto.
* testsuite/gas/i386/avx512vl_vpclmulqdq-intel.d: Ditto.
* testsuite/gas/i386/avx512vl_vpclmulqdq.d: Ditto.
* testsuite/gas/i386/avx512vnni-intel.d: Ditto.
* testsuite/gas/i386/avx512vnni.d: Ditto.
* testsuite/gas/i386/avx512vnni_vl-intel.d: Ditto.
* testsuite/gas/i386/avx512vnni_vl.d: Ditto.
* testsuite/gas/i386/bmi-intel.d: Ditto.
* testsuite/gas/i386/bmi.d: Ditto.
* testsuite/gas/i386/bmi2-intel.d: Ditto.
* testsuite/gas/i386/bmi2.d: Ditto.
* testsuite/gas/i386/cldemote-intel.d: Ditto.
* testsuite/gas/i386/cldemote.d: Ditto.
* testsuite/gas/i386/clflushopt-intel.d: Ditto.
* testsuite/gas/i386/clflushopt.d: Ditto.
* testsuite/gas/i386/clwb-intel.d: Ditto.
* testsuite/gas/i386/clwb.d: Ditto.
* testsuite/gas/i386/enqcmd-intel.d: Ditto.
* testsuite/gas/i386/enqcmd.d: Ditto.
* testsuite/gas/i386/gfni-intel.d: Ditto.
* testsuite/gas/i386/gfni.d: Ditto.
* testsuite/gas/i386/hreset.d: Ditto.
* testsuite/gas/i386/invpcid-intel.d: Ditto.
* testsuite/gas/i386/invpcid.d: Ditto.
* testsuite/gas/i386/keylocker-intel.d: Ditto.
* testsuite/gas/i386/keylocker.d: Ditto.
* testsuite/gas/i386/movdir-intel.d: Ditto.
* testsuite/gas/i386/movdir.d: Ditto.
* testsuite/gas/i386/pr27198.d: Ditto.
* testsuite/gas/i386/pr30248.d: Ditto.
* testsuite/gas/i386/prefetchwt1-intel.d: Ditto.
* testsuite/gas/i386/prefetchwt1.d: Ditto.
* testsuite/gas/i386/ptwrite-intel.d: Ditto.
* testsuite/gas/i386/ptwrite.d: Ditto.
* testsuite/gas/i386/raoint-intel.d: Ditto.
* testsuite/gas/i386/raoint.d: Ditto.
* testsuite/gas/i386/serialize.d: Ditto.
* testsuite/gas/i386/tbm-intel.d: Ditto.
* testsuite/gas/i386/tdx.d: Ditto.
* testsuite/gas/i386/tsxldtrk.d: Ditto.
* testsuite/gas/i386/vp2intersect-intel.d: Ditto.
* testsuite/gas/i386/vp2intersect.d: Ditto.
* testsuite/gas/i386/vpclmulqdq-intel.d: Ditto.
* testsuite/gas/i386/vpclmulqdq.d: Ditto.
* testsuite/gas/i386/waitpkg-intel.d: Ditto.
* testsuite/gas/i386/waitpkg.d: Ditto.
* testsuite/gas/i386/wrmsrns-intel.d: Ditto.
* testsuite/gas/i386/wrmsrns.d: Ditto.
* testsuite/gas/i386/x86-64-amx-bad.d: Ditto.
* testsuite/gas/i386/x86-64-amx-complex-bad.d: Ditto.
* testsuite/gas/i386/x86-64-amx-complex-intel.d: Ditto.
* testsuite/gas/i386/x86-64-amx-complex.d: Ditto.
* testsuite/gas/i386/x86-64-amx-fp16-bad.d: Ditto.
* testsuite/gas/i386/x86-64-amx-fp16-intel.d: Ditto.
* testsuite/gas/i386/x86-64-amx-fp16.d: Ditto.
* testsuite/gas/i386/x86-64-amx-intel.d: Ditto.
* testsuite/gas/i386/x86-64-amx.d: Ditto.
* testsuite/gas/i386/x86-64-avx-gather-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx-gather.d: Ditto.
* testsuite/gas/i386/x86-64-avx-ifma-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx-ifma.d: Ditto.
* testsuite/gas/i386/x86-64-avx-ne-convert-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx-ne-convert.d: Ditto.
* testsuite/gas/i386/x86-64-avx-vnni-int8-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx-vnni-int8.d: Ditto.
* testsuite/gas/i386/x86-64-avx512_bf16.d: Ditto.
* testsuite/gas/i386/x86-64-avx512_bf16_vl.d: Ditto.
* testsuite/gas/i386/x86-64-avx512_fp16-bad.d: Ditto.
* testsuite/gas/i386/x86-64-avx512_fp16-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512_fp16.d: Ditto.
* testsuite/gas/i386/x86-64-avx512_fp16_pseudo_ops.d: Ditto.
* testsuite/gas/i386/x86-64-avx512_fp16_vl-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512_fp16_vl.d: Ditto.
* testsuite/gas/i386/x86-64-avx512_vpopcntdq-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512_vpopcntdq.d: Ditto.
* testsuite/gas/i386/x86-64-avx512bitalg-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512bitalg.d: Ditto.
* testsuite/gas/i386/x86-64-avx512bitalg_vl-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512bitalg_vl.d: Ditto.
* testsuite/gas/i386/x86-64-avx512bw-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512bw-opts-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512bw-opts.d: Ditto.
* testsuite/gas/i386/x86-64-avx512bw.d: Ditto.
* testsuite/gas/i386/x86-64-avx512bw_vl-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512bw_vl-opts-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512bw_vl-opts.d: Ditto.
* testsuite/gas/i386/x86-64-avx512bw_vl.d: Ditto.
* testsuite/gas/i386/x86-64-avx512cd-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512cd.d: Ditto.
* testsuite/gas/i386/x86-64-avx512cd_vl-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512cd_vl.d: Ditto.
* testsuite/gas/i386/x86-64-avx512dq-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512dq.d: Ditto.
* testsuite/gas/i386/x86-64-avx512dq_vl-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512dq_vl.d: Ditto.
* testsuite/gas/i386/x86-64-avx512er-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512er.d: Ditto.
* testsuite/gas/i386/x86-64-avx512f-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512f-nondef.d: Ditto.
* testsuite/gas/i386/x86-64-avx512f-opts-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512f-opts.d: Ditto.
* testsuite/gas/i386/x86-64-avx512f.d: Ditto.
* testsuite/gas/i386/x86-64-avx512f_gfni-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512f_gfni.d: Ditto.
* testsuite/gas/i386/x86-64-avx512f_vaes-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512f_vaes.d: Ditto.
* testsuite/gas/i386/x86-64-avx512f_vl-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512f_vl-opts-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512f_vl-opts.d: Ditto.
* testsuite/gas/i386/x86-64-avx512f_vl.d: Ditto.
* testsuite/gas/i386/x86-64-avx512f_vpclmulqdq-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512f_vpclmulqdq.d: Ditto.
* testsuite/gas/i386/x86-64-avx512ifma-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512ifma.d: Ditto.
* testsuite/gas/i386/x86-64-avx512ifma_vl-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512ifma_vl.d: Ditto.
* testsuite/gas/i386/x86-64-avx512pf-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512pf.d: Ditto.
* testsuite/gas/i386/x86-64-avx512vbmi-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512vbmi.d: Ditto.
* testsuite/gas/i386/x86-64-avx512vbmi2-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512vbmi2.d: Ditto.
* testsuite/gas/i386/x86-64-avx512vbmi2_vl-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512vbmi2_vl.d: Ditto.
* testsuite/gas/i386/x86-64-avx512vbmi_vl-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512vbmi_vl.d: Ditto.
* testsuite/gas/i386/x86-64-avx512vl_gfni-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512vl_gfni.d: Ditto.
* testsuite/gas/i386/x86-64-avx512vl_vaes-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512vl_vaes.d: Ditto.
* testsuite/gas/i386/x86-64-avx512vl_vpclmulqdq-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512vl_vpclmulqdq.d: Ditto.
* testsuite/gas/i386/x86-64-avx512vnni-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512vnni.d: Ditto.
* testsuite/gas/i386/x86-64-avx512vnni_vl-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx512vnni_vl.d: Ditto.
* testsuite/gas/i386/x86-64-avx_gfni-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx_gfni.d: Ditto.
* testsuite/gas/i386/x86-64-bmi-intel.d: Ditto.
* testsuite/gas/i386/x86-64-bmi.d: Ditto.
* testsuite/gas/i386/x86-64-bmi2-intel.d: Ditto.
* testsuite/gas/i386/x86-64-bmi2.d: Ditto.
* testsuite/gas/i386/x86-64-cldemote-intel.d: Ditto.
* testsuite/gas/i386/x86-64-cldemote.d: Ditto.
* testsuite/gas/i386/x86-64-clflushopt-intel.d: Ditto.
* testsuite/gas/i386/x86-64-clflushopt.d: Ditto.
* testsuite/gas/i386/x86-64-clwb-intel.d: Ditto.
* testsuite/gas/i386/x86-64-clwb.d: Ditto.
* testsuite/gas/i386/x86-64-cmpccxadd-intel.d: Ditto.
* testsuite/gas/i386/x86-64-cmpccxadd.d: Ditto.
* testsuite/gas/i386/x86-64-fred-intel.d: Ditto.
* testsuite/gas/i386/x86-64-fred.d: Ditto.
* testsuite/gas/i386/x86-64-gfni-intel.d: Ditto.
* testsuite/gas/i386/x86-64-gfni.d: Ditto.
* testsuite/gas/i386/x86-64-hreset.d: Ditto.
* testsuite/gas/i386/x86-64-invpcid-intel.d: Ditto.
* testsuite/gas/i386/x86-64-invpcid.d: Ditto.
* testsuite/gas/i386/x86-64-keylocker-intel.d: Ditto.
* testsuite/gas/i386/x86-64-keylocker.d: Ditto.
* testsuite/gas/i386/x86-64-lkgs-intel.d: Ditto.
* testsuite/gas/i386/x86-64-lkgs.d: Ditto.
* testsuite/gas/i386/x86-64-movsxd-intel.d: Ditto.
* testsuite/gas/i386/x86-64-movsxd.d: Ditto.
* testsuite/gas/i386/x86-64-msrlist-intel.d: Ditto.
* testsuite/gas/i386/x86-64-msrlist.d: Ditto.
* testsuite/gas/i386/x86-64-prefetchi-intel.d: Ditto.
* testsuite/gas/i386/x86-64-prefetchi.d: Ditto.
* testsuite/gas/i386/x86-64-prefetchwt1-intel.d: Ditto.
* testsuite/gas/i386/x86-64-prefetchwt1.d: Ditto.
* testsuite/gas/i386/x86-64-ptwrite-intel.d: Ditto.
* testsuite/gas/i386/x86-64-ptwrite.d: Ditto.
* testsuite/gas/i386/x86-64-raoint-intel.d: Ditto.
* testsuite/gas/i386/x86-64-raoint.d: Ditto.
* testsuite/gas/i386/x86-64-serialize.d: Ditto.
* testsuite/gas/i386/x86-64-sysenter.d: Ditto.
* testsuite/gas/i386/x86-64-tbm-intel.d: Ditto.
* testsuite/gas/i386/x86-64-tdx.d: Ditto.
* testsuite/gas/i386/x86-64-tsxldtrk.d: Ditto.
* testsuite/gas/i386/x86-64-uintr.d: Ditto.
* testsuite/gas/i386/x86-64-vp2intersect-intel.d: Ditto.
* testsuite/gas/i386/x86-64-vp2intersect.d: Ditto.
* testsuite/gas/i386/x86-64-vpclmulqdq-intel.d: Ditto.
* testsuite/gas/i386/x86-64-vpclmulqdq.d: Ditto.
* testsuite/gas/i386/x86-64-waitpkg-intel.d: Ditto.
* testsuite/gas/i386/x86-64-waitpkg.d: Ditto.
* testsuite/gas/i386/x86-64-wrmsrns-intel.d: Ditto.
* testsuite/gas/i386/x86-64-wrmsrns.d: Ditto.
* testsuite/gas/i386/x86-64-xsavec-intel.d: Ditto.
* testsuite/gas/i386/x86-64-xsavec.d: Ditto.
* testsuite/gas/i386/x86-64-xsaves-intel.d: Ditto.
* testsuite/gas/i386/x86-64-xsaves.d: Ditto.
* testsuite/gas/i386/xsavec-intel.d: Ditto.
* testsuite/gas/i386/xsavec.d: Ditto.
* testsuite/gas/i386/xsaves-intel.d: Ditto.
* testsuite/gas/i386/xsaves.d: Ditto.

5 months agoAutomatic date update in version.in
GDB Administrator [Tue, 28 Nov 2023 00:00:24 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoi386: Use a fallback XSAVE layout for remote targets
John Baldwin [Mon, 27 Nov 2023 21:53:22 +0000 (13:53 -0800)] 
i386: Use a fallback XSAVE layout for remote targets

If a target provides a target description including registers from the
XSAVE extended region, but does not provide an XSAVE layout, use a
fallback XSAVE layout based on the included registers.  This fallback
layout matches GDB's behavior in earlier releases which assumes the
layout from Intel CPUs.

This fallback layout is currently only used for remote targets since
native targets which support XSAVE provide an explicit layout derived
from CPUID.

PR gdb/30912
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30912
Approved-By: Simon Marchi <simon.marchi@efficios.com>
5 months ago[gdb/testsuite] Add boards/cc-with-index-cache.exp
Tom de Vries [Mon, 27 Nov 2023 20:15:26 +0000 (21:15 +0100)] 
[gdb/testsuite] Add boards/cc-with-index-cache.exp

We have a target board cc-with-gdb-index that uses the gdb-add-index script to
add a .gdb_index index to an exec.

There is however an alternative way of adding a .gdb_index: the index-cache.

Add a new target board cc-with-index-cache.

This is not superfluous for two reasons:
- there is functionality that gdb-add-index doesn't support, but the
  index-cache does: the index-cache can add an index to an exec with a
  .gnu_debugaltlink (note that when using the cc-with-gdb-index board this
  case is quietly ignored), and
- using the index-cache is excercised in only a few test-cases, and having
  this target board extends the test coverage to the entire test suite.  This
  is for instance relevant because the index-cache is written by a worker
  thread in the background, so we can check more thoroughly for data races
  (see PR symtab/30837).

Tested on x86_64-linux.

Shell script changes checked with shellcheck.

Approved-By: Tom Tromey <tom@tromey.com>
5 months agoChange serial_readchar to throw
Tom Tromey [Tue, 29 Aug 2023 14:22:09 +0000 (08:22 -0600)] 
Change serial_readchar to throw

This changes serial_readchar to throw an exception rather than trying
to set and preserve errno.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30770

5 months agoChange serial_send_break and serial_write to throw
Tom Tromey [Wed, 6 Sep 2023 14:33:46 +0000 (08:33 -0600)] 
Change serial_send_break and serial_write to throw

This changes serial_send_break and serial_write to throw exceptions
rather than attempt to set errno and return an error indicator.  This
lets us correctly report failures on Windows.

Both functions had to be converted in a single patch because one
implementation of send_break works via write.

This also introduces remote_serial_send_break to handle error checking
when attempting to send a break.  This was previously ignored.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30770

5 months agoChange serial "open" functions to throw exception
Tom Tromey [Fri, 1 Sep 2023 18:11:37 +0000 (12:11 -0600)] 
Change serial "open" functions to throw exception

remote.c assumes that a failure to open the serial connection will set
errno.  This is somewhat true, because the Windows code tries to set
errno appropriately -- but only somewhat, because it isn't clear that
the "pex" code sets it, and the tcp code seems to do the wrong thing.
It seems better to simply have the serial open functions throw on
error.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30770

5 months agoChange serial_setbaudrate to throw exception
Tom Tromey [Tue, 29 Aug 2023 13:20:22 +0000 (07:20 -0600)] 
Change serial_setbaudrate to throw exception

remote.c has this code:

      if (serial_setbaudrate (rs->remote_desc, baud_rate))
{
  /* The requested speed could not be set.  Error out to
     top level after closing remote_desc.  Take care to
     set remote_desc to NULL to avoid closing remote_desc
     more than once.  */
  serial_close (rs->remote_desc);
  rs->remote_desc = NULL;
  perror_with_name (name);

The perror here cannot be correct, because if serial_setbaudrate did
set errno, it may be obscured by serial_close.

This patch changes serial_setbaudrate to throw an exception instead.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30770

5 months agoIntroduce throw_winerror_with_name
Tom Tromey [Fri, 1 Sep 2023 17:01:33 +0000 (11:01 -0600)] 
Introduce throw_winerror_with_name

This introduces throw_winerror_with_name, a Windows analog of
perror_with_name, and changes various places in gdb to call it.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30770

5 months agoFix latent bug in ser_windows_send_break
Tom Tromey [Fri, 1 Sep 2023 17:04:58 +0000 (11:04 -0600)] 
Fix latent bug in ser_windows_send_break

The ClearCommBreak documentation says:

    If the function fails, the return value is zero.

ser_windows_send_break inverts this check.  This has never been
noticed because the caller doesn't check the result.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30770

5 months agoFix bug in DAP handling of 'pause' requests
Tom Tromey [Fri, 17 Nov 2023 17:08:50 +0000 (10:08 -0700)] 
Fix bug in DAP handling of 'pause' requests

While working on cancellation, I noticed that a DAP 'pause' request
would set the "do not emit the continue" flag.  This meant that a
subsequent request that should provoke a 'continue' event would
instead suppress the event.

I then tried writing a more obvious test case for this, involving an
inferior call -- and discovered that gdb.events.cont does not fire for
an inferior call.

This patch installs a new event listener for gdb.events.inferior_call
and arranges for this to emit continue and stop events when
appropriate.  It also fixes the original bug, by adding a check to
exec_and_expect_stop.

5 months agogdb: make catch_syscall_enabled return bool
Simon Marchi [Mon, 27 Nov 2023 15:45:51 +0000 (15:45 +0000)] 
gdb: make catch_syscall_enabled return bool

Make it return a bool and adjust a few comparisons where it's used.

Change-Id: Ic77d23b0dcfcfc9195dfe65e4c7ff9cf3229f6fb

5 months agogdb/python: handle completion returning a non-sequence
Andrew Burgess [Thu, 16 Nov 2023 14:42:56 +0000 (14:42 +0000)] 
gdb/python: handle completion returning a non-sequence

GDB's Python API documentation for gdb.Command.complete() says:

  The 'complete' method can return several values:
     * If the return value is a sequence, the contents of the
       sequence are used as the completions.  It is up to 'complete'
       to ensure that the contents actually do complete the word.  A
       zero-length sequence is allowed, it means that there were no
       completions available.  Only string elements of the sequence
       are used; other elements in the sequence are ignored.

     * If the return value is one of the 'COMPLETE_' constants
       defined below, then the corresponding GDB-internal completion
       function is invoked, and its result is used.

     * All other results are treated as though there were no
       available completions.

So, returning a non-sequence, and non-integer from a complete method
should be fine; it should just be treated as though there are no
completions.

However, if I write a complete method that returns None, I see this
behaviour:

  (gdb) complete completefilenone x
  Python Exception <class 'TypeError'>: 'NoneType' object is not iterable
  warning: internal error: Unhandled Python exception
  (gdb)

Which is caused because we currently assume that anything that is not
an integer must be iterable, and we call PyObject_GetIter on it.  When
this call fails a Python exception is set, but instead of
clearing (and therefore ignoring) this exception as we do everywhere
else in the Python completion code, we instead just return with the
exception set.

In this commit I add a PySequence_Check call.  If this call returns
false (and we've already checked the integer case) then we can assume
there are no completion results.

I've added a test which checks returning a non-sequence.

Approved-By: Tom Tromey <tom@tromey.com>
5 months agoas: Add new estimated reciprocal instructions in LoongArch v1.1
Jiajie Chen [Thu, 26 Oct 2023 09:35:14 +0000 (17:35 +0800)] 
as: Add new estimated reciprocal instructions in LoongArch v1.1

New estimated reciprocal instructions in LoongArch v1.1:

- frecipe.s/d
- frsqrte.s/d
- vfrecipe.s/d
- vfrsqrte.s/d
- xvfrecipe.s/d
- xvfrsqrte.s/d

Signed-off-by: Jiajie Chen <c@jia.je>
5 months agoas: Add new atomic instructions in LoongArch v1.1
Jiajie Chen [Thu, 26 Oct 2023 09:35:13 +0000 (17:35 +0800)] 
as: Add new atomic instructions in LoongArch v1.1

LoongArch V1.1 release is out at
https://github.com/loongson/LoongArch-Documentation.

New atomic instructions in LoongArch v1.1:

- sc.q
- llacq.w/d
- screl.w/d
- amcas{_db}.b/h/w/d
- amswap{_db}.b/h
- amadd{_db}.b/h

Signed-off-by: Jiajie Chen <c@jia.je>
5 months agoAutomatic date update in version.in
GDB Administrator [Mon, 27 Nov 2023 00:00:15 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoAutomatic date update in version.in
GDB Administrator [Sun, 26 Nov 2023 00:00:12 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoAutomatic date update in version.in
GDB Administrator [Sat, 25 Nov 2023 00:00:11 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months ago[gdb/testsuite] Use more %progbits for arm
Tom de Vries [Fri, 24 Nov 2023 14:41:22 +0000 (15:41 +0100)] 
[gdb/testsuite] Use more %progbits for arm

On pinebook I ran into:
...
Running gdb.tui/tui-layout-asm-short-prog.exp ...
gdb compile failed, gdb.tui/tui-layout-asm-short-prog.S: Assembler messages:
gdb.tui/tui-layout-asm-short-prog.S:23: Error: \
  junk at end of line, first unrecognized character is `,'
...

Fix this by using %progbits instead of @progbits for arm.

Approved-by: Luis Machado <luis.machado@arm.com>
Tested on x86_64-linux and pinebook.

5 months ago[gdb/testsuite] Two fixes in gdb.python/tui-window-disabled.exp
Tom de Vries [Fri, 24 Nov 2023 14:38:17 +0000 (15:38 +0100)] 
[gdb/testsuite] Two fixes in gdb.python/tui-window-disabled.exp

I ran test-case gdb.python/tui-window-disabled.exp on a configuration without
python support, and ran into:
...
PASS: $exp: cleanup_properly=True: initial restart: set pagination off
UNSUPPORTED: $exp: cleanup_properly=True: couldn't restart GDB
PASS: $exp: cleanup_properly=False: initial restart: set pagination off
UNSUPPORTED: $exp: cleanup_properly=False: couldn't restart GDB
...

After looking into the test-case, I realized that this is a consequence of
!allow_python_tests.

Handle this instead by requiring allow_python_tests, such that we get the usual
and more clear:
...
UNSUPPORTED: $exp: require failed: allow_python_tests
...

Also fix a return without value in clean_restart_and_setup, which if triggered
would cause:
...
ERROR: expected boolean value but got ""
...

Tested on x86_64-linux.

5 months agogdb: Fix "target file /proc/.../cmdline contained unexpected null characters"
Ilya Leoshkevich [Wed, 19 Jul 2023 11:27:45 +0000 (13:27 +0200)] 
gdb: Fix "target file /proc/.../cmdline contained unexpected null characters"

When using the gcore command, GDB prints the following warning:

    (gdb) gcore
    warning: target file /proc/.../cmdline contained unexpected null characters

The reason is that cmdline is read with target_fileio_read_stralloc(),
which warns on seeing null characters. However, it's perfectly valid
for cmdline to contain \0s, so switch to target_fileio_read_alloc().

Approved-By: Tom Tromey <tom@tromey.com>
5 months agoRISC-V: drop leftover match_never() references
Jan Beulich [Fri, 24 Nov 2023 09:15:59 +0000 (10:15 +0100)] 
RISC-V: drop leftover match_never() references

Commit 27b33966b18e "RISC-V: disallow x0 with certain macro-insns"
wasn't properly re-based over recent opcode table additions.

5 months agox86: shrink opcode sets table
Jan Beulich [Fri, 24 Nov 2023 08:55:51 +0000 (09:55 +0100)] 
x86: shrink opcode sets table

Have i386-gen produce merely the offsets into i386_optab[]. Besides
allowing to shrink the table even on 32-bit builds, this results in
removing a level of indirection from the frequently accessed
current_templates, in return for adding a level of indirection when
looking up mnemonics (commonly happening just once per insn). Plus for
PIE builds of gas it also reduces the number of relocations by about two
thousand. Finally a somewhat ugly static variable can also be eliminated
from i386_displacement().

5 months agox86: also prefer VEX encoding over EVEX one for VCVTNEPS2BF16 when possible
Jan Beulich [Fri, 24 Nov 2023 08:55:29 +0000 (09:55 +0100)] 
x86: also prefer VEX encoding over EVEX one for VCVTNEPS2BF16 when possible

Deal with what 58bceb182740 ("x86: prefer VEX encodings over EVEX ones
when possible") left out, for being slightly less straightforward.

5 months agoRISC-V: reduce redundancy in sign/zero extension macro insn handling
Jan Beulich [Fri, 24 Nov 2023 08:53:55 +0000 (09:53 +0100)] 
RISC-V: reduce redundancy in sign/zero extension macro insn handling

Fold M_{S,Z}EXTH, deriving signed-ness from the incoming mnemonic. Fold
riscv_ext()'s calls md_assemblef(), the first of which were entirely
identical, while the other pair differed in just a single character.

Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
5 months agoRISC-V: disallow x0 with certain macro-insns
Jan Beulich [Fri, 24 Nov 2023 08:53:15 +0000 (09:53 +0100)] 
RISC-V: disallow x0 with certain macro-insns

While for some of the macro insns using x0 is kind of okay, as they
would merely resolve to a sequence of hint insns (and hence not cause
misbehavior at runtime), several of them have the degenerate AUIPC
followed by a load, store, or branch using other than the designated
symbol as address and hence causing runtime issues. Refuse to assemble
those, leveraging that the matching function so far wasn't really used
for macro insns: NULL is now allowed, indicating a match (which imo is
preferable over converting match_never() to match_always()), while
other matching functions now (also) used for macro insns need to avoid
calling match_opcode().

Note that for LA the restriction is slightly too strict: In non-PIC mode
using x0 would be okay-ish as per above (as it's just LLA there). Yet
libopcodes doesn't know what mode gas is presently assembling for, so we
want to err on the safe side.

Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
5 months agoFix building for the s390 target with clang
Nick Clifton [Fri, 24 Nov 2023 08:10:12 +0000 (08:10 +0000)] 
Fix building for the s390 target with clang

5 months agoRISC-V: Update 'Zfa' extension version
zengxiao [Tue, 21 Nov 2023 06:11:21 +0000 (14:11 +0800)] 
RISC-V: Update 'Zfa' extension version

Because the 'Zfa' extension has a version number of 1.0
(not 0.1). This commit updates the number.

bfd/ChangeLog:

            * elfxx-riscv.c (riscv_supported_std_z_ext): Update the version
            number of the 'Zfa' extension since it's ratified.

5 months agoAutomatic date update in version.in
GDB Administrator [Fri, 24 Nov 2023 00:00:10 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agos390: Correct prno instruction name
Jens Remus [Thu, 23 Nov 2023 14:48:59 +0000 (15:48 +0100)] 
s390: Correct prno instruction name

IBM z13 (arch11) introduced ppno (Perform Pseudorandom Number Operation).
IBM z14 (arch12) introduced prno (Perform Random Number Operation) and
deprecated ppno.

opcodes/
* s390-opc.txt: Correct prno instruction name.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
5 months agos390: Add missing extended mnemonics
Jens Remus [Thu, 23 Nov 2023 14:48:15 +0000 (15:48 +0100)] 
s390: Add missing extended mnemonics

Add extended mnemonics specified in the z/Architecture Principles of
Operation [1] and z/Architecture Reference Summary [2], that were
previously missing from the opcode table.

The following added extended mnemonics are synonyms to a base mnemonic
and therefore disassemble into their base mnemonic:
jc, jcth, lfi, llgfi, llghi

The following added extended mnemonics are more specific than their base
mnemonic and therefore disassemble into the added extended mnemonic:
risbhgz, risblgz, rnsbgt, rosbgt, rxsbgt

The following added extended mnemonics are more specific than their base
mnemonic, but disassemble into their base mnemonic due to design
constraints:
notr, notgr

The missing extended mnemonic jl* conditional jump long flavors cannot
be added, as they would clash with the existing non-standard extended
mnemonic j* conditional jump flavors jle and jlh. The missing extended
mnemonic jlc jump long conditional is not added, as the related jl*
flavors cannot be added.
Note that these missing jl* conditional jump long flavors are already
defined as non-standard jg* flavors instead. While the related missing
extended mnemonic jlc could be added as non-standard jgc instead it is
forgone in favor of not adding further non-standard mnemonics.

The missing extended mnemonics sllhh, sllhl, slllh, srlhh, srlhl, and
srllh cannot be implemented using the current design, as they require
computed operands. For that reason the following missing extended
mnemonics are not added as well, as they fall into the same category of
instructions that operate on high and low words of registers. They
should better be added together, not to confuse the user, which of those
instructions are currently implemented or not.
lhhr, lhlr, llhfr, llchhr, llchlr, llclhr, llhhhr, llhhlr, llhlhr,
nhhr, nhlr, nlhr, ohhr, ohlr, olhr, xhhr, xhlr, xlhr

[1] IBM z/Architecture Principles of Operation, SA22-7832-13, IBM z16,
    https://publibfp.dhe.ibm.com/epubs/pdf/a227832d.pdf
[2] IBM z/Architecture Reference Summary, SA22-7871-11,
    https://www.ibm.com/support/pages/sites/default/files/2022-09/SA22-7871-11.pdf

opcodes/
* s390-opc.c: Define operand formats R_CP16_28, U6_18, and
  U5_27. Define instruction formats RIE_RRUUU3, RIE_RRUUU4,
  and RRF_R0RR4.
* s390-opc.txt: Add extended mnemonics jc, jcth, lfi, llgfi,
  llghi, notgr, notr, risbhgz, risblgz, rnsbgt, rosbgt, and
  rxsbgt.

gas/
* config/tc-s390.c: Add support to insert operand for format
  R_CP16_28, reusing existing logic for format V_CP16_12.
* testsuite/gas/s390/esa-g5.s: Add test for extended mnemonic
  jc.
* testsuite/gas/s390/esa-g5.d: Likewise.
* testsuite/gas/s390/zarch-z900.s: Add test for extended
  mnemonic llghi.
* testsuite/gas/s390/zarch-z900.d: Likewise.
* testsuite/gas/s390/zarch-z9-109.s: Add tests for extended
  mnemonics lfi and llgfi.
* testsuite/gas/s390/zarch-z9-109.d: Likewise.
* testsuite/gas/s390/zarch-z10.s: Add tests for extended
  mnemonics rnsbgt, rosbgt, and rxsbgt.
* testsuite/gas/s390/zarch-z10.d: Likewise.
* testsuite/gas/s390/zarch-z196.s: Add tests for extended
  mnemonics jcth, risbhgz, and risblgz.
* testsuite/gas/s390/zarch-z196.d: Likewise.
* testsuite/gas/s390/zarch-arch13.s: Add tests for extended
  mnemonics notr and notgr.
* testsuite/gas/s390/zarch-arch13.d: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
5 months agos390: Align optional operand definition to specs
Jens Remus [Thu, 23 Nov 2023 14:46:46 +0000 (15:46 +0100)] 
s390: Align optional operand definition to specs

The IBM z/Architecture Principle of Operation [1] specifies the last
operand(s) of some (extended) mnemonics to be optional. Align the
mnemonic definitions in the opcode table according to specification.

This changes the last operand of the following (extended) mnemonics to
be optional:
risbg, risbgz, risbgn, risbgnz, risbhg, risblg, rnsbg, rosbg, rxsbg

Note that efpc and sfpc actually have only one operand, but had
erroneously been defined to have two. For backwards compatibility the
wrong RR register format must be retained. Since the superfluous second
operand is defined as optional the instruction can still be coded as
specified.

[1]: IBM z/Architecture Principles of Operation, SA22-7832-13, IBM z16,
     https://publibfp.dhe.ibm.com/epubs/pdf/a227832d.pdf

opcodes/
* s390-opc.txt: Align optional operand definition to
specification.

testsuite/
* zarch-z10.s: Add test cases for risbg, risbgz, rnsbg, rosbg,
  and rxsbg.
* zarch-z10.d: Likewise.
* zarch-z196.s: Add test cases for risbhg and risblg.
* zarch-z196.d: Likewise.
* zarch-zEC12.s: Add test cases for risbgn and risbgnz.
* zarch-zEC12.d: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
5 months agos390: Make operand table indices relative to each other
Jens Remus [Thu, 23 Nov 2023 14:45:42 +0000 (15:45 +0100)] 
s390: Make operand table indices relative to each other

This is a purely mechanical change. It allows subsequent insertions into
the operands table without having to renumber all operand indices.

The only differences in the resulting ELF object are in the .debug_info
section. This has been confirmed by diffing the following xxd and readelf
output:

xxd s390-opc.o
readelf -aW -x .text -x .data -x .bss -x .rodata -x .debug_info \
  -x .symtab -x .strtab -x .shstrtab --debug-dump s390-opc.o

opcodes/
* s390-opc.c: Make operand table indices relative to each other.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
5 months agos390: Add brasl edge test cases from ESA to z/Architecture
Jens Remus [Thu, 23 Nov 2023 14:44:41 +0000 (15:44 +0100)] 
s390: Add brasl edge test cases from ESA to z/Architecture

The ESA opcode test cases for IBM z900 contain a few edge cases. They
exercise the brasl mnemonic with its largest allowed negative and
positive offsets. Linux on zSeries in ESA mode executes in 31-bit
addressing mode. Therefore the ESA test cases are assembled with -m31.
In 31-bit addressing mode the address computation using those large
offsets wraps, which is correctly reflected in the disassembly.

Linux on Z in z/Architecture mode executes in 64-bit addressing mode.
Therefore the z/Architecture (zarch) test cases are assembled with -m64.
In 64-bit addressing mode the address computation using those large
offsets does not necessarily wrap.

gas/
* testsuite/gas/s390/zarch-z900.s: Add brasl tests from ESA that
  exercise edge cases.
* testsuite/gas/s390/zarch-z900.d: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
5 months agos390: Position independent verification of relative addressing
Jens Remus [Thu, 23 Nov 2023 14:43:36 +0000 (15:43 +0100)] 
s390: Position independent verification of relative addressing

Opcode test cases for z/Architecture instructions that use relative
addressing contained hardcoded offsets in the test verification
patterns. Inserting or reordering of instructions into those test cases
therefore required updating of those hardcoded offsets.

Use regular expressions with backreferences to verify results of test
cases containing instructions with relative addressing. This makes the
verification position independent.

gas/
* testsuite/gas/s390/esa-g5.d: Make opcode test verification
  pattern position independent where possible.
* testsuite/gas/s390/esa-z900.d: Likewise.
* testsuite/gas/s390/zarch-z900.d: Likewise.
* testsuite/gas/s390/zarch-z10.d: Likewise.
* testsuite/gas/s390/zarch-z196.d: Likewise.
* testsuite/gas/s390/zarch-zEC12.d: Likewise.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
5 months agoMIPS/GAS: Use addiu instead of addi in test elf-rel.
YunQiang Su [Thu, 23 Nov 2023 14:28:31 +0000 (14:28 +0000)] 
MIPS/GAS: Use addiu instead of addi in test elf-rel.

5 months agoMIPS/GAS: Fix test failures due to jr encoding changes on r6
YunQiang Su [Thu, 23 Nov 2023 12:53:56 +0000 (12:53 +0000)] 
MIPS/GAS: Fix test failures due to jr encoding changes on r6

5 months ago[gdb/python] Reformat missing_debug.py using black
Tom de Vries [Thu, 23 Nov 2023 06:37:19 +0000 (07:37 +0100)] 
[gdb/python] Reformat missing_debug.py using black

Reformat gdb/python/lib/gdb/missing_debug.py with black after commit
e8c3dafa5f5 ("[gdb/python] Don't import curses.ascii module unless necessary").

5 months agoFix build with GCC 7.5
Tom Tromey [Wed, 22 Nov 2023 13:54:40 +0000 (06:54 -0700)] 
Fix build with GCC 7.5

A recent change to 'struct field' caused a build failure with GCC
7.5.0, as reported by Tom de Vries:

/data/vries/gdb/src/gdb/gdbtypes.h:721:51: error:
‘field::m_accessibility’ is too small to hold all values of â€˜enum
class accessibility’ [-Werror]
   ENUM_BITFIELD (accessibility) m_accessibility : 2;
                                                   ^

Mark Wielaard pointed out that this was a GCC bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51242

This patch works around the bug by changing several members not to be
bitfields.  It reduces the size of the enum's underlying type,
instead.

I also changed m_bitsize to no longer be a bitfield -- that was done
for packing reasons in ancient times, but with m_accessibility not
being a bitfield, this no longer matters.

I removed fn_field::dummy.  In earlier times it was somewhat normal in
gdb to have these dummy fields to keep track of any available padding.
However, since the advent of "ptype/o", there doesn't seem to be any
need for this.

This patch does not change the size of struct field, fn_field, or
decl_field on 64-bit hosts.

5 months agoRISC-V: Add vector permutation instructions for T-Head VECTOR vendor extension
Jin Ma [Sat, 18 Nov 2023 07:08:59 +0000 (15:08 +0800)] 
RISC-V: Add vector permutation instructions for T-Head VECTOR vendor extension

T-Head has a range of vendor-specific instructions. Therefore
it makes sense to group them into smaller chunks in form of
vendor extensions.

This patch adds permutation instructions for the "XTheadVector"
extension. The 'th' prefix and the "XTheadVector" extension
are documented in a PR for the RISC-V toolchain conventions ([1]).

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Co-developed-by: Christoph Müllner <christoph.muellner@vrull.eu>
gas/ChangeLog:

* testsuite/gas/riscv/x-thead-vector.d: Add tests for
permutation instructions.
* testsuite/gas/riscv/x-thead-vector.s: Likewise.

include/ChangeLog:

* opcode/riscv-opc.h (MATCH_TH_VMVXS): New.

opcodes/ChangeLog:

* riscv-opc.c: Likewise.

5 months agoRISC-V: Add vector mask instructions for T-Head VECTOR vendor extension
Jin Ma [Sat, 18 Nov 2023 07:08:32 +0000 (15:08 +0800)] 
RISC-V: Add vector mask instructions for T-Head VECTOR vendor extension

T-Head has a range of vendor-specific instructions. Therefore
it makes sense to group them into smaller chunks in form of
vendor extensions.

This patch adds mask instructions for the "XTheadVector"
extension. The 'th' prefix and the "XTheadVector" extension
are documented in a PR for the RISC-V toolchain conventions ([1]).

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Co-developed-by: Christoph Müllner <christoph.muellner@vrull.eu>
gas/ChangeLog:

* testsuite/gas/riscv/x-thead-vector.d: Add tests for
mask instructions.
* testsuite/gas/riscv/x-thead-vector.s: Likewise.

include/ChangeLog:

* opcode/riscv-opc.h (MATCH_TH_VMPOPCM): New.

opcodes/ChangeLog:

* riscv-opc.c: Likewise.

5 months agoRISC-V: Add reductions instructions for T-Head VECTOR vendor extension
Jin Ma [Sat, 18 Nov 2023 07:08:12 +0000 (15:08 +0800)] 
RISC-V: Add reductions instructions for T-Head VECTOR vendor extension

T-Head has a range of vendor-specific instructions. Therefore
it makes sense to group them into smaller chunks in form of
vendor extensions.

This patch adds reductions instructions for the "XTheadVector"
extension. The 'th' prefix and the "XTheadVector" extension
are documented in a PR for the RISC-V toolchain conventions ([1]).

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Co-developed-by: Christoph Müllner <christoph.muellner@vrull.eu>
gas/ChangeLog:

* testsuite/gas/riscv/x-thead-vector.d: Add tests for
reductions instructions.
* testsuite/gas/riscv/x-thead-vector.s: Likewise.

opcodes/ChangeLog:

* riscv-opc.c: Likewise.

5 months agoRISC-V: Add floating-point arithmetic instructions for T-Head VECTOR vendor extension
Jin Ma [Sat, 18 Nov 2023 07:07:39 +0000 (15:07 +0800)] 
RISC-V: Add floating-point arithmetic instructions for T-Head VECTOR vendor extension

T-Head has a range of vendor-specific instructions. Therefore
it makes sense to group them into smaller chunks in form of
vendor extensions.

This patch adds floating-point arithmetic instructions for the
"XTheadVector" extension. The 'th' prefix and the
"XTheadVector" extension are documented in a PR for the
RISC-V toolchain conventions ([1]).

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Co-developed-by: Christoph Müllner <christoph.muellner@vrull.eu>
gas/ChangeLog:

* testsuite/gas/riscv/x-thead-vector.d: Add tests for
floating-point arithmetic instructions.
* testsuite/gas/riscv/x-thead-vector.s: Likewise.

include/ChangeLog:

* opcode/riscv-opc.h (MATCH_TH_VFSQRTV): New.

opcodes/ChangeLog:

* riscv-opc.c: Likewise.

5 months agoRISC-V: Add fixed-point arithmetic instructions for T-Head VECTOR vendor extension
Jin Ma [Sat, 18 Nov 2023 07:07:20 +0000 (15:07 +0800)] 
RISC-V: Add fixed-point arithmetic instructions for T-Head VECTOR vendor extension

T-Head has a range of vendor-specific instructions. Therefore
it makes sense to group them into smaller chunks in form of
vendor extensions.

This patch adds fixed-point arithmetic instructions for the
"XTheadVector" extension. The 'th' prefix and the
"XTheadVector" extension are documented in a PR for the
RISC-V toolchain conventions ([1]).

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Co-developed-by: Christoph Müllner <christoph.muellner@vrull.eu>
gas/ChangeLog:

* testsuite/gas/riscv/x-thead-vector.d: Add tests for
fixed-point arithmetic instructions.
* testsuite/gas/riscv/x-thead-vector.s: Likewise.

include/ChangeLog:

* opcode/riscv-opc.h (MATCH_TH_VAADDVV): New.

opcodes/ChangeLog:

* riscv-opc.c: Likewise.

5 months agoRISC-V: Add integer arithmetic instructions for T-Head VECTOR vendor extension
Jin Ma [Sat, 18 Nov 2023 07:07:00 +0000 (15:07 +0800)] 
RISC-V: Add integer arithmetic instructions for T-Head VECTOR vendor extension

T-Head has a range of vendor-specific instructions. Therefore
it makes sense to group them into smaller chunks in form of
vendor extensions.

This patch adds integer arithmetic instructions for the
"XTheadVector" extension. The 'th' prefix and the
"XTheadVector" extension are documented in a PR for the
RISC-V toolchain conventions ([1]).

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Co-developed-by: Christoph Müllner <christoph.muellner@vrull.eu>
gas/ChangeLog:

* testsuite/gas/riscv/x-thead-vector.d: Add tests for
integer arithmetic instructions.
* testsuite/gas/riscv/x-thead-vector.s: Likewise.

include/ChangeLog:

* opcode/riscv-opc.h (MATCH_TH_VADCVVM): New.

opcodes/ChangeLog:

* riscv-opc.c: Likewise.

5 months agoRISC-V: Add sub-extension XTheadZvamo for T-Head VECTOR vendor extension
Jin Ma [Sat, 18 Nov 2023 07:06:31 +0000 (15:06 +0800)] 
RISC-V: Add sub-extension XTheadZvamo for T-Head VECTOR vendor extension

T-Head has a range of vendor-specific instructions. Therefore
it makes sense to group them into smaller chunks in form of
vendor extensions.

This patch adds the sub-extension "XTheadZvamo" for the
"XTheadVector" extension, and it provides AMO instructions
for T-Head VECTOR vendor extension. The 'th' prefix and the
"XTheadVector" extension are documented in a PR for the
RISC-V toolchain conventions ([1]).

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Co-developed-by: Christoph Müllner <christoph.muellner@vrull.eu>
bfd/ChangeLog:

* elfxx-riscv.c (riscv_multi_subset_supports): Add support
for "XTheadZvamo" extension.
(riscv_multi_subset_supports_ext): Likewise.

gas/ChangeLog:

* doc/c-riscv.texi:
* testsuite/gas/riscv/x-thead-vector-zvamo.d: New test.
* testsuite/gas/riscv/x-thead-vector-zvamo.s: New test.

include/ChangeLog:

* opcode/riscv-opc.h (MATCH_TH_VAMOADDWV): New.
* opcode/riscv.h (enum riscv_insn_class): Add insn class.

opcodes/ChangeLog:

* riscv-opc.c: Likewise.

5 months agoRISC-V: Add load/store segment instructions for T-Head VECTOR vendor extension
Jin Ma [Sat, 18 Nov 2023 07:05:31 +0000 (15:05 +0800)] 
RISC-V: Add load/store segment instructions for T-Head VECTOR vendor extension

T-Head has a range of vendor-specific instructions. Therefore it
makes sense to group them into smaller chunks in form of vendor
extensions.

This patch adds provides load/store segment instructions for T-Head VECTOR
vendor extension, which same as the "Zvlsseg" extension in RVI 0.71 vector
extension, but belongs to the "XTheadVector" extension. The 'th' prefix
and the "XTheadVector" extension are documented in a PR for the
RISC-V toolchain conventions ([1]).

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Co-developed-by: Christoph Müllner <christoph.muellner@vrull.eu>
gas/ChangeLog:

* testsuite/gas/riscv/x-thead-vector.d: Add test.
* testsuite/gas/riscv/x-thead-vector.s: Likewise.

include/ChangeLog:

* opcode/riscv-opc.h (MATCH_TH_VLSEG2BV): New.

opcodes/ChangeLog:

* riscv-opc.c: Likewise.

5 months agoRISC-V: Add load/store instructions for T-Head VECTOR vendor extension
Jin Ma [Sat, 18 Nov 2023 07:04:50 +0000 (15:04 +0800)] 
RISC-V: Add load/store instructions for T-Head VECTOR vendor extension

T-Head has a range of vendor-specific instructions. Therefore
it makes sense to group them into smaller chunks in form of
vendor extensions.

This patch adds load/store instructions for the "XTheadVector"
extension. The 'th' prefix and the "XTheadVector" extension are
documented in a PR for the RISC-V toolchain conventions ([1]).

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Co-developed-by: Christoph Müllner <christoph.muellner@vrull.eu>
gas/ChangeLog:

* testsuite/gas/riscv/x-thead-vector.d: Add tests for
load/store instructions.
* testsuite/gas/riscv/x-thead-vector.s: Likewise.

include/ChangeLog:

* opcode/riscv-opc.h (MATCH_TH_VLBV): New.

opcodes/ChangeLog:

* riscv-opc.c: Likewise.

5 months agoRISC-V: Add configuration-setting instructions for T-Head VECTOR vendor extension
Jin Ma [Sat, 18 Nov 2023 07:04:01 +0000 (15:04 +0800)] 
RISC-V: Add configuration-setting instructions for T-Head VECTOR vendor extension

T-Head has a range of vendor-specific instructions.
Therefore it makes sense to group them into smaller chunks
in form of vendor extensions.

This patch adds configuration-setting instructions for the "XTheadVector"
extension. The 'th' prefix and the "XTheadVector" extension are documented
in a PR for the RISC-V toolchain conventions ([1]).

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Co-developed-by: Christoph Müllner <christoph.muellner@vrull.eu>
gas/ChangeLog:

* testsuite/gas/riscv/x-thead-vector.d: New test.
* testsuite/gas/riscv/x-thead-vector.s: New test.

opcodes/ChangeLog:

* riscv-opc.c: Likewise..

5 months agoRISC-V: Add CSRs for T-Head VECTOR vendor extension
Jin Ma [Sat, 18 Nov 2023 06:58:25 +0000 (14:58 +0800)] 
RISC-V: Add CSRs for T-Head VECTOR vendor extension

T-Head has a range of vendor-specific instructions.
Therefore it makes sense to group them into smaller chunks
in form of vendor extensions.

This patch adds the CSRs for XTheadVector. Because of the
conflict between encoding and teh 'V' extension, it is implemented
by alias. The 'th' prefix and the "XTheadVector" extension are
documented in a PR for the RISC-V toolchain conventions ([1]).

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Co-developed-by: Christoph Müllner <christoph.muellner@vrull.eu>
gas/ChangeLog:

* config/tc-riscv.c (enum riscv_csr_class): Add the class for
the CSRs of the "XTheadVector" extension.
(riscv_csr_address): Likewise.
* testsuite/gas/riscv/x-thead-vector-csr-warn.d: New test.
* testsuite/gas/riscv/x-thead-vector-csr-warn.l: New test.
* testsuite/gas/riscv/x-thead-vector-csr.d: New test.
* testsuite/gas/riscv/x-thead-vector-csr.s: New test.

include/ChangeLog:

* opcode/riscv-opc.h (DECLARE_CSR_ALIAS): Likewise.

opcodes/ChangeLog:

* riscv-dis.c (print_insn_args): Prefix the CSRs disassembly with 'th'.

5 months agoRISC-V: Add T-Head VECTOR vendor extension.
Jin Ma [Sat, 18 Nov 2023 06:53:08 +0000 (14:53 +0800)] 
RISC-V: Add T-Head VECTOR vendor extension.

T-Head has a range of vendor-specific instructions ([2]).
Therefore it makes sense to group them into smaller chunks
in form of vendor extensions.

This patch adds the "XTheadVector" extension, a collection of
T-Head-specific vector instructions. The 'th' prefix and the
"XTheadVector" extension are documented in a PR for the RISC-V
toolchain conventions ([1]).

Here are some things that need to be explained:
The "XTheadVector" extension is not a custom-extension, but
a non-standard non-conforming extension. The encoding space
of the "TheadVector" instructions overlaps with those of
the 'V' extension. This encoding space conflict is not on
purpose, but the result of issues in the past that have
been resolved since. Therefore, the "XTheadVector" extension
and the 'V' extension are in conflict.

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19
[2] https://github.com/T-head-Semi/thead-extension-spec/releases/download/2.3.0/xthead-2023-11-10-2.3.0.pdf

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Co-developed-by: Christoph Müllner <christoph.muellner@vrull.eu>
bfd/ChangeLog:

* elfxx-riscv.c (riscv_parse_check_conflicts): The
"XTheadVector" extension and the 'V' extension are in conflict.
(riscv_multi_subset_supports): Likewise..
(riscv_multi_subset_supports_ext): Likewise.

gas/ChangeLog:

* doc/c-riscv.texi:
* testsuite/gas/riscv/x-thead-vector-fail.d: New test.
* testsuite/gas/riscv/x-thead-vector-fail.l: New test.
* testsuite/gas/riscv/x-thead-vector.s: New test.

include/ChangeLog:

* opcode/riscv.h (enum riscv_insn_class):

5 months agoAutomatic date update in version.in
GDB Administrator [Thu, 23 Nov 2023 00:00:17 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoFix AIX thr!= NULL assertion failure during fork.
Aditya Vidyadhar Kamath [Wed, 22 Nov 2023 16:13:35 +0000 (10:13 -0600)] 
Fix AIX thr!= NULL assertion failure during fork.

In AIX, while we followed the child process and detach on fork was on we hit thr!= NULL assertion failure.

The reason for the same was GDB core trying to switch to a child thread with tid not set that does not
exist, since child's ptid was changed to ptid_t (pid, 0, tid) in sync_threadlists() as it was threaded.

The way this happened was when a new child process is born, its object file will be loaded, calling the new_objfile ()
in aix-thread.c file from clone_program_space, which is
called from within follow_fork_inferior. Therefore it end ups syncing threadlists via pd_update ().

This patch is a fix for the same where pd_update () is called in the wait () or in update_thread_list() hook only.

5 months ago[gdb/tui] Fix resizing of terminal to 1 or 2 lines
Tom de Vries [Wed, 22 Nov 2023 18:07:47 +0000 (19:07 +0100)] 
[gdb/tui] Fix resizing of terminal to 1 or 2 lines

When starting TUI in a terminal with 3 lines:
...
$ echo $LINES
3
$ gdb -q -tui
...
and resizing the terminal to 2 lines we run into a segfault.

The problem is that for the source window:
- the minimum height is 3 (the default), but
- the maximum height is only 2 because there are only 2 lines.

This discrepancy eventually leads to a call to newwin in make_window with:
...
(gdb) p height
$1 = 3
(gdb) p width
$2 = 56
(gdb) p y
$3 = -1
(gdb) p x
$4 = 0
...
which results in a nullptr.

This violates the assumption here in tui_apply_current_layout:
....
  /* Get the new list of currently visible windows.  */
  std::vector<tui_win_info *> new_tui_windows;
  applied_layout->get_windows (&new_tui_windows);
...
that get_windows only returns visible windows, which leads to tui_windows
holding a dangling pointer, which results in the segfault.

Fix this by:
- making sure get_windows only returns visible windows, and
- detecting the situation and dropping windows from the layout if
  there's no room for them.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
PR tui/31044
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31044

5 months ago[gdb/tui] Allow command window of 1 or 2 lines
Tom de Vries [Wed, 22 Nov 2023 18:07:47 +0000 (19:07 +0100)] 
[gdb/tui] Allow command window of 1 or 2 lines

When starting TUI in a terminal with 2 lines (likewise with 1 line):
...
$ echo $LINES
2
$ gdb -q -tui
...
we run into this assert in tui_apply_current_layout:
...
  /* This should always be made visible by a layout.  */
  gdb_assert (TUI_CMD_WIN != nullptr);
...

The problem is that for the command window:
- the minimum height is 3 (the default), but
- the maximum height is only 2 because there are only 2 lines.

This discrepancy eventually leads to a call to newwin in make_window with:
...
(gdb) p height
$1 = 3
(gdb) p width
$2 = 66
(gdb) p y
$3 = -1
(gdb) p x
$4 = 0
(gdb)
...
which results in a nullptr, which eventually triggers the assert.

The easiest way to fix this is to change the minimum height of the command
window to 1.  However, that would also change behaviour for the case that the
screen size is 3 lines or more.  For instance, in gdb.tui/winheight.exp the
number of lines in the terminal is 24, and the test-case checks that the user
cannot increase the source window height to the point that the command window
height would be less than 3.

Fix this by calculating the minimum height of the command window as follows:
- the default (3) if max_height () allows it, and
- max_height () otherwise.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
PR tui/31044
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31044

5 months ago[gdb/python] Don't import curses.ascii module unless necessary
Tom de Vries [Wed, 22 Nov 2023 18:02:34 +0000 (19:02 +0100)] 
[gdb/python] Don't import curses.ascii module unless necessary

I ran into a failure in test-case gdb.python/py-missing-debug.exp with python
3.6, which was fixed by commit 7db795bc67a ("gdb/python: remove use of
str.isascii()").

However, I subsequently ran into a failure with python 3.11:
...
(gdb) PASS: $exp: initial checks: debug info no longer found
source py-missing-debug.py^M
Traceback (most recent call last):^M
  File "py-missing-debug.py", line 17, in <module>^M
    from gdb.missing_debug import MissingDebugHandler^M
  File "missing_debug.py", line 21, in <module>^M
    from curses.ascii import isascii, isalnum^M
  File "/usr/lib64/python3.11/_import_failed/curses.py", line 16, in <module>^M
    raise ImportError(f"""Module '{failed_name}' is not installed.^M
ImportError: Module 'curses' is not installed.^M
Use:^M
  sudo zypper install python311-curses^M
to install it.^M
(gdb) FAIL: $exp: source python script
...

Apparently I have the curses module installed for 3.6, but not 3.11.

I could just install it, but the test-case worked fine with 3.11 before commit
7db795bc67a.

Fix this by only using the curses module when necessary, for python <= 3.7.

Tested on x86_64-linux, with both python 3.6 and 3.11.

5 months agogdbserver: cleanup monitor_show_help
Andrew Burgess [Sun, 5 Nov 2023 21:15:49 +0000 (21:15 +0000)] 
gdbserver: cleanup monitor_show_help

After this commit:

  commit 0b04e52316079981b2b77124198a405d826a05cd
  Date:   Sun Jan 19 14:33:37 2014 -0700

      link gdbserver against libiberty

we can cleanup how the help text is generated in monitor_show_help.
This doesn't change the output that the user will see -- it just folds
multiple monitor_output calls into one.

There should be no user visible change after this commit.

5 months agoLoongArch: fix internal error when as handling unsupported modifier.
Lulu Cai [Wed, 15 Nov 2023 11:20:53 +0000 (19:20 +0800)] 
LoongArch: fix internal error when as handling unsupported modifier.

5 months agoAutomatic date update in version.in
GDB Administrator [Wed, 22 Nov 2023 00:00:13 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoSimplify C++ type-printing
Tom Tromey [Fri, 27 Oct 2023 16:58:00 +0000 (10:58 -0600)] 
Simplify C++ type-printing

The C++ type-printing code had its own variant of the accessibility
enum.  This patch removes this and changes the code to use the new one
from gdbtypes.h.

This patch also changes the C++ code to recognize the default
accessibility of a class.  This makes ptype a bit more C++-like, and
lets us remove a chunk of questionable code.

Acked-By: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Keith Seitz <keiths@redhat.com>
5 months agoUse enum accessibility in types and member functions
Tom Tromey [Fri, 27 Oct 2023 16:51:50 +0000 (10:51 -0600)] 
Use enum accessibility in types and member functions

This changes nested types and member functions to use the new
'accessibility' enum, rather than separate private/protected flags.
This is done for consistency, but it also lets us simplify some other
code in the next patch.

Acked-By: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Keith Seitz <keiths@redhat.com>
5 months agoRemove char-based bitfield macros
Tom Tromey [Thu, 21 Sep 2023 16:40:10 +0000 (10:40 -0600)] 
Remove char-based bitfield macros

This removes the char-based bitfield macros from gdbtypes.h, as they
are no longer used.

Acked-By: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Keith Seitz <keiths@redhat.com>
5 months agoRemove some type field accessor macros
Tom Tromey [Thu, 21 Sep 2023 16:36:23 +0000 (10:36 -0600)] 
Remove some type field accessor macros

This removes TYPE_FIELD_PRIVATE, TYPE_FIELD_PROTECTED,
TYPE_FIELD_IGNORE, and TYPE_FIELD_VIRTUAL.

In c-varobj.c, match_accessibility can be removed entirely now.  Note
that the comment before this function was incorrect.

Acked-By: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Keith Seitz <keiths@redhat.com>
5 months agoRemove some QUIT calls from need_access_label_p
Tom Tromey [Thu, 21 Sep 2023 16:29:33 +0000 (10:29 -0600)] 
Remove some QUIT calls from need_access_label_p

I think these invocations of QUIT in need_access_label_p are overkill.
QUIT is already called from its caller.  This just removes them.

Acked-By: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Keith Seitz <keiths@redhat.com>
5 months agoAdd field::is_public
Tom Tromey [Thu, 21 Sep 2023 16:24:35 +0000 (10:24 -0600)] 
Add field::is_public

This adds a field::is_public convenience method, and updates one spot
to use it.

Acked-By: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Keith Seitz <keiths@redhat.com>
5 months agoRemove byte vectors from cplus_struct_type
Tom Tromey [Thu, 21 Sep 2023 16:21:04 +0000 (10:21 -0600)] 
Remove byte vectors from cplus_struct_type

This removes some byte vectors from cplus_struct_type, moving the
information into bitfields in holes in struct field.

A new 'enum accessibility' is added to hold some of this information.
A similar enum is removed from c-varobj.c.

Note that the stabs reader treats "ignored" as an accessibility.
However, the stabs texinfo documents this as a public field that is
optimized out -- unfortunately nobody has updated the stabs reader to
use the better value-based optimized-out machinery.  I looked and
apparently gcc never emitted this visibility value, so whatever
compiler generated this stab is unknown.  I left a comment in
gdbtypes.h to this effect.

Acked-By: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Keith Seitz <keiths@redhat.com>
5 months agoPrint field accessibility inline
Tom Tromey [Thu, 21 Sep 2023 16:49:57 +0000 (10:49 -0600)] 
Print field accessibility inline

This changes recursive_dump_type to print field accessibility
information "inline".  This is clearer and preserves the information
when the byte vectors are removed.

Acked-By: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Keith Seitz <keiths@redhat.com>
5 months agoUse .def file to stringify type codes
Tom Tromey [Thu, 21 Sep 2023 16:43:58 +0000 (10:43 -0600)] 
Use .def file to stringify type codes

This changes recursive_dump_type to reuse the type-codes.def file when
stringifying type codes.

This version of the patch changes the "unknown" case to an assert.

Acked-By: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Keith Seitz <keiths@redhat.com>
6 months agobpf: Fixed register parsing disambiguating with possible symbol.
Cupertino Miranda [Tue, 21 Nov 2023 12:26:08 +0000 (12:26 +0000)] 
bpf: Fixed register parsing disambiguating with possible symbol.

This changes parse_bpf_register to detect possible symbols that start with valid
register name, however due some following characters are not.
Also changed the regs-for-symbols-pseudo.s, adding some entries that
should not error if parser is properly detecting the symbol.

6 months ago[opcodes] ARC + PPC: Fix -Walloc-size warnings
Jan-Benedict Glaw [Tue, 21 Nov 2023 16:53:44 +0000 (17:53 +0100)] 
[opcodes] ARC + PPC: Fix -Walloc-size warnings

Recently, -Walloc-size warnings started to kick in. Fix these two
calloc() calls to match the intended usage pattern.

opcodes/ChangeLog:

* arc-dis.c (init_arc_disasm_info): Fix calloc() call.
* ppc-dis.c (powerpc_init_dialect): Ditto.

6 months agogdb: fix build of darwin-nat.c
Simon Marchi [Tue, 21 Nov 2023 16:42:41 +0000 (11:42 -0500)] 
gdb: fix build of darwin-nat.c

Patch 743877128 ("gdb: remove regcache's address space") changed the
signature of darwin_nat_target::cancel_breakpoint, but missing updating
the class declaration, resulting in:

      CXX    darwin-nat.o
    /Users/smarchi/src/binutils-gdb/gdb/darwin-nat.c:1154:20: error: out-of-line definition of 'cancel_breakpoint' does not match any declaration in 'darwin_nat_target'
    darwin_nat_target::cancel_breakpoint (inferior *inf, ptid_t ptid)
                       ^~~~~~~~~~~~~~~~~
    /Users/smarchi/src/binutils-gdb/gdb/darwin-nat.c:1290:9: error: too many arguments to function call, expected single argument 'ptid', have 2 arguments
                                        ptid_t (inf->pid, 0, thread->gdb_port)))
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Users/smarchi/src/binutils-gdb/gdb/darwin-nat.h:129:7: note: 'cancel_breakpoint' declared here
      int cancel_breakpoint (ptid_t ptid);
          ^

Fix that.

Change-Id: Iedd58b36777eb77bca9e23f94882b217c9c87059

6 months agoRefactor DAP queue handling
Tom Tromey [Tue, 7 Nov 2023 16:16:48 +0000 (09:16 -0700)] 
Refactor DAP queue handling

A couple of spots in the DAP code use the same workaround for the
absence of queue.SimpleQueue before Python 3.6.  This patch
consolidates these into a single spot.

6 months ago[gdb/tdep] Handle memory error in s390_linux_get_syscall_number
Tom de Vries [Tue, 21 Nov 2023 12:57:19 +0000 (13:57 +0100)] 
[gdb/tdep] Handle memory error in s390_linux_get_syscall_number

In s390_linux_get_syscall_number, we use read_memory_unsigned_integer, which
can throw a memory error.

According to the function comment though, it should return -1 on error:
...
/* Retrieve the syscall number at a ptrace syscall-stop.  Return -1
   upon error. */
...

Catch the memory error by using safe_read_memory_unsigned_integer instead,
similar to how that was fixed for arm in commit eb42bb14895 ("[gdb/tdep] Fix
catching syscall execve exit for arm").

Approved-By: Ulrich Weigand <uweigand@de.ibm.com>
6 months ago[gdb/testsuite] Fix spurious FAILs with examine-backward.exp, again
Tom de Vries [Tue, 21 Nov 2023 12:15:29 +0000 (13:15 +0100)] 
[gdb/testsuite] Fix spurious FAILs with examine-backward.exp, again

Commit 59a561480d5 ("Fix spurious FAILs with examine-backward.exp") describes
the problem that:
...
The test case examine-backward.exp issues the command "x/-s" after the end
of the first string in TestStrings, but without making sure that this
string is preceded by a string terminator.  Thus GDB may spuriously print
some random characters from before that string, and then the test fails.
...

The commit fixes the problem by adding a Barrier variable before the TestStrings
variable:
...
+const char Barrier[] = { 0x0 };
 const char TestStrings[] = {
...

There is however no guarantee that Barrier is placed immediately before
TestStrings.

Before recent commit 169fe7ab54b ("Change gdb.base/examine-backwards.exp for
AIX.") on x86_64-linux, I see:
...
0000000000400660 R Barrier
0000000000400680 R TestStrings
...

So while the Barrier variable is the first before the TestStrings variable,
it's not immediately preceding TestStrings.

After commit 169fe7ab54b:
...
0000000000402259 B Barrier
0000000000402020 D TestStrings
...
they're not even in the same section anymore.

Fix this reliably by adding the zero in the array itself:
...
char TestStringsBase[] = {
  0x0,
  ...
};
char *TestStrings = &TestStringsBase[1];
...
and do likewise for TestStringsH and TestStringsW.

Tested on x86_64-linux.

PR testsuite/31064
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31064

6 months agogdb: Use initializers in lambda captures unconditionally
Lancelot Six [Fri, 13 Oct 2023 13:00:08 +0000 (13:00 +0000)] 
gdb: Use initializers in lambda captures unconditionally

Initializers in lambda captures were introduced in C++14, and
conditionally used in gdb/cp-support.c and gdb/dwarf2/cooked-index.c.

Since C++17 is now required by GDB, use this feature unconditionally.

Change-Id: I87a3d567941e5c71217538fa75c952e4d421fa1d
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
6 months agogdb/disasm.h: Mark callbacks noexcept unconditionally
Lancelot Six [Fri, 13 Oct 2023 12:45:58 +0000 (12:45 +0000)] 
gdb/disasm.h: Mark callbacks noexcept unconditionally

Given that C++17 is now a requirement for GDB, update gdb/disasm.h to
define callback function types noexcept unconditionally.  The pre-C++17
configuration is not supported anymore.

Change-Id: I0a38e22b7912c70a11425363a991f0b01614343e
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
6 months agogdbsupport: Replace gdb::invoke_result with std::invoke_result
Lancelot Six [Fri, 13 Oct 2023 12:39:55 +0000 (12:39 +0000)] 
gdbsupport: Replace gdb::invoke_result with std::invoke_result

Given that GDB now requires C++17, we can replace gdb::invoke_result
with std::invoke_result which is provided by <type_traits>.

This patch also removes gdbsupport/invoke-result.h as it is not used
anymore.

Change-Id: I7e567356d38d6b3d85d8797d61cfc83f6f933f22
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
6 months agogdbsupport: Remove gdb::string_view
Lancelot Six [Fri, 13 Oct 2023 10:23:59 +0000 (10:23 +0000)] 
gdbsupport: Remove gdb::string_view

Now that all places using gdb::string_view have been updated to use
std::string_view, this patch drops the gdb::string_view implementation
and the tests which came with it.

As this drops the unittests/string_view-selftests.c, this also
implicitly solves PR build/23676, as pointed-out by Tom Tromey.

Change-Id: Idf5479b09e0ac536917b3f0e13aca48424b90df0
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23676

6 months agogdb: Remove uses of gdb::to_string (const std::string_view &)
Lancelot Six [Fri, 13 Oct 2023 10:54:46 +0000 (10:54 +0000)] 
gdb: Remove uses of gdb::to_string (const std::string_view &)

This patch removes all uses of to_string(const std::string_view&) and
use the std::string ctor or implicit conversion from std::string_view to
std::string instead.

A later patch will remove this gdb::to_string while removing
gdbsupport/gdb_string_view.h.

Change-Id: I877cde557a0727be7b0435107e3c7a2aac165895
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
6 months agogdb: Use std::string_view instead of gdb::string_view
Lancelot Six [Fri, 13 Oct 2023 10:17:02 +0000 (10:17 +0000)] 
gdb: Use std::string_view instead of gdb::string_view

Given that GDB now requires a C++17, replace all uses of
gdb::string_view with std::string_view.

This change has mostly been done automatically:
- gdb::string_view -> std::string_view
- #include "gdbsupport/gdb_string_view.h" -> #include <string_view>

One things which got brought up during review is that gdb::stging_view
does support being built from "nullptr" while std::sting_view does not.
Two places are manually adjusted to account for this difference:
gdb/tui/tui-io.c:tui_getc_1 and
gdbsupport/format.h:format_piece::format_piece.

The above automatic change transformed
"gdb::to_string (const gdb::string_view &)" into
"gdb::to_string (const std::string_view &)".  The various direct users
of this function are now explicitly including
"gdbsupport/gdb_string_view.h".  A later patch will remove the users of
gdb::to_string.

The implementation and tests of gdb::string_view are unchanged, they will
be removed in a following patch.

Change-Id: Ibb806a7e9c79eb16a55c87c6e41ad396fecf0207
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
6 months agogdbsupport: remove gdb::optional
Lancelot Six [Fri, 13 Oct 2023 09:55:19 +0000 (09:55 +0000)] 
gdbsupport: remove gdb::optional

The previous patch migrated all the uses of gdb::optional to use
std::optional instead,  so gdb::optional can be removed entirely
as well as the self-tests which came with it.

Change-Id: I96ecd67b850b01be10ef00eb85a78ac647d5adc7
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
6 months agogdb: Replace gdb::optional with std::optional
Lancelot Six [Fri, 13 Oct 2023 09:27:48 +0000 (09:27 +0000)] 
gdb: Replace gdb::optional with std::optional

Since GDB now requires C++17, we don't need the internally maintained
gdb::optional implementation.  This patch does the following replacing:
  - gdb::optional -> std::optional
  - gdb::in_place -> std::in_place
  - #include "gdbsupport/gdb_optional.h" -> #include <optional>

This change has mostly been done automatically.  One exception is
gdbsupport/thread-pool.* which did not use the gdb:: prefix as it
already lives in the gdb namespace.

Change-Id: I19a92fa03e89637bab136c72e34fd351524f65e9
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
6 months agogdb: Use C++17's std::make_unique instead of gdb::make_unique
Lancelot Six [Thu, 14 Sep 2023 11:13:24 +0000 (11:13 +0000)] 
gdb: Use C++17's std::make_unique instead of gdb::make_unique

gdb::make_unique is a wrapper around std::make_unique when compiled with
C++17.  Now that C++17 is required, use std::make_unique directly in the
codebase, and remove gdb::make_unique.

Change-Id: I80b615e46e4b7c097f09d78e579a9bdce00254ab
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net
6 months agoFix: symbols eliminated by --gc-sections still trigger warnings for gnu.warning.SYM
Nick Clifton [Tue, 21 Nov 2023 11:30:03 +0000 (11:30 +0000)] 
Fix: symbols eliminated by --gc-sections still trigger warnings for gnu.warning.SYM

  PR 31067
  Fix typo in previous delta: defined -> referenced.

6 months ago[gdb/tdep] Fix catching syscall execve exit for arm
Tom de Vries [Tue, 21 Nov 2023 10:44:07 +0000 (11:44 +0100)] 
[gdb/tdep] Fix catching syscall execve exit for arm

When running test-case gdb.base/catch-syscall.exp on a pinebook (64-bit
aarch64 kernel, 32-bit userland) I run into:
...
(gdb) PASS: $exp: execve: syscall(s) execve appears in 'info breakpoints'
continue^M
Continuing.^M
^M
Catchpoint 18 (call to syscall execve), 0xf7726318 in execve () from \
  /lib/arm-linux-gnueabihf/libc.so.6^M
(gdb) PASS: gdb.base/catch-syscall.exp: execve: program has called execve
continue^M
Continuing.^M
process 32392 is executing new program: catch-syscall^M
Cannot access memory at address 0xf77c6a7c^M
(gdb) FAIL: $exp: execve: syscall execve has returned
...

The memory error is thrown by arm_linux_get_syscall_number, when doing:
...
     /* PC gets incremented before the syscall-stop, so read the
         previous instruction.  */
      unsigned long this_instr =
        read_memory_unsigned_integer (pc - 4, 4, byte_order_for_code);
...

The reason for the error is that we're stopped at the syscall exit of syscall
execve, and the pc is at the first insn of the new exec, which also happens to
be the first insn in the code segment, so consequently we cannot read the
previous insn.

Fix this by detecting the situation by looking at the register state, similar
to what is done in aarch64_linux_get_syscall_number.

Furthermore, catch the memory error by using safe_read_memory_unsigned_integer
and return -1 instead, matching the documented behaviour of
arm_linux_get_syscall_number.

Finally, rather than using a hardcoded constant 11, introduce an ad-hoc
arm_sys_execve.

Tested on pinebook.

PR tdep/31071
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31071

6 months agoFix: symbols eliminated by --gc-sections still trigger warnings for gnu.warning.SYM
Nick Clifton [Tue, 21 Nov 2023 09:26:19 +0000 (09:26 +0000)] 
Fix: symbols eliminated by --gc-sections still trigger warnings for gnu.warning.SYM

  PR 31067
  * linker.c (_bfd_generic_link_add_one_symbol): When issuing a warning message, also display a message about the warning not being affected by garbage colleciton.
  * ld.texi (Special Sections): New entry in the linker manual. Describes how the .gnu.warning and .gnu.warning.SYM sections behave.

6 months agoFix gdb.bas/sigall.exp testcase in AIX.
Aditya Vidyadhar Kamath [Mon, 20 Nov 2023 10:13:49 +0000 (04:13 -0600)] 
Fix gdb.bas/sigall.exp testcase in AIX.

In AIX, we are not able to see the message of a signal recieved if a debugee recieves a signal.
This is a patch to fix the signal handling done incorrectly in AIX.

We remove the status that represent program recieving a signal and allow host_status_to_waitstatus to
handle it for us.

6 months agogdb: Fix segfault with a big .dynamic section size
Felix Willgerodt [Thu, 9 Nov 2023 13:08:10 +0000 (14:08 +0100)] 
gdb: Fix segfault with a big .dynamic section size

Consider a binary with an erroneous size of the .dynamic section:

$ readelf -S a.out
...
  [24] .dynamic          DYNAMIC          0000000000004c20  00003c20
       000000fffffffa40  0000000000000010  WA       7     0     8
...

This binary causes a segfault in GDB.  GDB is trying to write the .dynamic
section into memory allocated on the stack with alloca().  However, the
allocation silently fails and the subsequent access to the memory is
causing the segfault. (On my node at least.)

Stack allocation is a bad idea for something of variable size that GDB has
no control over.  So I changed the code to heap allocation.

In addition, I changed the type of sect_size to the type that bfd actually
returns.

There should be no user visible change after this.

Approved-By: Tom Tromey <tom@tromey.com>
6 months agoAutomatic date update in version.in
GDB Administrator [Tue, 21 Nov 2023 00:00:16 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 months agoRestore .gdb_index v9 display in readelf
Tom Tromey [Mon, 20 Nov 2023 16:31:32 +0000 (09:31 -0700)] 
Restore .gdb_index v9 display in readelf

An earlier patch (commit b05efa39 "readelf..debug-dump=loc displays
bogus base addresses") inadvertently removed support for displaying
.gdb_index v9 sections.

This patch corrects the oversight.  I tested this by using readelf on
an appropriate file.

* dwarf.c (display_gdb_index): Restore v9 display code.

6 months agoPowerPC: Fix test gdb.ada/finish-large.exp
Carl Love [Mon, 20 Nov 2023 16:13:22 +0000 (11:13 -0500)] 
PowerPC: Fix test gdb.ada/finish-large.exp

Function Create_large returns a large data structure.  On PowerPC, register
r3 contains the address of where the data structure to be returned is to
be stored.  However, on exit the ABI does not guarantee that r3 has not
been changed.  The GDB finish command prints the return value of the
function at the end of the function.  GDB needs to use the
DW_TAG_call_site information to determine the value of r3 on entry to
the function to correctly print the return value at the end of the
function.  The test must be compiled with -fvar-tracking for the
DW_TAG_call_site information to be included in the executable file.

This patch adds the -fvar-tracking option to the compile line if the
option is supported.

The patch fixes the one regression error for the test on PowerPC.

The patch has been tested on Power 10 and X86-64 with no regressions.

6 months agolibctf: adding CU mappings should be idempotent
Nick Alcock [Tue, 7 Nov 2023 21:11:18 +0000 (21:11 +0000)] 
libctf: adding CU mappings should be idempotent

When CTF finds conflicting types, it usually shoves each definition
into a CTF dictionary named after the compilation unit.

The intent of the obscure "cu-mapped link" feature is to allow you to
implement custom linkers that shove the definitions into other, more
coarse-grained units (say, one per kernel module, even if a module consists
of more than one compilation unit): conflicting types within one of these
larger components are hidden from name lookup so you can only look up (an
arbitrary one of) them by name, but can still be found by chasing type graph
links and are still fully deduplicated.

You do this by calling
ctf_link_add_cu_mapping (fp, "CU name", "bigger lump name"), repeatedly,
with different "CU name"s: the ctf_link() following that will put all
conflicting types found in "CU name"s sharing a "bigger lump name" into a
child dict in an archive member named "bigger lump name".

So it's clear enough what happens if you call it repeatedly with the same
"bigger lump name" more than once, because that's the whole point of it: but
what if you call it with the same "CU name" repeatedly?

ctf_link_add_cu_mapping (fp, "CU name", "bigger lump name");
ctf_link_add_cu_mapping (fp, "CU name", "other name");

This is meant to be the same as just doing the second of these, as if the
first was never called.  Alas, this isn't what happens, and what you get is
instead a bit of an inconsistent mess: more or less, the first takes
precedence, which is the exact opposite of what we wanted.

Fix this to work the right way round.

(I plan to add support for CU-mapped links to GNU ld, mainly so that we can
properly *test* this machinery.)

libctf/ChangeLog:

* ctf-link.c (ctf_create_per_cu): Note the behaviour of
repeatedly adding FROMs.
(ctf_link_add_cu_mapping): Implement that behavour.

6 months agogdb: fix reopen_exec_file for files with target: prefix
Andrew Burgess [Thu, 5 Oct 2023 12:12:42 +0000 (13:12 +0100)] 
gdb: fix reopen_exec_file for files with target: prefix

Following on from this commit:

  commit f2c4f78c813a9cef38b7e9c9ad18822fb9e19345
  Date:   Thu Sep 21 16:35:30 2023 +0100

      gdb: fix reread_symbols when an objfile has target: prefix

In this commit I update reopen_exec_file to correctly handle
executables with a target: prefix.  Before this commit we used the
system 'stat' call, which obviously isn't going to work for files with
a target: prefix (files located on a possibly remote target machine).

By switching to bfd_stat we will use remote fileio to stat the remote
files, which means we should now correctly detect changes in a remote
executable.

The program_space::ebfd_mtime variable, with which we compare the
result of bfd_stat is set with a call to bfd_get_mtime, which in turn
calls bfd_stat, so comparing to the result of calling bfd_stat makes
sense (I think).

As I discussed in the commit f2c4f78c813a, if a BFD is an in-memory
BFD, then calling bfd_stat will always return 0, while bfd_get_mtime
will always return the time at which the BFD was created.  As a result
comparing the results will always show the file having changed.

I don't believe that GDB can set the main executable to an in-memory
BFD object, so, in this commit, I simply assert that the executable is
not in-memory.  If this ever changes then we would need to decide how
to handle this case -- always reload, or never reload.  The assert
doesn't appear to trigger for our current test suite.

Approved-By: Tom Tromey <tom@tromey.com>
6 months agogdb: move all bfd_cache_close_all calls in gdb_bfd.c
Andrew Burgess [Tue, 24 Oct 2023 16:54:51 +0000 (17:54 +0100)] 
gdb: move all bfd_cache_close_all calls in gdb_bfd.c

In the following commit I ran into a problem.  The next commit aims to
improve GDB's handling of the main executable being a file on a remote
target (i.e. one with a 'target:' prefix).

To do this I have replaced a system 'stat' call with a bfd_stat call.

However, doing this caused a regression in gdb.base/attach.exp.

The problem is that the bfd library caches open FILE* handles for bfd
objects that it has accessed, which is great for short-lived, non
interactive programs (e.g. the assembler, or objcopy, etc), however,
for GDB this caching causes us a problem.

If we open the main executable as a bfd then the bfd library will
cache the open FILE*.  If some time passes, maybe just sat at the GDB
prompt, or with the inferior running, and then later we use bfd_stat
to check if the underlying, on-disk file has changed, then the bfd
library will actually use fstat on the underlying file descriptor.
This is of course slightly different than using system stat on with
the on-disk file name.

If the on-disk file has changed then system stat will give results for
the current on-disk file.  But, if the bfd cache is still holding open
the file descriptor for the original on-disk file (from before the
change) then fstat will return a result based on the original file,
and so show no change as having happened.

This is a known problem in GDB, and so far this has been solved by
scattering bfd_cache_close_all() calls throughout GDB.  But, as I
said, in the next commit I've made a change and run into a
problem (gdb.base/attach.exp) where we are apparently missing a
bfd_cache_close_all() call.

Now I could solve this problem by adding a bfd_cache_close_all() call
before the bfd_stat call that I plan to add in the next commit, that
would for sure solve the problem, but feels a little crude.

Better I think would be to track down where the bfd is being opened
and add a corresponding bfd_cache_close_all() call elsewhere in GDB
once we've finished doing whatever it is that caused us to open the
bfd in the first place.

This second solution felt like the better choice, so I tracked the
problem down to elf_locate_base and fixed that.  But that just exposed
another problem in gdb_bfd_map_section which was also re-opening the
bfd, so I fixed this (with another bfd_cache_close_all() call), and
that exposed another issue in gdbarch_lookup_osabi... and at this
point I wondered if I was approaching this problem the wrong way...

.... And so, I wonder, is there a _better_ way to handle these
bfd_cache_close_all() calls?

I see two problems with the current approach:

  1. It's fragile.  Folk aren't always aware that they need to clear
  the bfd cache, and this feels like something that is easy to
  overlook in review.  So adding new code to GDB can innocently touch
  a bfd, which populates the cache, which will then be a bug that can
  lie hidden until an on-disk file just happens to change at the wrong
  time ... and GDB fails to spot the change.  Additionally,

  2. It's in efficient.  The caching is intended to stop the bfd
  library from continually having to re-open the on-disk file.  If we
  have a function that touches a bfd then often that function is the
  obvious place to call bfd_cache_close_all.  But if a single GDB
  command calls multiple functions, each of which touch the bfd, then
  we will end up opening and closing the same on-disk file multiple
  times.  It feels like we would be better postponing the
  bfd_cache_close_all call until some later point, then we can benefit
  from the bfd cache.

So, in this commit I propose a new approach.  We now clear the bfd
cache in two places:

  (a) Just before we display a GDB prompt.  We display a prompt after
  completing a command, and GDB is about to enter an idle state
  waiting for further input from the user (or in async mode, for an
  inferior event).  If while we are in this idle state the user
  changes the on-disk file(s) then we would like GDB to notice this
  the next time it leaves its idle state, e.g. the next time the user
  executes a command, or when an inferior event arrives,

  (b) When we resume the inferior.  In synchronous mode, resuming the
  inferior is another time when GDB is blocked and sitting idle, but
  in this case we don't display a prompt.  As with (a) above, when an
  inferior event arrives we want GDB to notice any changes to on-disk
  files.

It turns out that there are existing observers for both of these
cases (before_prompt and target_resumed respectively), so my initial
thought was that I should attach to these observers in gdb_bfd.c, and
in both cases call bfd_cache_close_all().

And this does indeed solve the gdb.base/attach.exp problem that I see
with the following commit.

However, I see a problem with this solution.

Both of the observers I'm using are exposed through the Python API as
events that a user can hook into.  The user can potentially run any
GDB command (using gdb.execute), so Python code might end up causing
some bfds to be reopened, and inserted into the cache.

To solve this one solution would be to add a bfd_cache_close_all()
call into gdbpy_enter::~gdbpy_enter().  Unfortunately, there's no
similar enter/exit object for Guile, though right now Guile doesn't
offer the same event API, so maybe we could just ignore that
problem... but this doesn't feel great.

So instead, I think a better solution might be to not use observers
for the bfd_cache_close_all() calls.  Instead, I'll call
bfd_cache_close_all() directly from core GDB after we've notified the
before_prompt and target_resumed observers, this was we can be sure
that the cache is cleared after the observers have run, and before GDB
enters an idle state.

This commit also removes all of the other bfd_cache_close_all() calls
from GDB.  My claim is that these are no longer needed.

Approved-By: Tom Tromey <tom@tromey.com>
6 months agogdb/infrun: simplify process_event_stop_test
Guinevere Larsen [Sun, 24 Sep 2023 10:22:23 +0000 (12:22 +0200)] 
gdb/infrun: simplify process_event_stop_test

The previous commit introduced some local variables to make some if
statements simpler. This commit uses them more liberally throughout the
process_event_stop_test in order to simplify the function a little more.
No functional changes are expected.

Approved-By: Tom Tromey <tom@tromey.com>
6 months agogdb/record: print frame information when exiting a recursive call
Guinevere Larsen [Fri, 1 Sep 2023 11:47:32 +0000 (13:47 +0200)] 
gdb/record: print frame information when exiting a recursive call

Currently,  when GDB is reverse stepping out of a function into the same
function due to a recursive call, it doesn't print frame information, as
reported by PR record/29178. This happens because when the inferior
leaves the current frame, GDB decides to refresh the step information,
clobbering the original step_frame_id, making it impossible to figure
out later on that the frame has been changed.

This commit changes GDB so that, if we notice we're in this exact
situation, we won't refresh the step information.

Because of implementation details, this change can cause some debug
information to be read when it normally wouldn't before, which showed up
as a regression on gdb.dwarf2/dw2-out-of-range-end-of-seq. Since that
isn't a problem, the test was changed to allow for the new output.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29178
Approved-By: Tom Tromey <tom@tromey.com>