Commit Graph

112669 Commits

Author SHA1 Message Date
Mike Frysinger
6adb107113 sim: bfin: invert sim_cpu storage 2022-12-21 00:00:00 -05:00
Mike Frysinger
ffeb72b44c sim: sim_cpu: invert sim_cpu storage
Currently all ports have to declare sim_cpu themselves in their
sim-main.h and then embed the common sim_cpu_base in it.  This
dynamic makes it impossible to share common object code among
multiple ports because the core data structure is always different.

Let's invert this relationship: common code declares sim_cpu, and
the port uses the new arch_data field for its per-cpu state.

This is the first in a series of changes: it adds a define to select
between the old & new layouts, then converts all the ports that don't
need custom state over to the new layout.  This includes mn10300 that,
while it defines custom fields in its cpu struct, never uses them.
2022-12-20 23:57:38 -05:00
Mike Frysinger
d026e67ed4 sim: move register headers into sim/ namespace [PR sim/29869]
These headers define the register numbers for each port to implement
the sim_fetch_register & sim_store_register interfaces.  While gdb
uses these, the APIs are part of the sim, not gdb.  Move the headers
out of the gdb/ include namespace and into sim/ instead.
2022-12-20 21:06:32 -05:00
Mike Frysinger
897903a210 sim: ppc: drop old dgen.c generator
The spreg.[ch] files live in the source tree now and are created
with the dgen.py script, so we don't need this old tool anymore.
2022-12-20 21:05:43 -05:00
Mike Frysinger
ee3314c436 sim: ppc: move spreg.[ch] files to the source tree
Simplify the build by moving the generation of these files from
build-time (via dgen.c that we have to compile & execute on the
build system) to maintainer/release mode (via spreg-gen.py that
we only ever execute when the spreg table actually changes).  It
speeds up the build process and makes it easier for us to reason
about & review changes to the code generator.

The tool is renamed from "dgen" because it's hardcoded to only
generated spreg files.  It isn't a generalized tool for creating
lookup tables.
2022-12-20 21:05:43 -05:00
GDB Administrator
0d90ae96c5 Automatic date update in version.in 2022-12-21 00:00:53 +00:00
Hannes Domani
a61ce0ce48 Fix install-strip target
The libtool patch broke install-strip of gdb:

/bin/sh ../../gdb/../mkinstalldirs /src/gdb/inst/share/gdb/python/gdb
transformed_name=`t='s,y,y,'; \
                  echo gdb | sed -e "$t"` ; \
        if test "x$transformed_name" = x; then \
          transformed_name=gdb ; \
        else \
          true ; \
        fi ; \
        /bin/sh ../../gdb/../mkinstalldirs /src/gdb/inst/bin ; \
        /bin/sh ./libtool --mode=install STRIPPROG='strip' /bin/sh /src/gdb/gdb.git/install-sh -c -s \
                gdb \
                /src/gdb/inst/bin/$transformed_name ; \
        /bin/sh ../../gdb/../mkinstalldirs /src/gdb/inst/include/gdb ; \
        /usr/bin/install -c -m 644 jit-reader.h /src/gdb/inst/include/gdb/jit-reader.h
libtool: install: `/src/gdb/inst/bin/gdb' is not a directory
libtool: install: Try `libtool --help --mode=install' for more information.

Since INSTALL_PROGRAM_ENV is no longer at the beginning of the command, the
gdb executable is not installed with install-strip.
2022-12-20 20:38:20 +01:00
Torbjörn SVENSSON
106791196f bfd: Discard symbol regardless of warning flag
The discard of symbols should be performed whether the warning for
the discard is enabled or not.
Without this patch, ld would segfault in bfd_section_removed_from_list,
called in the if-statement right after this block, as the argument
isec->output_section can be NULL.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com>
2022-12-20 11:37:22 +01:00
Alan Modra
9d09914492 PR29915, bfdio.c does not compile with mingw.org's MinGW
PR 29915
	* configure.ac: Add AC_CHECK_DECLS test ___lc_codepage_func.
	* configure: Regenerate.
	* config.in: Regenerate.
	* bfdio.c (___lc_codepage_func): Move declaration to..
	(_bfd_real_fopen): ..here, and use !HAVE_DECL____LC_CODEPAGE_FUNC.
2022-12-20 19:01:10 +10:30
Alan Modra
b3737aadf1 Re: x86: remove i386-opc.c
Regen opcodes/po/POTFILES.in
2022-12-20 19:01:10 +10:30
Mike Frysinger
043f950abe sim: ppc: change spreg switch table generation to compile-time
Simplify the generator by always outputting the switch tables, and
leave the choice of whether to use them to the compiler via a -D
flag.
2022-12-19 20:32:34 -05:00
Mike Frysinger
09d236daec sim: dv-core: add hw_detach_address method [PR sim/25211]
The core device has an attach address method as the root of the tree
which calls out to the sim API.  But it doesn't have a corresponding
detach method which means we just crash if anything tries to detach
itself from the core.  In practice, the m68hc11 is the only model
that actually tries to detach itself on the fly, so no one noticed
earlier.

With this in place, we can delete the existing detach code from the
m68hc11 model since it defaults to "passthru" callback which will in
turn call the dv-core detach, and they have the same behavior -- call
the sim core API to detach from the address space.

Bug: https://sourceware.org/PR25211
2022-12-19 20:31:02 -05:00
Vladimir Mezentsev
309b9a1abf gprofng: PR29646 Various warnings
gprofng/ChangeLog
2022-12-19  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	PR gprofng/29646
	* common/core_pcbe.c: Fix missingReturn warning.
	* libcollector/iolib.c: Fix -Waddress warnings.
	* src/Settings.cc: Likewise.
	* src/checks.cc: Likewise.
	* libcollector/linetrace.c: Likewise.
	* libcollector/iotrace.c: Fix va_end_missing error.
	* libcollector/libcol_util.c: Fix uninitvar warning.
	* src/Command.cc: Fix arrayIndexOutOfBounds error.
	* src/Function.cc: Fix uninitStructMember warning.
	* src/ipc.cc: Fix -Wwrite-strings warnings.
2022-12-19 17:02:29 -08:00
GDB Administrator
bd1473135a Automatic date update in version.in 2022-12-20 00:00:54 +00:00
Tom Tromey
0d120726bd Avoid compiler warning in dwarf-do-refresh
The Emacs 28 compiler warns about dwarf-mode.el:

Warning (comp): dwarf-mode.el:180:32: Warning: Unused lexical argument `ignore'

This is easily fixed by prepending "_" to the parameter's name.

binutils/ChangeLog
2022-12-19  Tom Tromey  <tromey@adacore.com>

	* dwarf-mode.el (dwarf-do-refresh): Avoid compiler warning.
2022-12-19 09:46:54 -07:00
Tom Tromey
4ec2227afb Use bool in bpstat
This changes bpstat to use 'bool' rather than 'char', and updates the
uses.
2022-12-19 08:19:00 -07:00
Tom Tromey
dad6b350f9 Use bool constants for value_print_options
This changes the uses of value_print_options to use 'true' and 'false'
rather than integers.
2022-12-19 08:18:59 -07:00
Tom Tromey
6829683679 Remove quick_symbol_functions::relocated
quick_symbol_functions::relocated is only needed for psymtabs, and
there it is only needed for Rust.  However, because we've switched the
DWARF reader away from psymtabs, this means there's no longer a need
for this method at all.
2022-12-19 08:05:14 -07:00
Tom Tromey
975249ff4e Remove MI version 1
MI version 1 is long since obsolete.  Several years ago, I filed
PR mi/23170 for this.  I think it's finally time to remove this.
Any users of MI 1 can and should upgrade to a newer version.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23170
2022-12-19 07:47:37 -07:00
Tom Tromey
d1c34a1b4c Remove vestiges of MI version 0
I found a few vestiges of MI version 0 in the test suite.  This patch
removes them.
2022-12-19 07:46:45 -07:00
Alan Modra
956bc7a29f Tidy PR29893 and PR29908 fix
PR 29893
	PR 29908
	* dwarf.c (display_debug_addr): Combine dwarf5 unit_length checks.
	Delete dead code.
2022-12-19 22:30:36 +10:30
Jan Vrany
37e5833da5 gdb: fix command lookup in execute_command ()
Commit b5661ff2 ("gdb: fix possible use-after-free when
executing commands") used lookup_cmd_exact () to lookup
command again after its execution to avoid possible
use-after-free error.

However this change broke test gdb.base/define.exp which
defines a post-hook for subcommand ("target testsuite").
In this case,  lookup_cmd_exact () returned NULL because
there's no command 'testsuite' in top-level commands.

This commit fixes this case by looking up the command again
using the original command line via lookup_cmd ().

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2022-12-19 11:24:36 +00:00
Nick Clifton
42f39fdedc Fix potential illegal memory accesses when parsing corrupt DWARF data.
PR 29914
	* dwarf.c (fetch_indexed_value): Fail if the section is not big
	enough to contain a header size field.
	(display_debug_addr): Fail if the computed address size is too big
	or too small.
2022-12-19 11:13:46 +00:00
Nick Clifton
d14b3ea1c8 New Romainian translation for the GOLD subdirectory. 2022-12-19 09:47:36 +00:00
Jan Beulich
b1fb503404 gprofng/testsuite: skip Java test without JDK
There's no point in even trying the Java test when gprofng was built
without Java support, and when the building of the constituents of the
testcase also would fail. On such systems this converts the respective
tests from "unresolved" to "unsupported", making the overall testsuite
run no longer report failure just because of this.
2022-12-19 09:36:21 +01:00
Jan Beulich
f8b6a781fb gprofng/testsuite: eliminate bogus casts
Casting pointers to unsigned int is generally problematic and hence
compilers tend to warn about such. While here they're used only in
fprintf(), it still seems better to omit such casts, even if only to
avoid setting bad precedents.
2022-12-19 09:36:00 +01:00
Jan Beulich
08b50e1e03 gprofng/testsuite: correct line continuation in endcases.c
A backslash used to indicate line continuation (in a macro definition
here) is not supposed to be followed by blanks or other white space; the
end-of-line indicator is to follow immediately.
2022-12-19 09:35:37 +01:00
Jan Beulich
6cafa87824 gprofng/testsuite: correct names for signal handling tests
The signal handling tests spend most of their time in the signal
handlers, and hence for profile output to match anything in program
output, the respective name fields need to hold the handler function
names. This converts both respective tests from "unresolved" to actually
succeeding.
2022-12-19 09:35:18 +01:00
Jan Beulich
ecb828308c gprofng/testsuite: adjust linking of synprog
In order for so_syn.so and so_syx.so to be able to access the main
program's "testtime" variable, that variable needs exposing in the
dynamic symbol table. Since this is a test program only, do it the brute
force way and simply expose all global symbols.
2022-12-19 09:23:34 +01:00
Jan Beulich
8e0eb7c6b3 Arm: break gas dependency on libopcodes
gas doesn't use anything from libopcodes (anymore?) - suppress linking
in that library.
2022-12-19 09:23:13 +01:00
Jan Beulich
4fdeb2a379 x86: omit Cpu prefixes from opcode table
These enumerators can be used in only one specific field, and hence the
Cpu prefix isn't needed ther for disambiguation / name space separation.
2022-12-19 09:22:33 +01:00
GDB Administrator
2a517ca94d Automatic date update in version.in 2022-12-19 00:01:23 +00:00
Alan Modra
20d8836e4a Comment bfd_get_section_limit_octets and bfd_get_section_alloc_size
* bfd.c (bfd_get_section_limit_octets): Add comment.
	(bfd_get_section_alloc_size): Likewise.
	* libbfd.c (_bfd_generic_get_section_contents): Use
	bfd_get_section_limit_octets.
	* section.c (bfd_get_section_contents): Likewise.
	* bfd-in2.h: Regenerate.
2022-12-18 19:11:32 +10:30
Alan Modra
3bbdb440d0 ld bootstrap test in build dir with path containing symlinks
This allows the bootstrap test to run if you have a symlink somewhere
in the build path directory.  $ld depends on $base_dir which is set
via tcl [pwd], collapsing the symlink like /usr/bin/pwd, while $objdir
contains the symlink.

	* testsuite/ld-bootstrap/bootstrap.exp: Normalize paths when
	checking for ld build directory.
2022-12-18 19:11:32 +10:30
Joel Brobecker
4ff87a3052 Update gdb/NEWS after GDB 13 branch creation.
This commit a new section for the next release branch, and renames
the section of the current branch, now that it has been cut.
2022-12-18 08:38:25 +04:00
Joel Brobecker
4820e86403 Bump version to 14.0.50.DATE-git.
Now that the GDB 13 branch has been created,
this commit bumps the version number in gdb/version.in to
14.0.50.DATE-git

For the record, the GDB 13 branch was created
from commit 71c90666e6.

Also, as a result of the version bump, the following changes
have been made in gdb/testsuite:

	* gdb.base/default.exp: Change $_gdb_major to 14.
2022-12-18 08:34:03 +04:00
GDB Administrator
71c90666e6 Automatic date update in version.in 2022-12-18 00:01:10 +00:00
Alan Modra
56ba7527d2 bfd_get_relocated_section_contents allow NULL data buffer
This patch removes the bfd_malloc in default_indirect_link_order and
bfd_simple_get_relocated_section_contents, pushing the allocation down
to bfd_get_relocated_section_contents.  The idea is to make use of the
allocation done with sanity checking in bfd_get_full_section_contents,
which is called by bfd_generic_get_relocated_section_contents.

Doing this exposed a bug in bfd_get_full_section_contents.  With
relaxation it is possible that an input section rawsize is different
to the section size.  In that case we want to use the larger of
rawsize (the on-disk size for input sections) and size.

	* reloc.c (bfd_generic_get_relocated_section_contents),
	* reloc16.c (bfd_coff_reloc16_get_relocated_section_contents),
	* coff-alpha.c (alpha_ecoff_get_relocated_section_contents),
	* coff-sh.c (sh_coff_get_relocated_section_contents),
	* elf-m10200.c (mn10200_elf_get_relocated_section_contents),
	* elf-m10300.c (mn10300_elf_get_relocated_section_contents),
	* elf32-avr.c (elf32_avr_get_relocated_section_contents),
	* elf32-cr16.c (elf32_cr16_get_relocated_section_contents),
	* elf32-crx.c (elf32_crx_get_relocated_section_contents),
	* elf32-h8300.c (elf32_h8_get_relocated_section_contents),
	* elf32-nds32.c (nds32_elf_get_relocated_section_contents),
	* elf32-sh.c (sh_elf_get_relocated_section_contents),
	* elfxx-mips.c (_bfd_elf_mips_get_relocated_section_contents):
	Handle NULL data buffer.
	* bfd.c (bfd_get_section_alloc_size): New function.
	* bfd-in2.h: Regenerate.
	* compress.c (bfd_get_full_section_contents): Correct section
	malloc size.
	* linker.c (default_indirect_link_order): Don't malloc memory
	here before calling bfd_get_relocated_section_contents.
	* simple.c (bfd_simple_get_relocated_section_contents): Likewise.
2022-12-17 18:44:42 +10:30
Alan Modra
6f00d50e2b asan: elf.c:12621:18: applying zero offset to null pointer
That's this line in elf_parse_notes:
  while (p < buf + size)

	* elf.c (_bfd_elf_make_section_from_shdr): Don't call
	elf_parse_notes when sh_size is zero.
2022-12-17 18:44:42 +10:30
Alan Modra
499766a6d7 Re: The problem with warning in elf_object_p
Commit 5aa0f10c42 added a per_xvec_warn array to provide support for
warnings from elf_object_p (and a later patch for warnings from
pe_bfd_object_p) to be cached and then only printed if the target
matches.  It was quite limited in the style of message supported, only
one message could be printed, and didn't really meet the stated aim of
only warning when a target matches:  There are many other errors and
warnings that can be emitted by functions called from elf_object_p.

So this patch extends the error handler functions to support printing
to a string buffer, extends per_xvec_warn to support multiple errors/
warnings, and hooks this all into bfd_check_format_matches.  If
bfd_check_format_matches succeeds then any errors/warnings are printed
for the matching target.  If bfd_check_format_matches fails either due
to no match or to multiple matches and only one target vector produced
errors, then those errors are printed.

	* bfd.c (MAX_ARGS): Define, use throughout.
	(print_func): New typedef.
	(_bfd_doprnt): Add new print param.  Replace calls to fprintf
	with print.
	(PRINT_TYPE): Similarly.
	(error_handler_fprintf): Renamed from error_handler_internal.
	Use _bfd_get_error_program_name.  Add fprintf arg.  Move code
	setting up args..
	(_bfd_doprnt_scan): ..to here.  Add ap param.
	(struct buf_stream): New.
	(err_sprintf): New function.
	(error_handler_bfd): New static variable.
	(error_handler_sprintf): New function.
	(_bfd_set_error_handler_caching): New function.
	(_bfd_get_error_program_name): New function.
	* elfcode.h (elf_swap_shdr_in): Use _bfd_error_handler in
	warning messages.
	(elf_object_p): Likewise.
	* format.c (print_warnmsg): New function.
	(clear_warnmsg): Rewrite.
	(null_error_handler): New function.
	(bfd_check_format_matches): Ignore warnings from recursive calls
	checking first element of an archive.  Use caching error handler
	otherwise.  Print warnings on successful match, or when only one
	target has emitted warnings/errors.
	* peicode.h (pe_bfd_object_p): Use _bfd_error_handler in
	warning messages.
	* targets.c (per_xvec_warn): Change type of array elements.
	(struct per_xvec_message): New.
	(_bfd_per_xvec_warn): Rewrite.
	* Makefile.am (LIBBFD_H_FILES): Add bfd.c.
	* Makefile.in: Regenerate.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
2022-12-17 18:44:42 +10:30
Indu Bhagat
6e09ae77a1 sframe: doc: update spec for the mangled-RA bit in FRE
ChangeLog:

	* libsframe/doc/sframe-spec.texi
2022-12-16 22:02:11 -08:00
Indu Bhagat
5bec250b5a gas: sframe: testsuite: add testcase for .cfi_negate_ra_state
Add a new test to check that .cfi_negate_ra_state on aarch64 is handled
well (a non-empty SFrame section with valid SFrame FREs is generated).

ChangeLog:

	* testsuite/gas/cfi-sframe/cfi-sframe-aarch64-2.d: New test.
	* testsuite/gas/cfi-sframe/cfi-sframe-aarch64-2.s: Likewise.
	* testsuite/gas/cfi-sframe/cfi-sframe.exp: Adjust the list
	accordingly.
2022-12-16 22:02:07 -08:00
Indu Bhagat
49948bce0e objdump/readelf: sframe: emit marker for FREs with mangled RA
In the textual dump of the SFrame section, when an SFrame FRE recovers a
mangled RA, use string "[s]" in the output to indicate that the return
address is a signed (mangled) one.

ChangeLog:

        * libsframe/sframe-dump.c (dump_sframe_func_with_fres): Postfix
	with "[s]" if RA is signed with authorization code.
2022-12-16 22:02:02 -08:00
Indu Bhagat
9c4b163cb5 libsframe: provide new access API for mangled RA bit
include/ChangeLog:

	* sframe-api.h (sframe_fre_get_ra_mangled_p): New declaration.

ChangeLog:

	* libsframe/sframe.c (sframe_get_fre_ra_mangled_p): New
	definition.
	(sframe_fre_get_ra_mangled_p): New static function.
2022-12-16 22:01:57 -08:00
Indu Bhagat
28f69152b9 gas: sframe: add support for .cfi_negate_ra_state
DW_CFA_AARCH64_negate_ra_state in aarch64 is multiplexed with
DW_CFA_GNU_window_save in the DWARF format.

Remove the common-empty-4 testcase because the generated SFrame section
will not be be empty anymore.  A relevant test will be added in a later
commit.

ChangeLog:

	* gas/gen-sframe.c (sframe_v1_set_fre_info): Add new argument
	for mangled_ra_p.
	(sframe_set_fre_info): Likewise.
	(output_sframe_row_entry): Handle mangled_ra_p.
	(sframe_row_entry_new): Reset mangled_ra_p.
	(sframe_row_entry_initialize): Initialize mangled_ra_p.
	(sframe_xlate_do_gnu_window_save): New definition.
	(sframe_do_cfi_insn): Handle DW_CFA_GNU_window_save.
	* gas/gen-sframe.h (struct sframe_row_entry): New member.
	(struct sframe_version_ops): Add a new argument for
	mangled_ra_p.
	* gas/testsuite/gas/cfi-sframe/cfi-sframe.exp: Remove test.
	* gas/testsuite/gas/cfi-sframe/common-empty-4.d: Removed.
	* gas/testsuite/gas/cfi-sframe/common-empty-4.s: Removed.
2022-12-16 22:01:51 -08:00
Indu Bhagat
4604c72941 sframe.h: add support for .cfi_negate_ra_state
Use the last remaining bit in the 'SFrame FRE info' word to store whether
the RA is signed/unsigned with PAC authorization code: this bit is named
as the "mangled RA" bit.  This bit is still unused for x86-64.

The behaviour of the mangled-RA info bit in SFrame format closely
follows the behaviour of DW_CFA_AARCH64_negate_ra_state in DWARF.  During
unwinding, whenever an SFrame FRE with non-zero "mangled RA" bit is
encountered, it means the upper bits of the return address contain Pointer
Authentication code.  The unwinder, hence, must use appropriate means to
restore LR correctly in such cases.

include/ChangeLog:

	* sframe.h (SFRAME_V1_FRE_INFO_UPDATE_MANGLED_RA_P): New macro.
	(SFRAME_V1_FRE_MANGLED_RA_P): Likewise.
2022-12-16 22:01:40 -08:00
GDB Administrator
1c57b841ac Automatic date update in version.in 2022-12-17 00:01:15 +00:00
Pedro Alves
9dff6a5d54 Delay checking whether /proc/pid/mem is writable (PR gdb/29907)
As of 1bcb0708f2 ("gdb/linux-nat: Check whether /proc/pid/mem is
writable"), GDB checks if /proc/pid/mem is writable.  This is done
early at GDB startup, in order to get a consistent warning, instead of
a warning that depends on whenever GDB writes to inferior memory.

PR gdb/29907 points out that some build systems (like QEMU's,
apparently) may call 'gdb --version' to check GDB's presence & its
version on the system, and that Gentoo's build process has sandboxing
which blocks the /proc/pid/mem access and thus GDB warns, which
results in build fails.

To help with that, this patch delays the /proc/pid/mem check until we
start or attach to an inferior.  Ends up potentially emiting a warning
close where we already emit other ptrace- and /proc- related warnings,
which just Feels Right.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29907
Change-Id: I5537653ecfbbe76a04ab035e40e59d09b4980763
2022-12-16 16:04:58 +00:00
Nick Clifton
c7ce51d8c8 Fix previous delta to allow for compilation on 32-bit systems 2022-12-16 15:44:55 +00:00
Tom de Vries
832a980e17 [gdb/testsuite] Fix race in gdb.threads/detach-step-over.exp
Once in a while I run into:
...
FAIL: gdb.threads/detach-step-over.exp: \
  breakpoint-condition-evaluation=host: target-non-stop=off: non-stop=off: \
  displaced=off: iter 1: all threads running
...

In can easily reproduce this by doing:
...
     # Wait a bit, to give time for the threads to hit the
     # breakpoint.
-    sleep 1

     return true
...

Fix this by counting the running threads in a loop, effectively allowing 10
seconds (instead of 1) for the threads to start running, but only sleeping if
needed.

Reduces total execution time from 1m27s to 56s.

Tested on x86_64-linux.
2022-12-16 15:28:27 +01:00