binutils-gdb.git
2 years agogdb/testsuite: Remove duplicates from gdb.base/pretty-array.exp
Lancelot SIX [Sun, 21 Nov 2021 00:29:01 +0000 (00:29 +0000)]
gdb/testsuite: Remove duplicates from gdb.base/pretty-array.exp

When I run the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/pretty-array.exp ...
    DUPLICATE: gdb.base/pretty-array.exp: print nums
    DUPLICATE: gdb.base/pretty-array.exp: print nums

Fix by giving a name to the test cases.

Tested on x86_64-linux.

2 years agogdb/testsuite: Remove duplicates from gdb.base/ui-redirect.exp
Lancelot SIX [Sun, 21 Nov 2021 00:20:56 +0000 (00:20 +0000)]
gdb/testsuite: Remove duplicates from gdb.base/ui-redirect.exp

When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/ui-redirect.exp ...
    DUPLICATE: gdb.base/ui-redirect.exp: redirect while already logging: set logging redirect off

Fix by moving the first 'set logging redirect off' to the end of the
previous [with_test_prefix] test block. The statement's purpose is to
clean the on flag set in this previous block, so moving it there makes
sense and does not change the sequence of commands in the test file.

Tested on x86_64-linux.

2 years agogdb: completion-support.exp: improve leading whitespace support
Lancelot SIX [Sat, 20 Nov 2021 23:20:23 +0000 (23:20 +0000)]
gdb: completion-support.exp: improve leading whitespace support

There is a expect support library in the source tree designed to help
developers test the auto-completion capabilities of GDB.

One of the functions is test_gdb_complete_unique_re.  It is used
(usually indirectly via test_gdb_complete_unique) to test that a given
input line is completed as a given output line.  The test checks for two
ways to do the completion: using tab-completion, or using the
'complete' command.  To do this, calls to two dedicated functions are
performed.  If we omit few details, we can consider that a call to

    test_gdb_complete_unique $input $expected

is equivalent to the two following calls:

    test_gdb_complete_tab_unique $input $expected
    test_gdb_complete_cmd_unique $input $expected

When using the tab-completion, everything works as expected, but some
care must be taken when using the 'complete' command if the given input
has leading whitespaces.  In such situation, the output of the
'complete' command will drop the leading whitespaces.

The current approach is that in such situation, the input and expected
outputs are right trimmed (i.e. all leading whitespaces are removed)
when performing the command completion check.

This means that the following call:

    test_gdb_complete_unique "   $input" "   $expected"

is almost equivalent to (again, omitting few details and arguments):

    test_gdb_complete_tab_unique "   $input" "   $expected"
    test_gdb_complete_cmd_unique "$input" "$expected"

This approach comes with a problem that we encounter when running the
tests in complete-empty.exp.  When doing so, we have:

    Running .../gdb/testsuite/gdb.base/complete-empty.exp ...
    DUPLICATE: gdb.base/complete-empty.exp: empty-input-line: cmd complete ""

This is because the test file does something like:

    test_gdb_complete_unique "" "!" " " 1
    test_gdb_complete_unique "   " "   !" " " 1¬

which, if we do the substitution introduced above is equivalent to:

    test_gdb_complete_tab_unique "" "!"
    test_gdb_complete_cmd_unique "" "!"
    test_gdb_complete_tab_unique "   " "   !"
    test_gdb_complete_cmd_unique "" "!"

We see that the lines 2 and 4 are now the same, and for this reason the
testing framework complains about DUPLICATE test names.

To fix that, this commit proposes that instead of left trimming both
input and expected outputs, only the expected output is trimmed.

Care must be taken in the case the completion gives more possibilities
than allowed by the max-completions setting.  In this case, the input
will be repeated in the output in its left trimmed version.  This commit
also ensures that this is taken care of.

With this commit, the gdb.base/complete-empty.exp still passes all its
tests but does not report the DUPLICATE anymore.

Tested on x86_64-linux.

2 years agogdb/testsuite: Remove duplicates from gdb.base/subst.exp
Lancelot SIX [Sat, 20 Nov 2021 23:07:55 +0000 (23:07 +0000)]
gdb/testsuite: Remove duplicates from gdb.base/subst.exp

When I run the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/subst.ex ...
    DUPLICATE: gdb.base/subst.exp: unset substitute-path from, no rule entered yet

Fix by adjusting the problematic test name.

Tested on x86_64-linux.

2 years agogdb/testsuite: Remove duplicates from gdb.base/dfp-exprs.exp
Pedro Alves [Fri, 10 Dec 2021 22:41:54 +0000 (22:41 +0000)]
gdb/testsuite: Remove duplicates from gdb.base/dfp-exprs.exp

When I run the testsuite, I have:

    Running ../gdb/testsuite/gdb.base/dfp-exprs.exp ...
    DUPLICATE: gdb.base/dfp-exprs.exp: p 1.2dl < 1.3df

Replace hand-written tests checking various comparison operators between
various decimal floating point types with a loop to programmatically
generate all the combinations.  This removes the need to eyeball for all
suffixes, which lead to the original duplication.

Also add a lot more combinations, testing all comparison operators
comprehensively.  The result is 262 unique tests vs 104 before this
patch.

Tested on x86_86-linux.

Change-Id: Id215a3d610aa8e032bf06ee160b5e3aed4a92d1e

2 years agogdb/testsuite: Remove duplicates from gdb.base/ptype.exp
Lancelot SIX [Sat, 20 Nov 2021 22:57:10 +0000 (22:57 +0000)]
gdb/testsuite: Remove duplicates from gdb.base/ptype.exp

When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/ptype.exp ...
    DUPLICATE: gdb.base/ptype.exp: ptype the_highest
    DUPLICATE: gdb.base/ptype.exp: list intfoo
    DUPLICATE: gdb.base/ptype.exp: list charfoo

Fix by adjusting the offending test names.

Tested on x86_64-linux.

2 years agogdb/testsuite: Remove duplicates from gdb.base/dfp-test.exp
Lancelot SIX [Sat, 20 Nov 2021 00:10:07 +0000 (00:10 +0000)]
gdb/testsuite: Remove duplicates from gdb.base/dfp-test.exp

When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/dfp-test.exp ...
    DUPLICATE: gdb.base/dfp-test.exp: 1.23E is an invalid number
    DUPLICATE: gdb.base/dfp-test.exp: 1.23E45A is an invalid number
    DUPLICATE: gdb.base/dfp-test.exp: 1.23E is an invalid number
    DUPLICATE: gdb.base/dfp-test.exp: 1.23E45A is an invalid number

Fix by using proc_with_prefix where appropriate.

Tested on x86_64-linux.
Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
2 years agogdb/testsuite: Remove duplicates from gdb.base/del.exp
Lancelot SIX [Fri, 19 Nov 2021 23:55:05 +0000 (23:55 +0000)]
gdb/testsuite: Remove duplicates from gdb.base/del.exp

When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/del.exp ...
    DUPLICATE: gdb.base/del.exp: info break after removing break on main

Refactor slightly this test to run the various configurations under
foreach_with_prefix so each variant is automatically prefixed, ensuring
that the forgotten custom test name cannot happen.

Tested on x86_64-linux.

2 years agogdb/testsuite: Remove duplicates from gdb.base/solib-display.exp
Lancelot SIX [Fri, 19 Nov 2021 23:34:27 +0000 (23:34 +0000)]
gdb/testsuite: Remove duplicates from gdb.base/solib-display.exp

When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/solib-display.exp ...
    DUPLICATE: gdb.base/solib-display.exp: NO: break 25
    DUPLICATE: gdb.base/solib-display.exp: NO: continue
    DUPLICATE: gdb.base/solib-display.exp: IN: break 25
    DUPLICATE: gdb.base/solib-display.exp: IN: continue
    DUPLICATE: gdb.base/solib-display.exp: SEP: break 25
    DUPLICATE: gdb.base/solib-display.exp: SEP: continue

The 'break 25' appears because the test inserts two breakpoints at the
same location.  Fix this by only inserting the breakpoint once.

Fix the 'continue' DUPLICATE by giving a phony name to the second
continue: 'continue two'.

While at it, this commit also removes a trailing space.

Tested on x86_64-linux.

2 years agogdb/testsuite: Remove duplicates from gdb.base/decl-before-def.exp
Lancelot SIX [Fri, 19 Nov 2021 23:27:18 +0000 (23:27 +0000)]
gdb/testsuite: Remove duplicates from gdb.base/decl-before-def.exp

When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/decl-before-def.exp ...
    DUPLICATE: gdb.base/decl-before-def.exp: p a

Fix by giving explicit names to the two tests that use the same command.

Tested on x86_64-linux.

2 years agogdb/testsuite: Remove duplicates from gdb.base/pending.exp
Lancelot SIX [Fri, 19 Nov 2021 23:22:53 +0000 (23:22 +0000)]
gdb/testsuite: Remove duplicates from gdb.base/pending.exp

When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/pending.exp ...
    DUPLICATE: gdb.base/pending.exp: disable other breakpoints

Fix by adjusting the test names.

Tested on x86_64-linux.

2 years agogdb/testsuite: Remove duplicates from gdb.base/checkpoint.exp
Lancelot SIX [Fri, 19 Nov 2021 23:16:51 +0000 (23:16 +0000)]
gdb/testsuite: Remove duplicates from gdb.base/checkpoint.exp

When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/checkpoint.exp ...
    DUPLICATE: gdb.base/checkpoint.exp: verify lines 5 two
    DUPLICATE: gdb.base/checkpoint.exp: restart 0 one

This patch fixes the various erroneous incorrect test names.

While at it, this patch also remove some trailing white spaces across
the file.

Tested on x86_64-linux.

2 years agogdb/testsuite: Remove duplicates from gdb.base/pie-fork.exp
Lancelot SIX [Fri, 19 Nov 2021 23:08:23 +0000 (23:08 +0000)]
gdb/testsuite: Remove duplicates from gdb.base/pie-fork.exp

When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/pie-fork.exp ...
    DUPLICATE: gdb.base/pie-fork.exp: test_no_detach_on_fork: continue

Fix by giving explicit names to the 'continue' commands that cause the
duplicate message.

Tested on x86_64-linux.

2 years agogdb/testsuite: Remove duplicates from gdb.base/realname-expand.exp
Lancelot SIX [Fri, 19 Nov 2021 22:48:59 +0000 (22:48 +0000)]
gdb/testsuite: Remove duplicates from gdb.base/realname-expand.exp

When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/realname-expand.exp ...
    DUPLICATE: gdb.base/realname-expand.exp: set basenames-may-differ on

This is due to the fact that the test restarts GDB twice and each time
sets the basenames-may-differ setting.  This patch proposes to fix this
by not restarting GDB so the setting is maintained.  It just clears the
breakpoints between the two tests and updates the breakpoints number as
required.

This patch also perform some minor refactorings to improve visibility.

Tested on x86_64-linux.

2 years agogdb/testsuite: Remove duplicates from gdb.base/interp.exp
Lancelot SIX [Fri, 19 Nov 2021 19:55:05 +0000 (19:55 +0000)]
gdb/testsuite: Remove duplicates from gdb.base/interp.exp

When running the testsuite I have:

    Running .../gdb/testsuite/gdb.base/interp.exp ...
    DUPLICATE: gdb.base/interp.exp: interpreter-exec mi "-var-update *"

This is due to the fact that multiple successive instances of
gdb_test_multiple use 'pass $cmd', but one of them forgets to reset $cmd
to a new test name.

Fix by using 'pass $gdb_test_name', given that the gdb_test_name is set
by gdb_test_multiple.

While fixing this, this patch refactors all occurrences of the following
pattern:

    set cmd foo
    gdb_test_multiple $cmd $cmd {
        -re ... {
            pass $cmd
        }
    }

into

    gdb_test_multiple foo "" {
        -re ... {
            pass $gdb_test_name
         }
    }

This makes this test file coherent in its use of $gdb_test_name.

Tested on x86_64-linux.

2 years agogdb/testsuite: Remove duplicates from gdb.base/miscexprs.exp
Lancelot SIX [Fri, 19 Nov 2021 19:05:37 +0000 (19:05 +0000)]
gdb/testsuite: Remove duplicates from gdb.base/miscexprs.exp

When running the testsuite I see:

    Running .../gdb/testsuite/gdb.base/miscexprs.exp ...
    DUPLICATE: gdb.base/miscexprs.exp: print value of !ibig.i[100]
    DUPLICATE: gdb.base/miscexprs.exp: print value of !ibig.i[100]

This is due to an explicit test name repeated across multiple tests.
The actual test explicit names do not add much over the command from
wich default test names are derived.

Fix by removing the explicit test names across the file where they do
not add value.  While at doing some cleaning, also use $gdb_test_name in
the various uses of gdb_test_multiple.

Tested on x86_64-linux.

2 years agogdb/testsuite: Remove duplicates from gdb.base/stack-checking.exp
Lancelot SIX [Fri, 19 Nov 2021 18:58:04 +0000 (18:58 +0000)]
gdb/testsuite: Remove duplicates from gdb.base/stack-checking.exp

When running the testsuite I have:

    Running .../gdb/testsuite/gdb.base/stack-checking.exp ...
    DUPLICATE: gdb.base/stack-checking.exp: bt
    DUPLICATE: gdb.base/stack-checking.exp: bt

Fix by using with_test_prefix.

Tested on x86_64-linux.

2 years agoRISC-V: update docs to reflect privileged spec v1.9 has been dropped
Philipp Tomsich [Wed, 5 Jan 2022 13:57:28 +0000 (14:57 +0100)]
RISC-V: update docs to reflect privileged spec v1.9 has been dropped

After commit d8af286fffa ("RISC-V: Drop the privileged spec v1.9
support.") has removed support for privileged spec v1.9, this removes
it from the documentation.

References: d8af286fffa ("RISC-V: Drop the privileged spec v1.9 support.")

gas/ChangeLog:

* configure: Regenerate.
* configure.ac: Remove reference to priv spec 1.9.
* po/fr.po: Same.
* po/ru.po: Same.
* po/uk.po: Same.

2 years agoRISC-V: update docs for -mpriv-spec/--with-priv-spec for 1.12
Philipp Tomsich [Tue, 4 Jan 2022 17:12:32 +0000 (18:12 +0100)]
RISC-V: update docs for -mpriv-spec/--with-priv-spec for 1.12

While support for the privileged spec was added in a63375ac337
("RISC-V: Hypervisor ext: support Privileged Spec 1.12"), the
documentation has not been updated.  Add 1.12 to the relevant
documentation.

References: a63375ac337 ("RISC-V: Hypervisor ext: support Privileged Spec 1.12")

gas/ChangeLog:

* config/tc-riscv.c: Add 1.12 to the usage message.
* configure: Regenerate.
* configure.ac: Add 1.12 to the help/usage message.
* po/fr.po: Same.
* po/ru.po: Same.
* po/uk.po: Same.

2 years agoDo not use CC_HAS_LONG_LONG
Tom Tromey [Fri, 7 Jan 2022 21:00:33 +0000 (14:00 -0700)]
Do not use CC_HAS_LONG_LONG

ax.cc checks CC_HAS_LONG_LONG, but nothing defines this.  However,
PRINTF_HAS_LONG_LONG is checked in configure.  This patch removes the
former and keeps the latter.  This is PR remote/14976 (filed by me in
2012, lol).

I'm checking this in.

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

2 years agogdb/doc: shorten some source lines, and prevent some line breaks
Andrew Burgess [Wed, 22 Dec 2021 16:47:29 +0000 (16:47 +0000)]
gdb/doc: shorten some source lines, and prevent some line breaks

Building on the previous commit, this makes use of a trailing @ to
split long @deffn lines in the guile.texi source file.  This splitting
doesn't change how the document is laid out by texinfo.

I have also wrapped keyword and argument name pairs in @w{...} to
prevent line breaks appearing between the two.  I've currently only
done this for the longer @deffn lines, where a line break is
possible.  This makes the @deffn lines much nicer to read in the
generated pdf.

2 years agogdb/doc: Remove (...) around guile procedure names in @deffn lines
Andrew Burgess [Wed, 22 Dec 2021 16:04:56 +0000 (16:04 +0000)]
gdb/doc: Remove (...) around guile procedure names in @deffn lines

Most guile procedures in the guile.texi file are defined like:

  @deffn {Scheme Procedure} name arg1 arg2 arg3

But there are two places where we do this:

  @deffn {Scheme Procedure} (name arg1 arg2 arg3)

Notice the added (...).  Though this does represent how a procedure
call is written in scheme, it's not the normal style throughout the
manual.  I also checked the 'info guile' info page to see how they
wrote there declarations, and they use the first style too.

The second style also has the drawback that index entries are added as
'(name', and so they are grouped in the '(' section of the index,
which is not very user friendly.

In this commit I've changed the definitions of make-command and
make-parameter to use the first style.

The procedure declaration lines can get pretty long with all of the
arguments, and this was true for both of the procedures I am changing
in this commit.  I have made use of a trailing '@' to split the deffn
lines, and keep them under 80 characters in the texi source.  This
makes no difference to how the final document looks.

Finally, our current style for keyword arguments, appears to be:

  [#:keyword-name argument-name]

I don't really understand the reason for this, 'info guile' just seems
to use:

  [#:keyword-name]

which seems just as good to me.  But I don't propose to change
that just now.  What I do notice though, is that sometimes, texinfo
will place a line break between the keyword-name and the
argument-name, for example, the pdf of make-command is:

  make-command name [#:invoke invoke] [#:command-class
    command-class] [#:completer-class completer] [#:prefix? prefix] [#:doc
    doc-string]

Notice the line break after '#:command-class' and after '#:doc',
neither of which are ideal.  And so, for the two commands I am
changing in this commit, I have made use of @w{...} to prevent line
breaks between the keyword-name and the argument-name.  Now the pdf
looks like this:

  make-command name [#:invoke invoke]
    [#:command-class command-class] [#:completer-class completer]
    [#:prefix? prefix] [#:doc doc-string]

Which seems much better.  I'll probably update the other deffn lines
at some point.

2 years agoRevert previous delta to debug.c. Replace with patch to reject indirect types that...
Pavel Mayorov [Fri, 7 Jan 2022 12:34:37 +0000 (12:34 +0000)]
Revert previous delta to debug.c.  Replace with patch to reject indirect types that point to indirect types.

PR 28718
* dwarf.c: Revert previous delta.
(debug_get_real_type): Reject indirect types that point to
indirect types.
(debug_get_type_name, debug_get_type_size, debug_write_type):
Likewise.

2 years agoRISC-V: Updated the default ISA spec to 20191213.
Nelson Chu [Thu, 30 Dec 2021 15:23:46 +0000 (23:23 +0800)]
RISC-V: Updated the default ISA spec to 20191213.

Update the default ISA spec from 2.2 to 20191213 will change the default
version of i from 2.0 to 2.1.  Since zicsr and zifencei are separated
from i 2.1, users need to add them in the architecture string if they need
fence.i and csr instructions.  Besides, we also allow old ISA spec can
recognize zicsr and zifencei, but we won't output them since they are
already included in the i extension when i's version is less than 2.1.

bfd/
* elfxx-riscv.c (riscv_parse_add_subset): Allow old ISA spec can
recognize zicsr and zifencei.
gas/
* config/tc-riscv.c (DEFAULT_RISCV_ISA_SPEC): Updated to 20191213.
* testsuite/gas/riscv/csr-version-1p10.d: Added zicsr to -march since
the default version of i is 2.1.
* testsuite/gas/riscv/csr-version-1p11.d: Likewise.
* testsuite/gas/riscv/csr-version-1p12.d: Likewise.
* testsuite/gas/riscv/csr-version-1p9p1.d: Likewise.
* testsuite/gas/riscv/option-arch-03.d: Updated i's version to 2.1.
* testsuite/gas/riscv/option-arch-03.s: Likewise.
ld/
* testsuite/ld-riscv-elf/call-relax.d: Added zicsr to -march since
the default version of i is 2.1.
* testsuite/ld-riscv-elf/attr-merge-arch-01.d: Updated i's version to 2.1.
* testsuite/ld-riscv-elf/attr-merge-arch-01a.s: Likewise.
* testsuite/ld-riscv-elf/attr-merge-arch-01b.: Likewise.
* testsuite/ld-riscv-elf/attr-merge-arch-02.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-arch-02a.s: Likewise.
* testsuite/ld-riscv-elf/attr-merge-arch-02b.s: Likewise.
* testsuite/ld-riscv-elf/attr-merge-arch-03.d: Likewise.
* testsuite/ld-riscv-elf/attr-merge-arch-03a.s: Likewise.
* testsuite/ld-riscv-elf/attr-merge-arch-03b.s: Likewise.
* testsuite/ld-riscv-elf/attr-merge-arch-failed-02.d: Added zifencei
into Tag_RISCV_arch since it is added implied when i's version is
larger than 2.1.

2 years agoMove elf_backend_always_size_sections earlier
Alan Modra [Fri, 7 Jan 2022 03:13:56 +0000 (13:43 +1030)]
Move elf_backend_always_size_sections earlier

* elflink.c (bfd_elf_size_dynamic_sections): Move plt/got init
earlier and call elf_backend_always_size_sections at the start
of this function.

2 years agoAutomatic date update in version.in
GDB Administrator [Fri, 7 Jan 2022 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in

2 years agoldelfgen.c: Add missing newlines when calling einfo
H.J. Lu [Thu, 6 Jan 2022 22:52:11 +0000 (14:52 -0800)]
ldelfgen.c: Add missing newlines when calling einfo

* ldelfgen.c (ldelf_map_segments): Add the missing newline to
einfo.

2 years agoFix a stack exhaustion bug parsing malicious STABS format debug information.
Nick Clifton [Thu, 6 Jan 2022 16:37:26 +0000 (16:37 +0000)]
Fix a stack exhaustion bug parsing malicious STABS format debug information.

PR 28718
* debug.c (debug_write_type): Allow for malicious recursion via
indirect debug types.

2 years agoaarch64: Add support for new SME instructions
Richard Sandiford [Thu, 6 Jan 2022 16:22:54 +0000 (16:22 +0000)]
aarch64: Add support for new SME instructions

This patch adds support for three new SME instructions: ADDSPL,
ADDSVL and RDSVL.  They behave like ADDPL, ADDVL and RDVL, but read
the streaming vector length instead of the current vector length.

opcodes/
* aarch64-tbl.h (aarch64_opcode_table): Add ADDSPL, ADDSVL and RDSVL.
* aarch64-dis-2.c: Regenerate.

gas/
* testsuite/gas/aarch64/sme.s, testsuite/gas/aarch64/sme.d: Add tests
for ADDSPL, ADDSVL and RDSVL.

2 years agoUse target_announce_detach in more targets
Tom Tromey [Mon, 27 Dec 2021 05:03:09 +0000 (22:03 -0700)]
Use target_announce_detach in more targets

target_announce_detach was added in commit 0f48b757 ("Factor out
"Detaching from program" message printing").  There, Pedro wrote:

    (For now, I left the couple targets that print this a bit differently
    alone.  Maybe this could be further pulled out into infcmd.c.  If we
    did that, and those targets want to continue printing differently,
    this new function could be converted to a target method.)

It seems to me that the differences aren't very big, and in some cases
other targets handled the output a bit more nicely.  In particular,
some targets will print a different message when exec_file==NULL,
rather than printing the same output with an empty string as
exec_file.

This patch incorporates the nicer output into target_announce_detach,
then changes the remaining ports to use this function.

2 years agoIntroduce target_announce_attach
Tom Tromey [Mon, 27 Dec 2021 04:49:48 +0000 (21:49 -0700)]
Introduce target_announce_attach

This introduces target_announce_attach, by analog with
target_announce_detach.  Then it converts existing targets to use
this, rather than emitting their own output by hand.

2 years agogdb: make use add_setshow_prefix_cmd in gnu-nat.c
Andrew Burgess [Thu, 6 Jan 2022 12:53:20 +0000 (12:53 +0000)]
gdb: make use add_setshow_prefix_cmd in gnu-nat.c

In gnu-nat.c we currently implement some set/show prefix commands
"manually", that is, we call add_prefix_cmd, and assign a set and show
function to each prefix command.

These set/show functions print an error indicating that the user
didn't type a complete command.

If we instead switch to using add_setshow_prefix_cmd then we can
delete the set/show functions, GDB provides some default functions,
which give a nice help style summary that lists all of the available
sub-commands, along with a one line summary of what each does.

Though this clearly changes the existing behaviour, I think this
change is acceptable as the new behaviour is more inline with other
set/show prefix commands, and the new behaviour is more informative.

This change will conflict with Tom's change here:

  https://sourceware.org/pipermail/gdb-patches/2022-January/184724.html

Where Tom changes the set/show functions that I delete.  My suggestion
is that the set/show functions still be deleted even after Tom's
patch (or instead of Tom's patch).

For testing I've build GDB on GNU/Hurd, and manually tested these
functions.  I did a grep over the testsuite, and don't believe the
existing error messages are being checked for in any tests.

2 years agoUse warning in windows-nat error messages
Tom Tromey [Sun, 26 Dec 2021 21:21:28 +0000 (14:21 -0700)]
Use warning in windows-nat error messages

A warning in windows-nat.c can be converted to use the warning
function.  As a side effect, this arranges for the output to be sent
to gdb_stderr.

2 years agoClean up some dead code in windows-tdep.c
Tom Tromey [Sun, 26 Dec 2021 20:49:22 +0000 (13:49 -0700)]
Clean up some dead code in windows-tdep.c

windows-tdep.c checks the result of xmalloc, which isn't necessary.  I
initially removed this dead check, but then went a bit further and
modified the code so that some "goto"s and explicit memory management
could be removed.  Then, I added a couple of missing bounds checks.

I believe this also fixes a possible bug with a missing 0-termination
of a string.  I am not certain, but that is why I think the existing
code allocates a buffer that is 1 byte too long -- but then it fails
to set this byte to 0.

2 years agoAvoid crash in language_info
Tom Tromey [Wed, 5 Jan 2022 17:42:25 +0000 (10:42 -0700)]
Avoid crash in language_info

language_info calls:

  show_language_command (NULL, 1, NULL, NULL);

... "knowing" that show_language_command does not use its ui_file
parameter.  However, this was changed in commit 7514a661
("Consistently Use ui_file parameter to show callbacks").

This patch changes language_info to pass a ui_file.

It took a while to write the test -- this function is only called when
'verbose' is on and when switching the "expected" language in auto
mode.

2 years agoFix some failures in langs.exp
Tom Tromey [Thu, 6 Jan 2022 14:34:44 +0000 (07:34 -0700)]
Fix some failures in langs.exp

langs.exp currently has some fails for me because the stack trace
includes full paths to the source files.

    FAIL: gdb.base/langs.exp: up to foo in langs.exp
    FAIL: gdb.base/langs.exp: up to cppsub_ in langs.exp
    FAIL: gdb.base/langs.exp: up to fsub in langs.exp

This fixes the failures by making the filename regexps a bit more lax.

2 years agox86: drop NoAVX insn attribute
Jan Beulich [Thu, 6 Jan 2022 13:19:56 +0000 (14:19 +0100)]
x86: drop NoAVX insn attribute

To avoid issues like that addressed by 6e3e5c9e4181 ("x86: extend SSE
check to PCLMULQDQ, AES, and GFNI insns"), base the check on opcode
attributes and operand types.

2 years agox86: drop NoAVX from POPCNT
Jan Beulich [Thu, 6 Jan 2022 13:19:20 +0000 (14:19 +0100)]
x86: drop NoAVX from POPCNT

With the introduction of CpuPOPCNT the NoAVX attribute has become
meaningless for POPCNT.

2 years agox86: drop some "comm" template parameters
Jan Beulich [Thu, 6 Jan 2022 13:18:54 +0000 (14:18 +0100)]
x86: drop some "comm" template parameters

As already indicated in a remark when introducing these templates, the
"commutative" attribute is ignored for legacy encoding templates. Hence
it is possible to shorten a number of templates by specifying C directly
rather than through a template parameter. I think this helps readability
a bit.

2 years agox86: templatize FMA insn templates
Jan Beulich [Thu, 6 Jan 2022 13:18:23 +0000 (14:18 +0100)]
x86: templatize FMA insn templates

The operand ordering portion of the mnemonics repeats, causing a flurry
of almost identical templates. Abstract this out.

2 years agox86-64: restrict PC32 -> PLT32 conversion
Jan Beulich [Thu, 6 Jan 2022 13:17:40 +0000 (14:17 +0100)]
x86-64: restrict PC32 -> PLT32 conversion

Neither non-64-bit code nor uses with a non-zero offset from a symbol
should be converted to PLT32, as an eventual PLT entry would not express
what was requested.

2 years agogdb: Fix copyright year in gdb/testsuite/gdb.base/inferior-clone.exp
Lancelot SIX [Thu, 6 Jan 2022 11:53:29 +0000 (06:53 -0500)]
gdb: Fix copyright year in gdb/testsuite/gdb.base/inferior-clone.exp

I just realized that I forgot to update the year before pushing the
patch that created this file.  Since it landed after the global
copyright year update have been done, this file’s copyright year is
updated.

This patch fixes that.

Change-Id: I280f7d86e02d38425f7afdcf19a1c3500d51c23f

2 years agosim: ppc: migrate to standard uintXX_t types
Mike Frysinger [Mon, 6 Dec 2021 07:42:00 +0000 (02:42 -0500)]
sim: ppc: migrate to standard uintXX_t types

Drop the sim-specific unsignedXX types and move to the standard uintXX_t
types that C11 provides.

2 years agosim: common: migrate to standard uintXX_t types
Mike Frysinger [Mon, 6 Dec 2021 07:29:47 +0000 (02:29 -0500)]
sim: common: migrate to standard uintXX_t types

Drop the sim-specific unsignedXX types and move to the standard uintXX_t
types that C11 provides.

2 years agosim: igen: migrate to standard uintXX_t types
Mike Frysinger [Mon, 6 Dec 2021 07:18:31 +0000 (02:18 -0500)]
sim: igen: migrate to standard uintXX_t types

Move off the custom local 64-bit types and to the standard uintXX_t
types that C11 provides.

2 years agosim: mips: migrate to standard uintXX_t types
Mike Frysinger [Mon, 6 Dec 2021 07:17:02 +0000 (02:17 -0500)]
sim: mips: migrate to standard uintXX_t types

Move off the sim-specific unsignedXX types and to the standard uintXX_t
types that C11 provides.

2 years agosim: cris: migrate to standard uintXX_t types
Mike Frysinger [Mon, 6 Dec 2021 07:16:25 +0000 (02:16 -0500)]
sim: cris: migrate to standard uintXX_t types

Move off the sim-specific unsignedXX types and to the standard uintXX_t
types that C11 provides.

2 years agosim: iq2000: migrate to standard uintXX_t types
Mike Frysinger [Mon, 6 Dec 2021 07:16:02 +0000 (02:16 -0500)]
sim: iq2000: migrate to standard uintXX_t types

Move off the sim-specific unsignedXX types and to the standard uintXX_t
types that C11 provides.

2 years agosim: synacor: migrate to standard uintXX_t types
Mike Frysinger [Mon, 6 Dec 2021 07:15:41 +0000 (02:15 -0500)]
sim: synacor: migrate to standard uintXX_t types

Move off the sim-specific unsignedXX types and to the standard uintXX_t
types that C11 provides.

2 years agosim: msp430: migrate to standard uintXX_t types
Mike Frysinger [Mon, 6 Dec 2021 07:14:44 +0000 (02:14 -0500)]
sim: msp430: migrate to standard uintXX_t types

Move off the sim-specific unsignedXX types and to the standard uintXX_t
types that C11 provides.

2 years agosim: riscv: migrate to standard uintXX_t types
Mike Frysinger [Mon, 6 Dec 2021 07:10:27 +0000 (02:10 -0500)]
sim: riscv: migrate to standard uintXX_t types

Move off the sim-specific unsignedXX types and to the standard uintXX_t
types that C11 provides.

2 years agosim: bfin: migrate to standard uintXX_t types
Mike Frysinger [Mon, 6 Dec 2021 07:09:47 +0000 (02:09 -0500)]
sim: bfin: migrate to standard uintXX_t types

Move off the sim-specific unsignedXX types and to the standard uintXX_t
types that C11 provides.

2 years agosim: testsuite: migrate to standard uintXX_t types
Mike Frysinger [Sun, 5 Dec 2021 17:32:34 +0000 (12:32 -0500)]
sim: testsuite: migrate to standard uintXX_t types

This old code setup its own uintXX types, but since we require C11
now, we can assume the standard uintXX_t types exist and use them.

2 years agosim: erc32: migrate to standard uintXX_t types
Mike Frysinger [Sun, 5 Dec 2021 17:29:43 +0000 (12:29 -0500)]
sim: erc32: migrate to standard uintXX_t types

This old port setup its own uintXX types, but since we require C11
now, we can assume the standard uintXX_t types exist and use them.

2 years agosim: mn10300: migrate to standard uintXX_t types
Mike Frysinger [Sun, 5 Dec 2021 17:28:57 +0000 (12:28 -0500)]
sim: mn10300: migrate to standard uintXX_t types

This old port setup its own uintXX types, but since we require C11
now, we can assume the standard uintXX_t types exist and use them.

2 years agosim: v850: migrate to standard uintXX_t types
Mike Frysinger [Sun, 5 Dec 2021 17:28:46 +0000 (12:28 -0500)]
sim: v850: migrate to standard uintXX_t types

This old port setup its own uintXX types, but since we require C11
now, we can assume the standard uintXX_t types exist and use them.

2 years agosim: m68hc11: migrate to standard uintXX_t types
Mike Frysinger [Sun, 5 Dec 2021 17:26:29 +0000 (12:26 -0500)]
sim: m68hc11: migrate to standard uintXX_t types

This old port setup its own uintXX types, but since we require C11
now, we can assume the standard uintXX_t types exist and use them.

Also migrate off the sim-specific unsignedXX types.

2 years agosim: d10v: migrate to standard uintXX_t types
Mike Frysinger [Sun, 5 Dec 2021 17:24:12 +0000 (12:24 -0500)]
sim: d10v: migrate to standard uintXX_t types

This old port setup its own uintXX types, but since we require C11
now, we can assume the standard uintXX_t types exist and use them.

Also migrate off the sim-specific unsignedXX types.

2 years agosim: cr16: migrate to standard uintXX_t types
Mike Frysinger [Sun, 5 Dec 2021 17:22:54 +0000 (12:22 -0500)]
sim: cr16: migrate to standard uintXX_t types

This old port setup its own uintXX types, but since we require C11
now, we can assume the standard uintXX_t types exist and use them.

Also migrate off the sim-specific unsignedXX types.

2 years agoAutomatic date update in version.in
GDB Administrator [Thu, 6 Jan 2022 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in

2 years agox86: Add elf_x86_allocate_local_got_info
H.J. Lu [Wed, 5 Jan 2022 21:14:20 +0000 (13:14 -0800)]
x86: Add elf_x86_allocate_local_got_info

Add elf_x86_allocate_local_got_info to allocate x86 GOT info for local
symbols.

* elf32-i386.c (elf_i386_check_relocs): Call
elf_x86_allocate_local_got_info.
* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
* elfxx-x86.h (elf_x86_allocate_local_got_info): New.

2 years agoopcodes: Make i386-dis.c thread-safe
Vladimir Mezentsev [Wed, 5 Jan 2022 07:07:26 +0000 (23:07 -0800)]
opcodes: Make i386-dis.c thread-safe

Improve thread safety in print_insn_i386_att, print_insn_i386_intel and
print_insn_i386 by removing the use of static variables.

Tested on x86_64-pc-linux-gnu.

2022-01-04 Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

* i386-dis.c: Make print_insn_i386_att, print_insn_i386_intel
and print_insn_i386 thread-safe

2 years agodoc: Replace =frame-interp with =frames-interp
H.J. Lu [Wed, 5 Jan 2022 19:51:40 +0000 (11:51 -0800)]
doc: Replace =frame-interp with =frames-interp

The actual objdump and readelf option name is =frames-interp, not
=frames-interp.

PR binutils/28747
* doc/debug.options.texi: Replace =frame-interp with
=frames-interp.

2 years agoChange riscv_return_value to use RETURN_VALUE_ABI_PRESERVES_ADDRESS
Tom Tromey [Tue, 14 Dec 2021 15:46:59 +0000 (08:46 -0700)]
Change riscv_return_value to use RETURN_VALUE_ABI_PRESERVES_ADDRESS

Internally, AdaCore has a test that is equivalent to (really a direct
translation of) gdb.base/gnu_vector.exp.  On 32-bit RISC-V, the
"return" part of this test fails.

Joel tracked this down to riscv_return_value returning
RETURN_VALUE_ABI_RETURNS_ADDRESS.  Using
RETURN_VALUE_ABI_PRESERVES_ADDRESS is more correct here, and fixes the
bug.

I tested this for both 32- and 64-bit RISC-V using the AdaCore
internal test suite, and Andrew Burgess tested it using
gnu_vector.exp.

2 years agoFiltered output cleanup in expression dumping
Tom Tromey [Thu, 30 Dec 2021 19:34:15 +0000 (12:34 -0700)]
Filtered output cleanup in expression dumping

Most of the expression-dumping code uses filtered output, but a few
functions did not.  This patch cleans up these instance.

Note that this won't cause any behavior change, because the only calls
to dump_prefix_expression pass in gdb_stdlog.  However, in the long
run it's easier to audit the code if the number of uses of _unfiltered
is reduced.

2 years agoUse filtered output in terminal_info implementations
Tom Tromey [Mon, 27 Dec 2021 01:33:12 +0000 (18:33 -0700)]
Use filtered output in terminal_info implementations

This changes one terminal_info implementation, and
default_terminal_info, to use filtered output.  Other implementations
of this method already use filtered output.

I can't compile go32-nat.c, so this is a 'best effort' patch.

2 years agoUse filtered output in gnu-nat.c commands
Tom Tromey [Mon, 27 Dec 2021 01:22:30 +0000 (18:22 -0700)]
Use filtered output in gnu-nat.c commands

gnu-nat.c has a number of ordinary commands that should use filtered
output.  In a few cases, I changed the output to use gdb_stderr as
well.  I can't compile this file, so this patch is split out as a
"best effort".

2 years agoUse filtered output in *-tdep commands
Tom Tromey [Sat, 25 Dec 2021 05:15:42 +0000 (22:15 -0700)]
Use filtered output in *-tdep commands

Various targets introduce their own commands, which then use
unfiltered output.  It's better to use filtered output by default, so
this patch fixes the instances I found.

2 years agoUse filtered output in btrace-related commands
Tom Tromey [Mon, 27 Dec 2021 05:13:48 +0000 (22:13 -0700)]
Use filtered output in btrace-related commands

This changes btrace.c and record-btrace.c to use filtered output in
the commands implemented there.

2 years agoUse filtered output in some dumping commands
Tom Tromey [Thu, 30 Dec 2021 19:16:58 +0000 (12:16 -0700)]
Use filtered output in some dumping commands

There are several commands that may optionally send their output to a
file -- they take an optional filename argument and open a file.  This
patch changes these commands to use filtered output.  The rationale
here is that, when printing to gdb_stdout, filtering is appropriate --
it is, and should be, the default for all commands.  And, when writing
to a file, paging will not happen anyway (it only happens when the
stream==gdb_stdout), so using the _filtered form will not change
anything.

2 years agoUse filtered output in kill command
Tom Tromey [Mon, 27 Dec 2021 04:42:03 +0000 (21:42 -0700)]
Use filtered output in kill command

This changes the kill command to use filtered output.  I split this
one into its own patch because, out of an abundance of caution, I
changed the function to call bfd_cache_close_all a bit earlier, in
case pagination caused an exception.

2 years agoUse filtered output in ordinary commands
Tom Tromey [Sat, 25 Dec 2021 05:31:53 +0000 (22:31 -0700)]
Use filtered output in ordinary commands

Many otherwise ordinary commands choose to use unfiltered output
rather than filtered.  I don't think there's any reason for this, so
this changes many such commands to use filtered output instead.

Note that complete_command is not touched due to a comment there
explaining why unfiltered output is believed to be used.

2 years agoUse filtered output in language_info
Tom Tromey [Mon, 27 Dec 2021 01:17:55 +0000 (18:17 -0700)]
Use filtered output in language_info

Change language_info to use filtered output.  This is ok because the
sole caller uses filtered output elsewhere, and because this function
calls show_language_command, which also uses filtered output.

2 years agoUse filtered output in files_info implementations
Tom Tromey [Mon, 27 Dec 2021 01:14:39 +0000 (18:14 -0700)]
Use filtered output in files_info implementations

This changes the implementations of the target files_info method to
use filtered output.  This makes sense because the sole caller of this
method is an ordinary command (info_program_command).  This patch
changes this command to use filtered output as well.

2 years agoUse filtered output in target-descriptions.c
Tom Tromey [Sun, 26 Dec 2021 20:37:23 +0000 (13:37 -0700)]
Use filtered output in target-descriptions.c

target-descriptions.c uses unfiltered output.  However, if you happen
to invoke this command interactively, it's probably better for it to
use filtering.  For non-interactive use, this doesn't matter.

2 years agoUse filtered output for gdbarch dump
Tom Tromey [Sun, 26 Dec 2021 20:26:58 +0000 (13:26 -0700)]
Use filtered output for gdbarch dump

This changes gdbarch dumping to use filtered output.  This seems a bit
better to me, both on the principle that this is an ordinary command,
and because the output can be voluminous, so it may be nice to stop in
the middle.

2 years agoImplement putstr and putstrn in ui_file
Tom Tromey [Fri, 31 Dec 2021 17:40:02 +0000 (10:40 -0700)]
Implement putstr and putstrn in ui_file

In my tour of the ui_file subsystem, I found that fputstr and fputstrn
can be simplified.  The _filtered forms are never used (and IMO
unlikely to ever be used) and so can be removed.  And, the interface
can be simplified by removing a callback function and moving the
implementation directly to ui_file.

A new self-test is included.  Previously, I think nothing was testing
this code.

Regression tested on x86-64 Fedora 34.

2 years agoChange how versioned symbols are recorded
Tom Tromey [Tue, 3 Aug 2021 18:42:43 +0000 (12:42 -0600)]
Change how versioned symbols are recorded

A change to BFD caused a gdb regression when using the Ada "catch
exception" feature.  The bug is visible when a shared library throws
an exception that is caught in the main executable.

This was discussed here:

https://sourceware.org/pipermail/binutils/2021-July/117538.html

This patch implements Alan's proposed fix, namely to use VERSYM_HIDDEN
rather than the name when deciding to install a version-less symbol.

The internal test case is identical to the catch_ex_std.exp that is
in-tree, so I haven't added a new test.  I could not make that one
fail on x86-64 Linux, though.  It's possible that maybe I'd have to
update the system linker first, but I didn't want to try that.

Regression tested on x86-64 Fedora 32.

2 years agoFix inferior_thread attribute in new_thread event
Hannes Domani [Wed, 5 Jan 2022 15:37:28 +0000 (16:37 +0100)]
Fix inferior_thread attribute in new_thread event

Commit 72ee03ff58 fixed a use-after-move bug in add_thread_object, but
it changed the inferior_thread attribute to contain the inferior instead
of the actual thread.
This now uses the thread_obj in its new location instead.

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

2 years agoSimplify execute_control_commands_to_string
Tom Tromey [Sat, 25 Dec 2021 05:05:38 +0000 (22:05 -0700)]
Simplify execute_control_commands_to_string

execute_control_commands_to_string can be rewritten in terms of
execute_fn_to_string, which consolidates some knowledge about which
streams to redirect.

Regression tested on x86-64 Fedora 34.

2 years agoDo not print anything when self-backtrace unavailable
Tom Tromey [Wed, 5 Jan 2022 15:43:59 +0000 (08:43 -0700)]
Do not print anything when self-backtrace unavailable

Right now, gdb's self-backtrace feature will still print something
when a backtrace is unavailable:

   sig_write (_("----- Backtrace -----\n"));
[...]
     sig_write (_("Backtrace unavailable\n"));
    sig_write ("---------------------\n");

However, if GDB_PRINT_INTERNAL_BACKTRACE is undefined, it seems better
to me to print nothing at all.

This patch implements this change.  It also makes a couple of other
small changes in this same module: it adds a header guard to
bt-utils.h, and it protects the definitions of
gdb_internal_backtrace_1 with a check of GDB_PRINT_INTERNAL_BACKTRACE.

2 years agoFix pager regression
Tom Tromey [Mon, 3 Jan 2022 16:48:37 +0000 (09:48 -0700)]
Fix pager regression

The patch to fix paging with redirection caused a regression in the
internal AdaCore test suite.  The problem occurs when running an MI
command from the CLI using interpreter-exec, when paging is enabled.
This scenario isn't covered by the current test suite, so this patch
includes a new test.

The problem is that, in this situation, MI does:

  fputs_unfiltered (strcmp (context->command, "target-select") == 0
     ? "^connected" : "^done", mi->raw_stdout);

Here raw_stdout is a stdio_file wrapping stdout, so the pager thinks
that it is ok to buffer the output.  However, in this setup, it isn't
ok, and flushing the wrap buffer doesn't really work properly.  Also,
MI next does:

  mi_out_put (uiout, mi->raw_stdout);

... but this uses ui_file::write, which also doesn't flush the wrap
buffer.

I think all this will be fixed by the pager rewrite series I'm working
on.  However, in the meantime, adding the old gdb_stdout check back to
the pager fixes this problem.

Regression tested on x86-64 Fedora 34.

2 years agoelf: Set p_align to the minimum page size if possible
H.J. Lu [Tue, 14 Dec 2021 03:46:04 +0000 (19:46 -0800)]
elf: Set p_align to the minimum page size if possible

Currently, on 32-bit and 64-bit ARM, it seems that ld generates p_align
values of 0x10000 even if no section alignment is greater than 0x1000.
The issue is more general and probably affects other targets with multiple
page sizes.

While file layout absolutely must take 64K page size into account, that
does not have to be reflected in the p_align value.  If running on a 64K
kernel, the file will be loaded at a 64K page boundary by necessity. On
a 4K kernel, 64K alignment is not needed.

The glibc loader has been fixed to honor p_align:

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

similar to kernel:

commit ce81bb256a224259ab686742a6284930cbe4f1fa
Author: Chris Kennelly <ckennelly@google.com>
Date:   Thu Oct 15 20:12:32 2020 -0700

    fs/binfmt_elf: use PT_LOAD p_align values for suitable start address

This means that on 4K kernels, we will start to do extra work for 64K
p_align, but this pointless for pretty much all binaries (whose section
alignment rarely exceeds 16).

The minimum page size is used, instead of the maximum section alignment
due to this glibc bug:

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

It has been fixed in glibc 2.35.  But linker output must work on existing
glibc binaries.

1. Set p_align to the minimum page size while laying out segments aligning
to the maximum page size or section alignment.  The run-time loader can
align segments to the minimum page size or above, depending on system page
size.
2. If -z max-page-size=NNN is used, p_align will be set to the maximum
page size or the largest section alignment.
3. If a section requires alignment higher than the minimum page size,
don't set p_align to the minimum page size.
4. If a section requires alignment higher than the maximum page size,
set p_align to the section alignment.
5. For objcopy, when the minimum page size != the maximum page size,
p_align may be set to the minimum page size while segments are aligned
to the maximum page size.  In this case, the input p_align will be
ignored and the maximum page size will be used to align the ouput
segments.
6. Update linker to disallow the common page size > the maximum page size.
7. Update linker to avoid the common page size > the maximum page size.
8. Adjust pru_irq_map-1.d to expect p_align == sh_addralign:

Section Headers:
  [Nr] Name   Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]        NULL            00000000 000000 000000 00      0   0  0
  [ 1] .text  PROGBITS        20000000 00007c 000004 00  AX  0   0  4
...
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000074 0x00000000 0x00000000 0x00008 0x00008 RW  0x1
  LOAD           0x00007c 0x20000000 0x20000000 0x00004 0x00004 R E 0x4

vs.

Section Headers:
  [Nr] Name   Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]        NULL            00000000 000000 000000 00      0   0  0
  [ 1] .text  PROGBITS        20000000 00007c 000004 00  AX  0   0  4
...
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000074 0x00000000 0x00000000 0x00008 0x00008 RW  0x1
  LOAD           0x00007c 0x20000000 0x20000000 0x00004 0x00004 R E 0x1

To enable this linker optimization, the backend should define ELF_P_ALIGN
to ELF_MINPAGESIZE.

bfd/

PR ld/28689
PR ld/28695
* elf-bfd.h (elf_backend_data): Add p_align.
* elf.c (assign_file_positions_for_load_sections): Set p_align
to the default p_align value while laying out segments aligning
to maximum page size or section alignment.
(elf_is_p_align_valid): New function.
(copy_elf_program_header): Call elf_is_p_align_valid to determine
if p_align is valid.
* elfxx-target.h (ELF_P_ALIGN): New.  Default to 0.
(elfNN_bed): Add ELF_P_ALIGN.
* elfxx-x86.h (ELF_P_ALIGN): New.  Set to ELF_MINPAGESIZE.

include/

PR ld/28689
PR ld/28695
* bfdlink.h (bfd_link_info): Add maxpagesize_is_set.

ld/

PR ld/28689
PR ld/28695
* emultempl/elf.em (gld${EMULATION_NAME}_handle_option): Set
link_info.maxpagesize_is_set for -z max-page-size=NNN.
* ldelf.c (ldelf_after_parse): Disallow link_info.commonpagesize
> link_info.maxpagesize.
* testsuite/ld-elf/elf.exp: Pass -z max-page-size=0x4000 to
linker to build mbind2a and mbind2b.
* testsuite/ld-elf/header.d: Add -z common-page-size=0x100.
* testsuite/ld-elf/linux-x86.exp: Add PR ld/28689 tests.
* testsuite/ld-elf/p_align-1.c: New file.
* testsuite/ld-elf/page-size-1.d: New test.
* testsuite/ld-elf/pr26936.d: Add -z common-page-size=0x1000.
* testsuite/ld-elf/seg.d: Likewise.
* testsuite/ld-scripts/rgn-at5.d: Likewise.
* testsuite/ld-pru/pru_irq_map-1.d: Append 1 to name.  Adjust
expected PT_LOAD segment alignment.
* testsuite/ld-pru/pru_irq_map-2.d: Append 2 to name.
* testsuite/ld-scripts/pr23571.d: Add -z max-page-size=0x1000.

2 years agoAdjust quoted-sym-names test
Alan Modra [Wed, 5 Jan 2022 08:36:27 +0000 (19:06 +1030)]
Adjust quoted-sym-names test

Some targets restrict symbol addresses in .text to instruction
boundaries.

* testsuite/gas/all/quoted-sym-names.s: Define syms in .data.
* testsuite/gas/all/quoted-sym-names.d: Adjust to suit.

2 years agoinfinite recursion detected in gold testcase
Alan Modra [Wed, 5 Jan 2022 01:09:12 +0000 (11:39 +1030)]
infinite recursion detected in gold testcase

gold/testsuite/icf_test.cc:32:5: error: infinite recursion detected [-Werror=infinite-recursion]
   32 | int kept_func()
      |     ^~~~~~~~~

* testsuite/icf_test.cc: Avoid infinite recursion error.

2 years agoAutomatic date update in version.in
GDB Administrator [Wed, 5 Jan 2022 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in

2 years agold/x86: Update -z report-relative-reloc
H.J. Lu [Tue, 4 Jan 2022 19:07:50 +0000 (11:07 -0800)]
ld/x86: Update -z report-relative-reloc

Use 0x%v, instead of bfd_sprintf_vma, to report relative relocations.
Change linker relative relocations report from

tmpdir/dump: R_X86_64_IRELATIVE (offset: 0x0000000000002000, info: 0x0000000000000025, addend: 0x0000000000001007) against 'ifunc' for section '.data.rel.ro.local' in tmpdir/report-reloc-1.o

to

tmpdir/dump: R_X86_64_IRELATIVE (offset: 0x2000, info: 0x25, addend: 0x1007) against 'ifunc' for section '.data.rel.ro.local' in tmpdir/report-reloc-1.o

bfd/

* elfxx-x86.c (_bfd_x86_elf_link_report_relative_reloc): Use
0x%v instead of bfd_sprintf_vma.

ld/

* testsuite/ld-i386/report-reloc-1.l: Updated.
* testsuite/ld-x86-64/report-reloc-1.l: Likewise.

2 years agold: Improve thin archive member error message
H.J. Lu [Sat, 25 Dec 2021 00:04:03 +0000 (16:04 -0800)]
ld: Improve thin archive member error message

Improve thin archive member error message with:

ld: libbar.a(bar.o): error opening thin archive member: No such file or directory

instead of

ld: libbar.a: error adding symbols: No such file or directory

PR ld/28722
* archive.c (_bfd_get_elt_at_filepos): Add a pointer argument
for struct bfd_link_info.  Call linker callback when failing to
open thin archive member.
(_bfd_generic_get_elt_at_index): Pass NULL to
_bfd_get_elt_at_filepos.
(bfd_generic_openr_next_archived_file): Likewise.
* coff-alpha.c (alpha_ecoff_get_elt_at_filepos): Add a pointer
argument for struct bfd_link_info and pass it to
_bfd_get_elt_at_filepos.
(alpha_ecoff_openr_next_archived_file): Pass NULL to
_bfd_get_elt_at_filepos.
(alpha_ecoff_get_elt_at_index): Likewise.
* coff-rs6000.c (_bfd_xcoff_openr_next_archived_file): Likewise.
* ecoff.c (ecoff_link_add_archive_symbols): Pass info to
backend->get_elt_at_filepos.
* elflink.c (elf_link_is_defined_archive_symbol): info to
_bfd_get_elt_at_filepos.
* libbfd-in.h (_bfd_get_elt_at_filepos): Add a pointer argument
for struct bfd_link_info.
* libbfd.h: Regenerate.
* libecoff.h (ecoff_backend_data): Add a pointer argument for
struct bfd_link_info to get_elt_at_filepos.
* linker.c (_bfd_generic_link_add_archive_symbols): Pass info to
_bfd_get_elt_at_filepos.

2 years agogdb/testsuite: fix inferior-clone.exp for native-extended-gdbserver
Lancelot SIX [Wed, 29 Dec 2021 14:01:25 +0000 (09:01 -0500)]
gdb/testsuite: fix inferior-clone.exp for native-extended-gdbserver

003aae076207dbf32f98ba846158fc32669ef85f (gdb: Copy inferior properties
in clone-inferior) introduced a testcase that fails when testing with
the native-extended-gdbserver board:

    Running ../gdb/testsuite/gdb.base/inferior-clone.exp ...
    FAIL: gdb.base/inferior-clone.exp: inferior 2: clone-inferior
    FAIL: gdb.base/inferior-clone.exp: inferior 3: clone-inferior

The error is as follows:

    clone-inferior
    [New inferior 2]
    Added inferior 2 on connection 1 (extended-remote localhost:2346)
    (gdb) FAIL: gdb.base/inferior-clone.exp: inferior 2: clone-inferior

This fails because the testcase only expect the 'Added inferior 2' part
of the message.  The 'on connection 1 [...]' part is unexpected.

Fix by adjusting the testcase to a account for the possible trailing
part of the message.

Tested on x86_64-linux with native-extende-gdbserver and unix boards.

Change-Id: Ie3d6f04c9ffe9cab1fbda8ddf4935ee09b858c7a

2 years agoAdd ATTRIBUTE_UNUSED to load_build_id_debug_file()'s main_filename parameter.
Nick Clifton [Tue, 4 Jan 2022 10:33:11 +0000 (10:33 +0000)]
Add ATTRIBUTE_UNUSED to load_build_id_debug_file()'s main_filename parameter.

2 years agogdb: don't pass nullptr to sigwait
Andrew Burgess [Wed, 29 Dec 2021 11:53:49 +0000 (11:53 +0000)]
gdb: don't pass nullptr to sigwait

I tried building GDB on GNU/Hurd, and ran into this warning:

  gdbsupport/scoped_ignore_signal.h:78:16: error: null argument where non-null required (argument 2) [-Werror=nonnull]

This is because in this commit:

  commit 99624310dd82542c389c89c2e55d8cae36bb74e1
  Date:   Sun Jun 27 15:13:14 2021 -0400

      gdb: fall back on sigpending + sigwait if sigtimedwait is not available

A call to sigwait was introduced that passes nullptr as the second
argument, this call is only reached if sigtimedwait is not supported.

The original patch was written for macOS, I assume on that target
passing nullptr as the second argument is fine.

On my GNU/Linux box, the man-page for sigwait doesn't mention that
nullptr is allowed for the second argument, so my assumption would be
that nullptr is not OK, and, if I change the '#ifdef
HAVE_SIGTIMEDWAIT' introduced by the above patch to '#if 0', and
rebuild on GNU/Linux, I see the same warning that I see on GNU/Hurd.

I propose that we stop passing nullptr as the second argument to
sigwait, and instead pass a valid int pointer.  The value returned in
the int can then be used in an assert.

For testing, I (locally) made the change to the #ifdef I mentioned
above, compiled GDB, and ran the usual tests, this meant I was using
sigwait instead on sigtimedwait on GNU/Linux, I saw no regressions.

2 years agoRemove a spurious debugging message.
Nick Clifton [Tue, 4 Jan 2022 10:26:15 +0000 (10:26 +0000)]
Remove a spurious debugging message.

PR 28716
* dwarf.c (load_build_id_debug_file): Remove spurious printf.

2 years ago[gdb/build] Fix build breaker in gdb/cli/cli-logging.c
Tom de Vries [Tue, 4 Jan 2022 09:24:36 +0000 (10:24 +0100)]
[gdb/build] Fix build breaker in gdb/cli/cli-logging.c

Fix build breaker in gdb/cli/cli-logging.c:
...
gdb/cli/cli-logging.c: In function \
  ‘void show_logging_enabled(ui_file*, int, cmd_list_element*, const char*)’:
gdb/gdbsupport/gdb_locale.h:28:28: error: cannot convert ‘char*’ to ‘ui_file*’
   28 | # define _(String) gettext (String)
      |                    ~~~~~~~~^~~~~~~~
      |                            |
      |                            char*
gdb/cli/cli-logging.c:202:25: note: in expansion of macro ‘_’
  202 |     fprintf_unfiltered (_("on: Logging is enabled.\n"));
      |                         ^
...

Build and tested on x86_64-linux.

Fixes: 45aec4e5ed8 ("[gdb/cli] Improve show logging output")
2 years agox86/Intel: correct VFPCLASSP{S,D} handling when displacement is present
Jan Beulich [Tue, 4 Jan 2022 09:05:53 +0000 (10:05 +0100)]
x86/Intel: correct VFPCLASSP{S,D} handling when displacement is present

fits_in_disp8() can be called before ambiguous operands get resolved
or rejected (in process_suffix()), which requires that i.memshift be
non-negative to avoid an internal error. This case wasn't covered by
6c0946d0d28d ("x86: correct VFPCLASSP{S,D} operand size handling").

2 years agogas: rework handling of backslashes in quoted symbol names
Jan Beulich [Tue, 4 Jan 2022 09:05:17 +0000 (10:05 +0100)]
gas: rework handling of backslashes in quoted symbol names

Strange effects can result from the present handling, e.g.:

.if 1
"backslash\\":
.endif

yields first (correctly) "missing closing `"'" but then also "invalid
character '\' in mnemonic" and further "end of file inside conditional".
Symbols names ending in \ are in principle not expressable with that
scheme.

Instead of recording whether a backslash was seen, inspect the
subsequent character right away. Only accept \\ (meaning a single
backslash in the resulting symbol name) and \" (meaning an embedded
double quote in the resulting symbol name) for now, warning about any
other combination.

While perhaps not necessary immediately, also permit concatenated
strings to form a symbol name. This may become useful if going forward
we would want to support \<octal> or \x<hex> sequences, where closing
and re-opening quotes can be useful to delimit such sequences.

The ELF "Multibyte symbol names" test gets switched away from using
.set, as that would now also mean excluding nios2 and pru. By using
.equiv instead, even the existing #notarget can be dropped. (For h8300
the .section directive additionally needs attributes specified, to avoid
a target specific warning.)

2 years agoAutomatic date update in version.in
GDB Administrator [Tue, 4 Jan 2022 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in

2 years ago[gdb/cli] Improve show logging output
Tom de Vries [Mon, 3 Jan 2022 22:59:30 +0000 (23:59 +0100)]
[gdb/cli] Improve show logging output

Before commit 3b6acaee895 "Update more calls to add_prefix_cmd" we had the
following output for "show logging":
...
$ gdb -q -batch -ex "set trace-commands on" \
    -ex "set logging off" \
    -ex "show logging" \
    -ex "set logging on" \
    -ex "show logging"
+set logging off
+show logging
Future logs will be written to gdb.txt.
Logs will be appended to the log file.
Output will be logged and displayed.
Debug output will be logged and displayed.
+set logging on
+show logging
Currently logging to "gdb.txt".
Logs will be appended to the log file.
Output will be logged and displayed.
Debug output will be logged and displayed.
...

After that commit we have instead:
...
+set logging off
+show logging
debugredirect:  The logging output mode is off.
file:  The current logfile is "gdb.txt".
overwrite:  Whether logging overwrites or appends to the log file is off.
redirect:  The logging output mode is off.
+set logging on
+show logging
debugredirect:  The logging output mode is off.
file:  The current logfile is "gdb.txt".
overwrite:  Whether logging overwrites or appends to the log file is off.
redirect:  The logging output mode is off.
...
which gives less clear output for some subcommands.

OTOH, it's explicit about whether boolean values are on or off.

The new text seems to have been chosen to match the set/show help texts:
...
(gdb) help show logging
Show logging options.

List of show logging subcommands:

show logging debugredirect -- Show the logging debug output mode.
show logging file -- Show the current logfile.
show logging overwrite -- \
  Show whether logging overwrites or appends to the log file.
show logging redirect -- Show the logging output mode.
...

Make the show logging messages more clear, while still keep the boolean
values explicit, such that we have:
...
$ ./gdb.sh -q -batch -ex "show logging"
logging debugredirect:  off: \
  Debug output will go to both the screen and the log file.
logging enabled:  off: Logging is disabled.
logging file:  The current logfile is "gdb.txt".
logging overwrite:  off: Logging appends to the log file.
logging redirect:  off: Output will go to both the screen and the log file.
...

Tested on x86_64-linux.

2 years agoFix use of 'printf' in gdbtypes.c
Tom Tromey [Mon, 3 Jan 2022 18:04:01 +0000 (11:04 -0700)]
Fix use of 'printf' in gdbtypes.c

An earlier patch of mine, commit 64b7cc50 ("Remove
gdb_print_host_address") inadvertently changed a function in
gdbtypes.c to use printf rather than printf_filtered.  This patch
fixes the problem.

2 years agoFix regression in page-logging.exp
Tom Tromey [Mon, 3 Jan 2022 16:03:55 +0000 (09:03 -0700)]
Fix regression in page-logging.exp

Simon and Tom pointed out that page-logging.exp failed on their
machines.  Tom tracked this down to the "width" setting.  Since
there's no need in the test to change the width, it seems simplest to
remove the setting.  I confirmed that the test still fails if the fix
is backed out, ensuring that the test is still testing what it
purports to.

2 years agoSmall indentation fix in eval.c
Tom Tromey [Mon, 3 Jan 2022 14:55:20 +0000 (07:55 -0700)]
Small indentation fix in eval.c

I noticed that the AdaCore tree had a small divergence in eval.c -- it
had a fix for an indentation problem in binop_promote.  I'm checking
in this small fix as obvious.