Commit Graph

116772 Commits

Author SHA1 Message Date
Tom Tromey
596cd22cb1 Use gdb_dir_up in linux_proc_attach_tgid_threads
This changes linux_proc_attach_tgid_threads to use gdb_dir_up.  This
makes it robust against exceptions.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-12-01 10:36:00 -07:00
Tom Tromey
31141b5520 Minor cleanup in linux_proc_attach_tgid_threads
linux_proc_attach_tgid_threads computes a file name, and then
re-computes it for a warning.  It is better to reuse the
already-computed name here.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-12-01 10:36:00 -07:00
Simon Marchi
9d8fc40eb0 gdb: add missing regcache_map_entry array null terminators in aarch64-linux-tdep.c
Fix two spots in aarch64-linux-tdep.c that build regcache_map_entry
arrays without a null terminator.  The null terminators are needed for
regcache::transfer_regset and regcache_map_entry_size to work properly.

Change-Id: I3224a314e1360b319438f32de8c81e70ab42e105
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
Approved-By: Luis Machado <luis.machado@arm.com>
2023-12-01 11:20:34 -05:00
Simon Marchi
c47886c7a1 gdb: return when exceeding buffer size in regcache::transfer_regset
regcache::transfer_regset iterates over an array of regcache_map_entry,
transferring the registers (between regcache and buffer) described by
those entries.  It stops either when it reaches the end of the
regcache_map_entry array (marked by a null entry) or (it seems like the
intent is) when it reaches the end of the buffer (in which case not all
described registers are transferred).

I said "seems like the intent is", because there appears to be a small
bug.  transfer_regset is made of two loops:

    foreach regcache_map_entry:
      foreach register described by the regcache_map_entry:
        if the register doesn't fit in the remainder of the buffer:
	  break

        transfer register

When stopping because we have reached the end of the buffer, the break
only breaks out of the inner loop.

This problem causes some failures when I run tests such as
gdb.arch/aarch64-sme-core-3.exp (on AArch64 Linux, in qemu).  This is
partly due to aarch64_linux_iterate_over_regset_sections failing to add
a null terminator in its regcache_map_entry array, but I think there is
still a problem in transfer_regset.

The sequence to the crash is:

 - The `regcache_map_entry za_regmap` object built in
   aarch64_linux_iterate_over_regset_sections does not have a null
   terminator.
 - When the target does not have a ZA register,
   aarch64_linux_collect_za_regset calls `regcache->collect_regset` with
   a size of 0 (it's actually pointless, but still it should work).
 - transfer_regset gets called with a buffer size of 0.
 - transfer_regset detects that the register to transfer wouldn't fit in
   0 bytes, so it breaks out of the inner loop.
 - The outer loop tries to go read the next regcache_map_entry, but
   there isn't one, and we start reading garbage.

Obviously, this would get fixed by making
aarch64_linux_iterate_over_regset_sections use a null terminator (which
is what the following patch does).  But I think that when detecting that
there is not enough buffer left for the current register,
transfer_regset should return, not only break out of the inner loop.

This is a kind of contrived scenario, but imagine we have these two
regcache_map_entry objects:

  - 2 registers of 8 bytes
  - 2 registers of 4 bytes

For some reason, the caller passes a buffer of 12 bytes.
transfer_regset will detect that the second 8 byte register does not
fit, and break out of the inner loop.  However, it will then go try the
next regcache_map_entry.  It will see that it can fit one 4 byte
register in the remaining buffer space, and transfer it from/to there.
This is very likely not an expected behavior, we wouldn't expect to
read/write this sequence of registers from/to the buffer.

In this example, whether passing a 12 bytes buffer makes sense or
whether it is a size computation bug in the caller, we don't know, but I
think that exiting as soon as a register doesn't fit is the sane thing
to do.

Change-Id: Ia349627d2e5d281822ade92a8e7a4dea4f839e07
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
Reviewed-By: Luis Machado <luis.machado@arm.com>
2023-12-01 11:20:09 -05:00
Tom Tromey
f644dde103 Add link to Debugger Adapter Protocol node in documentation
I noticed that the interpreters node in the docs links to the DAP
protocol docs, but I thought the DAP node ought to as well.  This
patch adds a bit of introductory text there.

Approved-By: Eli Zaretskii <eliz@gnu.org>
2023-12-01 08:49:54 -07:00
Jeff Law
37d6ee9350 Fix right shifts in mcore simulator on 64 bit hosts.
If the value to be shifted has the sign bit set, the sign
bit would get copied into bits 32..63 of the temporary.  Those
would then be right shifted into the final value giving an
incorrect final result.

This was observed with upcoming GCC improvements which eliminate
unnecessary extensions.
2023-12-01 07:19:50 -07:00
Guinevere Larsen
fbd9e35c54 gdb/testsuite: fix completion tests when using READ1
The commit a3da2e7e55 has introduced
regressions when testing using the READ1 mechanism. The reason for that
is the new failure path in proc test_gdb_complete_tab_unique, which
looks for GDB suggesting more than what the test inputted, but not the
correct answer, followed by a white space. Consider the following case:

int foo(int bar, int baz);

Sending the command "break foo<tab>" to GDB will return

break foo(int, int)

which easily fits the buffer in normal testing, so everything works, but
when reading one character at a time, the test will find the partial
"break foo(int, " and assume that there was a mistake, so we get a
spurious FAIL.

That change was added because we wanted to avoid forcing a completion
failure to fail through timeout, which it had to do because there is no
way to verify that the output is done, mostly because when I was trying
to solve a different problem I kept getting reading errors and testing
completion was frustrating.

This commit implements a better way to avoid that frustration, by first
testing gdb's complete command and only if that passes we will test tab
completion. The difference is that when testing with the complete
command, we can tell when the output is over when we receive the GDB
prompt again, so we don't need to rely on timeouts. With this, the
change to test_gdb_complete_tab_unique has been removed as that test
will only be run and fail in the very unlikely scenario that tab
completion is different than command completion.

Approved-By: Andrew Burgess <aburgess@redhat.com>
2023-12-01 13:29:40 +01:00
Aditya Vidyadhar Kamath
d7ac0027a4 Remove unnecessary returns and unused variables in AIX.
This is a patch to simplify the pd_activate () in aix-thread.c incase of a failure to start a thread session
, since pd_activate () now has return type void.

Also this patch fixes the shadow declarartion warning in sync-threadlists.
2023-12-01 11:09:39 +01:00
Nick Clifton
1089d2017c Fix: nm -U short flag erroneously consumes argument
PR 31105
  * nm.c (main): Remove spurious colon after U in the call to getopt_long
2023-12-01 09:52:11 +00:00
Jan Beulich
036cee3ad8 ld: fix build with old makeinfo
Makeinfo 4.12 is unhappy about the new "Special Sections" without that
also having a @chapter line.
2023-12-01 10:13:36 +01:00
Jan Beulich
236b484749 binutils/Dwarf: avoid "shadowing" of glibc function name
Yet once again: Old enough glibc has an (unguarded) declaration of
index() in string.h, which triggers a "shadows a global declaration"
warning with at least some gcc versions.
2023-12-01 10:13:17 +01:00
Jan Beulich
2d9b910d56 gas: drop unused fields from struct segment_info_struct
user_stuff, dot, and lineno_list_{head,tail} have no users (left), while
bfd_section was only ever written.
2023-12-01 08:29:33 +01:00
Jan Beulich
0aa5d0c9e9 x86: adjust NOP generation after potential non-insn
Just like avoiding to do certain transformations potentially affected by
stand-alone prefixes or direct data emission, also avoid emitting
optimized NOPs right afterwards; insert a plain old NOP first in such
cases.
2023-12-01 08:29:11 +01:00
Jan Beulich
ce69d08114 x86: i386_cons_align() badly affects diagnostics
Warning without knowing what's going to follow isn't useful, the more
that appropriate warnings are emitted elsewhere in all cases. Not
updating state (file/line in particular) also isn't helpful, as it's
always the last directive ahead of a construct potentially needing
fiddling with that's "guilty" in that fiddling being suppressed.
2023-12-01 08:28:45 +01:00
Jan Beulich
54fc457388 gas: no md_cons_align() for .nop{,s}
.nop and .nops generate code, not data. Hence them invoking
md_cons_align() is at best inappropriate. In fact it actually gets in
the of x86'es state maintenance involving i386_cons_align().
2023-12-01 08:28:20 +01:00
Jan Beulich
175ce60f0f x86: suppress optimization after potential non-insn
Just like avoiding to do other transformations potentially affected by
stand-alone prefixes or direct data emission, also avoid optimization
on the following insn.
2023-12-01 08:27:49 +01:00
Jan Beulich
b5482fe535 x86: last-insn recording should be per-section
Otherwise intermediate section switches result in inconsistent behavior.
Note, however, that intermediate sub-section switches will continue to
result in inconsistent or even inappropriate behavior.

While there also add recording of state to s_insn().
2023-12-01 08:27:22 +01:00
Jan Beulich
1f865bae65 x86: allow 32-bit reg to be used with U{RD,WR}MSR
... as MSR index specifier: It is unreasonable to demand that people
write less readable / understandable code, just because the present
documentation mentions only Reg64. Whether to also adjust the
disassembler is a separate question, perhaps indeed more tightly tied
to what the spec says.
2023-12-01 08:26:36 +01:00
Simon Marchi
a521809d9b gdb: fix warnings about invalid [[fallthrough]] usage
Fix these two warnings, when building on macos:

      CXX    cp-name-parser.o
    /Users/smarchi/src/binutils-gdb/gdb/cp-name-parser.y:1644:7: error: fallthrough annotation does not directly precede switch label
          [[fallthrough]];
          ^

      CXX    dbxread.o
    /Users/smarchi/src/binutils-gdb/gdb/dbxread.c:2809:7: error: fallthrough annotation does not directly precede switch label
          [[fallthrough]];
          ^

In these two cases, we [[fallthrough]], followed by a regular label,
followed by a case label.  Move the [[fallthrough]] below the regular
label.

Change-Id: If4a3145139e050bdb6950c7f239badd5778e6f64
Approved-By: Tom Tromey <tom@tromey.com>
2023-11-30 23:16:39 -05:00
Patrick O'Neill
2b33b0d960 RISC-V: Make riscv_is_mapping_symbol stricter
riscv_is_mapping_symbol currently accepts any symbol that starts with $x
or $d. This patch makes the check more strict, requiring exactly $x, $d,
or $xrv. It also makes use of this stricter mapping in
riscv_is_valid_mapping_symbol.

ChangeLog:

	* bfd/cpu-riscv.c (riscv_elf_is_mapping_symbols): Match only
	strings that are exactly $x, $d, or $xrv.
	* opcodes/riscv-dis.c (riscv_is_valid_mapping_symbol): Use
	riscv_elf_is_mapping_symbols.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
2023-12-01 11:22:45 +08:00
Nelson Chu
8321007a98 RISC-V: Update gas/NEWS for RISC-V vendor extension news.
gas/
	* NEWS: Update RISC-V vendor extension news.
2023-12-01 09:29:12 +08:00
Nelson Chu
248bf6de04 RISC-V: Add SiFive custom vector coprocessor interface instructions v1.0
SiFive has define as set of flexible instruction for extending vector
coprocessor, it able to encoding opcode like .insn but with predefined
format.

List of instructions:
  sf.vc.x
  sf.vc.i
  sf.vc.vv
  sf.vc.xv
  sf.vc.iv
  sf.vc.fv
  sf.vc.vvv
  sf.vc.xvv
  sf.vc.ivv
  sf.vc.fvv
  sf.vc.vvw
  sf.vc.xvw
  sf.vc.ivw
  sf.vc.fvw
  sf.vc.v.x
  sf.vc.v.i
  sf.vc.v.vv
  sf.vc.v.xv
  sf.vc.v.iv
  sf.vc.v.fv
  sf.vc.v.vvv
  sf.vc.v.xvv
  sf.vc.v.ivv
  sf.vc.v.fvv
  sf.vc.v.vvw
  sf.vc.v.xvw
  sf.vc.v.ivw
  sf.vc.v.fvw

Spec of Xsfvcp
https://www.sifive.com/document-file/sifive-vector-coprocessor-interface-vcix-software

Co-authored-by: Hau Hsu <hau.hsu@sifive.com>
Co-authored-by: Kito Cheng <kito.cheng@sifive.com>
2023-12-01 09:29:07 +08:00
Christoph Müllner
ea1bd00742 RISC-V: Zv*: Add support for Zvkb ISA extension
Back then when the support for the RISC-V vector crypto extensions
was merged, the specification was frozen, but not ratified.
A frozen specification is allowed to change within tight bounds
before ratification and this has happend with the vector crypto
extensions.

The following changes were applied:
* A new extension Zvkb was defined, which is a strict subset of Zvbb.
* Zvkn and Zvks include now Zvkb instead of Zvbb.

This patch implements these changes between the frozen and the
ratified specification.

Note, that this technically an incompatible change of Zvkn and Zvks,
but I am not aware of any project that depends on the currently
implemented behaviour of Zvkn and Zvks. So this patch should be fine.

Reported-By: Jerry Shih <jerry.shih@sifive.com>
Reported-By: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2023-12-01 01:48:27 +01:00
GDB Administrator
3281156164 Automatic date update in version.in 2023-12-01 00:00:13 +00:00
Tom de Vries
d5835df2ee [gdb/build] Fix adding -DNDEBUG to python flags of release build
In gdb/configure the line:
...
    $development || tentative_python_cflags="$tentative_python_cflags -DNDEBUG"
...
intends to ensure that -DNDEBUG is added to the python flags of a release
build.

However, when building gdb-14-branch we have:
...
configure:22024: checking compiler flags for python code
  ...
configure:22047: result:  -fno-strict-aliasing -fwrapv
...

This is a regression since commit db6878ac55 ("Move sourcing of development.sh
to GDB_AC_COMMON"), which introduced a reference before assignment:
...
    $development || tentative_python_cflags="$tentative_python_cflags -DNDEBUG"
  ...
. $srcdir/../bfd/development.sh
...
and consequently -DNDEBUG is never added.

[ This was not obvious to me, but apparently evaluating an empty or undefined
variable in this context is similar to using ':' or 'true', so the line is
evaluated as:
...
    true || tentative_python_cflags="$tentative_python_cflags -DNDEBUG"
... ]

Fix this by moving GDB_AC_COMMON up in gdb/configure.ac, similar to how that
was done for gdbserver/configure.ac in commit db6878ac55.

[ Unfortunately, the move might introduce issues similar to the one we're
fixing, and I'm not sure how to check for this.  Shellcheck doesn't detect
this type of problem.  FWIW, I did run shellcheck (using arguments -xa, in the
src/gdb directory to make sure ../bfd/development.sh is taken into account)
before and after and observed that the number of lines/words/chars in the
shellcheck output is identical. ]

Build & tested on top of trunk.

Also build on top of gdb-14-branch, and observed this in gdb/config.log:
...
configure:25214: checking compiler flags for python code
  ...
configure:25237: result:  -fno-strict-aliasing -fwrapv -DNDEBUG
...

Approved-By: Tom Tromey <tom@tromey.com>

PR build/31099
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31099
2023-11-30 21:31:46 +01:00
YunQiang Su
946df73fa0 MIPS/GAS: Add -march=loongson2f to loongson-2f-3 test
On MIPSr6, the encoding of JR instruction has been chaned.
This patch can fix these failures for r6 default triples:
	ST Microelectronics Loongson-2F workarounds of Jump Instruction issue
2023-11-30 16:02:56 +00:00
YunQiang Su
070961b377 MIPS: Set r6 as default arch if vendor is img
This behavior is used by downstream toolchain since 2014,
and has been in GCC since the same year.

We don't support mips64*-img* due to GCC doesn't support it,
and we believe that the multilib should be used for this case.
2023-11-30 13:51:17 +00:00
Rainer Orth
53302c2d33 Fix procfs.c compilation
procfs.c doesn't currently compile on Solaris:

/vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c: In member function ‘virtual int procfs_target::can_use_hw_breakpoint(bptype, int, int)’:
/vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c:3017:9: error: ‘ptr_type’ was not declared in this scope; did you mean ‘var_types’?
 3017 |   type *ptr_type
      |         ^~~~~~~~
      |         var_types

This was caused by this patch:

commit 99d9c3b92c
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Fri Sep 29 14:24:38 2023 -0400

    gdb: remove target_gdbarch

Partially undoing it restores the build.

Tested on amd64-pc-solaris2.11.
2023-11-30 10:46:25 +01:00
Rainer Orth
56006f7938 libiberty: Disable hwcaps for sha1.o
This patch

commit bf4f40cc3195eb7b900bf5535cdba1ee51fdbb8e
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Nov 28 13:14:05 2023 +0100

    libiberty: Use x86 HW optimized sha1

broke Solaris/x86 bootstrap with the native as:

libtool: compile:  /var/gcc/regression/master/11.4-gcc/build/./gcc/gccgo -B/var/gcc/regression/master/11.4-gcc/build/./gcc/ -B/vol/gcc/i386-pc-solaris2.11/bin/ -B/vol/gcc/i386-pc-solaris2.11/lib/ -isystem /vol/gcc/i386-pc-solaris2.11/include -isystem /vol/gcc/i386-pc-solaris2.11/sys-include -fchecking=1 -minline-all-stringops -O2 -g -I . -c -fgo-pkgpath=internal/goarch /vol/gcc/src/hg/master/local/libgo/go/internal/goarch/goarch.go zgoarch.go
ld.so.1: go1: fatal: /var/gcc/regression/master/11.4-gcc/build/gcc/go1: hardware capability (CA_SUNW_HW_2) unsupported: 0x4000000  [ SHA1 ]
gccgo: fatal error: Killed signal terminated program go1

As is already done in a couple of other similar cases, this patches
disables hwcaps support for libiberty.

Initially, this didn't work because config/hwcaps.m4 uses target_os, but
didn't ensure it is defined.

Tested on i386-pc-solaris2.11 with as and gas.

2023-11-29  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	config:
	* hwcaps.m4 (GCC_CHECK_ASSEMBLER_HWCAP): Require
	AC_CANONICAL_TARGET.

	libiberty:
	* configure.ac (GCC_CHECK_ASSEMBLER_HWCAP): Invoke.
	* configure, aclocal.m4: Regenerate.
	* Makefile.in (COMPILE.c): Add HWCAP_CFLAGS.
2023-11-30 10:14:30 +01:00
Patrick O'Neill
460e0e6e3e RISC-V: Avoid updating state until symbol is found
Currently objdump gets and updates the map state once per symbol. Updating the
state (partiularly riscv_parse_subset) is expensive and grows quadratically
since we iterate over all symbols. By deferring this until once we've found the
symbol of interest, we can reduce the time to dump a 4k insn file of .norvc and
.rvc insns from ~47 seconds to ~0.13 seconds.

opcodes/ChangeLog:

	* riscv-dis.c (riscv_get_map_state): Remove state updating logic
	and rename to riscv_is_valid_mapping_symbol.
	(riscv_update_map_state): Add state updating logic to seperate function.
	(riscv_search_mapping_symbol): Use new riscv_update_map_state.
	(riscv_data_length): Ditto.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
2023-11-30 15:52:30 +08:00
Jose E. Marchesi
dd2947e76a gas: support double-slash line comments in BPF assembly
This patch makes the BPF assembler to support double-slash line
comments, like the llvm BPF assembler does.  At this point both
assemblers support the same commenting styles:

- Line comments preceded by # or //.
- Non-nestable block comments delimited by /* and */.

This patch also adds a couple of tests to make sure all the comment
styles work in both normal and pseudoc syntax.  The manual is also
updated to mention double-slash line comments.
2023-11-30 08:48:56 +01:00
GDB Administrator
0e78c95c49 Automatic date update in version.in 2023-11-30 00:00:24 +00:00
Tom Tromey
69f6730df3 Remove gdb_static_assert
C++17 makes the second parameter to static_assert optional, so we can
remove gdb_static_assert now.
2023-11-29 14:29:44 -07:00
Tom Tromey
d02f31bb13 Use C++17 void_t
C++17 has void_t and make_void, so gdbsupport/traits.h can be
simplified.

Approved-By: Pedro Alves <pedro@palves.net>
2023-11-29 14:29:44 -07:00
Tom Tromey
cc87f13181 Rely on copy elision in scope-exit.h
gdbsupport/scope-exit.h has a couple of comments about being able to
rely on copy elision in C++17.  This patch makes the change.

Approved-By: Pedro Alves <pedro@palves.net>
2023-11-29 14:29:44 -07:00
Tom Tromey
553b78748f Rely on C++17 <new> in new-op.cc
gdbsupport/new-op.cc has a comment about relying on the C++-17 <new>
header.  This patch implements the suggestion.

Approved-By: Pedro Alves <pedro@palves.net>
2023-11-29 14:29:44 -07:00
Tom Tromey
b096524827 Use try_emplace in index-write.c
index-write.c has a comment indicating that C++17's try_emplace could
be used.  This patch makes the change.

Approved-By: Pedro Alves <pedro@palves.net>
2023-11-29 14:29:44 -07:00
Tom Tromey
dead89d276 Enable some C++14 code in array-view.h
This changes gdbsupport/array-view.h to enable some code that is
C++14-specific.

Approved-By: Pedro Alves <pedro@palves.net>
2023-11-29 14:29:44 -07:00
Tom Tromey
d57f38ec74 Switch to -Wimplicit-fallthrough=5
This changes the various gdb-related directories to use
-Wimplicit-fallthrough=5, meaning that only the fallthrough attribute
can be used in switches -- special 'fallthrough' comments will no
longer be usable.

Approved-By: Pedro Alves <pedro@palves.net>
2023-11-29 14:29:43 -07:00
Tom Tromey
d182e39881 Use C++17 [[fallthrough]] attribute
This changes gdb to use the C++17 [[fallthrough]] attribute rather
than special comments.

This was mostly done by script, but I neglected a few spellings and so
also fixed it up by hand.

I suspect this fixes the bug mentioned below, by switching to a
standard approach that, presumably, clang supports.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23159
Approved-By: John Baldwin <jhb@FreeBSD.org>
Approved-By: Luis Machado <luis.machado@arm.com>
Approved-By: Pedro Alves <pedro@palves.net>
2023-11-29 14:29:43 -07:00
Vladimir Mezentsev
a0dc1f9a12 gprofng: support GNU option syntax in gp-display-html, plus various fixes
This is a major update of gp-display-html.  The option handling has been
modified to support the GNU style long option syntax.  Compatibility with
the previous syntax has been preserved. If still used, a warning is issued.
Through the --nowarnings option, this can be suppressed.
In addition to this, various lay-out changes have been implemented.  In
particular to reduce the number of lines that extend beyond column 79.
Several bugs have been fixed, for example in the handling of directory names.

gprofng/ChangeLog
2023-11-28  Ruud van der Pas  <ruud.vanderpas@oracle.com>

	* gp-display-html/gp-display-html.in: Change option syntax plus fixes.
2023-11-29 10:18:35 -08:00
Vladimir Mezentsev
46c5675798 gprofng: updated man pages and user guide
This is a major update of all the man pages.  Bugs 30679 and 30895 are
addressed.  In addition to fixes for typos, the texts have been expanded
and clarified, and line lengths no longer extend beyond column 79.  In
case of gp-display-html, the new option syntax is documented. The user
guide has a new section on the gprofng GUI.

gprofng/ChangeLog
2023-11-28  Ruud van der Pas  <ruud.vanderpas@oracle.com>

	PR 30679
	PR 30895
	* doc/gp-archive.texi: Expand the description of the options.
	* doc/gp-collect-app.texi: Fix various typos and textual improvements.
	* doc/gp-display-html.texi: Cover the new GNU long option syntax.
	* doc/gp-display-src.texi: Fix various typos and textual improvements.
	* doc/gp-display-text.texi: Fix typos fixed and textual improvements.
	* doc/gp-macros.texi: Fix a bug in the vspace macro and add new macro.
	* doc/gprofng.texi: Cover the GPROFNG_SYSCONFDIR environment variable.
	* doc/gprofng_ug.texi: Fix various typos and textual improvements.
	* doc/version.texi: Adapt the date and version number.
2023-11-29 10:18:34 -08:00
GDB Administrator
35efddd5a1 Automatic date update in version.in 2023-11-29 00:00:24 +00:00
Andrew Burgess
a393b15517 gdb/python: display errors from command completion
This commit makes the gdb.Command.complete methods more verbose when
it comes to error handling.

Previous to this commit if any commands implemented in Python
implemented the complete method, and if there were any errors
encountered when calling that complete method, then GDB would silently
hide the error and continue as if there were no completions.

This makes is difficult to debug any errors encountered when writing
completion methods, and encourages the idea that Python extensions can
be broken, and GDB will just silently work around them.

I don't think this is a good idea.  GDB should encourage extensions to
be written correctly, and robustly, and one way in which GDB can (I
think) support this, is by pointing out when an extension goes wrong.

In this commit I've gone through the Python command completion code,
and added calls to gdbpy_print_stack() or gdbpy_print_stack_or_quit()
in places where we were either clearing the Python error, or, in some
cases, just not handling the error at all.

One thing I have not changed is in cmdpy_completer (py-cmd.c) where we
process the list of completions returned from the Command.complete
method; this routine includes a call to gdbpy_is_string to check a
possible completion is a string, if not the completion is ignored.

I was tempted to remove this check, attempt to complete each result to
a string, and display an error if the conversion fails.  After all,
returning anything but a string is surely a mistake by the extension
author.

However, the docs clearly say that only strings within the returned
list will be considered as completions.  Anything else is ignored.  As
such, and to avoid (what I think is pretty unlikely) breakage of
existing code, I've retained the gdbpy_is_string check.

After the gdbpy_is_string check we call python_string_to_host_string,
if this call fails then I do now print the error, where before we
ignored the error.  I think this is OK; if GDB thinks something is a
string, but still can't convert it to a string, then I think it's OK
to display the error in that case.

Another case which I was a little unsure about was in
cmdpy_completer_helper, and the call to PyObject_CallMethodObjArgs,
which is when we actually call Command.complete.  Previously, if this
call resulted in an exception then we would ignore this and just
pretend there were no completions.

Of all the changes, this is possibly the one with the biggest
potential for breaking existing scripts, but also, is, I think, the
most useful change.  If the user code is wrong in some way, such that
an exception is raised, then previously the user would have no obvious
feedback about this breakage.  Now GDB will print the exception for
them, making it, I think, much easier to debug their extension.  But,
if there is user code in the wild that relies on raising an exception
as a means to indicate there are no completions .... well, that code
is going to break after this commit.  I think we can live with this
though, the exceptions means no completions thing was never documented
behaviour.

I also added a new error() call if the PyObject_CallMethodObjArgs call
raises an exception.  This causes the completion mechanism within GDB
to stop.  Within GDB the completion code is called twice, the first
time to compute the work break characters, and then a second time to
compute the actual completions.

If PyObject_CallMethodObjArgs raises an exception when computing the
word break character, and we print it by calling
gdbpy_print_stack_or_quit(), but then carry on as if
PyObject_CallMethodObjArgs had returns no completions, GDB will
call the Python completion code again, which results in another call
to PyObject_CallMethodObjArgs, which might raise the same exception
again.  This results in the Python exception being printed twice.

By throwing a C++ exception after the failed
PyObject_CallMethodObjArgs call, the completion mechanism is aborted,
and no completions are offered.  But importantly, the Python exception
is only printed once.  I think this gives a much better user
experience.

I've added some tests to cover this case, as I think this is the most
likely case that a user will run into.

Approved-By: Tom Tromey <tom@tromey.com>
2023-11-28 18:23:19 +00:00
Andrew Burgess
b489eb9088 gdb/testsuite: improve test regexp in gdb_get_worker_threads
I spotted I made a small mistake in this commit:

  commit aff250145a
  Date:   Fri Nov 24 12:04:36 2023 +0000

      gdb: generate gdb-index identically regardless of work thread count

In this commit I added a new proc in testsuite/lib/gdb.exp called
gdb_get_worker_threads.  This proc uses gdb_test_multiple with two
possible patterns.  One pattern is anchored with '^', while the other
is missing the '^' which it could use.

This commit adds the missing '^'.
2023-11-28 18:20:25 +00:00
Mike Frysinger
0f2fd47320 gnulib: mark configure +x 2023-11-28 12:55:29 -05:00
Simon Marchi
0a3249820f gdb: fix call to breakpoint_inserted_here_p in darwin-nat.c
Fixes this issue, introduced by f9582a22db ("[gdb] Fix segfault in
for_each_block, part 1"):

       CXX    darwin-nat.o
     /Users/smarchi/src/binutils-gdb/gdb/darwin-nat.c:1169:7: error: no matching function for call to 'breakpoint_inserted_here_p'
       if (breakpoint_inserted_here_p (inf->aspace, pc))
           ^~~~~~~~~~~~~~~~~~~~~~~~~~

Change-Id: I3bb6be75b650319f0fa1dbdceb379b18531da96c
2023-11-28 12:25:56 -05:00
Jose E. Marchesi
927d9ccfd3 gas: add NEWS entry for change of comment syntax in BPF assembler
2023-11-28  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* NEWS: Add entry about change of comment syntax in the BPF
	assembler.
2023-11-28 17:52:59 +01:00
Tom Tromey
14e461bed4 Emit DAP "process" event
DAP specifies a "process" event that is sent when a process is started
or attached to.  gdb was not emitting this (several DAP clients appear
to ignore it entirely), but it looked easy and harmless to implement.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30473
2023-11-28 08:47:24 -07:00
Tom de Vries
1f6ce80388 [gdb/tui] Use const std::string for string literals in tui-stack.c
I noticed in gdb/tui/tui-stack.c a source-level micro-optimization where
strlen with a string literal argument:
...
strlen ("bla")
...
is replaced with sizeof:
...
sizeof ("bla") - 1
...

The benefit of this is that the optimization is also done at O0, but the
drawback is that it makes the expression harder to read.

Use const std::string to encapsulate the string literals, and use
std::string::size () instead.

I tried making the string names (PROC_PREFIX, LINE_PREFIX, PC_PREFIX and
SINGLE_KEY) lower-case, but that clashed with a pre-existing pc_prefix, so
I've left them upper-case.

Tested on x86_64-linux.

Tested-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
2023-11-28 16:31:07 +01:00