binutils-gdb.git
19 months agox86: move reg_operands adjustment
Jan Beulich [Fri, 27 Jan 2023 08:23:38 +0000 (09:23 +0100)]
x86: move reg_operands adjustment

Ideally we'd do away with this somewhat questionable adjustment (leaving
i.types[] untouched). That's non-trivial though as it looks, so only
- move the logic into process_operands(), putting it closer to related
  logic and eliminating a conditional for operand-less insns,
- make it consistent (i.e. also affect %xmm0), eliminating an ugly
  special case later in the function.

19 months agox86: drop dead SSE2AVX-related code
Jan Beulich [Fri, 27 Jan 2023 08:23:12 +0000 (09:23 +0100)]
x86: drop dead SSE2AVX-related code

All (there are just two) SSE2AVX templates with %xmm0 as first operand
also specify VEX3SOURCES. Hence there's no need for an "else" to the
respective if(), and the if() itself can become an assertion.

19 months agox86: use ModR/M for FPU insns with operands
Jan Beulich [Fri, 27 Jan 2023 08:22:49 +0000 (09:22 +0100)]
x86: use ModR/M for FPU insns with operands

This is the correct way of expressing things; encoding the ModR/M byte
directly in base_opcode has always been bogus.

19 months agox86/Intel: improve special casing of certain insns
Jan Beulich [Fri, 27 Jan 2023 08:21:24 +0000 (09:21 +0100)]
x86/Intel: improve special casing of certain insns

Now that we have identifiers for the mnemonic strings we can avoid
opcode based comparisons, for (in many cases) being more expensive and
(in a few cases) being a little fragile and not self-documenting.

19 months agoopcodes: suppress internationalization on build helper tools
Jan Beulich [Fri, 27 Jan 2023 08:20:58 +0000 (09:20 +0100)]
opcodes: suppress internationalization on build helper tools

While one of the two actually having been instrumented (i386-gen.c) now
has that instrumentation dropped, there's still no point in honoring
such instrumentation in general (i.e. now for ia64-gen.c only), as that
only leads to a waste of resources.

With CFILES then being merely an alias of LIBOPCODES_CFILES, drop the
former variable altogether.

19 months agox86: remove internationalization from i386-gen.c
Jan Beulich [Fri, 27 Jan 2023 08:20:26 +0000 (09:20 +0100)]
x86: remove internationalization from i386-gen.c

This is a build time helper utility, which doesn't require translation.

19 months agoCall bfd_close_all_done in ld_cleanup
Alan Modra [Fri, 27 Jan 2023 05:02:06 +0000 (15:32 +1030)]
Call bfd_close_all_done in ld_cleanup

This is similar to "Call bfd_close_all_done in output_file_close",
but with some code tidying in the pe/pep write_build_id functions.
write_build_id is passed the output bfd as its parameter, so there is
no need to go looking for the output bfd via link_info (and doing so
will no longer work since I clear link_info.output_bfd before calling
bfd_close).

* emultempl/pe.em (write_build_id): Rename t to td.  Formatting.
Don't access pe_data(link_info.output_bfd), use td instead.
(setup_build_id): Rename t to td.  Formatting.
* emultempl/pep.em: As for pe.em.
* ldmain.c (ld_cleanup): Call bfd_close_all_done on linker bfds.
(main): Clear link_info.output_bfd when closing.

19 months agoPerform cleanup in bfd_close after errors
Alan Modra [Fri, 27 Jan 2023 04:46:03 +0000 (15:16 +1030)]
Perform cleanup in bfd_close after errors

It seems reasonable to continue after errors in bfd_close_all_done,
particularly since bfd_close_all_done is typically called on an output
file after we've hit some sort of error elsewhere.  The iovec test is
necessary if bfd_close_all_done is to work on odd bfd's opened by
bfd_create.

* opncls.c (bfd_close): Call bfd_close_all_done after errors
from _bfd_write_contents.
(bfd_close_all_done): Call _bfd_delete_bfd after errors.
Don't call iovec->bclose when iovec is NULL.

19 months agoCall bfd_close_all_done in output_file_close
Alan Modra [Fri, 27 Jan 2023 02:01:27 +0000 (12:31 +1030)]
Call bfd_close_all_done in output_file_close

bfd_cache_close_all is good for closing file descriptors, but doesn't
do the cleanup of bfd memory as in bfd_close_all_done.

PR 13056
* output-file.c (output_file_close): Call bfd_close_all_done,
not bfd_cache_close_all.

19 months agogas macro memory leaks
Alan Modra [Fri, 27 Jan 2023 00:01:56 +0000 (10:31 +1030)]
gas macro memory leaks

This tidies memory allocated for entries in macro_hash.  Freeing the
macro name requires a little restructuring of the define_macro
interface due to the name being used in the error message, and exposed
the fact that the name and other fields were not initialised by the
iq2000 backend.

There is also a fix for
 .macro .macro
 .endm
 .macro .macro
 .endm
which prior to this patch reported
mac.s:1: Warning: attempt to redefine pseudo-op `.macro' ignored
mac.s:3: Error: Macro `.macro' was already defined
rather than reporting the attempt to redefine twice.

* macro.c (macro_del_f): New function.
(macro_init): Use it when creating macro_hash.
(free_macro): Free macro name too.
(define_macro): Return the macro_entry, remove idx, file, line and
namep params.  Call as_where.  Report errors here.  Delete macro
from macro_hash on attempt to redefined pseudo-op.
(delete_macro): Don't call free_macro.
* macro.h (define_macro): Update prototype.
* read.c (s_macro): Adjust to suit.
* config/tc-iq2000.c (iq2000_add_macro): Init all fields of
macro_entry.

19 months agogas/testsuite: Add -gcodeview test for aarch64-w64-mingw32
Mark Harmstone [Thu, 26 Jan 2023 00:33:29 +0000 (00:33 +0000)]
gas/testsuite: Add -gcodeview test for aarch64-w64-mingw32

This is a copy of the x86 gas -gcodeview test, with changes made for the
differing instruction lengths between x86 and aarch64.

19 months agogas: Add CodeView constant for aarch64
Mark Harmstone [Wed, 25 Jan 2023 23:54:37 +0000 (23:54 +0000)]
gas: Add CodeView constant for aarch64

Adds the correct constant to the S_COMPILE3 CodeView record when
assembling aarch64-w64-mingw32 with the -gcodeview flag.

19 months agoUse clean_restart in gdb.base
Tom Tromey [Wed, 25 Jan 2023 21:55:12 +0000 (14:55 -0700)]
Use clean_restart in gdb.base

Change gdb.base to use clean_restart more consistently.

19 months agoUse clean_restart in gdb.python
Tom Tromey [Wed, 25 Jan 2023 21:48:55 +0000 (14:48 -0700)]
Use clean_restart in gdb.python

Change gdb.python to use clean_restart more consistently.

19 months agoUse clean_restart in gdb.cp
Tom Tromey [Wed, 25 Jan 2023 21:43:51 +0000 (14:43 -0700)]
Use clean_restart in gdb.cp

Change gdb.cp to use clean_restart more consistently.

19 months agoUse clean_restart in gdb.disasm
Tom Tromey [Wed, 25 Jan 2023 21:42:39 +0000 (14:42 -0700)]
Use clean_restart in gdb.disasm

Change gdb.disasm to use clean_restart more consistently.

19 months agoUse clean_restart in gdb.perf
Tom Tromey [Wed, 25 Jan 2023 21:41:57 +0000 (14:41 -0700)]
Use clean_restart in gdb.perf

Change gdb.perf to use clean_restart more consistently.

19 months agoUse clean_restart in gdb.go
Tom Tromey [Wed, 25 Jan 2023 21:41:39 +0000 (14:41 -0700)]
Use clean_restart in gdb.go

Change gdb.go to use clean_restart more consistently.

19 months agoUse clean_restart in gdb.stabs
Tom Tromey [Wed, 25 Jan 2023 21:41:23 +0000 (14:41 -0700)]
Use clean_restart in gdb.stabs

Change gdb.stabs to use clean_restart more consistently.

19 months agoUse clean_restart in gdb.fortran
Tom Tromey [Wed, 25 Jan 2023 17:48:44 +0000 (10:48 -0700)]
Use clean_restart in gdb.fortran

Change gdb.fortran to use clean_restart more consistently.

19 months agoUse clean_restart in gdb.ada
Tom Tromey [Wed, 25 Jan 2023 17:48:27 +0000 (10:48 -0700)]
Use clean_restart in gdb.ada

Change gdb.ada to use clean_restart more consistently.

19 months agoUse clean_restart in gdb.dwarf2
Tom Tromey [Wed, 25 Jan 2023 17:46:52 +0000 (10:46 -0700)]
Use clean_restart in gdb.dwarf2

Change gdb.dwarf2 to use clean_restart more consistently.

19 months agoUse clean_restart in gdb.reverse
Tom Tromey [Wed, 25 Jan 2023 17:45:30 +0000 (10:45 -0700)]
Use clean_restart in gdb.reverse

Change gdb.reverse to use clean_restart more consistently.

19 months agoUse clean_restart in gdb.arch
Tom Tromey [Wed, 25 Jan 2023 17:44:25 +0000 (10:44 -0700)]
Use clean_restart in gdb.arch

Change gdb.arch to use clean_restart more consistently.

19 months agoUse clean_restart in gdb.guile
Tom Tromey [Wed, 25 Jan 2023 17:39:53 +0000 (10:39 -0700)]
Use clean_restart in gdb.guile

Change gdb.guile to use clean_restart more consistently.

19 months agoUse clean_restart in gdb.threads
Tom Tromey [Wed, 25 Jan 2023 17:36:09 +0000 (10:36 -0700)]
Use clean_restart in gdb.threads

Change gdb.threads to use clean_restart more consistently.

19 months agoUse clean_restart in gdb.objc
Tom Tromey [Wed, 25 Jan 2023 17:31:34 +0000 (10:31 -0700)]
Use clean_restart in gdb.objc

Change gdb.objc to use clean_restart more consistently.

19 months agoUse clean_restart in gdb.trace
Tom Tromey [Wed, 25 Jan 2023 17:18:01 +0000 (10:18 -0700)]
Use clean_restart in gdb.trace

Change gdb.trace to use clean_restart more consistently.

19 months agoUse clean_restart in gdb.opencl
Tom Tromey [Wed, 25 Jan 2023 17:14:50 +0000 (10:14 -0700)]
Use clean_restart in gdb.opencl

Change gdb.opencl to use clean_restart more consistently.

19 months agoUse clean_restart in gdb.linespec
Tom Tromey [Wed, 25 Jan 2023 17:13:40 +0000 (10:13 -0700)]
Use clean_restart in gdb.linespec

Change gdb.linespec to use clean_restart more consistently.

19 months agoUse clean_restart in gdb.pascal
Tom Tromey [Wed, 25 Jan 2023 17:06:20 +0000 (10:06 -0700)]
Use clean_restart in gdb.pascal

Change gdb.pascal to use clean_restart more consistently.

19 months agoUse mi_clean_restart more
Tom Tromey [Wed, 25 Jan 2023 17:01:57 +0000 (10:01 -0700)]
Use mi_clean_restart more

This changes a number of MI tests to use mi_clean_restart rather than
separate calls.  This reduces the number of lines, which is nice, and
also provides a nicer model to copy for future tests.

19 months agoStart gdb after building executable in mi-basics.exp
Tom Tromey [Wed, 25 Jan 2023 17:00:58 +0000 (10:00 -0700)]
Start gdb after building executable in mi-basics.exp

A lot of the MI tests start gdb and only then build the executable.
This just seemed weird to me, so I've fixed this up.  In this patch,
no other cleanups are done, the startup is just moved to a more
logical (to me) spot.

19 months agoRemove unnecessary call to standard_testfile
Tom Tromey [Wed, 25 Jan 2023 16:56:46 +0000 (09:56 -0700)]
Remove unnecessary call to standard_testfile

This test does not build a program and does not need to call
standard_testfile.

19 months agoMinor "require" fixups
Tom Tromey [Wed, 25 Jan 2023 16:43:03 +0000 (09:43 -0700)]
Minor "require" fixups

I found a couple of spots that could use "require", and one spot where
hoisting the "require" closer to the top of the file made it more
clear.

19 months agoRemove some dead code in gdb.fortran/info-types.exp
Tom Tromey [Wed, 25 Jan 2023 16:37:25 +0000 (09:37 -0700)]
Remove some dead code in gdb.fortran/info-types.exp

An early "return" in this test case prevents a test from running.
This seems to have been intentional and has been in place since:

commit d57cbee932f86df06251498daa93154046dc77c0
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date:   Tue Dec 3 13:18:43 2019 +0000

    gdb/testsuite/fortran: Fix info-modules/info-types for gfortran 8+

This patch removes the dead code.

19 months agoEliminate spurious returns from the test suite
Tom Tromey [Wed, 25 Jan 2023 16:36:25 +0000 (09:36 -0700)]
Eliminate spurious returns from the test suite

A number of tests end with "return".  However, this is unnecessary.
This patch removes all of these.

19 months agoUse clean_restart in gdb.dlang
Tom Tromey [Wed, 25 Jan 2023 16:26:53 +0000 (09:26 -0700)]
Use clean_restart in gdb.dlang

Change gdb.dlang to use clean_restart more consistently.

19 months agoUse ordinary calling convention for clean_restart
Tom Tromey [Wed, 25 Jan 2023 16:25:36 +0000 (09:25 -0700)]
Use ordinary calling convention for clean_restart

clean_restart accepts a single optional argument.  Rather than using
{args} and handling the argument by hand, change it to use Tcl's own
argument-checking.

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

19 months agoFree gas/dwarf2dbg.c dirs
Alan Modra [Thu, 26 Jan 2023 08:42:09 +0000 (19:12 +1030)]
Free gas/dwarf2dbg.c dirs

Entries are allocated with xmemdup0.

* dwarf2dbg.c (dwarf2_cleanup): Free dirs entries.

19 months agoSanity check dwarf5 form of .file
Alan Modra [Thu, 26 Jan 2023 08:29:07 +0000 (18:59 +1030)]
Sanity check dwarf5 form of .file

There's a comment a few lines earlier saying that demand_copy_C_string
has already reported an error if it returns NULL.  Given the proximity
I decided not to duplicate the comment.

* dwarf2dbg.c (dwarf2_directive_filename): Check return of
demand_copy_C_string for file.

19 months agoresolve gas shift expressions with large exponents to zero
Alan Modra [Thu, 26 Jan 2023 08:14:51 +0000 (18:44 +1030)]
resolve gas shift expressions with large exponents to zero

* expr.c (resolve_expression <O_left_shift, O_right_shift>): Resolve
shifts exceeding bits in a valueT to zero.

19 months agosegv in coff_aarch64_addr32nb_reloc
Alan Modra [Thu, 26 Jan 2023 07:55:05 +0000 (18:25 +1030)]
segv in coff_aarch64_addr32nb_reloc

* coff-aarch64.c (coff_aarch64_addr32nb_reloc): When output_bfd
is NULL (which it is for objdump -W) get the output bfd via the
input section.

19 months agogdb/testsuite: initialize "correct" variable in gdb.cp/cpexprs.exp.tcl
Simon Marchi [Thu, 26 Jan 2023 20:46:51 +0000 (15:46 -0500)]
gdb/testsuite: initialize "correct" variable in gdb.cp/cpexprs.exp.tcl

Due to a GDB bug (visible when building with -D_GLIBCXX_DEBUG), GDB
crashes somewhere in the middle of gdb.cp/cpexprs.exp, and thus fails to
read the string, at gdb.cp/cpexprs.exp.tcl:725.  The "correct" variable
doesn't get set, and I then see this TCL error:

  ERROR: can't read "correct": no such variable

Avoid the TCL error by initializing the "correct" variable to a dummy
value.

Change-Id: I828968d9b2d105ef47f8da2ef598aa16a518c059

19 months agogdb/testsuite/dap: fix gdb.dap/basic-dap.exp disassembly test for PIE
Simon Marchi [Fri, 6 Jan 2023 18:26:19 +0000 (13:26 -0500)]
gdb/testsuite/dap: fix gdb.dap/basic-dap.exp disassembly test for PIE

Prior to this patch, I get:

    >>> {"seq": 17, "type": "request", "command": "disassemble", "arguments": {"memoryReference": "0x115d", "instructionCount": 1}}
    Content-Length: 147

    {"request_seq": 17, "type": "response", "command": "disassemble", "success": false, "message": "Cannot access memory at address 0x115d", "seq": 41}FAIL: gdb.dap/basic-dap.exp: disassemble one instruction success
    FAIL: gdb.dap/basic-dap.exp: instructions in disassemble output

The problem is that the PC to disassemble is taken from the breakpoint
insertion response, which happens before running.  With a PIE
executable, that PC is unrelocated, but the disassembly request happens
after relocation.

I chose to fix this by watching for a breakpoint changed event giving
the new breakpoint address, and recording the address from there.  I
think this is an interesting way to fix it, because it adds a bit of
test coverage, I don't think these events are checked right now.

Other ways to fix it would be:

 - Get the address by doing a breakpoint insertion after the program is
   started, or some other way.
 - Do the disassembly by symbol instead of by address.
 - Do the disassembly before running the program.

Change-Id: I3c396f796ac4c8b22e7dfd2fa1c5467f7a47e84e

19 months agogdb/testsuite/dap: make dap_wait_for_event_and_check return preceding messages
Simon Marchi [Fri, 6 Jan 2023 18:27:14 +0000 (13:27 -0500)]
gdb/testsuite/dap: make dap_wait_for_event_and_check return preceding messages

In the following patch, I change gdb.dap/basic-dap.exp such that after
waiting for some event, it checks if it received another event
meanwhile.  To help with this, make dap_wait_for_event_and_check and
_dap_dap_wait_for_event return a list with everything received before
the event of interest.  This is similar to what
dap_check_request_and_response returns.

Change-Id: I85c8980203a2dec833937e7552c2196bc137935d

19 months agogdb/testsuite/dap: rename dap_read_event to dap_wait_for_event_and_check
Simon Marchi [Fri, 6 Jan 2023 17:09:38 +0000 (12:09 -0500)]
gdb/testsuite/dap: rename dap_read_event to dap_wait_for_event_and_check

I think that name describes a bit better what the proc does, it is
similar to "wait_for" in tuiterm.exp.

Change-Id: Ie55aa011e6595dd1b5a874db13881ba572ace419

19 months agogdb/testsuite/dap: pass around dicts instead of TON objects
Simon Marchi [Fri, 6 Jan 2023 16:15:32 +0000 (11:15 -0500)]
gdb/testsuite/dap: pass around dicts instead of TON objects

The DAP helper functions generally return TON objects.  However, callers
almost all immediately use ton::2dict to convert them to dicts, to
access their contents.  This commits makes things a bit simpler for them
by having function return dicts directly instead.

The downside is that the TON objects contain type information.  For
instance, a "2" in a TCL dict could have been the integer 2 or the
string "2" in JSON.  By converting to TCL dicts, we lose that
information.  If some tests specifically want to check the types of some
fields, I think we can add intermediary functions that return TON
objects, without having to complicate other callers who don't care.

Change-Id: I2ca47bea355bf459090bae8680c6a917350b5c3f

19 months agogdb/testsuite/dap: remove catch from dap_read_event
Simon Marchi [Fri, 6 Jan 2023 16:39:29 +0000 (11:39 -0500)]
gdb/testsuite/dap: remove catch from dap_read_event

This catch didn't cause me any trouble, but for the same reason as the
preceding patch, I think it's a bit better to just let any exception
propagate, to make for easier debugging.

Change-Id: I1779e62c788b77fef2d50434edf4c3d2ec5e1c4c

19 months agogdb/testsuite/dap: make dap_request_and_response not catch / issue test result
Simon Marchi [Fri, 6 Jan 2023 16:09:00 +0000 (11:09 -0500)]
gdb/testsuite/dap: make dap_request_and_response not catch / issue test result

Following some of my changes, dap_request_and_response was failing and I
didn't know why.  I think it's better to make it not catch any
exception, and just make it do a simple "send request, read response".
If an exception is thrown while sending a request or reading a response,
things are going really badly, it's not like we'll want to recover from
that and continue the test.

Change-Id: I27568d3547f753c3a74e3e5a730d38a8caef9356

19 months agogdb/testsuite/dap: write requests to gdb.log
Simon Marchi [Fri, 6 Jan 2023 15:37:10 +0000 (10:37 -0500)]
gdb/testsuite/dap: write requests to gdb.log

This helps following what happens when reading gdb.log.  The downside is
that it becomes harder to tell what text is from GDB and what text is
going to GDB, but I think that seeing responses without seeing requests
is even more confusing.  At least, the lines are prefix with >>>, so
when you see this, you know that until the end of the line, it's
something that was sent to GDB, and not GDB output.

Change-Id: I1ba1acd8b16f4e64686c5ad268cc41082951c874

19 months agogdb/testsuite/dap: prefix some procs with _
Simon Marchi [Fri, 6 Jan 2023 15:35:53 +0000 (10:35 -0500)]
gdb/testsuite/dap: prefix some procs with _

Prefix some procs that are only used internally with an underscore, to
make it clear they are internal.  If they need to be used by some test
later, we can always un-prefix them.

Change-Id: Iacb8e77363b5d1f8b98d9ba5a6d115aee5c8925d

19 months agogdb/testsuite/dap: use gdb_assert in gdb.dap/basic-dap.exp
Simon Marchi [Fri, 6 Jan 2023 15:07:21 +0000 (10:07 -0500)]
gdb/testsuite/dap: use gdb_assert in gdb.dap/basic-dap.exp

Use gdb_assert instead of manual pass/fail.

Change-Id: I71fbc4e37a0a1ef4783056c7424e932651fa397f

19 months agogprofng: PR30043 libgprofng.so.* are installed to a wrong location
Vladimir Mezentsev [Thu, 26 Jan 2023 03:21:38 +0000 (19:21 -0800)]
gprofng: PR30043 libgprofng.so.* are installed to a wrong location

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

PR gprofng/30043
PR gprofng/28972
* src/Makefile.am: Use lib_LTLIBRARIES instead of pkglib_LTLIBRARIES.
* src/Makefile.in: Rebuild.

19 months ago[gdb/testsuite] Add gdb.base/unwind-on-each-insn-{amd64,i386}.exp
Tom de Vries [Thu, 26 Jan 2023 16:21:01 +0000 (17:21 +0100)]
[gdb/testsuite] Add gdb.base/unwind-on-each-insn-{amd64,i386}.exp

The gcc 4.4.x (and earlier) compilers had the problem that the unwind info in
the epilogue was inaccurate.

In order to work around this in gdb, epilogue unwinders were added with a
higher priority than the dwarf unwinders in the amd64 and i386 targets:
- amd64_epilogue_frame_unwind, and
- i386_epilogue_frame_unwind.

Subsequently, the epilogue unwind info problem got fixed in gcc 4.5.0.

However, the epilogue unwinders prevented gdb from taking advantage of the
fixed epilogue unwind info, so the scope of the epilogue unwinders was
limited, bailing out for gcc >= 4.5.0.

There was no regression test added for this preference scheme, so if we now
declare epilogue unwind info from all gcc versions as trusted, no test will
start failing.

Fix this by adding an amd64 and i386 regression test for this.

I have no gcc 4.4.x lying around, so I fabricated the assembly files by:
- commenting out some .cfi directives to break the epilogue unwind info, and
- hand-editing the producer info to 4.4.7 to activate the fix.

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

19 months ago[gdb/testsuite] Add and use is_x86_64_m64_target
Tom de Vries [Thu, 26 Jan 2023 09:09:44 +0000 (10:09 +0100)]
[gdb/testsuite] Add and use is_x86_64_m64_target

Add new proc is_x86_64_m64_target and use it where appropriate.

Tested on x86_64-linux.

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

19 months agold/testsuite: Add missing targets to PDB tests
Mark Harmstone [Wed, 25 Jan 2023 01:20:24 +0000 (01:20 +0000)]
ld/testsuite: Add missing targets to PDB tests

19 months agold: Add pdb support to aarch64-w64-mingw32
Mark Harmstone [Mon, 23 Jan 2023 23:01:54 +0000 (23:01 +0000)]
ld: Add pdb support to aarch64-w64-mingw32

This extends PDB support to the aarch64 PE targets.

The changes to the test files are just to make it so they can be assembled as
either x86, x86_64, or aarch64, mainly by changing the comment style.
The only actual code change here is in adding the architecture constants
to pdb.c.

19 months agogdb/arm: Use new dwarf2 function cache
Torbjörn SVENSSON [Thu, 17 Nov 2022 11:18:20 +0000 (12:18 +0100)]
gdb/arm: Use new dwarf2 function cache

This patch resolves the performance issue reported in pr/29738 by
caching the values for the stack pointers for the inner frame.  By
doing so, the impact can be reduced to checking the state and
returning the appropriate value.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Signed-off-by: Yvan Roux <yvan.roux@foss.st.com>
19 months agogdb: dwarf2 generic implementation for caching function data
Torbjörn SVENSSON [Thu, 17 Nov 2022 11:17:53 +0000 (12:17 +0100)]
gdb: dwarf2 generic implementation for caching function data

When there is no dwarf2 data for a register, a function can be called
to provide the value of this register.  In some situations, it might
not be trivial to determine the value to return and it would cause a
performance bottleneck to do the computation each time.

This patch allows the called function to have a "cache" object that it
can use to store some metadata between calls to reduce the performance
impact of the complex logic.

The cache object is unique for each function and frame, so if there are
more than one function pointer stored in the dwarf2_frame_cache->reg
array, then the appropriate pointer will be supplied (the type is not
known by the dwarf2 implementation).

dwarf2_frame_get_fn_data can be used to retrieve the function unique
cache object.
dwarf2_frame_allocate_fn_data can be used to allocate and retrieve the
function unique cache object.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Signed-off-by: Yvan Roux <yvan.roux@foss.st.com>
19 months agoClean up unusual code in mi-cmd-stack.c
Tom Tromey [Wed, 25 Jan 2023 15:04:39 +0000 (08:04 -0700)]
Clean up unusual code in mi-cmd-stack.c

I noticed some unusual code in mi-cmd-stack.c.  This code is a switch,
where one of the cases appears in the middle of another block.  It
seemed cleaner to me to have the earlier case just conditionally fall
through.

19 months agoi386: Pass -Wl,--no-as-needed to compiler as needed
H.J. Lu [Wed, 25 Jan 2023 16:57:57 +0000 (08:57 -0800)]
i386: Pass -Wl,--no-as-needed to compiler as needed

Pass -Wl,--no-as-needed to linker tests to fix

FAIL: Run pr19031
FAIL: Run got1
FAIL: Undefined weak symbol (-fPIE -no-pie)
FAIL: Undefined weak symbol (-fPIE -pie)

when --as-needed is passed to linker by compiler.

PR ld/30050
* testsuite/ld-i386/i386.exp: Pass -Wl,--no-as-needed to compiler
as needed.

19 months agoMove target check into allow_altivec_tests
Tom Tromey [Tue, 24 Jan 2023 19:50:20 +0000 (12:50 -0700)]
Move target check into allow_altivec_tests

Pedro pointed out that only PPC can possibly have altivec, so we can
move the target check into allow_altivec_tests.

19 months agoUse require with is_remote
Tom Tromey [Sun, 22 Jan 2023 20:38:26 +0000 (13:38 -0700)]
Use require with is_remote

This changes some tests to use require with 'is_remote', rather than
an explicit test.  This adds uniformity helps clean up more spots
where a test might exit early without any notification.

19 months agoAdd unsupported calls where needed
Tom Tromey [Sun, 22 Jan 2023 17:01:05 +0000 (10:01 -0700)]
Add unsupported calls where needed

A number of tests will exit early without saying why.  This patch adds
"unsupported" at spots like this that I could readily find.

There are definitely more of these; for example dw2-ranges.exp fails
silently because a compilation fails.  I didn't attempt to address
these as that is a much larger task.

19 months agoIntroduce and use is_any_target
Tom Tromey [Sun, 22 Jan 2023 17:05:00 +0000 (10:05 -0700)]
Introduce and use is_any_target

A few tests work on two different targets that can't be detected with
a single call to istarget -- that proc only accepts globs, not regular
expressions.

This patch introduces a new is_any_target proc and then converts these
tests to use it in a 'require'.

19 months agoUse require with istarget
Tom Tromey [Sun, 22 Jan 2023 05:41:25 +0000 (22:41 -0700)]
Use require with istarget

This changes many tests to use require when checking 'istarget'.  A
few of these conversions were already done in earlier patches.

No change was needed to 'require' to make this work, due to the way it
is written.  I think the result looks pretty clear, and it has the
bonus of helping to ensure that the reason that a test is skipped is
always logged.

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