binutils-gdb.git
19 months agoRename skip_vsx_tests to allow form
Tom Tromey [Sun, 22 Jan 2023 16:37:44 +0000 (09:37 -0700)]
Rename skip_vsx_tests to allow form

This renames skip_vsx_tests to allow_vsx_tests and updates it users to
use require.

19 months agoRename skip_power_isa_3_1_tests to allow form
Tom Tromey [Sun, 22 Jan 2023 16:12:30 +0000 (09:12 -0700)]
Rename skip_power_isa_3_1_tests to allow form

This renames skip_power_isa_3_1_tests to allow_power_isa_3_1_tests and
updates its users to use require.

19 months agoRename skip_float_test to allow form
Tom Tromey [Sun, 22 Jan 2023 06:02:42 +0000 (23:02 -0700)]
Rename skip_float_test to allow form

This renames skip_float_test to allow_float_test and updates its users
to use require.

19 months agoConvert skip_altivec_tests to allow form
Tom Tromey [Sun, 22 Jan 2023 05:43:55 +0000 (22:43 -0700)]
Convert skip_altivec_tests to allow form

This renames skip_altivec_tests to allow_altivec_tests and updates its
users to use require.

19 months ago[gdb/testsuite] Fix gdb.base/unwind-on-each-insn.exp for -m32
Tom de Vries [Wed, 25 Jan 2023 15:35:53 +0000 (16:35 +0100)]
[gdb/testsuite] Fix gdb.base/unwind-on-each-insn.exp for -m32

With test-case gdb.base/unwind-on-each-insn.exp and target board unix/-m32, I
now get:
...
 # of expected passes            25
...
instead of:
...
 # of expected passes            133
...
as I used to get before commit d25a8dbc7c3 ("[gdb/testsuite] Allow debug
srcfile2 in gdb.base/unwind-on-each-insn.exp"), due to the test-case trying to match
"rip = " and info frame printing "eip = " instead.

Fix this by dropping "rip" from the regexp.

Tested on x86_64-linux, target boards unix/{-m64,-m32}.

19 months ago[gdb/testsuite] Allow debug srcfile2 in gdb.base/unwind-on-each-insn.exp
Tom de Vries [Wed, 25 Jan 2023 14:24:17 +0000 (15:24 +0100)]
[gdb/testsuite] Allow debug srcfile2 in gdb.base/unwind-on-each-insn.exp

Test-case gdb.base/unwind-on-each-insn.exp compiles $srcfile with debug info, and
$srcfile2 without.

Occasionally, I try both files with debug info:
...
-             $srcfile $debug_flags $srcfile2 $nodebug_flags]]} {
+             $srcfile $debug_flags $srcfile2 $debug_flags]]} {
...

This shortcuts the test due to no longer recognizing that stepi still lands
in foo.

Fix this by determining whether still in foo by checking the info frame output.

Tested on x86_64-linux.

19 months ago[gdb/testsuite] Allow nodebug srcfile in gdb.base/unwind-on-each-insn.exp
Tom de Vries [Wed, 25 Jan 2023 12:44:17 +0000 (13:44 +0100)]
[gdb/testsuite] Allow nodebug srcfile in gdb.base/unwind-on-each-insn.exp

Test-case gdb.base/unwind-on-each-insn.exp compiles $srcfile with debug info, and
$srcfile2 without.

Occasionally, I try both files with debug info:
...
-             $srcfile $debug_flags $srcfile2 $nodebug_flags]]} {
+             $srcfile $debug_flags $srcfile2 $debug_flags]]} {
...
and both files without:
...
-             $srcfile $debug_flags $srcfile2 $nodebug_flags]]} {
+             $srcfile $nodebug_flags $srcfile2 $nodebug_flags]]} {
...

In the latter case, I run into:
...
FAIL: gdb.base/unwind-on-each-insn.exp: foo: instruction 1: bt 2
FAIL: gdb.base/unwind-on-each-insn.exp: foo: instruction 1: up
...
due to a mismatch between the regexp and the different output due to using
nodebug.

Fix this by making the regexp less strict.

Tested on x86_64-linux.

19 months agogdb, i386: Update stale comment in i386-tdep.h.
Felix Willgerodt [Thu, 14 Jul 2022 14:26:16 +0000 (16:26 +0200)]
gdb, i386: Update stale comment in i386-tdep.h.

The comment seems no longer valid, the functions technically check for
non-pseudo registers, like zmmh.  Which is a valid use case.

19 months ago[gdb/testsuite] Analyze non-leaf fn in gdb.base/unwind-on-each-insn.exp
Tom de Vries [Wed, 25 Jan 2023 12:27:03 +0000 (13:27 +0100)]
[gdb/testsuite] Analyze non-leaf fn in gdb.base/unwind-on-each-insn.exp

In test-case gdb.base/unwind-on-each-insn.exp, we stepi through function foo
to check various invariants at each insn, in particular hoping to excercise
insns that modify stack and frame pointers.

Function foo is a leaf function, so add a non-leaf function bar, and step
through it as well (using nexti instead of stepi).

With the updated test-case, on powerpc64le-linux, I run into PR tdep/30049:
...
FAIL: bar: instruction 5: bt 2
FAIL: bar: instruction 5: up
FAIL: bar: instruction 5: [string equal $fid $::main_fid]
FAIL: bar: instruction 6: bt 2
FAIL: bar: instruction 6: up
FAIL: bar: instruction 6: [string equal $fid $::main_fid]
...

Tested on:
- x86_64-linux (-m64 and -m32)
- s390x-linux (-m64 and -m31)
- aarch64-linux
- powerpc64le-linux

19 months ago[gdb/testsuite] Improve leaf fn in gdb.base/unwind-on-each-insn.exp
Tom de Vries [Wed, 25 Jan 2023 12:27:03 +0000 (13:27 +0100)]
[gdb/testsuite] Improve leaf fn in gdb.base/unwind-on-each-insn.exp

In test-case gdb.base/unwind-on-each-insn.exp, we stepi through function foo
to check various invariants at each insn, in particular hoping to excercise
insns that modify stack and frame pointers.

For x86_64-linux, we have a reasonably complex foo (and similar for -m32):
...
  4004bc:       55                      push   %rbp
  4004bd:       48 89 e5                mov    %rsp,%rbp
  4004c0:       90                      nop
  4004c1:       5d                      pop    %rbp
  4004c2:       c3                      ret
...
Both stack pointer (%rsp) and frame pointer (%rbp) are modified.

Also for s390x-linux (and similar for -m31):
...
0000000001000668 <foo>:
 1000668:       e3 b0 f0 58 00 24       stg     %r11,88(%r15)
 100066e:       b9 04 00 bf             lgr     %r11,%r15
 1000672:       e3 b0 b0 58 00 04       lg      %r11,88(%r11)
 1000678:       07 fe                   br      %r14
...
Frame pointer (%r11) is modified.

Likewise for powerpc64le-linux:
...
00000000100006c8 <foo>:
    100006c8:   f8 ff e1 fb     std     r31,-8(r1)
    100006cc:   d1 ff 21 f8     stdu    r1,-48(r1)
    100006d0:   78 0b 3f 7c     mr      r31,r1
    100006d4:   00 00 00 60     nop
    100006d8:   30 00 3f 38     addi    r1,r31,48
    100006dc:   f8 ff e1 eb     ld      r31,-8(r1)
    100006e0:   20 00 80 4e     blr
...
Both stack pointer (r1) and frame pointer (r31) are modified.

But for aarch64-linux, we have:
...
00000000004005fc <foo>:
  4005fc:       d503201f        nop
  400600:       d65f03c0        ret
...
There's no insn that modifies stack or frame pointer.

Fix this by making foo more complex, adding an (unused) argument:
...
0000000000400604 <foo>:
  400604:       d10043ff        sub     sp, sp, #0x10
  400608:       f90007e0        str     x0, [sp, #8]
  40060c:       d503201f        nop
  400610:       910043ff        add     sp, sp, #0x10
  400614:       d65f03c0        ret
...
such that the stack pointer (sp) is modified.

[ Note btw that we're seeing the effects of -momit-leaf-frame-pointer, with
-mno-omit-leaf-frame-pointer we have instead:
...
0000000000400604 <foo>:
  400604:       a9be7bfd        stp     x29, x30, [sp, #-32]!
  400608:       910003fd        mov     x29, sp
  40060c:       f9000fa0        str     x0, [x29, #24]
  400610:       d503201f        nop
  400614:       a8c27bfd        ldp     x29, x30, [sp], #32
  400618:       d65f03c0        ret
...
such that also the frame pointer (x29) is modified. ]

Having made foo more complex, we now run into the following fail on
x86_64/-m32:
...
FAIL: gdb.base/unwind-on-each-insn.exp: instruction 1: $sp_value == $main_sp
....

The problem is that the stack pointer has changed inbetween the sampling of
main_sp and *foo, in particular by the push insn:
...
 804841a:       68 c0 84 04 08          push   $0x80484c0
 804841f:       e8 10 00 00 00          call   8048434 <foo>
...

Fix this by updating main_sp.

On powerpc64le-linux, with gcc 7.5.0 I now run into PR tdep/30021:
...
FAIL: gdb.base/unwind-on-each-insn.exp: insn 7: $fba_value == $main_fba
FAIL: gdb.base/unwind-on-each-insn.exp: insn 7: [string equal $fid $main_fid]
...
but I saw the same failure before this commit with gcc 4.8.5.

Tested on:
- x86_64-linux (-m64 and -m32)
- s390x-linux (-m64 and -m31)
- powerpc64le-linux
- aarch64-linux

Also I've checked that the test-case still functions as regression test for PR
record/16678 on x86_64.

19 months agogdb/tui: make use of a scoped_restore
Andrew Burgess [Thu, 5 Jan 2023 15:13:54 +0000 (15:13 +0000)]
gdb/tui: make use of a scoped_restore

Make use of a scoped_restore object in tui_mld_read_key instead of
doing a manual save/restore.

I don't think the existing code can throw an exception, so this is
just a cleanup rather than a bug fix.

There should be no user visible changes after this commit.

19 months agogdb/tui: better filtering of tab completion results for focus command
Andrew Burgess [Tue, 20 Dec 2022 15:45:32 +0000 (15:45 +0000)]
gdb/tui: better filtering of tab completion results for focus command

While working on the previous couple of commits, I noticed that the
'focus' command would happily suggest 'status' as a possible focus
completion, even though the 'status' window is non-focusable, and,
after the previous couple of commits, trying to focus the status
window will result in an error.

This commit improves the tab-completion results for the focus command
so that the status window is not included.

19 months agogdb/tui: convert if/error to an assert
Andrew Burgess [Thu, 22 Dec 2022 12:43:38 +0000 (12:43 +0000)]
gdb/tui: convert if/error to an assert

While working on the previous commit, I realised that there was an
error in tui_set_focus_command that could never be triggered.

Since the big tui rewrite (adding dynamic layouts) it is no longer
true that there is a tui_win_info object for every window at all
times.  We now only create a tui_win_info object for a particular
window, when the window is part of the current layout.  As a result,
if we have a tui_win_info pointer, then the window must be visible
inside tui_set_focus_command (this function calls tui_enable as its
first action, which makes the current layout visible).

The gdb.tui/tui-focus.exp test script exercises this area of code, and
doesn't trigger the assert, nor do any of our other existing tui
tests.

19 months agogdb/testsuite/tui: more testing of the 'focus' command
Andrew Burgess [Tue, 20 Dec 2022 15:01:29 +0000 (15:01 +0000)]
gdb/testsuite/tui: more testing of the 'focus' command

I noticed that we didn't have many tests of the tui 'focus' command,
so I started adding some.  This exposed a bug in GDB; we are able to
focus windows that should not be focusable, e.g. the 'status' window.

This is harmless until we then do 'focus next' or 'focus prev', along
this code path we assert that the currently focused window is
focusable, which obviously, is not always true, so GDB fails with an
assertion error.

The fix is simple; add a check to the tui_set_focus_command function
to ensure that the selected window is focusable.  If it is not then an
error is thrown.  The new tests I've added cover this case.

19 months agogdb/testsuite: update gdb.tui/tui-nl-filtered-output.exp
Andrew Burgess [Thu, 22 Dec 2022 10:24:22 +0000 (10:24 +0000)]
gdb/testsuite: update gdb.tui/tui-nl-filtered-output.exp

Following on from the previous commit, in this commit I am updating
the test script gdb.tui/tui-nl-filtered-output.exp to take account of
the changes in commit:

  commit 9162a27c5f5828240b53379d735679e2a69a9f41
  Date:   Tue Nov 13 11:59:03 2018 -0700

      Change gdb test suite's TERM setting

In the above commit the TERM environment variable was changed to be
'dumb' by default, which means that tests, that previously activated
tui mode, no longer do unless TERM is set to 'ansi'.

As the gdb.tui/tui-nl-filtered-output.exp script didn't do this, the
test stopped working.  As the expect patterns in this script were
pretty generic no tests actually started failing, and we never
noticed.

In this commit I update the test script to correctly activate our
terminal emulator, the test continues to pass after this update, but
now we are testing in tui mode.

19 months agogdb/testsuite: update gdb.tui/tui-disasm-long-lines.exp
Andrew Burgess [Tue, 20 Dec 2022 16:25:33 +0000 (16:25 +0000)]
gdb/testsuite: update gdb.tui/tui-disasm-long-lines.exp

Following on from the previous commit, in this commit I am updating
the test script gdb.tui/tui-disasm-long-lines.exp to take account of
the changes in commit:

  commit 9162a27c5f5828240b53379d735679e2a69a9f41
  Date:   Tue Nov 13 11:59:03 2018 -0700

      Change gdb test suite's TERM setting

In the above commit the TERM environment variable was changed to be
'dumb' by default, which means that tests, that previously activated
tui mode, no longer do unless TERM is set to 'ansi'.

As the gdb.tui/tui-disasm-long-lines.exp script didn't do this, the
test stopped working.  As the expect patterns in this script were
pretty generic no tests actually started failing, and we never
noticed.

In this commit I update the script to use Term::clean_restart, which
correctly sets TERM to 'ansi'.  I've also added a check that the asm
box does appear on the screen, which should indicate that tui mode has
correctly activated.

However, I also notice that GDB doesn't appear to fully work
correctly.  The test should display the disassembly for the test
program, but it doesn't.

The test is trying to disassemble some code that (deliberately) uses a
very long symbol name, this eventually results in GDB entering
tui_source_window_base::show_source_content and trying to allocate an
ncurses pad in order to hold the current page of disassembler output.

Unfortunately, due to the very long line, the call to newpad fails,
meaning that tui_source_window_base::m_pad is nullptr.  Luckily non of
the following calls appear to crash when passed a nullptr, however,
all the output that is written to the pad is lost, which is why we
don't see any assembly code written to the screen.

As the test history indicates that the script was originally checking
for a crash in GDB when the long identifier was encountered, I think
there is value in just leaving the test as it is for now, I have a fix
for the issue of the newpad call failing, which I'll post in a follow
up commit later.

19 months agogdb/testsuite: extend gdb.tui/tui-layout.exp test script
Andrew Burgess [Fri, 25 Nov 2022 18:19:16 +0000 (18:19 +0000)]
gdb/testsuite: extend gdb.tui/tui-layout.exp test script

In passing I noticed that the gdb.tui/tui-layout.exp test script was a
little strange, it tests the layout command multiple times, but never
sets up our ANSI terminal emulator, so every layout command fails with
a message about the terminal lacking the required abilities.

It turns out that this was caused by this commit:

  commit 9162a27c5f5828240b53379d735679e2a69a9f41
  Date:   Tue Nov 13 11:59:03 2018 -0700

      Change gdb test suite's TERM setting

This was when we changed the testsuite to set the TERM environment
variable to "dumb" by default.

After this, any tui test that didn't set the terminal mode back to
'ansi' would fail to activate tui mode.

For the tui-layout.exp test it just so happens that the test patterns
are generic enough that the test continued to pass, even after this
change.

In this commit I have updated the test so we now check the layout
command both with a 'dumb' terminal and with the 'ansi' terminal.
When testing with the 'ansi' terminal, I have some limited validation
that GDB correctly entered tui mode.

I figured that it is probably worth having at least one test in the
test suite that deliberately tries to enter tui mode in a dumb
terminal, it would be sad if we one day managed to break GDB such that
this caused a crash, and never noticed.

19 months agogdb/testsuite: rename test source file to match test script
Andrew Burgess [Thu, 12 Jan 2023 13:24:40 +0000 (13:24 +0000)]
gdb/testsuite: rename test source file to match test script

The previous commit touched the source file for the test script
gdb.cp/cpcompletion.exp.  This source file is called pr9594.cc.  The
source file is only used by the one test script.

This commit renames the source file to cpcompletion.cc to match the
test script, this is more inline with how we name source files these
days.

19 months agogdb/testsuite: use test_gdb_complete_unique more in C++ tests
Andrew Burgess [Thu, 12 Jan 2023 13:21:27 +0000 (13:21 +0000)]
gdb/testsuite: use test_gdb_complete_unique more in C++ tests

Spotted in gdb.cp/cpcompletion.exp that we could replace some uses of
gdb_test with test_gdb_complete_unique, this will extend the
completion testing to check tab-completion as well as completion using
the 'complete' command in some additional cases.

19 months agoAutomatic date update in version.in
GDB Administrator [Wed, 25 Jan 2023 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in

19 months agogprofng: PR29521 [docs] man pages are not in the release tarball
Vladimir Mezentsev [Fri, 20 Jan 2023 23:39:55 +0000 (15:39 -0800)]
gprofng: PR29521 [docs] man pages are not in the release tarball

gprofng/ChangeLog
2023-01-20  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

PR gprofng/29521
* configure.ac: Check if $MAKEINFO and $HELP2MAN are missing.
* Makefile.am: Build doc if $MAKEINFO exists.
* doc/gprofng.texi: Update documentation for gprofng.
* doc/Makefile.am: Build gprofng.1.
* src/Makefile.am: Move the build of gprofng.1 to doc/Makefile.am.
* configure: Rebuild.
* Makefile.in: Rebuild.
* doc/Makefile.in: Rebuild.
* src/Makefile.in: Rebuild.

19 months agolibsframe/doc: fix some warnings
Indu Bhagat [Tue, 24 Jan 2023 18:07:13 +0000 (10:07 -0800)]
libsframe/doc: fix some warnings

'make pdf' in libsframe shows some warnings, some of which (especially
the Overfull warnings) are causing undesirable effects on the rendered
output.  Few examples of the warnings:

  Underfull \hbox (badness 10000) in paragraph at lines 406--407
   @texttt pauth_

  Underfull \hbox (badness 10000) in paragraph at lines 407--410
   @textrm Specify which key is used for signing the return

  ...

  Overfull \hbox (2.0987pt too wide) in paragraph at lines 412--413
   @texttt fdetype[]|

  ...

  Overfull \hbox (28.87212pt too wide) in paragraph at lines 446--447
   @textrm SFRAME[]FDE[]TYPE[]PCMASK|

  ...

This patch adjusts column widths of the affected cells to fix a subset
of these warnings.  For the rest of the warnings, use explicit newline
command to fix them.

libsframe/
* doc/sframe-spec.texi: Fix various underfull and overfull
warnings.

19 months agoFix seg-fault when generating an empty DLL with LTO enabled.
Nick Clifton [Tue, 24 Jan 2023 09:47:43 +0000 (09:47 +0000)]
Fix seg-fault when generating an empty DLL with LTO enabled.

ld   PR 29998
     * pe-dll.c (generate_reloc): Handle sections
     with no assigned output section.
     Terminate early of there are no relocs to put
     in the .reloc section.
     (pe_exe_fill_sections): Do not emit an empty
     .reloc section.

bfd  * cofflink.c (_bfd_coff_generic_relocate_section):
     Add an assertion that the output section is set
     for defined, global symbols.

19 months agogdb: some int to bool conversion
Enze Li [Sun, 22 Jan 2023 05:38:41 +0000 (13:38 +0800)]
gdb: some int to bool conversion

When building GDB with clang 16, I got this,

  CXX    maint.o
maint.c:1045:23: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
      m_space_enabled = 1;
                      ^ ~
maint.c:1057:22: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
      m_time_enabled = 1;
                     ^ ~
maint.c:1073:24: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
      m_symtab_enabled = 1;
                       ^ ~
3 errors generated.

Work around this by using bool bitfields instead.

Tested by rebuilding on x86_64-linux with clang 16 and gcc 12.

Approved-By: Tom Tromey <tom@tromey.com>
19 months agold: Avoid magic numbers for subsystems in pe.em and pep.em
Mark Harmstone [Tue, 24 Jan 2023 00:52:30 +0000 (00:52 +0000)]
ld: Avoid magic numbers for subsystems in pe.em and pep.em

19 months agoAutomatic date update in version.in
GDB Administrator [Tue, 24 Jan 2023 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in

19 months agold: Set default subsystem for arm-pe to IMAGE_SUBSYSTEM_WINDOWS_GUI
Mark Harmstone [Sun, 22 Jan 2023 23:45:03 +0000 (23:45 +0000)]
ld: Set default subsystem for arm-pe to IMAGE_SUBSYSTEM_WINDOWS_GUI

This fixes the test failures introduced by 87a5cf5c, by changing the
default subsystem for arm-pe from 9 (IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) to
2 (IMAGE_SUBSYSTEM_WINDOWS_GUI), which matches what happens with other
PE targets.

As far as I can tell there's no working modern Windows CE toolchain
knocking about anyway, so this change shouldn't inconvenience anyone.

19 months agoAdd support for secidx relocations to aarch64-w64-mingw32
Mark Harmstone [Mon, 23 Jan 2023 00:26:07 +0000 (00:26 +0000)]
Add support for secidx relocations to aarch64-w64-mingw32

This patch adds support for the .secidx directive and its corresponding
relocation to aarch64-w64-mingw32. As with x86, this is a two-byte LE
integer which gets filled in with the 1-based index of the output
section that a symbol ends up in.

This is needed for PDBs, which represent addresses as a .secrel32,
.secidx pair.

The test is substantially the same as for amd64, but with changes made
for padding and alignment.

19 months ago[gdb/tdep, aarch64] Fix frame address of last insn
Tom de Vries [Mon, 23 Jan 2023 15:49:36 +0000 (16:49 +0100)]
[gdb/tdep, aarch64] Fix frame address of last insn

Consider the test-case test.c, compiled without debug info:
...
void
foo (const char *s)
{
}

int
main (void)
{
  foo ("foo");
  return 0;
}
...

Disassembly of foo:
...
0000000000400564 <foo>:
  400564:       d10043ff        sub     sp, sp, #0x10
  400568:       f90007e0        str     x0, [sp, #8]
  40056c:       d503201f        nop
  400570:       910043ff        add     sp, sp, #0x10
  400574:       d65f03c0        ret
...

Now, let's do "info frame" at each insn in foo, as well as printing $sp
and $x29 (and strip the output of info frame to the first line, for brevity):
...
$ gdb -q a.out
Reading symbols from a.out...
(gdb) b *foo
Breakpoint 1 at 0x400564
(gdb) r
Starting program: a.out

Breakpoint 1, 0x0000000000400564 in foo ()
(gdb) display /x $sp
1: /x $sp = 0xfffffffff3a0
(gdb) display /x $x29
2: /x $x29 = 0xfffffffff3a0
(gdb) info frame
Stack level 0, frame at 0xfffffffff3a0:
(gdb) si
0x0000000000400568 in foo ()
1: /x $sp = 0xfffffffff390
2: /x $x29 = 0xfffffffff3a0
(gdb) info frame
Stack level 0, frame at 0xfffffffff3a0:
(gdb) si
0x000000000040056c in foo ()
1: /x $sp = 0xfffffffff390
2: /x $x29 = 0xfffffffff3a0
(gdb) info frame
Stack level 0, frame at 0xfffffffff3a0:
(gdb) si
0x0000000000400570 in foo ()
1: /x $sp = 0xfffffffff390
2: /x $x29 = 0xfffffffff3a0
(gdb) info frame
Stack level 0, frame at 0xfffffffff3a0:
(gdb) si
0x0000000000400574 in foo ()
1: /x $sp = 0xfffffffff3a0
2: /x $x29 = 0xfffffffff3a0
(gdb) info frame
Stack level 0, frame at 0xfffffffff3b0:
 pc = 0x400574 in foo; saved pc = 0x40058c
(gdb) si
0x000000000040058c in main ()
1: /x $sp = 0xfffffffff3a0
2: /x $x29 = 0xfffffffff3a0
...

The "frame at" bit lists 0xfffffffff3a0 except at the last insn, where it
lists 0xfffffffff3b0.

The frame address is calculated here in aarch64_make_prologue_cache_1:
...
  unwound_fp = get_frame_register_unsigned (this_frame, cache->framereg);
  if (unwound_fp == 0)
    return;

  cache->prev_sp = unwound_fp + cache->framesize;
...

For insns after the prologue, we have cache->framereg == sp and
cache->framesize == 16, so unwound_fp + cache->framesize gives the wrong
answer once sp has been restored to entry value by the before-last insn.

Fix this by detecting the situation that the sp has been restored.

This fixes PRs tdep/30010 and tdep/30011.

This also fixes the aarch64 FAILs in gdb.reverse/solib-precsave.exp and
gdb.reverse/solib-reverse.exp I reported in PR gdb/PR29721.

Tested on aarch64-linux.
PR tdep/30010
PR tdep/30011
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30010
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30011

19 months ago[gdb/testsuite] Avoid using .eh_frame in gdb.base/unwind-on-each-insn.exp
Tom de Vries [Mon, 23 Jan 2023 10:54:43 +0000 (11:54 +0100)]
[gdb/testsuite] Avoid using .eh_frame in gdb.base/unwind-on-each-insn.exp

One purpose of the gdb.base/unwind-on-each-insn.exp test-case is to test the
architecture-specific unwinders on foo, so unwind-on-each-insn-foo.c is
compiled with nodebug, to prevent the dwarf unwinders from taking effect.

For for instance gcc x86_64 though, -fasynchronous-unwind-tables is enabled by
default, generating an .eh_frame section contribution which might enable the
dwarf unwinders and bypass the architecture-specific unwinders.

Currently, that happens to be not the case due to the current implementation
of epilogue_unwind_valid, which assumes that in absence of debug info proving
that the compiler is gcc >= 4.5.0, the .eh_frame contribution is invalid.

That may change though, see PR30028, in which case
gdb.base/unwind-on-each-insn.exp stops being a regression test for commit
49d7cd733a7 ("Change calculation of frame_id by amd64 epilogue unwinder").

Fix this by making sure that we don't use .eh_frame info regardless of
epilogue_unwind_valid, simply by not generating it using
-fno-asynchronous-unwind-tables.

Tested on x86_64-linux, target boards unix/{-m64,-m32}, using compilers
gcc 7.5.0 and clang 13.0.1.

19 months agoUpdated Swedish translation for the binutils sub-directory
Nick Clifton [Mon, 23 Jan 2023 10:53:12 +0000 (10:53 +0000)]
Updated Swedish translation for the binutils sub-directory

19 months ago[gdb/testsuite] Simplify gdb.base/unwind-on-each-insn.exp
Tom de Vries [Mon, 23 Jan 2023 09:32:45 +0000 (10:32 +0100)]
[gdb/testsuite] Simplify gdb.base/unwind-on-each-insn.exp

In test-case gdb.base/unwind-on-each-insn.exp, we try to determine the last
disassembled insn in function foo.

This in it self is fragile, as demonstrated by commit 91836f41e20 ("Powerpc
fix for gdb.base/unwind-on-each-insn.exp").

The use of the last disassembled insn in the test-case is to stop stepping in
foo once reaching it.

However, the intent is to stop stepping just before returning to main.

There is no guarantee that the last disassembled insn:
- is actually executed
- is executed just before returning to main
- is executed only once.

Fix this by simplying the test-case to continue stepping till stepping out of
foo.

Tested on x86_64-linux.

19 months ago[gdb/testsuite] Fix untested in gdb.base/frame-view.exp
Tom de Vries [Mon, 23 Jan 2023 07:59:20 +0000 (08:59 +0100)]
[gdb/testsuite] Fix untested in gdb.base/frame-view.exp

When running test-case gdb.base/frame-view.exp, I see:
...
gdb compile failed, ld: frame-view0.o: in function `main':
frame-view.c:73: undefined reference to `pthread_create'
ld: frame-view.c:76: undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
UNTESTED: gdb.base/frame-view.exp: failed to prepare
...

Fix this by adding pthreads to the compilation flags.

Tested on x86_64-linux.

19 months agoFix objdump --reloc for specific symbol
Vladislav Khmelevsky [Sun, 22 Jan 2023 18:07:36 +0000 (22:07 +0400)]
Fix objdump --reloc for specific symbol

If objdump is used with both --disassemble=symbol and --reloc options
skip relocations that have addresses before the symbol, so that they
are not displayed.

19 months agoAutomatic date update in version.in
GDB Administrator [Mon, 23 Jan 2023 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

19 months agoRemove path name from test
Tom Tromey [Sat, 21 Jan 2023 21:59:16 +0000 (14:59 -0700)]
Remove path name from test

The test suite reports several path names in tests.  I couldn't find
most of these, and I suspect they are false reports, but I did manage
to locate one.  This one is probably harmless, as I think the path
does not vary; but it's also easy to fix and suppress one warning.

19 months agoMinor cleanup in gdb.btrace/enable.exp
Tom Tromey [Sun, 22 Jan 2023 17:53:06 +0000 (10:53 -0700)]
Minor cleanup in gdb.btrace/enable.exp

I noticed a weird-looking bit of code in gdb.btrace/enable.exp that is
left over from an earlier change.  This patch moves the "!" inside the
braces, where it belongs.

19 months agoMinor fixup in allow_aarch64_sve_tests
Tom Tromey [Sun, 22 Jan 2023 16:43:01 +0000 (09:43 -0700)]
Minor fixup in allow_aarch64_sve_tests

An earlier patch failed to update a string in allow_aarch64_sve_tests.

19 months agoAutomatic date update in version.in
GDB Administrator [Sun, 22 Jan 2023 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in

19 months agoAutomatic date update in version.in
GDB Administrator [Sat, 21 Jan 2023 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

19 months agogdb: make frame_info_ptr auto-reinflatable
Simon Marchi [Wed, 14 Dec 2022 03:34:41 +0000 (22:34 -0500)]
gdb: make frame_info_ptr auto-reinflatable

This is the second step of making frame_info_ptr automatic, reinflate on
demand whenever trying to obtain the wrapper frame_info pointer, either
through the get method or operator->.  Make the reinflate method
private, it is used as a convenience method in those two.

Add an "is_null" method, because it is often needed to know whether the
frame_info_ptr wraps an frame_info or is empty.

Make m_ptr mutable, so that it's possible to reinflate const
frame_info_ptr objects.  Whether m_ptr is nullptr or not does not change
the logical state of the object, because we re-create it on demand.  I
believe this is the right use case for mutable.

Change-Id: Icb0552d0035e227f81eb3c121d8a9bb2f9d25794
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
19 months agogdb: make frame_info_ptr grab frame level and id on construction
Simon Marchi [Wed, 14 Dec 2022 03:34:40 +0000 (22:34 -0500)]
gdb: make frame_info_ptr grab frame level and id on construction

This is the first step of making frame_info_ptr automatic.  Remove the
frame_info_ptr::prepare_reinflate method, move that code to the
constructor.

Change-Id: I85cdae3ab1c043c70e2702e7fb38e9a4a8a675d8
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
19 months agogdb: make user-created frames reinflatable
Simon Marchi [Wed, 14 Dec 2022 03:34:39 +0000 (22:34 -0500)]
gdb: make user-created frames reinflatable

This patch teaches frame_info_ptr to reinflate user-created frames
(frames created through create_new_frame, with the "select-frame view"
command).

Before this patch, frame_info_ptr doesn't support reinflating
user-created frames, because it currently reinflates by getting the
current target frame (for frame 0) or frame_find_by_id (for other
frames).  To reinflate a user-created frame, we need to call
create_new_frame, to make it lookup an existing user-created frame, or
otherwise create one.

So, in prepare_reinflate, get the frame id even if the frame has level
0, if it is user-created.  In reinflate, if the saved frame id is user
create it, call create_new_frame.

In order to test this, I initially enhanced the gdb.base/frame-view.exp
test added by the previous patch by setting a pretty-printer for the
type of the function parameters, in which we do an inferior call.  This
causes print_frame_args to not reinflate its frame (which is a
user-created one) properly.  On one machine (my Arch Linux one), it
properly catches the bug, as the frame is not correctly restored after
printing the first parameter, so it messes up the second parameter:

    frame
    #0  baz (z1=hahaha, z2=<error reading variable: frame address is not available.>) at /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/frame-view.c:40
    40        return z1.m + z2.n;
    (gdb) FAIL: gdb.base/frame-view.exp: with_pretty_printer=true: frame
    frame
    #0  baz (z1=hahaha, z2=<error reading variable: frame address is not available.>) at /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/frame-view.c:40
    40        return z1.m + z2.n;
    (gdb) FAIL: gdb.base/frame-view.exp: with_pretty_printer=true: frame again

However, on another machine (my Ubuntu 22.04 one), it just passes fine,
without the appropriate fix.  I then thought about writing a selftest
for that, it's more reliable.  I left the gdb.base/frame-view.exp pretty
printer test there, it's already written, and we never know, it might
catch some unrelated issue some day.

Change-Id: I5849baf77991fc67a15bfce4b5e865a97265b386
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
19 months agogdb: make it possible to restore selected user-created frames
Simon Marchi [Wed, 14 Dec 2022 03:34:38 +0000 (22:34 -0500)]
gdb: make it possible to restore selected user-created frames

I would like to improve frame_info_ptr to automatically grab the
information needed to reinflate a frame, and automatically reinflate it
as needed.  One thing that is in the way is the fact that some frames
can be created out of thin air by the create_new_frame function.  These
frames are not the fruit of unwinding from the target's current frame.
These frames are created by the "select-frame view" command.

These frames are not correctly handled by the frame save/restore
functions, save_selected_frame, restore_selected_frame and
lookup_selected_frame.  This can be observed here, using the test
included in this patch:

    $ ./gdb --data-directory=data-directory -nx -q testsuite/outputs/gdb.base/frame-view/frame-view
    Reading symbols from testsuite/outputs/gdb.base/frame-view/frame-view...
    (gdb) break thread_func
    Breakpoint 1 at 0x11a2: file /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/frame-view.c, line 42.
    (gdb) run
    Starting program: /home/simark/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/frame-view/frame-view

    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/usr/lib/../lib/libthread_db.so.1".
    [New Thread 0x7ffff7cc46c0 (LWP 4171134)]
    [Switching to Thread 0x7ffff7cc46c0 (LWP 4171134)]

    Thread 2 "frame-view" hit Breakpoint 1, thread_func (p=0x0) at /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/frame-view.c:42
    42        foo (11);
    (gdb) info frame
    Stack level 0, frame at 0x7ffff7cc3ee0:
     rip = 0x5555555551a2 in thread_func (/home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/frame-view.c:42); saved rip = 0x7ffff7d4e8fd
     called by frame at 0x7ffff7cc3f80
     source language c.
     Arglist at 0x7ffff7cc3ed0, args: p=0x0
     Locals at 0x7ffff7cc3ed0, Previous frame's sp is 0x7ffff7cc3ee0
     Saved registers:
      rbp at 0x7ffff7cc3ed0, rip at 0x7ffff7cc3ed8
    (gdb) thread 1
    [Switching to thread 1 (Thread 0x7ffff7cc5740 (LWP 4171122))]
    #0  0x00007ffff7d4b4b6 in ?? () from /usr/lib/libc.so.6

Here, we create a custom frame for thread 1 (using the stack from thread
2, for convenience):

    (gdb) select-frame view 0x7ffff7cc3f80 0x5555555551a2

The first calls to "frame" looks good:

    (gdb) frame
    #0  thread_func (p=0x7ffff7d4e630) at /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/frame-view.c:42
    42        foo (11);

But not the second one:

    (gdb) frame
    #0  0x00007ffff7d4b4b6 in ?? () from /usr/lib/libc.so.6

This second "frame" command shows the current target frame instead of
the user-created frame.

It's not totally clear how the "select-frame view" feature is expected
to behave, especially since it's not tested.  I heard accounts that it
used to be possible to select a frame like this and do "up" and "down"
to navigate the backtrace starting from that frame.  The fact that
create_new_frame calls frame_unwind_find_by_frame to install the right
unwinder suggest that it used to be possible.  But that doesn't work
today:

    (gdb) select-frame view 0x7ffff7cc3f80 0x5555555551a2
    (gdb) up
    Initial frame selected; you cannot go up.
    (gdb) down
    Bottom (innermost) frame selected; you cannot go down.

and "backtrace" always shows the actual thread's backtrace, it ignores
the user-created frame:

    (gdb) bt
    #0  0x00007ffff7d4b4b6 in ?? () from /usr/lib/libc.so.6
    #1  0x00007ffff7d50403 in ?? () from /usr/lib/libc.so.6
    #2  0x000055555555521a in main () at /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/frame-view.c:56

I don't want to address all the `select-frame view` issues , but I think
we can agree that the "frame" command changing the selected frame, as
shown above, is a bug.  I would expect that command to show the
currently selected frame and not change it.

This happens because of the scoped_restore_selected_frame object in
print_frame_args.  The frame information is saved in the constructor
(the backtrace below), and restored in the destructor.

    #0  save_selected_frame (frame_id=0x7ffdc0020ad0, frame_level=0x7ffdc0020af0) at /home/simark/src/binutils-gdb/gdb/frame.c:1682
    #1  0x00005631390242f0 in scoped_restore_selected_frame::scoped_restore_selected_frame (this=0x7ffdc0020ad0) at /home/simark/src/binutils-gdb/gdb/frame.c:324
    #2  0x000056313993581e in print_frame_args (fp_opts=..., func=0x62100023bde0, frame=..., num=-1, stream=0x60b000000300) at /home/simark/src/binutils-gdb/gdb/stack.c:755
    #3  0x000056313993ad49 in print_frame (fp_opts=..., frame=..., print_level=1, print_what=SRC_AND_LOC, print_args=1, sal=...) at /home/simark/src/binutils-gdb/gdb/stack.c:1401
    #4  0x000056313993835d in print_frame_info (fp_opts=..., frame=..., print_level=1, print_what=SRC_AND_LOC, print_args=1, set_current_sal=1) at /home/simark/src/binutils-gdb/gdb/stack.c:1126
    #5  0x0000563139932e0b in print_stack_frame (frame=..., print_level=1, print_what=SRC_AND_LOC, set_current_sal=1) at /home/simark/src/binutils-gdb/gdb/stack.c:368
    #6  0x0000563139932bbe in print_stack_frame_to_uiout (uiout=0x611000016840, frame=..., print_level=1, print_what=SRC_AND_LOC, set_current_sal=1) at /home/simark/src/binutils-gdb/gdb/stack.c:346
    #7  0x0000563139b0641e in print_selected_thread_frame (uiout=0x611000016840, selection=...) at /home/simark/src/binutils-gdb/gdb/thread.c:1993
    #8  0x0000563139940b7f in frame_command_core (fi=..., ignored=true) at /home/simark/src/binutils-gdb/gdb/stack.c:1871
    #9  0x000056313994db9e in frame_command_helper<frame_command_core>::base_command (arg=0x0, from_tty=1) at /home/simark/src/binutils-gdb/gdb/stack.c:1976

Since the user-created frame has level 0 (identified by the saved level
-1), lookup_selected_frame just reselects the target's current frame,
and the user-created frame is lost.

My goal here is to fix this particular problem.

Currently, select_frame does not set selected_frame_id and
selected_frame_level for frames with level 0.  It leaves them at
null_frame_id / -1, indicating to restore_selected_frame to use the
target's current frame.  User-created frames also have level 0, so add a
special case them such that select_frame saves their selected id and
level.

save_selected_frame does not need any change.

Change the assertion in restore_selected_frame that checks `frame_level
!= 0` to account for the fact that we can restore user-created frames,
which have level 0.

Finally, change lookup_selected_frame to make it able to re-create
user-created frame_info objects from selected_frame_level and
selected_frame_id.

Add a minimal test case for the case described above, that is the
"select-frame view" command followed by the "frame" command twice.  In
order to have a known stack frame to switch to, the test spawns a second
thread, and tells the first thread to use the other thread's top frame.

Change-Id: Ifc77848dc465fbd21324b9d44670833e09fe98c7
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
19 months agogdb: add create_new_frame(frame_id) overload
Simon Marchi [Wed, 14 Dec 2022 03:34:37 +0000 (22:34 -0500)]
gdb: add create_new_frame(frame_id) overload

The subsequent patches will need to call create_new_frame with an
existing frame_id representing a user created frame.  They could call
the existing create_new_frame, passing both addresses, but it seems
nicer to have a version of the function that takes a frame_id directly.

Change-Id: If31025314fec0c3e644703e4391a5ef8079e1a32
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
19 months agogdb: add user-created frames to stash
Simon Marchi [Wed, 14 Dec 2022 03:34:36 +0000 (22:34 -0500)]
gdb: add user-created frames to stash

A subsequent patch makes it possible for frame_info_ptr to reinflate
user-created frames.  If two frame_info_ptr objects wrapping the same
user-created frame_info need to do reinflation, we want them to end up
pointing to the same frame_info instance, and not create two separate
frame_infos.  Otherwise, GDB gets confused down the line, as the state
kept in one frame_info object starts differing from the other
frame_info.

Achieve this by making create_new_frame place the user-created frames in
the frame stash.  This way, when the second frame_info_ptr does
reinflation, it will find the existing frame_info object, created by the
other frame_info_ptr, in the frame stash.

To make the frame stash differentiate between regular and user-created
frame infos which would otherwise be equal, change frame_addr_hash and
frame_id::operator== to account for frame_id::user_created_p.

I made create_new_frame look up existing frames in the stash, and only
create one if it doesn't find one.  The goal is to avoid the
"select-frame view"/"info frame view"/"frame view" commands from
overriding existing entries into the stash, should the user specify the
same frame more than once.  This will also help in the subsequent patch
that makes frame_info_ptr capable of reinflating user-created frames.
It will be able to just call create_new_frame and it will do the right
thing.

Change-Id: I14ba5799012056c007b4992ecb5c7adafd0c2404
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
19 months agogdb: add frame_id::user_created_p
Simon Marchi [Wed, 14 Dec 2022 03:34:35 +0000 (22:34 -0500)]
gdb: add frame_id::user_created_p

Later in this series, we'll need to differentiate frame ids for regular
frames (obtained from the target state and unwinding from it) vs frame
ids for user-created frames (created with create_new_frame).  Add the
frame_id::user_created_p field to indicate a frame is user-created, and
set it in create_new_frame.

The field is otherwise not used yet, so not changes in behavior are
expected.

Change-Id: I60de3ce581ed01bf0fddb30dff9bd932840120c3
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
19 months agogdb: move frame_info_ptr to frame.{c,h}
Simon Marchi [Tue, 3 Jan 2023 17:48:48 +0000 (12:48 -0500)]
gdb: move frame_info_ptr to frame.{c,h}

A patch later in this series will make frame_info_ptr access some
fields internal to frame_info, which we don't want to expose outside of
frame.c.  Move the frame_info_ptr class to frame.h, and the definitions
to frame.c.  Remove frame-info.c and frame-info.h.

Change-Id: Ic5949759e6262ea0da6123858702d48fe5673fea
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
19 months agogdb: move call site types to call-site.h
Simon Marchi [Wed, 14 Dec 2022 03:34:33 +0000 (22:34 -0500)]
gdb: move call site types to call-site.h

I hesitated between putting  the file in the dwarf2 directory (as
gdb/dwarf2/call-site.h) or in the common directory (as gdb/call-site.h).
The concept of call site is not DWARF-specific, another debug info
reader could provide this information.  But as it is, the implementation
is a bit DWARF-specific, as one form it can take is a DWARF expression
and parameters can be defined using a DWARF register number.  So I ended up
choosing to put it under dwarf2/.  If another debug info reader ever
wants to provide call site information, we can introduce a layer of
abstraction between the "common" call site and the "dwarf2" call site.

The copyright start year comes from the date `struct call_site` was
introduced.

Change-Id: I1cd84aa581fbbf729edc91b20f7d7a6e0377014d
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
19 months agogdb: move sect_offset and cu_offset to dwarf2/types.h
Simon Marchi [Wed, 14 Dec 2022 03:34:32 +0000 (22:34 -0500)]
gdb: move sect_offset and cu_offset to dwarf2/types.h

I want to move the call_site stuff out of gdbtypes.h, to a new header
file, to break some cyclic include problem.  The call_site stuff uses
cu_offset, also defined in gdbtypes.h, so cu_offset also needs to move
somewhere else (otherwise, call-site.h will need to include gdbtypes.h,
and we are back to square 1).  I could move cu_offset to the future new
file dwarf2/call-site.h, but it doesn't sound like a good place for it,
at cu_offset is not specific to call sites, it's used throughout
dwarf2/.  So, move it to its own file, dwarf2/types.h.  For now,
gdbtypes.h includes dwarf2/types.h, but that will be removed once the
call site stuff is moved to its own file.

Move sect_offset with it too.  sect_offset is not a DWARF-specific
concept, but for the moment it is only used in dwarf2/.

Change-Id: I1fd2a3b7b67dee789c4874244b044bde7db43d8e
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
19 months agogdb: remove language.h include from frame.h
Simon Marchi [Wed, 14 Dec 2022 03:34:31 +0000 (22:34 -0500)]
gdb: remove language.h include from frame.h

This helps resolve some cyclic include problem later in the series.
The only language-related thing frame.h needs is enum language, and that
is in defs.h.

Doing so reveals that a bunch of files were relying on frame.h to
include language.h, so fix the fallouts here and there.

Change-Id: I178a7efec1953c2d088adb58483bade1f349b705
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
19 months agogdb: move compile_instance to compile/compile.h
Simon Marchi [Wed, 14 Dec 2022 03:34:30 +0000 (22:34 -0500)]
gdb: move compile_instance to compile/compile.h

struct compile_instance needs to be visible to users, since we use
std::unique<compile_instance>.  language.c and c-lang.c currently
includes compile-internal.h for this reason, which kind of defeats the
purpose of having an "internal" header file.

Change-Id: Iedffe5f1173b3de7bdc1be533ee2a68e6f6c549f
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
19 months agogdb: move type_map_instance to compile/compile.c
Simon Marchi [Wed, 14 Dec 2022 03:34:29 +0000 (22:34 -0500)]
gdb: move type_map_instance to compile/compile.c

It's only used in compile/compile.c, it doesn't need to be in a header.

Change-Id: Ic5bec996b7b0cd7130055d1e8ff238b5ac4292a3
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
19 months agoUpload SFrame spec files as well
Indu Bhagat [Fri, 20 Jan 2023 19:14:11 +0000 (11:14 -0800)]
Upload SFrame spec files as well

binutils/
* README-how-to-make-a-release: Include sframe-spec html and pdf
files.

19 months agoUse bool in pc_in_* functions
Tom Tromey [Wed, 18 Jan 2023 23:36:52 +0000 (16:36 -0700)]
Use bool in pc_in_* functions

I noticed that pc_in_unmapped_range had a weird return type -- it was
returning a CORE_ADDR but intending to return a bool.  This patch
changes all the pc_in_* functions to return bool instead.

19 months agoConstify notif_client
Tom Tromey [Wed, 21 Dec 2022 21:15:16 +0000 (14:15 -0700)]
Constify notif_client

It seems to me that a notif_client is read-only, so this patch changes
the code to use "const" everywhere.

19 months agogdb: remove struct trad_frame forward declaration
Simon Marchi [Fri, 20 Jan 2023 17:35:01 +0000 (12:35 -0500)]
gdb: remove struct trad_frame forward declaration

I found this forward declaration for a struct that doesn't exist, remove
it.

Change-Id: Ib9473435a949452160598035e5e0fe19fcdc4d20

19 months agoMake gdb.ada/ptype_tagged_param.exp pass
Tom Tromey [Thu, 19 Jan 2023 16:30:18 +0000 (09:30 -0700)]
Make gdb.ada/ptype_tagged_param.exp pass

gdb.ada/ptype_tagged_param.exp is failing for me on x86-64 Fedora 36.
However, it's actually generating the correct output -- it is just
that the test thinks that the "ptype" will not work because I do not
have the GNAT debuginfo installed.

This patch changes the code to accept either result, and then to issue
a kfail as appropriate.

19 months agogdb/dwarf: fix UBsan crash in read_subrange_type
Simon Marchi [Fri, 20 Jan 2023 16:51:54 +0000 (11:51 -0500)]
gdb/dwarf: fix UBsan crash in read_subrange_type

When running gdb.ada/arrayptr.exp (and others) on Ubuntu 22.04, with the
`gnat-11` package installed (not `gnat`), with UBSan activated, I get:

    (gdb) break foo.adb:40
    /home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:17689:20: runtime error: shift exponent 127 is too large for 64-bit type 'long unsigned int'

The problematic DIEs are:

    0x00001460:       DW_TAG_subrange_type
                        DW_AT_lower_bound [DW_FORM_data1]   (0x00)
                        DW_AT_upper_bound [DW_FORM_data16]  (ffffffffffffffff3f00000000000000)
                        DW_AT_name [DW_FORM_strp]   ("foo__packed_array___XP7___XDLU_0__1180591620717411303423")
                        DW_AT_type [DW_FORM_ref4]   (0x0000153f "long_long_long_unsigned")
                        DW_AT_GNAT_descriptive_type [DW_FORM_ref4]  (0x0000147e)
                        DW_AT_artificial [DW_FORM_flag_present]     (true)

    0x0000153f:   DW_TAG_base_type
                    DW_AT_byte_size [DW_FORM_data1] (0x10)
                    DW_AT_encoding [DW_FORM_data1]  (DW_ATE_unsigned)
                    DW_AT_name [DW_FORM_strp]       ("long_long_long_unsigned")
                    DW_AT_artificial [DW_FORM_flag_present] (true)

When processed by this code:

    negative_mask =
      -((ULONGEST) 1 << (base_type->length () * TARGET_CHAR_BIT - 1));
    if (low.kind () == PROP_CONST
        && !base_type->is_unsigned () && (low.const_val () & negative_mask))
      low.set_const_val (low.const_val () | negative_mask);

When the base type's length (16 bytes in this case) is larger than a
ULONGEST (typically 8 bytes), the bit shift is too large.

My obvious fix is just to skip the fixup for base types larger than a
ULONGEST (8 bytes).  I don't think we really handle constant attribute
values larger than 8 bytes anyway, so this is part of a much larger
problem.

Add a test that replicates this situation, but uses bounds that fit in a
signed 64 bit, so we get a sensible result.

Change-Id: I8d0a24f3edd83b44e0761a0ce38922d3e2e112fb
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29386

19 months agogdb/testsuite: add test for negative subrange bounds with unsigned form
Simon Marchi [Fri, 20 Jan 2023 16:41:08 +0000 (11:41 -0500)]
gdb/testsuite: add test for negative subrange bounds with unsigned form

I am looking at this code [1]:

  /* Normally, the DWARF producers are expected to use a signed
     constant form (Eg. DW_FORM_sdata) to express negative bounds.
     But this is unfortunately not always the case, as witnessed
     with GCC, for instance, where the ambiguous DW_FORM_dataN form
     is used instead.  To work around that ambiguity, we treat
     the bounds as signed, and thus sign-extend their values, when
     the base type is signed.  */
  negative_mask =
    -((ULONGEST) 1 << (base_type->length () * TARGET_CHAR_BIT - 1));
  if (low.kind () == PROP_CONST
      && !base_type->is_unsigned () && (low.const_val () & negative_mask))
    low.set_const_val (low.const_val () | negative_mask);
  if (high.kind () == PROP_CONST
      && !base_type->is_unsigned () && (high.const_val () & negative_mask))
    high.set_const_val (high.const_val () | negative_mask);

Nothing in the testsuite seems to exercise it, as when I remove it, all
of gdb.dwarf2 still passes.  And tests in other directories would be
compiler-dependent, so would rely on having a buggy compiler.

Update gdb.dwarf2/subrange.exp to have a test for it.  When removing the
code above, the new test fails with:

  ptype array_with_buggy_negative_bounds_type^M
  type = array [240..244] of signed_byte^M
  (gdb) FAIL: gdb.dwarf2/subrange.exp: ptype array_with_buggy_negative_bounds_type

instead of the expected:

  ptype array_with_buggy_negative_bounds_type^M
  type = array [-16..-12] of signed_byte^M
  (gdb) PASS: gdb.dwarf2/subrange.exp: ptype array_with_buggy_negative_bounds_type

[1] https://gitlab.com/gnutools/binutils-gdb/-/blob/5ea14aa4e53fa37f4ba4517497ed2c1e4c60dee2/gdb/dwarf2/read.c#L17681-17695

Change-Id: I1992a3ff0cb1e90fa8a9114dae6c591792f059c2

19 months agoAdd testcase ld-elf/merge4
Michael Matz [Wed, 12 Oct 2022 15:29:43 +0000 (17:29 +0200)]
Add testcase ld-elf/merge4

to check a situation that once failed with the new section merging
when it mishandled offsets pointing into alignment padding in mergable
string sections (i.e. pointing to zeros).  It made bootstrap.exp fail
but that depends on many factors to actually go wrong so this is a more
explicit variant of it.

19 months agoarm32: Fix rodata-merge-map
Michael Matz [Thu, 3 Nov 2022 17:00:04 +0000 (18:00 +0100)]
arm32: Fix rodata-merge-map

the test expects a second, but useless, $d mapping symbol for
the partially merged section, and specifically disallows one
for the completely merged section.  The new merging algorithm
makes it so that also the partially merged sections are conceptually
SEC_EXCLUDED, except the first merge section (e.g. as if the very
first object file already contains all strings).  So that second mapping
symbol is now missing.  It never was needed anyway.

So, adjust the test.

19 months agoFaster string merging
Michael Matz [Wed, 20 Jul 2022 15:22:15 +0000 (17:22 +0200)]
Faster string merging

* use power-of-two hash table
* use better hash function (hashing 32bits at once and with better
  mixing characteristics)
* use input-offset-to-entry maps instead of retaining full input
  contents for lookup time
* don't reread SEC_MERGE section multiple times
* care for cache behaviour for the hot lookup routine

The overall effect is less usage in libz and much faster string merging
itself.  On a debug-info-enabled cc1 the effect at the time of this
writing on the machine I used was going from 14400 perf samples to 9300
perf samples or from 3.7 seconds to 2.4 seconds, i.e. about 33% .

19 months agoAdd OpenBSD ARM GAS support.
Frederic Cambus [Fri, 20 Jan 2023 10:46:37 +0000 (10:46 +0000)]
Add OpenBSD ARM GAS support.

19 months agox86: split i386-gen's opcode hash entry struct
Jan Beulich [Fri, 20 Jan 2023 09:18:40 +0000 (10:18 +0100)]
x86: split i386-gen's opcode hash entry struct

All glibc malloc() implementations I've checked have a smallest
allocation size worth of 3 pointers, with an increment worth of 2
pointers. Hence mnemonics with multiple templates can be stored more
efficiently when maintaining the shared "name" field only in the actual
hash entry. (To express the shared nature, also convert "name" to by
pointer-to-const.)

While doing the conversation also pull out common code from the involved
if/else construct in expand_templates().

19 months agox86: embed register and alike names in disassembler
Jan Beulich [Fri, 20 Jan 2023 09:18:17 +0000 (10:18 +0100)]
x86: embed register and alike names in disassembler

Register names are (including their nul terminators) on average almost 4
bytes long. Otoh no register name is longer than 8 bytes. Hence even for
32-bit builds using a pointer is only slightly more space efficient than
embedding the strings. A level of indirection can be also avoided by
embedding the names as an array of 8 characters directly in the arrays,
and the number of base relocations in libopcodes.so (or PIE builds of
statically linked executables) goes down as well.

To amortize for the otherwise reduced folding of string literals by the
linker, use att_names_seg[] in place of string literals in append_seg()
and OP_ESreg().

19 months agox86: embed register names in reg_entry
Jan Beulich [Fri, 20 Jan 2023 09:17:53 +0000 (10:17 +0100)]
x86: embed register names in reg_entry

Register names are (including their nul terminators) on average almost 4
bytes long. Otoh no register name is longer than 7 bytes. Hence even for
32-bit builds using a pointer is only slightly more space efficient than
embedding the strings. A level of indirection can be also avoided by
embedding the names as an array of 8 characters directly in the struct,
and the number of base relocations in PIE builds of gas goes down as
well.

19 months agox86: avoid strcmp() in a few places
Jan Beulich [Fri, 20 Jan 2023 09:17:23 +0000 (10:17 +0100)]
x86: avoid strcmp() in a few places

Now that we have identifiers for the mnemonic strings we can avoid
strcmp() in a number of places, comparing the offsets into the mnemonic
string table instead. While doing this also
- convert a leftover strncmp() to startswith() (apparently an oversight
  when rebasing the original patch introducing the startswith() uses),
- use the new shorthand for current_templates->start also elsewhere in
  md_assemble() (valid up to the point where match_template() is
  called).

19 months agox86: absorb allocation in i386-gen
Jan Beulich [Fri, 20 Jan 2023 09:16:56 +0000 (10:16 +0100)]
x86: absorb allocation in i386-gen

When generating the mnemonic string table we already set up an
identifier for the following entry in a number of cases. Re-use that on
the next loop iteration rather than re-doing allocation and conversion.

19 months agox86: re-use insn mnemonic strings as much as possible
Jan Beulich [Fri, 20 Jan 2023 09:16:17 +0000 (10:16 +0100)]
x86: re-use insn mnemonic strings as much as possible

Compact the mnemonic string table such that the tails of longer
mnemonics are re-used for shorter ones, going beyond what compilers
would typically do, but matching what ELF linkers may do when processing
SHF_MERGE|SHF_STRINGS sections. This reduces table size by about 12.5%.

19 months agox86: move insn mnemonics to a separate table
Jan Beulich [Fri, 20 Jan 2023 09:15:48 +0000 (10:15 +0100)]
x86: move insn mnemonics to a separate table

Using full pointers to reference the insn mnemonic strings is not very
efficient. With overall string size presently just slightly over 20k,
even a 16-bit value would suffice. Use "unsigned int" for now, as
there's no good use we could presently make of the otherwise saved 16
bits.

For 64-bit builds this reduces table size by 6.25% (prior to the recent
ISA extension additions it would have been 12.5%), with a similar effect
on cache occupation of table entries accessed. For PIE builds of gas
this also reduces the number of base relocations quite a bit (obviously
independent of bitness).

19 months agox86: abstract out obtaining of a template's mnemonic
Jan Beulich [Fri, 20 Jan 2023 09:14:46 +0000 (10:14 +0100)]
x86: abstract out obtaining of a template's mnemonic

In preparation for changing the representation of the "name" field
introduce a wrapper function. This keeps the mechanical change separate
from the functional one.

19 months agoAutomatic date update in version.in
GDB Administrator [Fri, 20 Jan 2023 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

19 months agoUse "maint ignore-probes" in no-libstdcxx-probe.exp
Tom Tromey [Thu, 19 Jan 2023 18:26:53 +0000 (11:26 -0700)]
Use "maint ignore-probes" in no-libstdcxx-probe.exp

While looking at some test output, I saw that no-libstdcxx-probe.exp
was not being run.  However, it occurred to me that Tom de Vries' new
"maint ignore-probes" command could be used to enable this test
unconditionally.

Reviewed-by: Tom de Vries <tdevries@suse.de>
19 months agoi386: Don't emit unsupported TLS relocs on Solaris
Rainer Orth [Thu, 19 Jan 2023 21:48:58 +0000 (13:48 -0800)]
i386: Don't emit unsupported TLS relocs on Solaris

Emit R_386_TLS_LE and R_386_TLS_IE, instead of R_386_TLS_LE_32 and
R_386_TLS_IE_32, on Solaris.

PR ld/13671
* elf32-i386.c (elf_i386_tls_transition): Only emit R_386_TLS_LE,
R_386_TLS_IE on Solaris.
(elf_i386_relocate_section): Only use R_386_TLS_GD->R_386_TLS_LE
transition on Solaris.

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
19 months agoGDB/testsuite: Expand for character string limiting options
Andrew Burgess [Thu, 19 Jan 2023 21:15:56 +0000 (21:15 +0000)]
GDB/testsuite: Expand for character string limiting options

Modify test cases that verify the operation of the array element limit
with character strings such that they are executed twice, once with the
`set print characters' option set to `elements' and the limit controlled
with the `set print elements' option, and then again with the limit
controlled with the `set print characters' option instead.  Similarly
with the `-elements' and `-characters' options for the `print' command.
Additionally verify that said `print' command options combined yield the
expected result.

Verify correct $_gdb_setting and $_gdb_setting_str values for the `print
characters' setting, in particular the `void' value for the `elements'
default, which has no corresponding integer value exposed.

Add Guile and Python coverage for the `print characters' GDB setting.

There are new tests for Ada and Pascal, as the string printing code for
these languages is different than the generic string printing code used
by other languages.  Modula2 also has different string printing code,
but (a) this is similar to Pascal, and (b) there are no existing modula2
tests written in Modula2, so I'm not sure how I'd even test the Modula2
string printing.

Co-Authored-By: Maciej W. Rozycki <macro@embecosm.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
19 months agoGDB: Add a character string limiting option
Andrew Burgess [Thu, 19 Jan 2023 21:15:56 +0000 (21:15 +0000)]
GDB: Add a character string limiting option

This commit splits the `set/show print elements' option into two.  We
retain `set/show print elements' for controlling how many elements of an
array we print, but a new `set/show print characters' setting is added
which is used for controlling how many characters of a string are
printed.

The motivation behind this change is to allow users a finer level of
control over how data is printed, reflecting that, although strings can
be thought of as arrays of characters, users often want to treat these
two things differently.

For compatibility reasons by default the `set/show print characters'
option is set to `elements', which makes the limit for character strings
follow the setting of the `set/show print elements' option, as it used
to.  Using `set print characters' with any other value makes the limit
independent from the `set/show print elements' setting, however it can
be restored to the default with the `set print characters elements'
command at any time.

A corresponding `-characters' option for the `print' command is added,
with the same semantics, i.e. one can use `elements' to make a given
`print' invocation follow the limit of elements, be it set with the
`-elements' option also given with the same invocation or taken from the
`set/show print elements' setting, for characters as well regardless of
the current setting of the `set/show print characters' option.

The GDB changes are all pretty straightforward, just changing references
to the old 'print_max' to use a new `get_print_max_chars' helper which
figures out which of the two of `print_max' and `print_max_chars' values
to use.

Likewise, the documentation is just updated to reference the new setting
where appropriate.

To make people's life easier the message shown by `show print elements'
now indicates if the setting also applies to character strings:

(gdb) set print characters elements
(gdb) show print elements
Limit on string chars or array elements to print is 200.
(gdb) set print characters unlimited
(gdb) show print elements
Limit on array elements to print is 200.
(gdb)

and the help text shows the dependency as well:

(gdb) help set print elements
Set limit on array elements to print.
"unlimited" causes there to be no limit.
This setting also applies to string chars when "print characters"
is set to "elements".
(gdb)

In the testsuite there are two minor updates, one to add `-characters'
to the list of completions now shown for the `print' command, and a bare
minimum pair of checks for the right handling of `set print characters'
and `show print characters', copied from the corresponding checks for
`set print elements' and `show print elements' respectively.

Co-Authored-By: Maciej W. Rozycki <macro@embecosm.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
19 months agoGDB: Allow arbitrary keywords in integer set commands
Maciej W. Rozycki [Thu, 19 Jan 2023 21:15:56 +0000 (21:15 +0000)]
GDB: Allow arbitrary keywords in integer set commands

Rather than just `unlimited' allow the integer set commands (or command
options) to define arbitrary keywords for the user to use, removing
hardcoded arrangements for the `unlimited' keyword.

Remove the confusingly named `var_zinteger', `var_zuinteger' and
`var_zuinteger_unlimited' `set'/`show' command variable types redefining
them in terms of `var_uinteger', `var_integer' and `var_pinteger', which
have the range of [0;UINT_MAX], [INT_MIN;INT_MAX], and [0;INT_MAX] each.

Following existing practice `var_pinteger' allows extra negative values
to be used, however unlike `var_zuinteger_unlimited' any number of such
values can be defined rather than just `-1'.

The "p" in `var_pinteger' stands for "positive", for the lack of a more
appropriate unambiguous letter, even though 0 obviously is not positive;
"n" would be confusing as to whether it stands for "non-negative" or
"negative".

Add a new structure, `literal_def', the entries of which define extra
keywords allowed for a command and numerical values they correspond to.
Those values are not verified against the basic range supported by the
underlying variable type, allowing extra values to be allowed outside
that range, which may or may not be individually made visible to the
user.  An optional value translation is possible with the structure to
follow the existing practice for some commands where user-entered 0 is
internally translated to UINT_MAX or INT_MAX.  Such translation can now
be arbitrary.  Literals defined by this structure are automatically used
for completion as necessary.

So for example:

const literal_def integer_unlimited_literals[] =
  {
    { "unlimited", INT_MAX, 0 },
    { nullptr }
  };

defines an extra `unlimited' keyword and a user-visible 0 value, both of
which get translated to INT_MAX for the setting to be used with.

Similarly:

const literal_def zuinteger_unlimited_literals[] =
  {
    { "unlimited", -1, -1 },
    { nullptr }
  };

defines the same keyword and a corresponding user-visible -1 value that
is used for the requested setting.  If the last member were omitted (or
set to `{}') here, then only the keyword would be allowed for the user
to enter and while -1 would still be used internally trying to enter it
as a part of a command would result in an "integer -1 out of range"
error.

Use said error message in all cases (citing the invalid value requested)
replacing "only -1 is allowed to set as unlimited" previously used for
`var_zuinteger_unlimited' settings only rather than propagating it to
`var_pinteger' type.  It could only be used for the specific case where
a single extra `unlimited' keyword was defined standing for -1 and the
use of numeric equivalents is discouraged anyway as it is for historical
reasons only that they expose GDB internals, confusingly different
across variable types.  Similarly update the "must be >= -1" Guile error
message.

Redefine Guile and Python parameter types in terms of the new variable
types and interpret extra keywords as Scheme keywords and Python strings
used to communicate corresponding parameter values.  Do not add a new
PARAM_INTEGER Guile parameter type, however do handle the `var_integer'
variable type now, permitting existing parameters defined by GDB proper,
such as `listsize', to be accessed from Scheme code.

With these changes in place it should be trivial for a Scheme or Python
programmer to expand the syntax of the `make-parameter' command and the
`gdb.Parameter' class initializer to have arbitrary extra literals along
with their internal representation supplied.

Update the testsuite accordingly.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
19 months agolibsframe: Use AM_SILENT_RULES macro in configure.ac
Indu Bhagat [Thu, 19 Jan 2023 20:40:44 +0000 (12:40 -0800)]
libsframe: Use AM_SILENT_RULES macro in configure.ac

Silence 'make' by default.

libsframe/
* configure.ac: Use AM_SILENT_RULES.
* configure: Regenerate.

19 months agoRemove some unused includes
Tom Tromey [Thu, 19 Jan 2023 18:08:06 +0000 (11:08 -0700)]
Remove some unused includes

I noticed a few spots that include gnu-stabs.h but that do not need
to.  This patch removes these unnecessary includes.  Tested by
rebuilding.

19 months ago[gdb/tdep, aarch64] Remove fp and sp reg aliases, add x31 reg alias
Tom de Vries [Thu, 19 Jan 2023 13:05:08 +0000 (14:05 +0100)]
[gdb/tdep, aarch64] Remove fp and sp reg aliases, add x31 reg alias

In aarch64-tdep.c we find these register aliases:
...
{
  /* 64-bit register names.  */
  {"fp", AARCH64_FP_REGNUM},
  {"lr", AARCH64_LR_REGNUM},
  {"sp", AARCH64_SP_REGNUM},
...

The sp alias is superfluous, because the canonical name of x31 is already sp.

The fp alias is superfluous, because it's already taken by the default meaning
of fp, assigned here in _initialize_frame_reg:
...
  user_reg_add_builtin ("fp", value_of_builtin_frame_fp_reg, NULL);
...

Fix this by removing the fp and sp aliases.

While we're at it, add an x31 alias for sp.

Approved-By: Luis Machado <luis.machado@arm.com>
Tested on aarch64-linux.
PR tdep/30012
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30012

19 months ago[gdb/testsuite] Fix gdb.python/py-value-cc.exp for big endian
Tom de Vries [Thu, 19 Jan 2023 12:44:13 +0000 (13:44 +0100)]
[gdb/testsuite] Fix gdb.python/py-value-cc.exp for big endian

On s390x-linux, I run into:
...
(gdb) python print(u[u_fields[0]])^M
99^M
(gdb) PASS: gdb.python/py-value-cc.exp: u's first field via field
python print(u[u_fields[1]])^M
0 '\000'^M
(gdb) FAIL: gdb.python/py-value-cc.exp: u's second field via field
...

There's a var u of this type:
...
union U {
  int a;
  char c;
};
...
and after assigning 99 to u.a, the test-case expects u.c to contain 99 (which
it does on x86_64), but instead it contains 0.

Fix this by instead assigning 0x63636363, to ensure that u.c == 99 for both
little and big endian.

Tested on x86_64-linux and s390x-linux.

19 months agoReinitialise macro_nest
Alan Modra [Wed, 18 Jan 2023 23:10:20 +0000 (09:40 +1030)]
Reinitialise macro_nest

* input-scrub.c (input_scrub_begin): Init macro_nest.

19 months agoPR 30022, concurrent builds can fail
Alan Modra [Wed, 18 Jan 2023 23:04:56 +0000 (09:34 +1030)]
PR 30022, concurrent builds can fail

So let's not copy .libs/libbfd.a to libbfd.a now that nothing in the
binutils-gdb source tries to link against it.

PR 30022
* Makefile.am (noinst_LIBRARIES, libbfd_a_SOURCES, stamp-lib),
(libbfd.a): Delete rules.
(CLEANFILES): Adjust to suit.

19 months agotoplevel: Makefile.def: add install-strip dependency on libsframe
Indu Bhagat [Thu, 19 Jan 2023 07:17:49 +0000 (23:17 -0800)]
toplevel: Makefile.def: add install-strip dependency on libsframe

As noted in PR libsframe/30014 - FTBFS: install-strip fails because
bfdlib relinks and fails to find libsframe, the install time
dependencies of libbfd need to be updated.

PR libsframe/30014
* Makefile.def: Reflect that libsframe needs to installed before
libbfd.  Reorder a bit to better track libsframe dependencies.
* Makefile.in: Regenerate.

19 months agoThe fuzzers have found the reloc special functions in coff-aarch64.c
Alan Modra [Tue, 17 Jan 2023 11:23:00 +0000 (21:53 +1030)]
The fuzzers have found the reloc special functions in coff-aarch64.c

All of them need a bfd_reloc_offset_in_range check before accessing
data + reloc_entry->address.  This patch adds the missing checks and
sanity checks reloc offsets in coff_pe_aarch64_relocate_section too.

All of them also need changing to support objdump -W calls to
bfd_simple_get_relocated_section_contents.  At least, secrel_reloc
needs the support, the others might not be present in dwarf debug
sections.

* coff-aarch64.c (coff_aarch64_rel21_reloc): Range check
reloc offset.  Support final-linking.
(coff_aarch64_po12l_reloc): Likewise.
(coff_aarch64_addr32nb_reloc): Likewise.
(coff_aarch64_secrel_reloc): Likewise.
(coff_pe_aarch64_relocate_section): Range check reloc offset.

19 months agoCorrect coff-aarch64 howtos and delete unnecessary special functions
Alan Modra [Sat, 14 Jan 2023 11:43:30 +0000 (22:13 +1030)]
Correct coff-aarch64 howtos and delete unnecessary special functions

The remaining special functions are still broken except when called
by gas bfd_install_relocation.

* coff-aarch64.c (coff_aarch64_addr64_reloc),
(coff_aarch64_addr32_reloc, coff_aarch64_branch26_reloc),
(coff_aarch64_branch19_reloc, coff_aarch64_branch14_reloc),
(coff_aarch64_po12a_reloc): Delete.
(HOWTO_INSTALL_ADDEND): Define as 1.
(HOW): Remove pcrel_off.  Correct all the howtos.
(CALC_ADDEND): Define.
(coff_aarch64_rtype_to_howto): New function.
(coff_rtype_to_howto): Define.

19 months agocoff-aarch64.c howtos
Alan Modra [Fri, 13 Jan 2023 06:11:54 +0000 (16:41 +1030)]
coff-aarch64.c howtos

This is just a patch to fix overlong lines.  Wrapping the HOWTO macro
in a new HOW macro helps in this.  No functional changes here.

* coff-aarch64.c (HOW): Define and use for reloc howtos.

19 months agohowto install_addend
Alan Modra [Mon, 16 Jan 2023 02:19:03 +0000 (12:49 +1030)]
howto install_addend

This adds a new flag to the reloc howtos that can be used to
incrementally change targets over to simple bfd_install_relocation
that just installs the addend without any weird adjustments.
I've made a few other changes to bfd_install_relocation, removing dead
code and comments that are really only applicable to
bfd_perform_relocation.

There is also a reloc offset bounds check change.  I've moved the
check to where data is accessed, as it seems reasonable to me to not
perform the check unless it is needed.  There is precedence for this;
Relocations against absolute symbols already avoided the check.

I also tried always performing the reloc offset check, and ran into
testsuite failures due to _NONE and _ALIGN relocs at the end of
sections.  These likely would be fixed if all such reloc howtos had
size set to zero, but I would rather not edit lots of files when it
involves checking that target code does not use the size.

* reloc.c (struct reloc_howto_struct): Add install_addend.
(HOWTO_INSTALL_ADDEND): Define.
(HOWTO): Init new field with HOWTO_INSTALL_ADDEND.
(bfd_install_relocation): Remove comments copied from
bfd_perform_relocation that aren't applicable here.  Remove
code dealing with output_offset and output_section.  Just set
relocation to addend if install_addend.  Move reloc offset
bounds check to just before section data is accessed, avoiding
the check when data is not accessed.
* bfd-in2.h: Regenerate.

19 months agosim: info: convert verbose field to a bool
Mike Frysinger [Thu, 19 Jan 2023 01:14:54 +0000 (20:14 -0500)]
sim: info: convert verbose field to a bool

The verbose argument has always been an int treated as a bool, so
convert it to an explicit bool.  Further, update the API docs to
match the reality that the verbose value is actually used by some
of the internal modules.

19 months agosim: unify sim-signal.o building
Mike Frysinger [Thu, 19 Jan 2023 00:26:58 +0000 (19:26 -0500)]
sim: unify sim-signal.o building

Now that sim-main.h has been reduced significantly, we can remove it
from sim-signal.c and unify it across all boards since it compiles to
the same code.

19 months agosim: v850: reduce extra header inclusion to igen files
Mike Frysinger [Thu, 19 Jan 2023 00:11:38 +0000 (19:11 -0500)]
sim: v850: reduce extra header inclusion to igen files

Limit these extra header includes to only when specific igen files
include us until we can move the includes to the igen fils directly.

19 months agosim: v850: drop redundant define
Mike Frysinger [Thu, 19 Jan 2023 00:07:19 +0000 (19:07 -0500)]
sim: v850: drop redundant define

This is already in v850/local.mk, so we can drop it from sim-main.h.

19 months agosim: mn10300: minimize mn10300-sim.h include in sim-main.h
Mark Wielaard [Sun, 15 Jan 2023 19:24:06 +0000 (20:24 +0100)]
sim: mn10300: minimize mn10300-sim.h include in sim-main.h

sim-main.h is special since it is one of the files automatically
included in igen generated files. But this means anything including
sim-main.h might get everything included just for the igen files.

To prevent clashing symbols/defines only include sim-fpu.h,
sim-signal.h, mn10300-sim.h from sim-main.h if it is included
from one of the generated igen C files. Add explicit includes
of mn10300-sim.h, sim-fpu.h and/or sim-signal.h to dv-mn103cpu.c,
interp.c and op_utils.c.

19 months agoAutomatic date update in version.in
GDB Administrator [Thu, 19 Jan 2023 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

19 months agoGDB: Add references to erased args in cli-decode.c
Maciej W. Rozycki [Wed, 18 Jan 2023 23:38:50 +0000 (23:38 +0000)]
GDB: Add references to erased args in cli-decode.c

Complement commit 1d7fe7f01b93 ("gdb: Introduce setting construct within
cmd_list_element") and commit 702991711a91 ("gdb: Have setter and getter
callbacks for settings") and update inline documentation accordingly for
`add_set_or_show_cmd' and `add_setshow_cmd_full_erased', documenting the
`args' parameter and removing references to `var', `set_setting_func'
and `get_setting_func'.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
19 months agoGDB: Add missing inline documentation for `add_setshow_cmd_full'
Maciej W. Rozycki [Wed, 18 Jan 2023 23:23:00 +0000 (23:23 +0000)]
GDB: Add missing inline documentation for `add_setshow_cmd_full'

Complement commit 1d7fe7f01b93 ("gdb: Introduce setting construct
within cmd_list_element") and add missing description for
`add_setshow_cmd_full'.

19 months agoGDB: Correct inline documentation for `add_setshow_cmd_full_erased'
Maciej W. Rozycki [Wed, 18 Jan 2023 23:23:00 +0000 (23:23 +0000)]
GDB: Correct inline documentation for `add_setshow_cmd_full_erased'

Use proper English in the description of SET_LIST and SHOW_LIST.

19 months agoGDB: Fix documentation for `theclass' parameters in cli-decode.c
Maciej W. Rozycki [Wed, 18 Jan 2023 21:54:37 +0000 (21:54 +0000)]
GDB: Fix documentation for `theclass' parameters in cli-decode.c

Rename CLASS to THECLASS in the documentation for `theclass' parameters
throughout cli-decode.c, complementing commit fe978cb071b4 ("C++ keyword
cleanliness, mostly auto-generated").

Approved-By: Simon Marchi <simon.marchi@efficios.com>
19 months agoFix 'make TAGS' in gdbserver
Tom Tromey [Fri, 23 Dec 2022 20:28:20 +0000 (13:28 -0700)]
Fix 'make TAGS' in gdbserver

PR build/29003 points out that "make TAGS" is broken in gdbserver.
This patch fixes the problem that is pointed out there, plus another
one I noticed while working on that -- namely that the "sed" computes
the wrong names for some source files.  Finally, a couple of obsolete
variable references are removed.

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