binutils-gdb.git
21 months agosim/ppc: Add ATTRIBUTE_PRINTF
Tsukasa OI [Thu, 6 Oct 2022 06:36:32 +0000 (06:36 +0000)]
sim/ppc: Add ATTRIBUTE_PRINTF

Clang generates a warning if the format string of a printf-like function is
not a literal ("-Wformat-nonliteral").  On the default configuration, it
causes a build failure (unless "--disable-werror" is specified).

To avoid warnings on the printf-like wrapper, it requires proper
__attribute__((format)) and we have ATTRIBUTE_PRINTF macro for this reason.

This commit adds ATTRIBUTE_PRINTF to the printf-like functions.

For the error function defined in sim_calls.c, the ATTRIBUTE_NORETURN
has been moved to the function declaration.

21 months agosim/m68hc11: Add ATTRIBUTE_PRINTF
Tsukasa OI [Thu, 6 Oct 2022 06:36:31 +0000 (06:36 +0000)]
sim/m68hc11: Add ATTRIBUTE_PRINTF

Clang generates a warning if the format string of a printf-like function is
not a literal ("-Wformat-nonliteral").  On the default configuration, it
causes a build failure (unless "--disable-werror" is specified).

To avoid warnings on the printf-like wrapper, it requires proper
__attribute__((format)) and we have ATTRIBUTE_PRINTF macro for this reason.

This commit adds ATTRIBUTE_PRINTF to a printf-like function.

21 months agosim/m32c: Add ATTRIBUTE_PRINTF
Tsukasa OI [Thu, 6 Oct 2022 06:36:30 +0000 (06:36 +0000)]
sim/m32c: Add ATTRIBUTE_PRINTF

Clang generates a warning if the format string of a printf-like function is
not a literal ("-Wformat-nonliteral").  On the default configuration, it
causes a build failure (unless "--disable-werror" is specified).

To avoid warnings on the printf-like wrapper, it requires proper
__attribute__((format)) and we have ATTRIBUTE_PRINTF macro for this reason.

This commit adds ATTRIBUTE_PRINTF to the printf-like functions.

21 months agosim/erc32: Add ATTRIBUTE_PRINTF
Tsukasa OI [Thu, 6 Oct 2022 06:36:29 +0000 (06:36 +0000)]
sim/erc32: Add ATTRIBUTE_PRINTF

Clang generates a warning if the format string of a printf-like function is
not a literal ("-Wformat-nonliteral").  On the default configuration, it
causes a build failure (unless "--disable-werror" is specified).

To avoid warnings on the printf-like wrapper, it requires proper
__attribute__((format)) and we have ATTRIBUTE_PRINTF macro for this reason.

This commit adds ATTRIBUTE_PRINTF to the printf-like functions.

21 months agosim/cris: Add ATTRIBUTE_PRINTF
Tsukasa OI [Thu, 6 Oct 2022 06:36:28 +0000 (06:36 +0000)]
sim/cris: Add ATTRIBUTE_PRINTF

Clang generates a warning if the format string of a printf-like function is
not a literal ("-Wformat-nonliteral").  On the default configuration, it
causes a build failure (unless "--disable-werror" is specified).

To avoid warnings on the printf-like wrapper, it requires proper
__attribute__((format)) and we have ATTRIBUTE_PRINTF macro for this reason.

This commit adds ATTRIBUTE_PRINTF to a printf-like function.

21 months agosim/common: Add ATTRIBUTE_PRINTF
Tsukasa OI [Thu, 6 Oct 2022 06:36:27 +0000 (06:36 +0000)]
sim/common: Add ATTRIBUTE_PRINTF

Clang generates a warning if the format string of a printf-like function is
not a literal ("-Wformat-nonliteral").  On the default configuration, it
causes a build failure (unless "--disable-werror" is specified).

To avoid warnings on the printf-like wrapper, it requires proper
__attribute__((format)) and we have ATTRIBUTE_PRINTF macro for this reason.

This commit adds ATTRIBUTE_PRINTF to a printf-like function.

21 months agofix compressed_debug_section_names definition for "zlib"
Martin Liska [Tue, 11 Oct 2022 13:25:06 +0000 (15:25 +0200)]
fix compressed_debug_section_names definition for "zlib"

bfd/ChangeLog:

* libbfd.c: Set COMPRESS_DEBUG_GABI_ZLIB for "zlib" value.

21 months agoadd --enable-default-compressed-debug-sections-algorithm configure option
Martin Liska [Mon, 3 Oct 2022 07:42:20 +0000 (09:42 +0200)]
add --enable-default-compressed-debug-sections-algorithm configure option

ChangeLog:

* configure.ac: Add --enable-default-compressed-debug-sections-algorithm.
* configure: Regenerate.

gas/ChangeLog:

* NEWS: Document the new option.
* as.c (flag_compress_debug): Set default algorithm based
on the configure option.
* configure.ac: Add --enable-default-compressed-debug-sections-algorithm.
* configure: Regenerate.
* config.in: Likewise.

ld/ChangeLog:

* NEWS: Document the new option.
* configure.ac: Add --enable-default-compressed-debug-sections-algorithm.
* configure: Regenerate.
* config.in: Likewise.
* ldmain.c: Set default algorithm based
on the configure option.

21 months agorefactor usage of compressed_debug_section_type
Martin Liska [Mon, 3 Oct 2022 07:11:00 +0000 (09:11 +0200)]
refactor usage of compressed_debug_section_type

bfd/ChangeLog:

* bfd-in.h (bfd_hash_set_default_size): Add COMPRESS_UNKNOWN
  enum value.
(struct compressed_type_tuple): New.
* bfd-in2.h (bfd_hash_set_default_size): Regenerate.
(struct compressed_type_tuple): Likewise.
* libbfd.c (ARRAY_SIZE): New macro.
(bfd_get_compression_algorithm): New function.
(bfd_get_compression_algorithm_name): Likewise.

gas/ChangeLog:

* as.c: Do not special-case, use the new functions.

ld/ChangeLog:

* emultempl/elf.em: Do not special-case, use the new functions.
* lexsup.c (elf_static_list_options): Likewise.

21 months agosim/riscv: fix multiply instructions on simulator
Tsukasa OI [Wed, 31 Aug 2022 01:46:08 +0000 (01:46 +0000)]
sim/riscv: fix multiply instructions on simulator

After this commit:

  commit 0938b032daa52129b4215d8e0eedb6c9804f5280
  Date:   Wed Feb 2 10:06:15 2022 +0900

      RISC-V: Add 'Zmmul' extension in assembler.

some instructions in the RISC-V simulator stopped working as a new
instruction class 'INSN_CLASS_ZMMUL' was added, and some existing
instructions were moved into this class.

The simulator doesn't currently handle this instruction class, and so
the instructions will now cause an illegal instruction trap.

This commit adds support for INSN_CLASS_ZMMUL, and adds a test that
ensures the affected instructions can be executed by the simulator.

Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Reviewed-by: Andrew Burgess <aburgess@redhat.com>
21 months agoError: attempt to get value of unresolved symbol `L0'
Nick Clifton [Tue, 11 Oct 2022 10:52:38 +0000 (11:52 +0100)]
Error: attempt to get value of unresolved symbol `L0'

* symbols.c (S_GET_VALUE): If the unresolved symbol is the fake
label provide a more helpful error message to the user.

21 months agosim/moxie: add custom directory stamp rule
Tsukasa OI [Sun, 9 Oct 2022 03:57:12 +0000 (03:57 +0000)]
sim/moxie: add custom directory stamp rule

Because sim/moxie/moxie-gdb.dtb is neither a program nor a library, automake
does not generate dirstamp file ($builddir/sim/moxie/.dirstamp) for it.

When maintainer mode is enabled, it tries to rebuild sim/moxie/moxie-gdb.dtb
but fails because there's no rules for automake-generated dirstamp file
which moxie-gdb.dtb depends.

This commit adds its own rule for the directory stamp (modified copy of the
automake output) and adds the directory stamp file to DISTCLEANFILES to
mimic automake-generated behavior (although "make distclean" does not work
when maintainer mode is enabled).

21 months agogdb/testsuite: Fix formatting of python script
Bruno Larsen [Tue, 11 Oct 2022 09:22:37 +0000 (11:22 +0200)]
gdb/testsuite: Fix formatting of python script

The python black formatter was complaining about formatting on the
script gdb.python/pretty-print-call-by-hand.py.  This commit changed
the offending lines to make the formatter happy.

21 months ago[gdb/testsuite] Fix prompt parsing in capture_command_output
Tom de Vries [Tue, 11 Oct 2022 08:14:38 +0000 (10:14 +0200)]
[gdb/testsuite] Fix prompt parsing in capture_command_output

I noticed in capture_command_output that the output of a single command is
matched using two gdb_test_multiples:
- the first one matching the echoed command and skipping an optional prefix,
- the second one matching the output and the prompt.

This is error-prone, because the first gdb_test_multiple has implicit
clauses which may consume the prompt.

The problem is easy to spot with an example.  First consider:
...
set output [capture_command_output "print 1" "\\\$1 = "]
gdb_assert { [string equal $output "1"] }
...
for which we get:
...
PASS: [string equal $output "1"]
...

If we change the prefix string to a no-match, say "1 = ", and update the
output string match accordingly, we get instead:
...
FAIL: capture_command_output for print 1
FAIL: [string equal $output "\$1 = 1"]
...

The first FAIL is produced by the first gdb_test_multiple, consuming the prompt.

The second gdb_test_multiple then silently times out waiting for another prompt,
after which the second FAIL is produced.  Note that the timeout is silent
because the gdb_test_multiple is called with an empty message argument.

The second FAIL is because capture_command_output returns "", given that all
the command output was consumed by the first gdb_test_multiple.

Fix this by rewriting capture_command_output to use only a single
gdb_test_multiple.

Tested on x86_64-linux.

21 months agogprofng: no need to build version.texi
Vladimir Mezentsev [Mon, 10 Oct 2022 23:50:13 +0000 (16:50 -0700)]
gprofng: no need to build version.texi

gprofng/ChangeLog
2022-10-10  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

PR gprofng/29465
PR gprofng/29667
* doc/Makefile.am: No need to build version.texi.
* doc/Makefile.in: Rebuild.

21 months agogprofng: use the --libdir path to find libraries
Vladimir Mezentsev [Mon, 10 Oct 2022 22:34:42 +0000 (15:34 -0700)]
gprofng: use the --libdir path to find libraries

gprofng/ChangeLog
2022-10-10  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

PR gprofng/29663
* src/Makefile.am: Add -DLIBDIR to CPPFLAGS.
* src/Makefile.in: Rebuild.
* src/envsets.cc (putenv_libcollector_ld_misc): Use LIBDIR to find
the gprofng libraries.

21 months agogprofng: run tests without installation
Vladimir Mezentsev [Mon, 10 Oct 2022 19:57:19 +0000 (12:57 -0700)]
gprofng: run tests without installation

gprofng/ChangeLog
2022-10-10  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

PR gprofng/29107
* testsuite/config/default.exp: Set up environment to run gprofng tests
without installation.
* testsuite/lib/Makefile.skel: Likewise.
* testsuite/lib/display-lib.exp: Likewise.

21 months agogdb/testsuite: fix race in gdb.base/async-shell.exp
Simon Marchi [Mon, 10 Oct 2022 01:21:53 +0000 (21:21 -0400)]
gdb/testsuite: fix race in gdb.base/async-shell.exp

I see some random failures in this test:

    FAIL: gdb.base/async-shell.exp: run & (timeout)

It can be reliably reproduced on a recent enough GNU/Linux with this
change:

    diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
    index 44cc28b30051..2a3c8253ba5a 100644
    --- a/gdb/testsuite/lib/gdb.exp
    +++ b/gdb/testsuite/lib/gdb.exp
    @@ -1301,6 +1301,7 @@ proc gdb_test_multiple { command message args } {
         }
         set gdb_test_name "$message"

    +    sleep 2
         set result 0
         set code [catch {gdb_expect $code} string]

"recent enough" means a system where libpthread.so was merged with
libc.so, so at least glibc 2.34.

The problem is that the `run &` command prints some things after the
prompt:

    (gdb) [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/usr/lib/../lib/libthread_db.so.1".

If expect is quick enough, it will consume only up to the prompt.  But
if it is slow enough, it will consume those messages at the same time as
the prompt, in which case the gdb_test used for "run &" won't match.  By
default, the prompt used by gdb_test uses a `$` to anchor the match at
the end of the buffer.  If there's anything following the prompt, it
won't match.

The diff above adds a delay between sending the command and consuming
the output, giving GDB more time to output the messages, giving a good
chance that expect consumes them at the same time as the prompt.

This is normally handled by using gdb_test_multiple and specifying a
pattern that ends with "$gdb_prompt", but not a trailing $.  I think
this is common enough that it deserves its own gdb_test option.
Therefore, add the -no-anchor-prompt option to gdb_test, and
gdb_test_no_output for completeness.  Use it in
gdb.base/async-shell.exp.

Change-Id: I9051d8800d1c10a2e95db1a575991f7723492f1b
Approved-By: Tom de Vries <tdevries@suse.de>
21 months agoAutomatic date update in version.in
GDB Administrator [Tue, 11 Oct 2022 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in

21 months agoFix a latent bug in print_wchar
Tom Tromey [Sun, 13 Feb 2022 01:41:34 +0000 (18:41 -0700)]
Fix a latent bug in print_wchar

print_wchar keeps track of when escape sequences are emitted, to force
an escape sequence if needed by a subsequent character.  For example
for the string concatenation "\0" "1", gdb will print "\000\061" --
because printing "\0001" might be confusing.

However, this code has two errors.  First, this logic is not needed
for octal escapes, because there is a length limit of 3 for octal
escapes, and gdb always prints these with "%.3o".  Second, though,
this *is* needed for hex escapes, because those do not have a length
limit.

This patch fixes these problems and adds the appropriate tests.

21 months agoDon't use wchar_printable in print_wchar
Tom Tromey [Sat, 12 Feb 2022 01:24:23 +0000 (18:24 -0700)]
Don't use wchar_printable in print_wchar

print_wchar uses wchar_printable, but this isn't needed -- all the
relevant cases are already handled by the 'switch'.  This changes the
code to use gdb_iswprint, and removes a somewhat confusing comment
related to this code.

21 months agoRemove c_printstr
Tom Tromey [Sat, 12 Feb 2022 01:14:17 +0000 (18:14 -0700)]
Remove c_printstr

This renames c_printstr, removing a layer of indirection.

21 months agoRemove c_emit_char
Tom Tromey [Sat, 12 Feb 2022 01:10:00 +0000 (18:10 -0700)]
Remove c_emit_char

This renames c_emit_char, removing a layer of indirection.

21 months agoBoolify need_escape in generic_emit_char
Tom Tromey [Thu, 10 Feb 2022 23:57:34 +0000 (16:57 -0700)]
Boolify need_escape in generic_emit_char

This changes 'need_escape' in generic_emit_char to be of type bool,
rather than int.

21 months agoFix latent quote char bug in generic_printstr
Tom Tromey [Thu, 27 Jan 2022 01:07:18 +0000 (18:07 -0700)]
Fix latent quote char bug in generic_printstr

generic_printstr prints an empty string like:

      fputs_filtered ("\"\"", stream);

However, this seems wrong to me if the quote character is something
other than double quote.  This patch fixes this latent bug.  Thanks to
Andrew for the test case.

Co-authored-by: Andrew Burgess <aburgess@redhat.com>
21 months agoFix the guile build
Tom Tromey [Mon, 10 Oct 2022 13:47:32 +0000 (07:47 -0600)]
Fix the guile build

The frame_info_ptr patches broke the build with Guile.  This patch
fixes the problem.  In mos cases I chose to preserve the use of
frame_info_ptr, at least where I could be sure that the object
lifetime did not interact with Guile's longjmp-based exception scheme.

Tested on x86-64 Fedora 34.

21 months ago[gdb/testsuite] Detect trailing ^C/^D in command
Tom de Vries [Mon, 10 Oct 2022 14:24:38 +0000 (16:24 +0200)]
[gdb/testsuite] Detect trailing ^C/^D in command

Detect a trailing ^C/^D in the command argument of gdb_test_multiple, and
error out.

Tested on x86_64-linux.

21 months ago[gdb/testsuite] Fix error message for cmd with trailing newline
Tom de Vries [Mon, 10 Oct 2022 12:44:40 +0000 (14:44 +0200)]
[gdb/testsuite] Fix error message for cmd with trailing newline

I noticed that the error message in gdb_test_multiple about trailing newline
in a command does not mention the offending command, nor the word command:
...
    if [string match "*\[\r\n\]" $command] {
        error "Invalid trailing newline in \"$message\" test"
    }
...

Fix this by using instead:
...
        error "Invalid trailing newline in \"$command\" command"
...

Also add a test-case to trigger this: gdb.testsuite/gdb-test.exp.

Tested on x86_64-linux.

21 months agogdb: include the base address in in-memory bfd filenames
Andrew Burgess [Wed, 5 Oct 2022 14:26:11 +0000 (15:26 +0100)]
gdb: include the base address in in-memory bfd filenames

The struct target_buffer (in gdb_bfd.c) is used to hold information
about an in-memory BFD object created by GDB.  For now this mechanism
is used by GDB when loading information about JIT symfiles.

This commit updates target_buffer (in gdb_bfd.c) to be more C++ like,
and, at the same time, adds the base address of the symfile into the
BFD filename.

Right now, every in-memory BFD is given the filename "<in-memory>".
This filename is visible in things like 'maint info symtabs' and
'maint info line-table'.  If there are multiple in-memory BFD objects
then it can be hard to match keep track if which BFD is which.  This
commit changes the name to be "<in-memory@ADDRESS>" where ADDRESS is
replaced with the base address for where the in-memory symbol file was
read from.

As an example of how this is useful, here's the output of 'maint info
jit' showing a single loaded JIT symfile:

  (gdb) maintenance info jit
  jit_code_entry address symfile address    symfile size
  0x00000000004056b0     0x0000000007000000 17320

And here's part of the output from 'maint info symtabs':

  (gdb) maintenance info symtabs
  ...snip...
  { objfile <in-memory@0x7000000> ((struct objfile *) 0x5258250)
    { ((struct compunit_symtab *) 0x4f0afb0)
      debugformat DWARF 4
      producer GNU C17 9.3.1 20200408 (Red Hat 9.3.1-2) -mtune=generic -march=x86-64 -g -fno-stack-protector -fpic
      name jit-elf-solib.c
      dirname /tmp/binutils-gdb/build/gdb/testsuite
      blockvector ((struct blockvector *) 0x5477850)
      user ((struct compunit_symtab *) (null))
   { symtab /tmp/binutils-gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/jit-elf-solib.c ((struct symtab *) 0x4f0b030)
     fullname (null)
     linetable ((struct linetable *) 0x5477880)
   }
    }
  }

I've added a new test that checks the new in-memory file names are
generated correctly, and also checks that the in-memory JIT files can
be dumped back out using 'dump binary memory'.

21 months agogdb: remove filename arg from gdb_bfd_open_from_target_memory
Andrew Burgess [Wed, 5 Oct 2022 14:25:59 +0000 (15:25 +0100)]
gdb: remove filename arg from gdb_bfd_open_from_target_memory

The filename argument to gdb_bfd_open_from_target_memory was never
used; this argument had a default value of nullptr, and the only call
to this function, in jit.c, relied on the default value.

In the next commit I'm going to make some changes to the
gdb_bfd_open_from_target_memory function, and, though I could take
account of a filename parameter, it seems pointless to maintain an
unused argument.

This commit removes the filename argument.

There should be no user visible changes after this commit.

21 months agogdb: add infcall specific debugging
Andrew Burgess [Tue, 10 May 2022 14:16:46 +0000 (15:16 +0100)]
gdb: add infcall specific debugging

Add two new commands:

  set debug infcall on|off
  show debug infcall

These enable some new debugging related to when GDB makes inferior
function calls.  I've added some basic debugging for what I think are
the major steps in the inferior function call process, but I'm sure we
might want to add more later.

21 months agogdb: extra debug output in thread.c
Andrew Burgess [Mon, 5 Sep 2022 15:56:35 +0000 (16:56 +0100)]
gdb: extra debug output in thread.c

Add some extra 'threads' debug in a couple of places in thread.c.
I've also added an additional gdb_assert in one case.

21 months agogdb: improve infrun_debug_show_threads output
Andrew Burgess [Tue, 10 May 2022 14:15:44 +0000 (15:15 +0100)]
gdb: improve infrun_debug_show_threads output

This commit switches to use INFRUN_SCOPED_DEBUG_START_END in the
infrun_debug_show_threads function, which means the output will get an
extra level of indentation, this looks a little nicer I think.

21 months agoAdd ability to create reproducible source tarballs.
Nick Clifton [Mon, 10 Oct 2022 10:28:45 +0000 (11:28 +0100)]
Add ability to create reproducible source tarballs.

* src-release.sh: Add "-r <date>" option to create reproducible
tarballs based upon a fixed timestamp of <date>.
* binutils/README-how-to-make-a-release: Add a line showing how to
use -r <date> when creating a binutils release.

21 months agogdb/frame: Add reinflation method for frame_info_ptr
Bruno Larsen [Mon, 25 Jul 2022 17:06:37 +0000 (14:06 -0300)]
gdb/frame: Add reinflation method for frame_info_ptr

Currently, despite having a smart pointer for frame_infos, GDB may
attempt to use an invalidated frame_info_ptr, which would cause internal
errors to happen.  One such example has been documented as PR
python/28856, that happened when printing frame arguments calls an
inferior function.

To avoid failures, the smart wrapper was changed to also cache the frame
id, so the pointer can be reinflated later.  For this to work, the
frame-id stuff had to be moved to their own .h file, which is included
by frame-info.h.

Frame_id caching is done explicitly using the prepare_reinflate method.
Caching is done manually so that only the pointers that need to be saved
will be, and reinflating has to be done manually using the reinflate
method because the get method and the -> operator must not change
the internals of the class.  Finally, attempting to reinflate when the
pointer is being invalidated causes the following assertion errors:

check_ptrace_stopped_lwp_gone: assertion `lp->stopped` failed.
get_frame_pc: Assertion `frame->next != NULL` failed.

As for performance concerns, my personal testing with `time make
chec-perf GDB_PERFTEST_MODE=run` showed an actual reduction of around
10% of time running.

This commit also adds a testcase that exercises the python/28856 bug with
7 different triggers, run, continue, step, backtrace, finish, up and down.
Some of them can seem to be testing the same thing twice, but since this
test relies on stale pointers, there is always a chance that GDB got lucky
when testing, so better to test extra.

Regression tested on x86_64, using both gcc and clang.

Approved-by: Tom Tomey <tom@tromey.com>
21 months agoChange GDB to use frame_info_ptr
Tom Tromey [Mon, 25 Jul 2022 17:06:35 +0000 (14:06 -0300)]
Change GDB to use frame_info_ptr

This changes GDB to use frame_info_ptr instead of frame_info *
The substitution was done with multiple sequential `sed` commands:

sed 's/^struct frame_info;/class frame_info_ptr;/'
sed 's/struct frame_info \*/frame_info_ptr /g' - which left some
    issues in a few files, that were manually fixed.
sed 's/\<frame_info \*/frame_info_ptr /g'
sed 's/frame_info_ptr $/frame_info_ptr/g' - used to remove whitespace
    problems.

The changed files were then manually checked and some 'sed' changes
undone, some constructors and some gets were added, according to what
made sense, and what Tromey originally did

Co-Authored-By: Bruno Larsen <blarsen@redhat.com>
Approved-by: Tom Tomey <tom@tromey.com>
21 months agoIntroduce frame_info_ptr smart pointer class
Tom Tromey [Mon, 25 Jul 2022 17:06:34 +0000 (14:06 -0300)]
Introduce frame_info_ptr smart pointer class

This adds frame_info_ptr, a smart pointer class.  Every instance of
the class is kept on an intrusive list.  When reinit_frame_cache is
called, the list is traversed and all the pointers are invalidated.
This should help catch the typical GDB bug of keeping a frame_info
pointer alive where a frame ID was needed instead.

Co-Authored-By: Bruno Larsen <blarsen@redhat.com>
Approved-by: Tom Tomey <tom@tromey.com>
21 months agoRemove frame_id_eq
Tom Tromey [Mon, 25 Jul 2022 17:06:33 +0000 (14:06 -0300)]
Remove frame_id_eq

This replaces frame_id_eq with operator== and operator!=.  I wrote
this for a version of this series that I later abandoned; but since it
simplifies the code, I left this patch in.

Approved-by: Tom Tomey <tom@tromey.com>
21 months agogdb/testsuite: use 'end' at the end of python blocks
Andrew Burgess [Sat, 8 Oct 2022 15:58:00 +0000 (16:58 +0100)]
gdb/testsuite: use 'end' at the end of python blocks

Within the testsuite, use the keyword 'end' to terminate blocks of
Python code being sent to GDB, rather than sending \004.  I could only
find three instances of this, all in tests that I originally wrote.  I
have no memory of there being any special reason why I used \004
instead of 'end' - I assume I copied this from somewhere else that has
since changed.

Non of the tests being changed here are specifically about whether
\004 can be used to terminate a Python block, so I think switching to
the more standard 'end' keyword is the right choice.

21 months agogdbsupport: re-generate configure
Simon Marchi [Mon, 10 Oct 2022 01:27:37 +0000 (21:27 -0400)]
gdbsupport: re-generate configure

I get this diff when re-generating configure, probably leftover from
67d1991b785 ("egrep in binutils").

Change-Id: I759c88c2bad648736d33ff98089db45c9b686356

21 months agoMerge configure.ac from gcc project
Alan Modra [Mon, 10 Oct 2022 00:38:40 +0000 (11:08 +1030)]
Merge configure.ac from gcc project

To merge with gcc's copy of configure.ac we need to revert changes to
configure.ac in the following gcc commits:
dc832fb39fc0 2022-08-25
fc259b522c0f 2022-06-25
Then reapply configure.ac changes in binutils from these binutils
commits:
50ad1254d503 2021-01-09
bb368aad297f 2022-03-11
e5f2f7d901ee 2022-07-26
2cac01e3ffff 2022-09-26
Plus copy over gcc's config/ax_cxx_compile_stdcxx.m4, then regenerate
configure.

21 months agoAutomatic date update in version.in
GDB Administrator [Mon, 10 Oct 2022 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in

21 months agoAutomatic date update in version.in
GDB Administrator [Sun, 9 Oct 2022 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in

21 months agoMerge both implementations of debug_names::insert
Tom Tromey [Fri, 23 Sep 2022 22:23:41 +0000 (16:23 -0600)]
Merge both implementations of debug_names::insert

The class debug_names has two 'insert' overloads, but only one of them
is ever called externally, and it simply forwards to the other
implementation.  It seems cleaner to me to have a single method, so
this patch merges the two.

21 months ago[gdb/testsuite] Fix silent fail in gdb.server/connect-with-no-symbol-file.exp
Tom de Vries [Sat, 8 Oct 2022 08:47:47 +0000 (10:47 +0200)]
[gdb/testsuite] Fix silent fail in gdb.server/connect-with-no-symbol-file.exp

With native and target boards native-gdbserver, remote-gdbserver-on-localhost and
remote-stdio-gdbserver I have for gdb.server/connect-with-no-symbol-file.exp:
...
 # of expected passes            8
...
but with native-extended-gdbserver I have instead:
...
 # of expected passes            8
 # of unexpected failures        4
...

The extra FAILs are of the form:
...
(gdb) detach^M
Detaching from pid process 28985^M
[Inferior 1 (process 28985) detached]^M
(gdb) FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: \
  action=permission: connection to GDBserver succeeded
...
and are due to the fact that the actual gdb output doesn't match the regexp:
...
    gdb_test "detach" \
       ".*Detaching from program: , process.*Ending remote debugging.*" \
       "connection to GDBserver succeeded"
...

With native, the actual gdb output is:
...
(gdb) detach^M
Detaching from pid process 29657^M
Ending remote debugging.^M
[Inferior 1 (process 29657) detached]^M
(gdb) Remote debugging from host ::1, port 51028^M
...
and because the regexp doesn't match, it triggers an implicit clause for
"Ending remote debugging" in gdb_test_multiple, which has the consequence
that the FAIL is silent.

Fix:
- the regexp by making it less strict
- the silent fail by rewriting into a gdb_test_multiple, and adding an
  explicit fail clause.

Tested on x86_64-linux, using native and aforementioned target boards.

21 months agoAutomatic date update in version.in
GDB Administrator [Sat, 8 Oct 2022 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in

21 months agogdb/testsuite: fix gdb.threads/linux-dp.exp regex
Lancelot SIX [Fri, 7 Oct 2022 13:44:40 +0000 (14:44 +0100)]
gdb/testsuite: fix gdb.threads/linux-dp.exp regex

On ubuntu 22.04 with the libc6-dbg package installed, I have the
following failure:

    where
    #0  print_philosopher (n=3, left=33 '!', right=33 '!') at .../gdb/testsuite/gdb.threads/linux-dp.c:105
    #1  0x000055555555576a in philosopher (data=0x55555555937c) at .../gdb/testsuite/gdb.threads/linux-dp.c:148
    #2  0x00007ffff7e11b43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
    #3  0x00007ffff7ea3a00 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
    (gdb) FAIL: gdb.threads/linux-dp.exp: first thread-specific breakpoint hit

The regex for this test accounts for different situations (with /
without debug symbol) but assumes that if debug info is present the
backtrace shows execution under pthread_create.  However, for the
implementation under test, we are under start_thread.

Update the regex to accept start_thread.

Tested on Ubuntu-22.04 x86_64 with and without libc6-dbg debug symbols
available.

Change-Id: I1e1536279890bca2cd07f038e026b41e46af44e0

21 months ago[gdb/testsuite] Handle host cleanfiles
Tom de Vries [Fri, 7 Oct 2022 16:08:00 +0000 (18:08 +0200)]
[gdb/testsuite] Handle host cleanfiles

When running test-case gdb.server/abspath.exp with host board
local-remote-host-notty, I get:
...
$ git sti
  ...
        deleted:    gdb/testsuite/gdb.xml/trivial.xml
...

This happens as follows.  The test-case calls skip_gdbserver_test, which calls
gdb_skip_xml_test, which does:
...
    set xml_file [gdb_remote_download host "${srcdir}/gdb.xml/trivial.xml"]
...

Then proc gdb_remote_download appends $xml_file (which for this particular
host board happens to be ${srcdir}/gdb.xml/trivial.xml) to cleanfiles, which
ends up being handled in gdb_finish by:
...
       eval remote_file target delete $cleanfiles
...

The problem is that a host file is deleted using target delete.

Fix this by splitting cleanfiles up in cleanfiles_target and cleanfiles_host.

Tested on x86_64-linux.

21 months ago[gdb/testsuite] Remove unnecessary warning in gdb.base/default.exp
Tom de Vries [Fri, 7 Oct 2022 14:17:35 +0000 (16:17 +0200)]
[gdb/testsuite] Remove unnecessary warning in gdb.base/default.exp

When running test-case gdb.base/default.exp with target board
native-gdbserver, we get:
...
WARNING: Skipping backtrace and break tests because of GDB stub.
...

There's no need for such a warning, so remove it.

Tested on x86_64-linux with native and target board native-gdbserver.

21 months ago[gdb/testsuite] Fix have_mpx with remote-gdbserver-on-localhost
Tom de Vries [Fri, 7 Oct 2022 14:17:35 +0000 (16:17 +0200)]
[gdb/testsuite] Fix have_mpx with remote-gdbserver-on-localhost

With target board remote-gdbserver-on-localhost and gdb.arch/i386-mpx-call.exp
I run into:
...
FAIL: gdb.arch/i386-mpx-call.exp: upper_bnd0: continue to a bnd violation
...

This is due to the have_mpx test which should return 0, but instead returns 1
because the captured output:
...
No MPX support
No MPX support
...
does not match the used regexp:
...
    set status [expr ($status == 0) \
                   && ![regexp "^No MPX support\r\n" $output]]
...
which does match the captured output with native:
...
No MPX support^M
No MPX support^M
...

Fix this by making the \r in the regexp optional.

Tested on x86_64-linux, with native and target board
remote-gdbserver-on-localhost.

21 months ago[gdb/testsuite] Fix DUPLICATEs with remote-gdbserver-on-localhost
Tom de Vries [Fri, 7 Oct 2022 14:17:34 +0000 (16:17 +0200)]
[gdb/testsuite] Fix DUPLICATEs with remote-gdbserver-on-localhost

Fix some DUPLICATEs that we run into with target board
remote-gdbserver-on-localhost, by using test_with_prefix.

Tested on x86_64-linux, with native and target board
remote-gdbserver-on-localhost.

21 months ago[gdb/testsuite] Fix path in test name in gdb_load_shlib
Tom de Vries [Fri, 7 Oct 2022 14:17:34 +0000 (16:17 +0200)]
[gdb/testsuite] Fix path in test name in gdb_load_shlib

When running test-case gdb.server/solib-list.exp with target board
remote-gdbserver-on-localhost, I run into:
...
(gdb) set solib-search-path $outputs/gdb.server/solib-list^M
(gdb) PASS: gdb.server/solib-list.exp: non-stop 0: \
  set solib-search-path $outputs/gdb.server/solib-list
PATH: gdb.server/solib-list.exp: non-stop 0: \
  set solib-search-path $outputs/gdb.server/solib-list
...

This is due to this code in gdb_load_shlib:
...
       gdb_test "set solib-search-path [file dirname $file]" "" ""
...

Fix this by setting an explicit test name.

Tested on x86_64-linux, with native and target boards
remote-gdbserver-on-localhost, native-gdbserver and native-extended-gdbserver.

21 months agoPR29653, objcopy/strip: fuzzed small input file induces large output file
Alan Modra [Thu, 6 Oct 2022 23:53:05 +0000 (10:23 +1030)]
PR29653, objcopy/strip: fuzzed small input file induces large output file

_bfd_check_format functions should not print errors or warnings if
they return NULL.  A NULL return means the particular target under
test does not match, so there isn't any reason to make a complaint
about the target.  In fact there isn't a good reason to warn even if
the target matches, except via the _bfd_per_xvec_warn mechanism; Some
other target might be a better match.

This patch tidies pe_bfd_object_p with the above in mind, and
restricts the PE optional header SectionAlignment and FileAlignment
fields somewhat.  I chose to warn on nonsense values rather than
refusing to match.  Refusing to match would be OK too.

PR 29653
* peXXigen.c (_bfd_XXi_swap_aouthdr_in): Don't emit error about
invalid NumberOfRvaAndSizes here.  Limit loop copying data
directory to IMAGE_NUMBEROF_DIRECTORY_ENTRIES.
* peicode.h (pe_bfd_object_p): Don't clear and test bfd_error
around bfd_coff_swap_aouthdr_in.  Warn on invalid SectionAlignment,
FileAlignment and NumberOfRvaAndSizes.  Don't return NULL on
invalid NumberOfRvaAndSizes.

21 months agoAutomatic date update in version.in
GDB Administrator [Fri, 7 Oct 2022 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in

21 months agoFix indentation in riscv-tdep.c
Tom Tromey [Thu, 6 Oct 2022 17:26:38 +0000 (11:26 -0600)]
Fix indentation in riscv-tdep.c

This just fixes some indentation in riscv-tdep.c.

21 months agogdb/arm: Handle lazy FPU state preservation
Torbjörn SVENSSON [Thu, 6 Oct 2022 14:01:10 +0000 (16:01 +0200)]
gdb/arm: Handle lazy FPU state preservation

Read LSPEN, ASPEN and LSPACT bits from FPCCR and use them together
with FPCAR to identify if lazy FPU state preservation is active for
the current frame.  See "Lazy context save of FP state", in B1.5.7,
also ARM AN298, supported by Cortex-M4F architecture for details on
lazy FPU register stacking.  The same conditions are valid for other
Cortex-M cores with FPU.

This patch has been verified on a STM32F4-Discovery board by:
a) writing a non-zero value (lets use 0x1122334455667788 as an
   example) to all the D-registers in the main function
b) configured the SysTick to fire
c) in the SysTick_Handler, write some other value (lets use
   0x0022446688aaccee as an example) to one of the D-registers (D0 as
   an example) and then do "SVC #0"
d) in the SVC_Handler, write some other value (lets use
   0x0099aabbccddeeff) to one of the D-registers (D0 as an example)

In GDB, suspend the execution in the SVC_Handler function and compare
the value of the D-registers for the SVC_handler frame and the
SysTick_Handler frame.  With the patch, the value of the modified
D-register (D0) should be the new value (0x009..eff) on the
SVC_Handler frame, and the intermediate value (0x002..cee) for the
SysTick_Handler frame.  Now compare the D-register value for the
SysTick_Handler frame and the main frame.  The main frame should
have the initial value (0x112..788).

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Signed-off-by: Yvan ROUX <yvan.roux@foss.st.com>
21 months ago[gdb/symtab] Factor out have_complaint
Tom de Vries [Thu, 6 Oct 2022 12:53:07 +0000 (14:53 +0200)]
[gdb/symtab] Factor out have_complaint

After committing 8ba677d3560 ("[gdb/symtab] Don't complain about function
decls") I noticed that quite a bit of code in read_func_scope is used to decide
whether to issue the "cannot get low and high bounds for subprogram DIE at
$hex" complaint, which executes unnecessarily if we have the default
"set complaints 0".

Fix this by (NFC):
- factoring out new static function have_complaint from macro complaint, and
- using it to wrap the relevant code in read_func_scope.

Tested on x86_64-linux.

21 months agogdb: add missing nullptr checks in bpstat_check_breakpoint_conditions
Andrew Burgess [Thu, 6 Oct 2022 08:35:18 +0000 (09:35 +0100)]
gdb: add missing nullptr checks in bpstat_check_breakpoint_conditions

Add a couple of missing nullptr checks in the function
bpstat_check_breakpoint_conditions.

No user visible change after this commit.

21 months agogdb: more infrun debug from breakpoint.c
Andrew Burgess [Tue, 4 Oct 2022 12:51:46 +0000 (13:51 +0100)]
gdb: more infrun debug from breakpoint.c

This commit adds additional infrun debug from the breakpoint.c file.
The new debug output all relates to breakpoint condition evaluation.

There is already some infrun debug emitted from the breakpoint.c file,
so hopefully, adding more will not be contentious.  I think the
functions being instrumented make sense as part of the infrun process,
the inferior stops, evaluates the condition, and then either stops or
continues.  This new debug gives more insight into that process.

I had to make the bp_location* argument to find_loc_num_by_location
const, and add a declaration for find_loc_num_by_location.

There should be no user visible changes unless they turn on debug
output.

21 months agogdb: add some additional debug in mark_async_event_handler
Andrew Burgess [Tue, 4 Oct 2022 10:59:26 +0000 (11:59 +0100)]
gdb: add some additional debug in mark_async_event_handler

Extend the existing debug printf call to include the previous state of
the async_event_handler object.

21 months agoRISC-V: Print XTheadMemPair literal as "immediate"
Tsukasa OI [Mon, 26 Sep 2022 10:47:53 +0000 (10:47 +0000)]
RISC-V: Print XTheadMemPair literal as "immediate"

The operand type "Xl(...)" denotes that (...) is a literal.  Specifically,
they are intended to be a constant immediate value.

This commit prints "Xl(...)" operand with dis_style_immediate style,
not dis_style_text.

opcodes/ChangeLog:

* riscv-dis.c (print_insn_args): Use dis_style_immediate on
the constant literal of the "Xl..." operand.

21 months agoRISC-V: Fix T-Head immediate types on printing
Tsukasa OI [Mon, 26 Sep 2022 11:13:51 +0000 (11:13 +0000)]
RISC-V: Fix T-Head immediate types on printing

This commit fixes two minor typing-related issues for
T-Head immediate operands.

1.  A signed type must be specified when printing with %i.
2.  unsigned/signed int is not portable enough for max 32-bit immediates.
    Instead, we should use unsigned/signed long.
    The format string is changed accordingly.

opcodes/ChangeLog:

* riscv-dis.c (print_insn_args): Fix T-Head immediate types on
printing.

21 months agoRISC-V: Print comma and tabs as the "text" style
Tsukasa OI [Tue, 2 Aug 2022 08:51:44 +0000 (17:51 +0900)]
RISC-V: Print comma and tabs as the "text" style

On the RISC-V disassembler, some separators have non-text style when
printed with another word with another style.

This commit splits those, making sure that those comma and tabs are printed
with the "text" style.

opcodes/ChangeLog:

* riscv-dis.c (print_insn_args): Split and print the comma as
text.  (riscv_disassemble_insn): Split and print tabs as text.
(riscv_disassemble_data): Likewise.

21 months agoRISC-V: Optimize riscv_disassemble_data printf
Tsukasa OI [Tue, 2 Aug 2022 08:18:33 +0000 (17:18 +0900)]
RISC-V: Optimize riscv_disassemble_data printf

This commit makes types of printf arguments on riscv_disassemble_data
as small as possible (as long as we can preserve the portability) to reduce
the cost of printf (especially on 32-bit host).

opcodes/ChangeLog:

* riscv-dis.c (riscv_disassemble_data): Use smallest possible type
to printing data.

21 months agoRISC-V: Fix printf argument types corresponding %x
Tsukasa OI [Wed, 13 Jul 2022 13:33:07 +0000 (22:33 +0900)]
RISC-V: Fix printf argument types corresponding %x

"%x" format specifier requires unsigned type, not int.  This commit
fixes this issue on the RISC-V disassembler.

opcodes/ChangeLog:

* riscv-dis.c (print_insn_args): Fix printf argument types where
the format specifier is "%x".

21 months agoRISC-V: Fix immediates to have "immediate" style
Tsukasa OI [Tue, 2 Aug 2022 08:42:44 +0000 (17:42 +0900)]
RISC-V: Fix immediates to have "immediate" style

This commit fixes certain print calls on immediate operands to have
dis_style_immediate.

opcodes/ChangeLog:

* riscv-dis.c (print_insn_args): Fix immediates to have
"immediate" style.  (riscv_disassemble_data): Likewise.

21 months agoAutomatic date update in version.in
GDB Administrator [Thu, 6 Oct 2022 00:00:17 +0000 (00:00 +0000)]
Automatic date update in version.in

21 months agoRe: bfd BLD-POTFILES.in dependencies
Alan Modra [Wed, 5 Oct 2022 23:15:56 +0000 (09:45 +1030)]
Re: bfd BLD-POTFILES.in dependencies

Removing $BLD_POTFILES from BFD-POTFILES.in was correct, but left a
hole in dependencies.
make[4]: Entering directory '/home/alan/build/gas/all/bfd/po'
make[4]: *** No rule to make target '../elf32-aarch64.c', needed by '/home/alan/src/binutils-gdb/bfd/po/bfd.pot'.  Stop.

* Makefile.am (BUILT_SOURCES): Add BUILD_CFILES.
* Makefile.in: Regenerate.

21 months agox86/gas: support quoted address scale factor in AT&T syntax
Jan Beulich [Wed, 5 Oct 2022 07:16:24 +0000 (09:16 +0200)]
x86/gas: support quoted address scale factor in AT&T syntax

An earlier attempt (e68c3d59acd0 ["x86: better respect quotes in
parse_operands()"]) needed undoing (cc0f96357e0b ["x86: permit
parenthesized expressions again as addressing scale factor"]) as far its
effect here went. As indicated back then, the issue is the backwards
scanning of the operand string to find the matching opening parenthesis.
Switch to forward scanning, finding the last outermost unquoted opening
parenthesis (which is the one matching the trailing closing one).

21 months agoArm64: support CLEARBHB alias
Jan Beulich [Wed, 5 Oct 2022 07:15:51 +0000 (09:15 +0200)]
Arm64: support CLEARBHB alias

While the Arm v8 ARM (rev I-a) still doesn't mention this alias, it is
(typically via a macro) already in use in kernels and alike.

21 months agoPR29647, objdump -S looping
Alan Modra [Wed, 5 Oct 2022 00:55:26 +0000 (11:25 +1030)]
PR29647, objdump -S looping

Fuzzed input with this in .debug_line
  [0x0000003b]  Special opcode 115: advance Address by 8 to 0x401180 and Line by -2 to -1

PR 29647
* objdump.c (print_line): Don't decrement line number here..
(dump_lines): ..do so here instead, ensuring loop terminates.

21 months agoRe: stab nearest_line bfd_malloc_and_get_section
Alan Modra [Tue, 4 Oct 2022 23:57:46 +0000 (10:27 +1030)]
Re: stab nearest_line bfd_malloc_and_get_section

It didn't take long for the fuzzers to avoid size checks in
bfd_malloc_and_get_section.  Plug this hole.

* syms.c (_bfd_stab_section_find_nearest_line): Ignore fuzzed
sections with no contents.

21 months agogprofng: fix build with --enable-pgo-build=lto
Vladimir Mezentsev [Tue, 4 Oct 2022 16:13:56 +0000 (09:13 -0700)]
gprofng: fix build with --enable-pgo-build=lto

gprofng/ChangeLog
2022-10-04  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

PR gprofng/29579
* libcollector/dispatcher.c: Fix the symbol version in SYMVER_ATTRIBUTE.
* libcollector/iotrace.c: Likewise.
* libcollector/linetrace.c: Likewise.
* libcollector/mmaptrace.c: Likewise.
* libcollector/synctrace.c: Likewise.

21 months agoAutomatic date update in version.in
GDB Administrator [Wed, 5 Oct 2022 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in

21 months agoRemove decode_location_spec_default
Tom Tromey [Thu, 29 Sep 2022 23:16:04 +0000 (17:16 -0600)]
Remove decode_location_spec_default

This removes decode_location_spec_default, inlining it into its sole
caller.

Regression tested on x86-64 Fedora 34.

21 months agogas: NEWS: Mention the T-Head extensions that were recently added
Palmer Dabbelt [Fri, 30 Sep 2022 22:00:37 +0000 (15:00 -0700)]
gas: NEWS: Mention the T-Head extensions that were recently added

21 months ago[gdb/symtab] Don't complain about function decls
Tom de Vries [Tue, 4 Oct 2022 14:51:03 +0000 (16:51 +0200)]
[gdb/symtab] Don't complain about function decls

[ Requires "[gdb/symtab] Don't complain about inlined functions" as
submitted here (
https://sourceware.org/pipermail/gdb-patches/2022-September/191762.html ). ]

With the test-case included in this patch, we get:
...
(gdb) ptype main^M
During symbol reading: cannot get low and high bounds for subprogram DIE \
  at 0xc1^M
type = int (void)^M
(gdb) FAIL: gdb.dwarf2/anon-ns-fn.exp: ptype main without complaints
...

The DIE causing the complaint is a function declaration:
...
 <2><c1>: Abbrev Number: 3 (DW_TAG_subprogram)
    <c2>   DW_AT_name        : foo
    <c8>   DW_AT_declaration : 1
...
which is referred to from the DIE representing the function definition:
...
 <1><f4>: Abbrev Number: 7 (DW_TAG_subprogram)
    <f5>   DW_AT_specification: <0xc1>
    <f9>   DW_AT_low_pc      : 0x4004c7
    <101>   DW_AT_high_pc     : 0x7
...
which does contain the low and high bounds.

Fix this by not complaining about function declarations.

Tested on x86_64-linux.

21 months ago[gdb/symtab] Don't complain about inlined functions
Tom de Vries [Tue, 4 Oct 2022 14:51:03 +0000 (16:51 +0200)]
[gdb/symtab] Don't complain about inlined functions

With the test-case included in this patch, we get:
...
(gdb) ptype main^M
During symbol reading: cannot get low and high bounds for subprogram DIE \
  at 0x113^M
During symbol reading: cannot get low and high bounds for subprogram DIE \
  at 0x11f^M
type = int (void)^M
(gdb) FAIL: gdb.dwarf2/inline.exp: ptype main
...

The complaints are about foo, with DW_AT_inline == DW_INL_inlined:
...
 <1><11f>: Abbrev Number: 6 (DW_TAG_subprogram)
    <120>   DW_AT_name        : foo
    <126>   DW_AT_prototyped  : 1
    <126>   DW_AT_type        : <0x10c>
    <12a>   DW_AT_inline      : 1       (inlined)
...
and foo2, with DW_AT_inline == DW_INL_declared_inlined:
...
 <1><113>: Abbrev Number: 5 (DW_TAG_subprogram)
    <114>   DW_AT_name        : foo2
    <11a>   DW_AT_prototyped  : 1
    <11a>   DW_AT_type        : <0x10c>
    <11e>   DW_AT_inline      : 3       (declared as inline and inlined)
...

Fix this by not complaining about inlined functions.

Tested on x86_64-linux.

21 months agogdb/riscv: Partial support for instructions up to 176-bit
Tsukasa OI [Tue, 4 Oct 2022 08:42:35 +0000 (08:42 +0000)]
gdb/riscv: Partial support for instructions up to 176-bit

Because riscv_insn_length started to support instructions up to 176-bit,
we need to increase buf size to 176-bit in size.

Also, that would break an assumption in riscv_insn::decode so this commit
fixes it, noting that instructions longer than 64-bit are not fully
supported yet.

21 months agoRISC-V: Fix buffer overflow on print_insn_riscv
Tsukasa OI [Tue, 4 Oct 2022 08:35:30 +0000 (08:35 +0000)]
RISC-V: Fix buffer overflow on print_insn_riscv

Because riscv_insn_length started to support instructions up to 176-bit,
we need to increase packet buffer size to 176-bit in size.

include/ChangeLog:

* opcode/riscv.h (RISCV_MAX_INSN_LEN): Max instruction length for
use in buffer size.

opcodes/ChangeLog:

* riscv-dis.c (print_insn_riscv): Increase buffer size for max
176-bit length instructions.

21 months agoRISC-V: Renamed INSN_CLASS for floating point in integer extensions.
Nelson Chu [Tue, 4 Oct 2022 13:11:59 +0000 (21:11 +0800)]
RISC-V: Renamed INSN_CLASS for floating point in integer extensions.

Just added suffix _INX for those INSN_CLASS should be enough to represent
their fpr can be replaced by gpr.

21 months agoNote that at least dejagnu version 1.5.3 is required in order to be ale to run the...
Nick Clifton [Tue, 4 Oct 2022 09:53:16 +0000 (10:53 +0100)]
Note that at least dejagnu version 1.5.3 is required in order to be ale to run the testsuites.

* README-maintainer-mode: Add a minimum version of dejagnu
requirement.

21 months agoopcodes/riscv: style csr names as registers
Andrew Burgess [Mon, 3 Oct 2022 09:59:57 +0000 (10:59 +0100)]
opcodes/riscv: style csr names as registers

While reviewing another patch I noticed that RISC-V CSR names are
given the text style, not the register style.  This patch fixes this
mistake.

21 months ago[AArch64] Update FPSR/FPCR fields for FPU and SVE
Luis Machado [Thu, 22 Sep 2022 11:53:33 +0000 (12:53 +0100)]
[AArch64] Update FPSR/FPCR fields for FPU and SVE

I noticed some missing flags/fields from FPSR and FPCR registers in
both the FPU and SVE target descriptions.

This patch adds those and makes the SVE versions of FPSR and FPCR
use the proper flags/bitfields types.

21 months agoSupport objcopy changing compression to or from zstd
Alan Modra [Tue, 4 Oct 2022 02:44:05 +0000 (13:14 +1030)]
Support objcopy changing compression to or from zstd

Commit 2cac01e3ffff lacked support for objcopy changing compression
style.  Add that support, which meant a rewrite of
bfd_compress_section_contents.  In the process I've fixed some memory
leaks.

* compress.c (bfd_is_section_compressed_info): Rename from
bfd_is_section_compressed_with_header and add ch_type param
to return compression header ch_type field.
Update all callers.
(decompress_section_contents): Remove buffer and size params.
Rewrite.  Update callers.
(bfd_init_section_compress_status): Free contents on failure.
(bfd_compress_section): Likewise.
* elf.c (_bfd_elf_make_section_from_shdr): Support objcopy
changing between any of the three compression schemes.  Report
"unable to compress/decompress" rather than "unable to
initialize compress/decompress status" on compress/decompress
failures.
* bfd-in2.h: Regenerate.

21 months agoRe: compress .gnu.debuglto_.debug_* sections if requested
Alan Modra [Tue, 4 Oct 2022 02:39:36 +0000 (13:09 +1030)]
Re: compress .gnu.debuglto_.debug_* sections if requested

Enable zlib-gnu compression for .gnu.debuglto_.debug_*.  This differs
from zlib-gnu for .debug_* where the name is changed to .zdebug_*.
The name change isn't really needed.

bfd/
* elf.c (elf_fake_sections): Replace "." with ".z" in debug
section names only when name was ".d*", ie. ".debug_*".
(_bfd_elf_assign_file_positions_for_non_load): Likewise.
gas/
* write.c (compress_debug): Compress .gnu.debuglto_.debug_*
for zlib-gnu too.  Compress .gnu.linkonce.wi.*.

21 months agocompress .gnu.debuglto_.debug_* sections if requested
Martin Liska [Thu, 29 Sep 2022 12:10:30 +0000 (14:10 +0200)]
compress .gnu.debuglto_.debug_* sections if requested

Right now, when using LTO, the intermediate object files do contain
debug info in sections starting with .gnu.debuglto_ prefix and are
not compressed when --compress-debug-sections is used.

It's a mistake and we can save quite some disk space. The following
example comes from tramp3d when the corresponding LTO sections
are compressed with zlib:

$ bloaty tramp3d-v4-v2.o -- tramp3d-v4.o
    FILE SIZE        VM SIZE
 --------------  --------------
   +83%     +10  [ = ]       0    [Unmapped]
 -68.0%    -441  [ = ]       0    .gnu.debuglto_.debug_line
 -52.3%    -759  [ = ]       0    .gnu.debuglto_.debug_line_str
 -62.4% -3.24Ki  [ = ]       0    .gnu.debuglto_.debug_abbrev
 -64.8% -1.12Mi  [ = ]       0    .gnu.debuglto_.debug_info
 -88.8% -4.58Mi  [ = ]       0    .gnu.debuglto_.debug_str
 -27.7% -5.70Mi  [ = ]       0    TOTAL

bfd/ChangeLog:

* elf.c (_bfd_elf_make_section_from_shdr): Compress all debug
  info sections.

gas/ChangeLog:

* write.c (compress_debug): Compress also ".gnu.debuglto_.debug_"
if the compression algorithm is different from zlib-gnu.

21 months agoRISC-V/gas: allow generating up to 176-bit instructions with .insn
Jan Beulich [Tue, 4 Oct 2022 07:46:11 +0000 (09:46 +0200)]
RISC-V/gas: allow generating up to 176-bit instructions with .insn

For the time being simply utilize O_big to avoid widening other fields,
bypassing append_insn() etc.

21 months agoRISC-V/gas: don't open-code insn_length()
Jan Beulich [Tue, 4 Oct 2022 07:45:31 +0000 (09:45 +0200)]
RISC-V/gas: don't open-code insn_length()

Use the helper when it can be used.

21 months agoRISC-V/gas: drop stray call to install_insn()
Jan Beulich [Tue, 4 Oct 2022 07:45:08 +0000 (09:45 +0200)]
RISC-V/gas: drop stray call to install_insn()

add_fixed_insn(), by calling move_insn(), already invokes install_insn().

21 months agoRISC-V/gas: drop riscv_subsets static variable
Jan Beulich [Tue, 4 Oct 2022 07:44:44 +0000 (09:44 +0200)]
RISC-V/gas: drop riscv_subsets static variable

It's fully redundant with the subset_list member of riscv_rps_as.

21 months agoRISC-V: don't cast expressions' X_add_number to long in diagnostics
Jan Beulich [Tue, 4 Oct 2022 07:40:55 +0000 (09:40 +0200)]
RISC-V: don't cast expressions' X_add_number to long in diagnostics

There's no need for such workarounds anymore now that we use C99
uniformly. This addresses several testsuite failures encountered when
(cross-)building on a 32-bit host.

21 months agoignore DWARF debug information for -gsplit-dwarf with dwarf-5
Potharla, Rupesh [Tue, 4 Oct 2022 07:39:53 +0000 (09:39 +0200)]
ignore DWARF debug information for -gsplit-dwarf with dwarf-5

Skip dwo_id for split dwarf.

* dwarf2.c (parse_comp_unit): Skip DWO_id for DW_UT_skeleton.

21 months agoAutomatic date update in version.in
GDB Administrator [Tue, 4 Oct 2022 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in

21 months agoFix self-move warning check for GCC 13+
Jan-Benedict Glaw [Mon, 3 Oct 2022 14:56:24 +0000 (16:56 +0200)]
Fix self-move warning check for GCC 13+

GCC 13 got the self-move warning (0abb78dda084a14b3d955757c6431fff71c263f3),
but that warning is only checked for clang, resulting in:

/usr/lib/gcc-snapshot/bin/g++ -x c++    -I. -I. -I./config -DLOCALEDIR="\"/tmp/gdb-m68k-linux/share/locale\"" -DHAVE_CONFIG_H -I./../include/opcode -I./../readline/readline/.. -I./../zlib  -I../bfd -I./../bfd -I./../include -I../libdecnumber -I./../libdecnumber  -I./../gnulib/import -I../gnulib/import -I./.. -I.. -I./../libbacktrace/ -I../libbacktrace/  -DTUI=1    -I./.. -pthread  -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-variable -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare -Wno-error=maybe-uninitialized -Wno-mismatched-tags -Wsuggest-override -Wimplicit-fallthrough=3 -Wduplicated-cond -Wshadow=local -Wdeprecated-copy -Wdeprecated-copy-dtor -Wredundant-move -Wmissing-declarations -Wstrict-null-sentinel -Wformat -Wformat-nonliteral -Werror -g -O2   -c -o unittests/environ-selftests.o -MT unittests/environ-selftests.o -MMD -MP -MF unittests/.deps/environ-selftests.Tpo unittests/environ-selftests.c
unittests/environ-selftests.c: In function 'void selftests::gdb_environ_tests::test_self_move()':
unittests/environ-selftests.c:228:7: error: moving 'env' of type 'gdb_environ' to itself [-Werror=self-move]
  228 |   env = std::move (env);
      |   ~~~~^~~~~~~~~~~~~~~~~
unittests/environ-selftests.c:228:7: note: remove 'std::move' call
cc1plus: all warnings being treated as errors
make[1]: *** [Makefile:1896: unittests/environ-selftests.o] Error 1
make[1]: Leaving directory '/var/lib/laminar/run/gdb-m68k-linux/3/binutils-gdb/gdb'
make: *** [Makefile:13193: all-gdb] Error 2

21 months agogdb: constify inferior::target_is_pushed
Simon Marchi [Fri, 30 Sep 2022 00:14:41 +0000 (20:14 -0400)]
gdb: constify inferior::target_is_pushed

Change-Id: Ia4143b9c63cb76e2c824ba773c66f5c5cd94b2aa

21 months ago[AArch64] Handle W registers as pseudo-registers instead of aliases of X registers
Luis Machado [Thu, 15 Sep 2022 14:57:01 +0000 (15:57 +0100)]
[AArch64] Handle W registers as pseudo-registers instead of aliases of X registers

The aarch64 port handles W registers as aliases of X registers. This is
incorrect because X registers are 64-bit and W registers are 32-bit.

This patch teaches GDB how to handle W registers as pseudo-registers of
32-bit, the bottom half of the X registers.

Testcase included.

21 months ago[AArch64] Fix pseudo-register numbering in the presence of unexpected additional...
Luis Machado [Fri, 9 Sep 2022 09:30:53 +0000 (10:30 +0100)]
[AArch64] Fix pseudo-register numbering in the presence of unexpected additional registers

When using AArch64 GDB with the QEMU debugging stub (in user mode), we get
additional system registers that GDB doesn't particularly care about, so
it doesn't number those explicitly.

But given the pseudo-register numbers are above the number of real registers,
we need to setup/account for the real registers first before going ahead and
numbering the pseudo-registers.  This has to happen at the end of
aarch64_gdbarch_init, after the call to tdesc_use_registers, as that
updates the total number of real registers.

This is in preparation to supporting pointer authentication for bare metal
aarch64 (QEMU).

21 months agoreadelf: DO not load section headers from file offset zero
Nick Clifton [Mon, 3 Oct 2022 12:19:21 +0000 (13:19 +0100)]
readelf: DO not load section headers from file offset zero

* readelf.c (get_32bit_section_headers): Return false if the
e_shoff field is zero.
(get_64bit_section_headers): Likewise.

21 months agoRISC-V: Move supervisor instructions after all unprivileged ones
Tsukasa OI [Wed, 28 Sep 2022 12:41:38 +0000 (12:41 +0000)]
RISC-V: Move supervisor instructions after all unprivileged ones

This location of supervisor instructions is out of place (because many other
privileged instructions are located at the tail but after the supervisor
instructions, we have many unprivileged instructions including bit
manipulation / crypto / vector instructions).

Not only that, this is harmful to implement pseudoinstructions in the latest
'P'-extension proposal (CLROV and RDOV).  This commit moves supervisor
instructions after all unprivileged instructions.

opcodes/ChangeLog:

* riscv-opc.c (riscv_opcodes): Adjust indents.  Move supervisor
instructions after all unprivileged instructions.