Commit Graph

110112 Commits

Author SHA1 Message Date
Jan Beulich
04dfe7aa52 Arm64: follow-on to PR gas/27217 fix
PR gas/27217

Prior to trying to address PR gas/28888 I noticed anomalies in how
certain insns would / wouldn't be affected in similar ways.

Commit eac4eb8ecb ("Fix a problem assembling AArch64 sources when a
relocation is generated against a symbol that has a defined value") had
two copy-and-paste mistakes, passing the wrong type to
aarch64_force_reloc().

It further failed to add placeholder relocation types to that function's
block of case labels leading to a return of 1. While not of interest for
aarch64_force_relocation() (these placeholders are resolved right in
parse_operands()), calls to aarch64_force_reloc() happen before that
resolution would take place.
2022-05-18 17:55:55 +02:00
Nick Clifton
2a89fa9613 Fix compile time warning building gold with Clang-14.
* int_encoding.cc (get_length_as_unsigned_LEB_128): Remove
	current_length variable.
2022-05-18 16:29:57 +01:00
Victor Do Nascimento
320f42099a oops - forgot changelog entry for the previous delta. 2022-05-18 16:26:21 +01:00
Victor Do Nascimento
3363d8560f arm: Add unwind support for mixed register lists
* config/tc-arm.c (parse_reg_list): Add handling of mixed register
	types.
	(reg_names): Enumerate pseudoregister according to mapped physical
	register number.
	(s_arm_unwind_save_pseudo): Modify function signature.
	(s_arm_unwind_save_core): Likewise.
	(s_arm_unwind_save_mixed): New function.
	(s_arm_unwind_save): Generate register list mask to pass to nested
	functions.
	* testsuite/gas/arm/unwind-pacbti-m.s: Expand test for mixed
 	register type lists.
 	* testsuite/gas/arm/unwind-pacbti-m.d: Likewise.
	* testsuite/gas/arm/unwind-pacbti-m-readelf.d: Likewise.
2022-05-18 16:25:12 +01:00
Carl Love
301fe55e9c PowerPC: bp-permanent.exp, kill-after-signal fix
Fix changes that didn't make it into commit:
dd9cd55e99.

Fix missing -wrap on gdb_test_multiple in gdb.base/kill-after-signal.exp
that is causing regression test on x86_64-linux with taskset -c 0.
2022-05-18 15:11:42 +00:00
Yichao Yu
1fe8486103 [AArch64] Return the regnum for PC (32) on aarch64
This will allow the unwind info to explicitly specify a different value
for the return address from the link register.
Such usage, although uncommon, is valid and useful for signal frames.
It is also supported by aadwarf64 from ARM (Note 9 in [1]).

Ref https://sourceware.org/pipermail/gdb/2022-May/050091.html

[1] https://github.com/ARM-software/abi-aa/blob/2022Q1/aadwarf64/aadwarf64.rst#dwarf-register-names

Signed-off-by: Luis Machado <luis.machado@arm.com>
2022-05-18 15:42:23 +01:00
Jan Beulich
4bb8b8e938 x86: shrink op_riprel
It is only ever initialized from a boolean, so it as well as related
variables' types can simply be bool and there's no masking to 32 bits
needed in set_op().
2022-05-18 14:39:58 +02:00
Nick Clifton
2c3cc81e06 Add a --no-weak option to nm.
PR 29135
	* nm.c (non_weak): New variable.
	(filter_symbols): When non-weak is true, ignore weak symbols.
	(long_options): Add --no-weak.
	(usage): Mention --no-weak.
	(main): Handle -W/--no-weak.
	* doc/binutils.texi: Document new feature.
	* NEWS: Mention the new feature.
	* testsuite/binutils-all/nm.exp: Add test of new feature.
	* testsuite/binutils-all/no-weak.s: New test source file.
2022-05-18 13:15:22 +01:00
Pedro Alves
c76d61da4a Support -prompt and -lbl in gdb_test
This teaches gdb_test to forward the -prompt and -lbl options to
gdb_test_multiple.

The option parsing is done with parse_args.

As a cleanup, instead of using llength and lindex to get at the
positional arguments, use lassign, and check whether the corresponding
variable is empty.

Convert gdb.base/ui-redirect.exp and gdb.xml/tdesc-reload.exp to use
gdb_test -prompt/-lbl instead of gdb_test_multiple as examples.

Change-Id: I243e1296d32c05a421ccef30b63d43a89eaeb4a0
2022-05-18 11:59:37 +01:00
Luis Machado
44b6e80160 Remove unused DWARF PAUTH registers
The AARCH64_DWARF_PAUTH_DMASK and AARCH64_DWARF_PAUTH_CMASK DWARF registers
never made their way into the aadwarf64. The following patch removes these
constants and their use.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=26295
2022-05-18 11:24:55 +01:00
Luis Machado
c9cd8ca465 Rename PAUTH_RA_STATE to RA_SIGN_STATE
The aadwarf64 [1] names this register RA_SIGN_STATE, so update the code to use
the same name.

[1] https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst
2022-05-18 11:24:45 +01:00
Tom de Vries
a2ff75485c [gdb/testsuite] Simplify unknown lang testing in gdb.base/parse_number.exp
Move testing of language unknown out of the $supported_archs loop in
gdb.base/parse_number.exp.  This reduces total amount of tests from 18466 to
17744.

Tested on x86_64-linux.
2022-05-18 12:12:29 +02:00
Tom de Vries
71630188ad [gdb/testsuite] Use hex_for_lang in gdb.base/parse_number.exp
In gdb.base/parse_number.exp, add a new proc hex_for_lang that formats a hex
number appropriately for a given language.

Tested on x86_64-linux.
2022-05-18 12:12:29 +02:00
Tom de Vries
192257c998 [gdb/tdep] Add gdb/syscalls/update-linux-from-src.sh
Add a new script gdb/syscalls/update-linux-from-src.sh, that can be used to
generate *-linux.xml.in files from linux kernel sources, like so:
...
$ ./update-linux-from-src.sh ~/upstream/linux-stable.git
Skipping aarch64-linux.xml.in, no syscall.tbl
Generating amd64-linux.xml.in
Skipping arm-linux.xml.in, use arm-linux.py instead
Skipping bfin-linux.xml.in, no longer supported
Generating i386-linux.xml.in
Generating mips-n32-linux.xml.in
Generating mips-n64-linux.xml.in
Generating mips-o32-linux.xml.in
Generating ppc64-linux.xml.in
Generating ppc-linux.xml.in
Generating s390-linux.xml.in
Generating s390x-linux.xml.in
Generating sparc64-linux.xml.in
Generating sparc-linux.xml.in
...

Update *-linux.xml.in and *-linux.xml using linux kernel tag v5.18-rc6.
2022-05-18 11:56:32 +02:00
Tamar Christina
e1e1528448 AArch64: Enable FP16 by default for Armv9-A.
In Armv9-A SVE is mandatory, and for SVE FP16 is mandatory.  This fixes a disconnect
between GCC and binutils where GCC has FP16 on by default and gas doesn't.

include/ChangeLog:

2022-05-16  Tamar Christina  <tamar.christina@arm.com>

	* opcode/aarch64.h (AARCH64_ARCH_V9_FEATURES): Add AARCH64_FEATURE_F16.
2022-05-18 10:37:10 +01:00
Jan Beulich
85aaf32e61 gas: avoid octal numbers being accepted when processing .linefile
Compilers would put decimal numbers there, so I think we should treat
finding octal numbers the same as finding bignums - ignore them as
actually being comments of some very specific form.
2022-05-18 09:38:40 +02:00
Jan Beulich
9c70556165 gas: avoid bignum related errors when processing .linefile
Any construct which to the scrubber looks like a C preprocessor
line/file "directive" is converted to .linefile, but the amount of
checking the scrubber does is minimal (albeit it does let through only
decimal digits for the line part of the contruct). Since the scrubber
conversion is further tied to # being a line comment character, anything
which upon closer inspection turns out not to be a line/file "directive"
is supposed to be treated as a comment, i.e. ignored. Therefore we
cannot use get_absolute_expression(), as this may raise errors. Open-
code the function instead, treating everything not resulting in
O_constant as a comment as well.

Furthermore also bounds-check the parsed value. This bounds check tries
to avoid implementation defined behavior (which may be the raising of an
implementation defined signal), but for now makes the assumption that
int has less than 64 bits. The way bfd_signed_vma (which is what offsetT
aliases) is defined in bfd.h for the BFD64 case I cannot really see a
clean way of avoiding this assumption. Omitting the #ifdef, otoh, would
risk "condition is always false" warnings by compilers.

Convert get_linefile_number() to return bool at this occasion as well.
2022-05-18 09:38:18 +02:00
Jan Beulich
7e6d6b62d8 gas: fold do_repeat{,_with_expander}()
do_repeat_with_expander() already deals with the "no expander" case
quite fine, so there's really little point having two functions. What it
lacks compared with do_repeat() is a call to sb_build(), which can
simply be moved (and the then redundant sb_new() be avoided). Along with
this moving also flip if the main if()'s condition such that the "no
expander" case is handled first.
2022-05-18 09:37:34 +02:00
Jan Beulich
43fe575c32 gas: don't ignore .linefile inside false conditionals
When assembling code previously pre-processed by a C compiler, long
enough comments may have been collapsed into "# <line> <file>"
constructs. If we skip these, line numbers (and possibly even file
names) will be off / wrong in both diagnostics and debug info.
2022-05-18 09:37:00 +02:00
Jan Beulich
2e55c34282 gas: simplify ignore_input()
First of all convert to switch(), in preparation of adding another
directive here which may not be ignored. While doing so drop dead code:
A string the first two characters of which do not match "if" also wont
match "ifdef" or "ifndef".
2022-05-18 09:36:00 +02:00
Jan Beulich
818432e841 gas: tweak .irp and alike file/line handling for M68K/MRI
In commit 2ee1792bec ("gas: further adjust file/line handling for .irp
and alike") I neglected the need to omit the leading . in M68K/MRI mode.
2022-05-18 09:35:29 +02:00
Xi Ruoyao
01ae03b5b9 gold: don't invoke IA32 syscall in x86_64 assembly testcase
pr17704a_test.s is a x86_64 assembly file, but it invokes IA32 exit
syscall with "int 0x80".  This causes a segfault on kernels with
CONFIG_IA32_EMULATION disabled.

gold/

	* testsuite/pr17704a_test.s (_start): Invoke x86_64 exit syscall
	instead of its IA32 counterpart.
2022-05-18 09:34:31 +02:00
GDB Administrator
ed11f0543e Automatic date update in version.in 2022-05-18 00:00:31 +00:00
Nikolaos Chatzikonstantinou
e84412c6a3 Fix typo in info page 2022-05-17 09:00:05 -06:00
Pedro Alves
a1f2ddd383 Fix gdb.python/py-connection.exp with remote targets
After the patch to make gdb_test's question non-optional when
specified, gdb.python/py-connection.exp started failing like so:

  $ make check TESTS="gdb.python/py-connection.exp" RUNTESTFLAGS="--target_board=native-gdbserver"
  (gdb) PASS: gdb.python/py-connection.exp: info connections while the connection is still around
  disconnect^M
  Ending remote debugging.^M
  (gdb) FAIL: gdb.python/py-connection.exp: kill the inferior

The problem is that "disconnect" when debugging with the native target
asks the user whether to kill the program, while with remote targets,
it doesn't.

Fix it by explicitly killing before disconnecting.

Tested with --target_board unix, native-gdbserver, and native-extended-gdbserver.

Change-Id: Icd85015c76deb84b71894715d43853c1087eba0b
2022-05-17 13:03:07 +01:00
Felix Willgerodt
49a73ab9d3 gdb, btrace: Throw an error for empty recordings when replaying starts.
This makes record_btrace_start_replaying() more consistent, as it already
errors out e.g. on a recording with only gaps.
2022-05-17 12:41:13 +02:00
Pedro Alves
ed01945057 Make gdb_test's question non-optional if specified
gdb_test supports handling scenarios where GDB asks a question before
finishing handling some command.  The full prototype of gdb_test is:

  # gdb_test COMMAND PATTERN MESSAGE QUESTION RESPONSE

However, QUESTION is a question that GDB _may_ ask, not one that GDB
_must_ ask:

 # QUESTION is a question GDB may ask in response to COMMAND, like
 #   "are you sure?"
 # RESPONSE is the response to send if QUESTION appears.

If GDB doesn't raise the question, the test still passes.

I think that this is a misfeature.  If GDB regresses and stops asking
a question, the testsuite won't notice.  So I think that if a QUESTION
is specified, gdb_test should ensure it comes out of GDB.

Running the testsuite exposed a number of tests that pass
QUESTION/RESPONSE to GDB, but no question comes out.  The previous
commits fixed them all, so this commit changes gdb_test's behavior.

A related issue is that gdb_test doesn't enforce that if you specify
QUESTION, that you also specify RESPONSE.  I.e., you should pass 1, 2,
3, or 5 arguments to gdb_test, but never 4, or more than 5.  Making
gdb_test detect bogus arguments actually regressed some testcases,
also all fixed in previous commits.

Change-Id: I47c39c9034e6a6841129312037a5ca4c5811f0db
2022-05-17 11:13:39 +01:00
Pedro Alves
d7440bee9f gdb.base/skip.exp: Don't abuse gdb_test's question support
gdb.base/skip.exp abuses gdb_test's support for answering a GDB
question to do this:

    # With gcc 9.2.0 we jump once back to main before entering foo here.
    # If that happens try to step a second time.
    gdb_test "step" "foo \\(\\) at.*" "step 3" \
	"main \\(\\) at .*\r\n$gdb_prompt " "step"

After a patch later in this series, gdb_test will FAIL if GDB does NOT
issue the question, so this test would start failing on older GCCs.

Switch to using gdb_test_multiple instead.  There are three spots in
the file that have the same pattern, and they're actually in a
sequence of commands that is repeated those 3 times.  Factor all that
out to a procedure.

I don't have gcc 9.2 handy, but I do have gcc 6.5, and that one is
affected as well, so update the comment.

Change-Id: If0a7e3cdf5191b4eec95ce0c8845c3a4d801c39e
2022-05-17 11:08:22 +01:00
Pedro Alves
8d08cccb01 Avoid having to unload file in gdb.server/connect-with-no-symbol-file.exp
gdb.server/connect-with-no-symbol-file.exp's connect_no_symbol_file
does:

	gdb_test "file" ".*" "discard symbol table" \
	    {Discard symbol table from `.*'\? \(y or n\) } "y"

A following patch will make gdb_test expect the question out of GDB if
one is passed down as argument to gdb_test.  With that, this test
starts failing.  This is because connect_no_symbol_file is called in a
loop, and the first time around, there's a loaded file, so "file" asks
the "Discard symbol table ... ?" question, while in the following
iterations there's no file, so there's no question.

Fix this by not loading a file into GDB in the first place.

Change-Id: I810c036b57842c4c5b47faf340466b0d446d1abc
2022-05-17 10:31:36 +01:00
Pedro Alves
1fe69430d1 Fix bogus gdb_test invocations
A following patch will make gdb_test error out if bogus arguments are
passed, which exposed bugs in a few testcases:

 - gdb.python/py-parameter.exp, passing a spurious "1" as extra
   parameter, resulting in:

   ERROR: Unexpected arguments: {set test-file-param bar.txt} {The name of the file has been changed to bar.txt} {set new file parameter} 1

 - gdb.python/py-xmethods.exp, a missing test message, resulting in
   the next gdb_test being interpreted as message, question and
   response!  With the enforcing patch, this was caught with:

   ERROR: Unexpected arguments: {p g.mul<char>('a')} {From Python G<>::mul.*} gdb_test {p g_ptr->mul<char>('a')} {From Python G<>::mul.*} {after: g_ptr->mul<char>('a')}

 - gdb.base/pointers.exp, missing a quote.

Change-Id: I66f2db4412025a64121db7347dfb0b48240d46d4
2022-05-17 10:31:36 +01:00
Pedro Alves
35b72e4e5b gdb.base/scope.exp: Remove bogus gdb_test questions
This test is abusing the QUESTION/RESPONSE feature to send an
alternative command to GDB if the first command fails.  Like so:

   gdb_test "print 'scope0.c'::filelocal" \
	    "\\\$$decimal = 1" "print 'scope0.c'::filelocal at main" \
	    "No symbol \"scope0.c\" in current context.*" \
	    "print '$srcdir/$subdir/scope0.c'::filelocal"

So if 'scope0.c' doesn't work, we try again with
'$srcdir/$subdir/scope0.c'.  I strongly suspect this is really an
obsolete test.  I think that if '$srcdir/$subdir/scope0.c' works, then
'scope0.c' should have worked too, thus I'd think that if we pass due
to the question path, then it's a bug.  So just remove the question
part passed to gdb_test.

Change-Id: I2acc99285f1d519284051b49693b5441fbdfe3cd
2022-05-17 10:31:36 +01:00
Pedro Alves
bc6004dfd2 Remove gdb_test questions that GDB doesn't ask
Change-Id: Ib2616dc883e9dc9ee100f6c86d83a921a0113c16
2022-05-17 10:31:35 +01:00
Nelson Chu
035784e345 RISC-V: Added half-precision floating-point v1.0 instructions.
bfd/
	* elfxx-riscv.c (riscv_implicit_subsets): Added implicit f
	and zicsr for zfh.
	(riscv_supported_std_z_ext): Added default v1.0 version for zfh.
	(riscv_multi_subset_supports): Handle INSN_CLASS_ZFH,
	INSN_CLASS_D_AND_ZFH and INSN_CLASS_Q_AND_ZFH.
gas/
	* config/tc-riscv.c (FLT_CHARS): Added "hH".
	(macro): Expand Pseudo M_FLH and M_FSH.
	(riscv_pseudo_table): Added .float16 directive.
	* testsuite/gas/riscv/float16-be.d: New testcase for .float16.
	* testsuite/gas/riscv/float16-le.d: Likewise.
	* testsuite/gas/riscv/float16.s: Likewise.
	* testsuite/gas/riscv/fp-zfh-insns.d: New testcase for zfh.
	* testsuite/gas/riscv/fp-zfh-insns.s: Likewise.
include/
	* opcode/riscv-opc.h: Added MASK and MATCH encodings for zfh.
	* opcode/riscv.h: Added INSN_CLASS and pseudo macros for zfh.
opcodes/
	* riscv-opc.c (riscv_opcodes): Added zfh instructions.
2022-05-17 13:31:38 +08:00
GDB Administrator
626d0e40e5 Automatic date update in version.in 2022-05-17 00:00:35 +00:00
Ilya Leoshkevich
973773de93 IBM zSystems: Fix left-shifting negative PCRel32 values (PR gas/29152)
s390_insert_operand ()'s val, min and max are encoded PCRel32 values
and need to be left-shifted by 1 before being shown to the user.
Left-shifting negative values is undefined behavior in C, but the
current code does not try to prevent it, causing UBSan to complain.

Fix by casting the values to their unsigned equivalents before
shifting.
2022-05-16 22:00:17 +02:00
Pedro Alves
187075ebbc Reindent gdbsupport/event-loop.cc:handle_file_event
The handle_file_event function has a few unnecessary {} lexical
blocks, presumably because they were originally if blocks, and the
conditions were removed, or something along those lines.

Remove the unnecessary blocks, and reindent.

Change-Id: Iaecbe5c9f4940a80b81dbbc42e51ce506f6aafb2
2022-05-16 19:58:08 +01:00
Pedro Alves
36a5b37053 gdbsupport/event-loop.cc: simplify !HAVE_POLL paths
gdbsupport/event-loop.cc throughout handles the case of use_poll being
true on a system where HAVE_POLL is not defined, by calling
internal_error if that situation ever happens.

Simplify this by moving the "use_poll" global itself under HAVE_POLL,
so that it's way more unlikely to ever end up in such a situation.
Then, move the code that checks the value of use_poll under HAVE_POLL
too, and remove the internal_error calls.  Like, from:

    if (use_poll)
      {
  #ifdef HAVE_POLL
        // poll code
  #else
      internal_error (....);
  #endif /* HAVE_POLL */
      }
    else
      {
	// select code
      }

to

  #ifdef HAVE_POLL
    if (use_poll)
      {
        // poll code
      }
    else
  #endif /* HAVE_POLL */
      {
	// select code
      }

While at it, make use_poll be a bool.  The current code is using
unsigned char most probably to save space, but I don't think it really
matters here.

Co-Authored-By: Youling Tang <tangyouling@loongson.cn>
Change-Id: I0dd74fdd4d393ccd057906df4cd75e8e83c1cdb4
2022-05-16 19:54:20 +01:00
Eli Zaretskii
e90601a4f1 gdb: Fix typo in last change in gdb.texinfo 2022-05-16 19:46:06 +03:00
Eli Zaretskii
8c9b320a8e gdb: Document the 'metadata' styling in GDB displays.
The 'metadata' styling was never documented in the GDB manual.
This fills that gap.
2022-05-16 19:03:59 +03:00
Tom Tromey
1779689128 Fix Ada exception regression on Windows
The breakpoint c++-ification series introduced another bug in Ada --
it caused "catch exception" and related commands to fail on Windows.
The problem is that the re_set method calls the wrong superclass
method, so the breakpoint doesn't get correctly re-set when the
runtime offsets change.  This patch fixes the problem.
2022-05-16 09:08:43 -06:00
Bruno Larsen
cdd4206647 gdb/testsuite: fix "continue outside of loop" TCL errors
Many test cases had a few lines in the beginning that look like:

if { condition } {
  continue
}

Where conditions varied, but were mostly in the form of ![runto_main] or
[skip_*_tests], making it quite clear that this code block was supposed
to finish the test if it entered the code block. This generates TCL
errors, as most of these tests are not inside loops.  All cases on which
this was an obvious mistake are changed in this patch.
2022-05-16 10:07:43 -03:00
GDB Administrator
b7ff32f191 Automatic date update in version.in 2022-05-16 00:00:37 +00:00
GDB Administrator
6d8b70895c Automatic date update in version.in 2022-05-15 00:00:21 +00:00
GDB Administrator
0b99131d48 Automatic date update in version.in 2022-05-14 00:00:19 +00:00
Tom Tromey
5400535a70 Remove unused field cooked_index::m_start
cooked_index::m_start is unused and can be removed.  I think this was
a leftover from a previous approach in the index finalization code,
and then when rewriting it I forgot to remove it.

Tested by rebuilding.
2022-05-13 13:47:39 -06:00
Tom Tromey
fcab58390f Implement pid_to_exec_file for Windows in gdbserver
I noticed that gdbserver did not implement pid_to_exec_file for
Windows, while gdb did implement it.  This patch moves the code to
nat/windows-nat.c, so that it can be shared.  This makes the gdbserver
implementation trivial.
2022-05-13 08:21:16 -06:00
Tom Tromey
4eab18b566 Remove windows_process_info::id
I noticed that windows_process_info::id is only used by gdbserver, and
not really necessary.  This patch removes it.
2022-05-13 08:21:16 -06:00
Tom Tromey
0e90c44162 Constify target_pid_to_exec_file
This changes target_pid_to_exec_file and target_ops::pid_to_exec_file
to return a "const char *".  I couldn't build many of these targets,
but did examine the code by hand -- also, as this only affects the
return type, it's normally pretty safe.  This brings gdb and gdbserver
a bit closer, and allows for the removal of a const_cast as well.
2022-05-13 08:21:16 -06:00
Tom Tromey
f1025b233f Put corefile-run.core into test subdirectory
I noticed that corefile-run.core ends up in the 'runtest' directory.
It's better, when at all possible, for test files to end up in the
test's designated subdirectory.  This patch makes this change.
2022-05-13 08:16:31 -06:00
Tom Tromey
28c5801a94 Do not double-read minimal symbols for PE COFF
This changes coffread.c to avoid re-reading minimal symbols when
possible.  This only works when there are no COFF symbols to be read,
but at least for my mingw builds of gdb, this seems to be the case.

Tested using the AdaCore internal test suite on Windows.  I also did
some local builds to ensure that no warnings crept in.
2022-05-13 08:06:12 -06:00