Commit Graph

115281 Commits

Author SHA1 Message Date
Tom Tromey
eef2e91d32 Refactor py-inferior.exp
This changes py-inferior.exp to make it a bit more robust when adding
new inferiors during the course of the test.

Approved-By: Pedro Alves <pedro@palves.net>
2023-07-14 10:52:56 -06:00
Tom Tromey
f591041956 Minor cleanups in py-inferior.exp
While working on this series, I noticed a some oddities in
py-inferior.exp.  One is an obviously incorrect comment, and the
others are confusing test names.  This patch fixes these.

Approved-By: Pedro Alves <pedro@palves.net>
2023-07-14 10:52:56 -06:00
Tom Tromey
23e46b680f Revert "Simplify auto_load_expand_dir_vars and remove substitute_path_component"
This reverts commit 02601231fd.

This commit was a refactoring to remove an xrealloc and simplify
utils.[ch].  However, it has a flaw -- it mishandles a substitution
like "$datadir/subdir".

I am backing out the patch in the interests of fixing the regression
before GDB 14.  It can be reinstated (with modifications) later if we
like.

Regression tested on x86-64 Fedora 36.
2023-07-14 10:35:49 -06:00
John Baldwin
40e76c4db1 Test that native targets can read a tdesc without a process attached.
This ensures that 'unset tdesc filename' does not generate any output
on a "bare" native target inferior without an attached process.
2023-07-14 08:39:24 -07:00
John Baldwin
6af166ed58 Add a have_native_target helper function for use with require.
Move logic from auto-connect-native-target.exp into this helper.
2023-07-14 08:39:24 -07:00
John Baldwin
a4a688ffa4 *-linux-nat: Handle null inferior in read_description.
Don't invoke ptrace in the target read_description method if there is
not an active inferior to query via ptrace.  Instead, use the default
register set for the architecture.

Previously the native target could report an error from a failed
ptrace operation when fetching a tdesc without an attached process.
For example on Linux x86-64:

(gdb) target native
Done.  Use the "run" command to start a process.
(gdb) unset tdesc filename
Couldn't get CS register: No such process.
2023-07-14 08:39:24 -07:00
John Baldwin
97b6e0f6c8 *-fbsd-nat: Handle null inferior in read_description.
Don't invoke ptrace in the target read_description method if there is
not an active inferior to query via ptrace.  Instead, use the default
register set for the architecture.

Previously the native target could report an error from a failed
ptrace operation when fetching a tdesc without an attached process.
For example on FreeBSD/amd64:

(gdb) target native
Done.  Use the "run" command to start a process.
(gdb) unset tdesc filename
Couldn't get registers: Operation not permitted.
2023-07-14 08:39:24 -07:00
Tobias Burnus
36b6b4594e Re: Let '^' through the lexer
Fix "make pdf".
2023-07-15 00:04:45 +09:30
Bruno Larsen
a4e5901bb1 gdb/doc: document '+' argument for 'list' command
The command 'list' has accepted the argument '+' for many years already,
but this option wasn't documented either in the texinfo docs or in the
help text for the command.  This commit documents it.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
2023-07-14 10:58:18 +02:00
Bruno Larsen
f52625f1f2 gdb/cli: Improve UX when using list with no args
When using "list" with no arguments, GDB will first print the lines
around where the inferior is stopped, then print the next N lines until
reaching the end of file, at which point it warns the user "Line X out
of range, file Y only has X-1 lines.".  This is usually desirable, but
if the user can no longer see the original line, they may have forgotten
the current line or that a list command was used at all, making GDB's
error message look cryptic. It was reported in bugzilla as PR cli/30497.

This commit improves the user experience by changing the behavior of
"list" slightly when a user passes no arguments.  It now prints that the
end of the file has been reached and recommends that the user use the
command "list ." instead.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30497
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
2023-07-14 10:58:17 +02:00
Bruno Larsen
3e3a1874fc gdb/cli: add '.' as an argument for 'list' command
Currently, after the user has used the list command once, there is no
self-contained way to ask GDB to print the location where the inferior is
stopped.  The current best options require either using a separate
command to scope out where the inferior is stopped, or using "list *$pc"
requiring knowledge of GDB standard registers.  This commit adds a way
to do that using '.' as a new argument for the 'list' command.  If the
inferior isn't running, the command prints around the main function.

Because this necessitated having the inferior running and the test was
(seemingly unnecessarily) using printf in a non-essential way and it
would make the resulting log harder to read for no benefit, it was
replaced by a different statement.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
2023-07-14 10:58:17 +02:00
Bruno Larsen
0f819434f2 gdb/cli: Factor out code to list lines around a given line
A future patch will add more situations that calculates "lines around a
certain point" to be printed using print_source_lines, and the logic
could be re-used. As a preparation for those commits, this one factors
out that part of the logic of the list command into its own function.
No functional changes are expected

Approved-By: Tom Tromey <tom@tromey.com>
2023-07-14 10:57:34 +02:00
Vladimir Mezentsev
9d9f26d8b1 gprofng: 30602 [2.41] gprofng test hangs on i686-linux-gnu
There were several problems in the gprofng testing:
 - we did not catch a timeout for each test.
 - we used exit() to stop a failed test. But this stops all other tests.
 - we used a time_t (long) type in smalltest.c instead of a long long type.

	PR gprofng/30602
	* configure.ac: Launch only native testing.
	* configure: Rebuild.
	* testsuite/config/default.exp: Set TEST_TIMEOUT.
	* testsuite/gprofng.display/setpath_map.exp: Use return instead of exit.
	* testsuite/gprofng.display/gp-archive.exp: Likewise.
	* testsuite/gprofng.display/gp-collect-app_F.exp: Likewise.
	* testsuite/gprofng.display/display.exp: Delete an unnecessary test
	for native testing.
	* testsuite/lib/display-lib.exp (run_native_host_cmd): Add timeout.
	* testsuite/lib/smalltest.c: Use a long long type instead of time_t.
2023-07-13 21:53:36 -07:00
Alan Modra
a879fdb267 Make the default gas symbol hash table larger
We may as well start with the symbol table a little larger, saving
time resizing.  Even a simple C hello world compiled with -O2 -g will
exceed 16 symbols (by well over 3 times with gcc-11).

	* symbols.c (symbol_begin): Create sy_hash with more entries.
2023-07-14 12:01:41 +09:30
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