Commit Graph

113393 Commits

Author SHA1 Message Date
Andrew Burgess
58c6d2ac10 gdb/tui: improve errors from tui focus command
This commit improves (I think) the errors from the tui focus command.
There are a number of errors that can be triggered by the focus
command, they include:

  (1) Window name "NAME" is ambiguous

  (2) Unrecognized window name "NAME"

  (3) Window "NAME" cannot be focused

Error (1) is triggered when the user gives a partial window name, and
the name matches multiple windows in the current layout.

It is worth noting that the ambiguity must be within the current
layout; if the partial name matches one window in the current layout,
and one or more windows not in the current layout, then this is not
ambiguous, and focus will shift to the matching window in the current
layout.

This error was not previous being tested, but in this commit I make
use of the Python API to trigger and test this error.

Error (3) is simple enough, and was already being tested.  This is
triggered by something like 'focus status'.  The named window needs to
be present in the current layout, and non-focusable in order to
trigger the error.

Error (2) is what I'd like to improve in this commit.  This error
triggers if the name the user gives doesn't match any window in the
current layout.  Even if GDB does know about the window, but the
window isn't in the current layout, then GDB will say it doesn't
recognize the window name.

In this commit I propose to to split this error into three different
errors.  These will be:

  (a) Unrecognized window name "NAME"

  (b) No windows matching "NAME" in the current layout

  (c) Window "NAME" is not in the current layout

Error (a) is the same as before, but will now only trigger if GDB
doesn't know about window NAME at all.  If the window is known, but
not in the current layout then one of the other errors will trigger.

Error (b) will trigger if NAME is ambiguous for multiple windows that
are not in the current layout.  If NAME identifies a single window in
the current layout then that window will continue to be selected, just
as it currently is.  Only in the case where NAME doesn't identify a
window in the current layout do we then check all the other known
windows, if NAME matches multiple of these, then (b) is triggered.

Finally, error (c) is used when NAME uniquely identifies a single
window that is not in the current layout.

The hope with these new errors is that the user will have a better
understanding of what went wrong.  Instead of GDB claiming to not know
about a window, the mention of the current layout will hint to the
user that they should first switch layouts.

There are tests included for all the new errors.
2023-01-27 16:20:10 +00:00
Andrew Burgess
efe1b6507b gdb/testsuite: fix line feed scrolling in tuiterm.exp
In a following commit I managed to trigger the line feed scrolling
case in tuiterm.exp.  This case is currently unhandled, and this
commit fills in this missing functionality.

The implementation is pretty simple, just scroll all the content up
one line at a time until the cursor is back on the screen (a single
line of scroll is all that should be needed).

This change is untested in this commit, but is required by the next
commit.
2023-01-27 16:20:10 +00:00
Nick Clifton
1c66b8a039 Another fix for EFI generation with LTO enabled.
PR 29998 * pe-dll.c (build_filler_bfd): Initialise the next field of the filler input statement, so that it does not break the file chain.
2023-01-27 12:00:35 +00:00
Jan Beulich
31b4cda3d5 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.
2023-01-27 09:23:38 +01:00
Jan Beulich
95dfdd858c 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.
2023-01-27 09:23:12 +01:00
Jan Beulich
bd78280846 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.
2023-01-27 09:22:49 +01:00
Jan Beulich
c47b4d7120 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.
2023-01-27 09:21:24 +01:00
Jan Beulich
800c5dd7b3 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.
2023-01-27 09:20:58 +01:00
Jan Beulich
06ceca3a90 x86: remove internationalization from i386-gen.c
This is a build time helper utility, which doesn't require translation.
2023-01-27 09:20:26 +01:00
Alan Modra
1f5e6267aa 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.
2023-01-27 15:47:09 +10:30
Alan Modra
8219cab3f8 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.
2023-01-27 15:46:45 +10:30
Alan Modra
3e7cde4dca 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.
2023-01-27 15:46:20 +10:30
Alan Modra
c026360c75 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.
2023-01-27 15:38:52 +10:30
Mark Harmstone
48afe8b710 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.
2023-01-27 04:03:17 +00:00
Mark Harmstone
c194b6ac48 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.
2023-01-27 04:03:15 +00:00
Tom Tromey
c95d486d35 Use clean_restart in gdb.base
Change gdb.base to use clean_restart more consistently.
2023-01-26 18:28:32 -07:00
Tom Tromey
9b2234b063 Use clean_restart in gdb.python
Change gdb.python to use clean_restart more consistently.
2023-01-26 18:28:32 -07:00
Tom Tromey
e125b18278 Use clean_restart in gdb.cp
Change gdb.cp to use clean_restart more consistently.
2023-01-26 18:28:32 -07:00
Tom Tromey
eefe81b523 Use clean_restart in gdb.disasm
Change gdb.disasm to use clean_restart more consistently.
2023-01-26 18:28:32 -07:00
Tom Tromey
396b136e89 Use clean_restart in gdb.perf
Change gdb.perf to use clean_restart more consistently.
2023-01-26 18:28:32 -07:00
Tom Tromey
5ae820f38f Use clean_restart in gdb.go
Change gdb.go to use clean_restart more consistently.
2023-01-26 18:28:32 -07:00
Tom Tromey
c852f1aeca Use clean_restart in gdb.stabs
Change gdb.stabs to use clean_restart more consistently.
2023-01-26 18:28:32 -07:00
Tom Tromey
1d6704e0ce Use clean_restart in gdb.fortran
Change gdb.fortran to use clean_restart more consistently.
2023-01-26 18:28:32 -07:00
Tom Tromey
0ce635282e Use clean_restart in gdb.ada
Change gdb.ada to use clean_restart more consistently.
2023-01-26 18:28:32 -07:00
Tom Tromey
e8d8a0df4b Use clean_restart in gdb.dwarf2
Change gdb.dwarf2 to use clean_restart more consistently.
2023-01-26 18:28:32 -07:00
Tom Tromey
b825d4a3de Use clean_restart in gdb.reverse
Change gdb.reverse to use clean_restart more consistently.
2023-01-26 18:28:31 -07:00
Tom Tromey
6dbbae3b67 Use clean_restart in gdb.arch
Change gdb.arch to use clean_restart more consistently.
2023-01-26 18:28:31 -07:00
Tom Tromey
888438e2b4 Use clean_restart in gdb.guile
Change gdb.guile to use clean_restart more consistently.
2023-01-26 18:28:31 -07:00
Tom Tromey
a30f2b7b7e Use clean_restart in gdb.threads
Change gdb.threads to use clean_restart more consistently.
2023-01-26 18:28:31 -07:00
Tom Tromey
3ae2b57582 Use clean_restart in gdb.objc
Change gdb.objc to use clean_restart more consistently.
2023-01-26 18:28:31 -07:00
Tom Tromey
a7e727aea7 Use clean_restart in gdb.trace
Change gdb.trace to use clean_restart more consistently.
2023-01-26 18:28:31 -07:00
Tom Tromey
49e118b61f Use clean_restart in gdb.opencl
Change gdb.opencl to use clean_restart more consistently.
2023-01-26 18:28:31 -07:00
Tom Tromey
4eed72400b Use clean_restart in gdb.linespec
Change gdb.linespec to use clean_restart more consistently.
2023-01-26 18:28:31 -07:00
Tom Tromey
836b6c10cd Use clean_restart in gdb.pascal
Change gdb.pascal to use clean_restart more consistently.
2023-01-26 18:28:31 -07:00
Tom Tromey
3ad2b4af38 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.
2023-01-26 18:28:31 -07:00
Tom Tromey
d6acf25c03 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.
2023-01-26 18:28:31 -07:00
Tom Tromey
306e12673e Remove unnecessary call to standard_testfile
This test does not build a program and does not need to call
standard_testfile.
2023-01-26 18:28:31 -07:00
Tom Tromey
eacd228909 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.
2023-01-26 18:28:31 -07:00
Tom Tromey
e1a772ad89 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 d57cbee932
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.
2023-01-26 18:28:31 -07:00
Tom Tromey
879ebc5300 Eliminate spurious returns from the test suite
A number of tests end with "return".  However, this is unnecessary.
This patch removes all of these.
2023-01-26 18:28:31 -07:00
Tom Tromey
9b21b701bb Use clean_restart in gdb.dlang
Change gdb.dlang to use clean_restart more consistently.
2023-01-26 18:28:31 -07:00
Tom Tromey
6b9276b7e6 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.
2023-01-26 18:28:31 -07:00
GDB Administrator
3efac389d8 Automatic date update in version.in 2023-01-27 00:00:10 +00:00
Alan Modra
d437724a56 Free gas/dwarf2dbg.c dirs
Entries are allocated with xmemdup0.

	* dwarf2dbg.c (dwarf2_cleanup): Free dirs entries.
2023-01-27 08:18:46 +10:30
Alan Modra
dd61b2d1ac 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.
2023-01-27 08:18:46 +10:30
Alan Modra
44a178cc69 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.
2023-01-27 08:18:46 +10:30
Alan Modra
c37de29815 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.
2023-01-27 08:18:45 +10:30
Simon Marchi
4707199bd7 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
2023-01-26 15:53:50 -05:00
Simon Marchi
d4c4ea7583 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
2023-01-26 14:31:33 -05:00
Simon Marchi
8abd06e066 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
2023-01-26 14:31:33 -05:00