Commit Graph

115267 Commits

Author SHA1 Message Date
Alan Modra
4993e5cc1e Fix loongarch build with gcc-4.5
* loongarch-opc.c (loongarch_alias_opcodes): Don't trigger
	gcc-4.5 bug in handling of struct initialisation.
2023-07-14 11:59:50 +09:30
Alan Modra
6d872a1a80 More tidies to objcopy archive handling
This makes sure copy_archive exits with ibfd and obfd closed.  Error
paths didn't do that, leading to memory leaks.  None of this matters
very much.

	* objcopy.c (copy_archive): bfd_close ibfd and obfd on error
	return paths.  Remove braces around "list" free.
	(copy_file): Don't close invalid file descriptor.
2023-07-14 11:53:48 +09:30
Alan Modra
478409b71d AIX_WEAK_SUPPORT
Making target code depend on a host define like _AIX52 is never
correct, so out it goes.  Also, sort some config.bfd entries a little
to make it more obvious there is a config difference between aix5.1
and aix5.2.  These two changes should make no difference to anything
in binutils.  The gas define of AIX_WEAK_SUPPORT on the other hand was
wrong, so fix that.  Finally, fix some testsuite fails on aix < 5.2 by
simply not running the tests.

include/
	* coff/internal.h (C_WEAKEXT): Don't depend on _AIX52.
bfd/
	* coffcode.h (coff_slurp_symbol_table): Don't depend on _AIX52.
	(coff_classify_symbol): Likewise.
	* config.bfd: Sort some entries.
gas/
	* configure.ac (AIX_WEAK_SUPPORT): Don't set for aix5.[01].
	* configure: Regenerate.
	* testsuite/gas/ppc/aix.exp (xcoff-visibility-1*) Don't run
	for aix < 5.2.
2023-07-14 11:43:52 +09:30
GDB Administrator
0d8de8f255 Automatic date update in version.in 2023-07-14 00:00:19 +00:00
Tom Tromey
22f6f7979c Implement 'Enum_Val and 'Enum_Rep
This patch implements the Ada 2022 attributes 'Enum_Val and 'Enum_Rep.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2023-07-13 11:45:09 -06:00
Tom Tromey
1e5ae3d17f Remove ada_attribute_name
ada_attribute_name uses an array that must be kept in sync with an
enum -- but the comment here refers to an enum that no longer exists.
Looking at the sole caller, I see this can only be called for two
opcodes.  So, remove this entirely and inline it.
2023-07-13 11:44:47 -06:00
Michael Matz
f6f78318fc Let '^' through the lexer
so that the (existing) code in parser and expression evaluator
actually get to see it and handle it as XOR.  Also adjust docu
to match what's there.
2023-07-13 17:21:06 +02:00
Alan Modra
22e90ac5af elf_object_p load of dynamic symbols
This fixes an uninitialised memory access on a fuzzed file:
0 0xf22e9b in offset_from_vma /src/binutils-gdb/bfd/elf.c:1899:2
1 0xf1e90f in _bfd_elf_get_dynamic_symbols /src/binutils-gdb/bfd/elf.c:2099:13
2 0x10e6a54 in bfd_elf32_object_p /src/binutils-gdb/bfd/elfcode.h:851:9

Hopefully it will also stop any attempt to load dynamic symbols from
eu-strip debug files.

	* elfcode.h (elf_object_p): Do not attempt to load dynamic
	symbols for a file with no section headers until all the
	program headers are swapped in.  Do not fail on eu-strip debug
	files.
2023-07-13 14:27:51 +09:30
GDB Administrator
e726bad8af Automatic date update in version.in 2023-07-13 00:00:17 +00:00
Tom de Vries
a839dbdce5 [gdb/tui] Assume HAVE_WBORDER
The tui border-kind setting allows values acs, ascii and space.

The values ascii and space however don't work well with !HAVE_WBORDER.

Fix this by removing the !HAVE_WBORDER case, which was introduced for Ultrix
support, which is now obsolete.

Tested on x86_64-linux.

PR tui/30580
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30580

Approved-By: Tom Tromey <tom@tromey.com>
2023-07-12 16:27:40 +02:00
Tom de Vries
664ac93fa8 [gdb/tui] Make translate return entry->value instead of entry
The only use of "entry = translate (...)" is entry->value.

Simplify using the function by returning entry->value instead.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2023-07-12 12:07:40 +02:00
Tom de Vries
275cef1349 [gdb/tui] Merge tui border-kind corner translation tables
The tables:
- tui_border_kind_translate_ulcorner
- tui_border_kind_translate_urcorner
- tui_border_kind_translate_llcorner
- tui_border_kind_translate_lrcorner
are identical.

Merge and rename to tui_border_kind_translate_corner.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2023-07-12 12:07:40 +02:00
Tom de Vries
0bad8af9ce [gdb/tui] Introduce translate_acs
In function tui_update_variables we have the somewhat inconvenient:
...
  entry = translate (tui_border_kind, tui_border_kind_translate_lrcorner);
  int val = (entry->value < 0) ? ACS_LRCORNER : entry->value;
...

Add a new function translate_acs, that allows us to do the more straighforward:
...
  int val = translate_acs (tui_border_kind, tui_border_kind_translate_lrcorner,
			   ACS_LRCORNER);
...

By special-casing "acs" in translate_acs, we can now remove the acs entries
from the translation tables.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2023-07-12 12:07:40 +02:00
Tom de Vries
ec1115b344 [gdb/tui] Remove default entries in TUI translation tables
The TUI translation tables contain default entries at the end:
...
static struct tui_translate tui_border_kind_translate_hline[] = {
  { "space",    ' ' },
  { "ascii",    '-' },
  { "acs",      -1 },
  { 0, 0 },
  { "ascii",    '-' }
};
...

A simpler way of implementing this would be to to declare the first (or last)
entry the default, but in fact these default entries are not used.

Make this explicit by removing the default entries, and asserting in translate
that an entry will always be found.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2023-07-12 12:07:40 +02:00
Alan Modra
9dbd067f96 .noinit and .persistent for msp430
Similar to the previous patch, but also tidy a few more sections.

	* scripttempl/elf32msp430.sc (.text, .rodata, .data, .bss, .noinit),
	(.persistent): Align the section rather than aligning inside.
2023-07-12 09:31:40 +09:30
Alan Modra
dbe6d432d1 .noinit and .persistent alignment
It's more elegant to make the section match up with its "_start"
symbol.  We could align by setting the address of the section (by
using ALIGN before the colon), but this way we also set sh_addralign
to at least $ALIGNMENT.

	* scripttempl/elf.sc (.noinit, .persistent): Align the output
	section rather than using ". = ALIGN();" at the beginning.
	Set address to zero when not a final link.
2023-07-12 09:31:40 +09:30
Alan Modra
9596ca8194 Re: Align linkerscript symbols according to ABI
Align dot before symbols defined outside of output sections.  Before _end
is already aligned.

	* scripttempl/elf.sc (def_symbol): Tidy excess space.
	(_edata): Align before emitting symbol when SYMBOL_ABI_ALIGNMENT.
2023-07-12 09:31:40 +09:30
Alan Modra
1052fb3ecb Re: Keeping track of rs6000-coff archive element pointers
bfd/
	* coff-rs6000.c (add_range): Revise comment, noting possible fail.
	(_bfd_xcoff_openr_next_archived_file): Start with clean ranges.
binutils/
	* bfdtest1.c: Enhance to catch errors on second scan.
2023-07-12 09:31:40 +09:30
GDB Administrator
0ec80e0265 Automatic date update in version.in 2023-07-12 00:00:26 +00:00
Tom Tromey
606d863236 Remove some TODOs from gdb.cp tests
This patch removes many TODOs from the gdb.cp tests.
Going through the patch:

* bs15503.exp - these have been commented out forever and rely on
  libstdc++ debuginfo.  It's better to just remove these.

* classes.exp - the test is wrong, I think, according to the C++ ABI
  that gdb understands; and the test can be fixed and comments removed
  with a simple change to the code.

* ctti.exp - there's no need to bail out any more, as the test works.

* exception.exp - the code relying on the line numbers can't work,
  because gdb never prints that message anyway.

Reviewed-By: Bruno Larsen <blarsen@redhat.com>
2023-07-11 08:53:34 -06:00
Jan Beulich
034b6bec54 x86: simplify table-referencing macros
First of all it is entirely unclear why THREE_BYTE_TABLE_PREFIX() was
introduced by bf890a93a7. Nothing uses the .prefix_requirement values
from the two relevant entries.

And then having VEX_Cn_TABLE() and friends take arguments is misleading.
These aren't used (or pointlessly used in the case of VEX_C5_TABLE); the
respective table index is decoded from the insn (or implied in the case
of VEX_C5_TABLE).
2023-07-11 08:22:17 +02:00
Jan Beulich
1a05d24e98 x86: convert 0FXOP to just XOP in enumerator names
There's nothing 0f-ish in XOP encodings.
2023-07-11 08:21:51 +02:00
Jan Beulich
310e6b6322 x86: misc further register-only insns don't need to go through mod_table[]
Several already use OP_R(), which rejects the memory forms of insns, and
a few others can easily be converted to do so as well. Note that for it
to be able to use BadOp() without forward declaration, OP_Skip_MODRM() is
moved down.

While there add the previously missing PREFIX_OPCODE to legacy opcode
0FD7.
2023-07-11 08:21:28 +02:00
Jan Beulich
2bd8129f96 x86: various operations on mask registers can avoid going through mod_table[]
Now that we have OP_R(), use it here as well, while wiring memory-only
operands to OP_M() at the same time. To keep the number of consumed
opcode bytes similar to before, make BadOp() also account for VEX/XOP/
EVEX prefix bytes. To keep that change simple, convert need_vex to an
actual count of prefix bytes (keeping intact all prior boolean uses of
the field).

Note how this improves disassembly of such bad encodings, by at least
leaving a hint towards what a "nearby" instruction is. (For KSHIFT*
change the immediates test testcases use, such that disassembly remains
sufficiently in sync.)

While there also use Ux for VPMOV{B,W,D,Q}2M, where decoding through
mod_table[] was missing in the earlier scheme.
2023-07-11 08:21:03 +02:00
Jan Beulich
2ad525c286 x86: slightly rework handling of some register-only insns
Fold OP_MS() and OP_XS() into OP_R(), paralleling OP_M(). Use operand
names (largely) matching those in the SDM. For 128-bit-only forms use
Uxmm though, marking 256-bit forms as bad. This then allows no longer
going through vex_len_table[] for two of the insns.

Specifically _do not_ continue to mis-use v_mode.
2023-07-11 08:20:17 +02:00
Jan Beulich
5d9f7f5099 x86: SIMD shift-by-immediate don't need to go through mod_table[]
OP_MS() and OP_XS() reject memory forms of insns quite fine. This then
also eliminates mis-named enumerators (we use M_1 for register forms).
2023-07-11 08:19:53 +02:00
Jan Beulich
61ff570794 x86: misc further memory-only insns don't need to go through mod_table[]
Several already use OP_M(), which rejects the register forms of insns,
and a few others can easily be converted to do so as well. (Note that
FXSAVE_Fixup() wires through to OP_M(). Note further that OP_IndirE(),
which wasn't placed very well anyway, is moved down to avoid the need to
forward-declare BadOp().)

Also adjust formatting of and drop PREFIX_OPCODE from a few adjacent
entries.
2023-07-11 08:19:22 +02:00
Jan Beulich
7be4d0e3f0 x86: {,V}MOVNT* don't need to go through mod_table[]
Most of them use Mx already for the memory operand, which rejects the
register form of the insn. Use that operand type also for the two EVEX
forms which so far have used EXEvexXNoBcst (and thus failed to reject
the register forms), compensating by flagging broadcast as bad for all
Mx. This way several other insns which don't permit embedded broadcast
either are also covered at the same time.
2023-07-11 08:17:22 +02:00
Jan Beulich
3ef1c4468d x86: fold legacy/VEX {,V}MOV{H,L}* entries
By changing decode order to do ModR/M.mod last (rather than VEX.L), the
VEX entries (which are already reused by EVEX decoding) can be folded
with their legacy counterparts as well. Note how this change of decode
order also allows removing two auxiliary #define-s, which were
introduced during earlier folding (because of that unhelpful order of
steps).
2023-07-11 08:16:00 +02:00
Jan Beulich
c8bbc28bb8 x86: fold certain legacy/VEX table entries
Introduce macro V to expand to 'v' in the VEX/EVEX case, and replace a
couple of abort()s where legacy code can now legitimately make it. While
there for {,V}LDDQU drop hoing through mod_table[] - OP_M() rejects
register operands quite fine.
2023-07-11 08:15:39 +02:00
Jan Beulich
eb70d820e8 ld/PDB: fix off-by-1 in add_globals_ref()
Copying one too many bytes can corrupt memory, detected/reported by
glibc on a 32-bit distro.
2023-07-11 08:14:57 +02:00
GDB Administrator
c4fb288bbb Automatic date update in version.in 2023-07-11 00:00:16 +00:00
Tom Tromey
5768573861 Remove target_close
I noticed that target_close is only called in two places:
solib-svr4.c, and target_ops_ref_policy::decref.

This patch fixes the former by changing target_bfd_reopen to return a
target_ops_up and then fixing the sole caller.  Then it removes
target_close by inlining its body into the decref method.

The advantage of this approach is that targets are now automatically
managed.

Regression tested on x86-64 Fedora 38.

Approved-By: Andrew Burgess <aburgess@redhat.com>
2023-07-10 15:43:08 -06:00
Tom Tromey
9fe01a376b Update TUI window title when changed
I wrote a TUI window in Python, and I noticed that setting its title
did not result in a refresh, so the new title did not appear.  This
patch corrects this problem.
2023-07-10 13:48:22 -06:00
Tom Tromey
405a9dd064 Add Ada scope test for DAP
This adds a DAP test for fetching scopes and variables with an Ada
program.  This test is the reason that the FrameVars code does not
check is_constant on the symbols it returns.

Note that this test also shows that string-printing is incorrect in
Ada.  This is a known bug but I'm still considering how to fix it.
2023-07-10 13:17:31 -06:00
Tom Tromey
c38bda5104 Handle typedefs in no-op pretty printers
The no-ops pretty-printers that were introduced for DAP have a classic
gdb bug: they neglect to call check_typedef.  This will cause some
strange behavior; for example not showing the children of a variable
whose type is a typedef of a structure type.  This patch fixes the
oversight.
2023-07-10 13:17:31 -06:00
Tom Tromey
5b86f10883 Reimplement DAP stack traces using frame filters
This reimplements DAP stack traces using frame filters.  This slightly
simplifies the code, because frame filters and DAP were already doing
some similar work.  This also renames RegisterReference and
ScopeReference to make it clear that these are private (and so changes
don't have to worry about other files).

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30468
2023-07-10 13:17:30 -06:00
Tom Tromey
f921fe9318 Simplify FrameVars
FrameVars implements its own variant of Symbol.is_variable.  This
patch replaces this code.
2023-07-10 13:17:30 -06:00
Tom Tromey
4a1311ba0c Fix oversights in frame decorator code
The frame decorator "FrameVars" code misses a couple of cases,
discovered when working on related DAP changes.

First, fetch_frame_locals does not stop when reaching a function
boundary.  This means it would return locals from any enclosing
functions.

Second, fetch_frame_args assumes that all arguments are at the
outermost scope, but this doesn't seem to be required by gdb.
2023-07-10 13:17:30 -06:00
Tom Tromey
70ef91c5aa Add new interface to frame filter iteration
This patch adds a new function, frame_iterator, that wraps the
existing code to find and execute the frame filters.  However, unlike
execute_frame_filters, it will always return an iterator -- whereas
execute_frame_filters will return None if no frame filters apply.

Nothing uses this new function yet, but it will used by a subsequent
DAP patch.
2023-07-10 13:17:30 -06:00
Tom Tromey
7355e1a74d Fix execute_frame_filters doc string
When reading the doc string for execute_frame_filters, I wasn't sure
if the ranges were inclusive or exclusive.  This patch updates the doc
string to reflect my findings, and also fixes an existing typo.
2023-07-10 13:17:30 -06:00
Tom Tromey
b812967a60 Change 'handle_id' to be a local variable
The global variable 'handle_id' in tracectf.c is only used in a single
function, so change it to be a local variable.

Reviewed-by: Keith Seitz <keiths@redhat.com>
2023-07-10 13:02:11 -06:00
Tom Tromey
940d6baa70 Move definition of ctf_target type
This moves the definition of the ctf_target type into the
HAVE_LIBBABELTRACE block.  This type is only used in this block, so it
makes sense to only define it there.

Reviewed-by: Keith Seitz <keiths@redhat.com>
2023-07-10 13:02:11 -06:00
Tom Tromey
d3a05ac895 Constify tfile_interp_line
This adds 'const' to tfile_interp_line.

Reviewed-by: Keith Seitz <keiths@redhat.com>
2023-07-10 13:02:11 -06:00
Tom Tromey
ebd4fd0a4f Use function_view in traceframe_walk_blocks
This change traceframe_walk_blocks to take a function_view.  This
simplifies the code somewhat and lets us entirely remove one helper
function.

Reviewed-by: Keith Seitz <keiths@redhat.com>
2023-07-10 13:02:11 -06:00
Tom Tromey
d4ea64fb5d Use unique_ptr for trace_dirname
This changes trace_dirname to use unique_ptr, removing some manual
memory management.

Reviewed-by: Keith Seitz <keiths@redhat.com>
2023-07-10 13:02:11 -06:00
Tom Tromey
c7b3e7462a Use unique_ptr for trace_filename
This changes trace_filename to use unique_ptr, removing some manual
memory management.

Reviewed-by: Keith Seitz <keiths@redhat.com>
2023-07-10 13:02:11 -06:00
Tom Tromey
ec714f6b59 Replace use of xfree with byte_vector
This replaces a use of xfree with a byte_vector.

Reviewed-by: Keith Seitz <keiths@redhat.com>
2023-07-10 13:02:11 -06:00
Tom Tromey
fb4e5d7dda Remove a use of xfree
This removes a use of xfree from tracefile-tfile.c, replacing it with
a unique_xmalloc_ptr.

Reviewed-by: Keith Seitz <keiths@redhat.com>
2023-07-10 13:02:11 -06:00
Tom Tromey
dd2532ad8a Avoid crash with absolute symbol
A user supplied an executable and a remote logfile that could be used
to crash gdb.  The problem is that the BFD section for a particular
symbol was null, because the section was not marked "allocated".
Digging deeper, the problem was that elfread.c dropped the section for
absolute symbols.  This patch fixes the crash.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30431
2023-07-10 11:01:38 -06:00