Alan Modra [Wed, 1 Jun 2022 07:22:58 +0000 (16:52 +0930)]
asan: NULL deref in scan_unit_for_symbols
Since commit
b43771b045 it has been possible to look up addresses
that match a unit with errors, since ranges are added to a trie while
the unit is being parsed. On error, parse_comp_unit leaves
first_child_die_ptr NULL which results in a NULL info_ptr being passed
to scan_unit_for_symbols. Fix this by setting unit->error.
Also wrap some overlong lines, and fix some formatting errors.
* dwarf2.c: Formatting.
(parse_comp_unit): Set unit->error on err_exit path.
GDB Administrator [Thu, 2 Jun 2022 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Wed, 1 Jun 2022 17:29:40 +0000 (19:29 +0200)]
[gdb] Fix warning in foreach_arch selftests
When running the selftests, I run into:
...
$ gdb -q -batch -ex "maint selftest"
...
Running selftest execute_cfa_program::aarch64:ilp32.
warning: A handler for the OS ABI "GNU/Linux" is not built into this
configuration of GDB. Attempting to continue with the default aarch64:ilp32
settings.
...
and likewise for execute_cfa_program::i8086 and
execute_cfa_program::ia64-elf32.
The warning can easily be reproduced outside the selftests by doing:
...
$ gdb -q -batch -ex "set arch aarch64:ilp32"
...
and can be prevented by first doing "set osabi none".
Fix the warning by setting osabi to none while doing selftests that iterate
over all architectures.
Tested on x86_64-linux.
Tom Tromey [Tue, 24 May 2022 16:15:17 +0000 (10:15 -0600)]
Add gdb.current_language and gdb.Frame.language
This adds the gdb.current_language function, which can be used to find
the current language without (1) ever having the value "auto" or (2)
having to parse the output of "show language".
It also adds the gdb.Frame.language, which can be used to find the
language of a given frame. This is normally preferable if one has a
Frame object handy.
Yvan Roux [Wed, 1 Jun 2022 11:08:00 +0000 (11:08 +0000)]
[arm] Don't use special treatment for PC
In an exception frame the PC register is extracted from the stack
just like other base registers, so there is no need for a special
treatment.
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com>
Signed-off-by: Yvan Roux <yvan.roux@foss.st.com>
Yvan Roux [Wed, 1 Jun 2022 11:08:00 +0000 (11:08 +0000)]
[arm] Add support for FPU registers in prologue unwinder
The prologue unwinder had support for FPU registers, but only to
calculate the correct offset on the stack, the values were not saved.
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com>
Signed-off-by: Yvan Roux <yvan.roux@foss.st.com>
Yvan Roux [Wed, 1 Jun 2022 11:08:00 +0000 (11:08 +0000)]
[arm] d0..d15 are 64-bit each, not 32-bit
When unwinding the stack, the floating point registers d0 to d15
need to be handled as double words, not words.
Only the first 8 registers have been confirmed fixed with this patch
on a STM32F407-DISC0 board, but the upper 8 registers on Cortex-M33
should be handled in the same way.
The test consisted of running a program compiled with float-abi=hard.
In the main function, a function taking a double as an argument was
called. After the function call, a hardware timer was used to
trigger an interrupt.
In the debug session, a breakpoint was set in the function called
from main to verify the content of the registers using "info float"
and another breakpoint in the interrupt handler was used to check
the same registers using "info float" on frame 2 (the frame just
before the dummy frame created for the signal handler in gdb).
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com>
Signed-off-by: Yvan Roux <yvan.roux@foss.st.com>
Yvan Roux [Wed, 1 Jun 2022 11:08:00 +0000 (11:08 +0000)]
[arm] Cleanup: use hex for offsets
Changed offset from decimal to hex to match architecture reference
manual terminology and keep coherency with the rest of the code.
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com>
Signed-off-by: Yvan Roux <yvan.roux@foss.st.com>
Jiangshuai Li [Wed, 1 Jun 2022 06:46:01 +0000 (14:46 +0800)]
gdb:csky save fpu and vdsp info to struct csky_gdbarch_tdep
First, add three variables fpu_abi, fpu_hardfp and vdsp_version
to csky_gdbarch_tdep. They will be initialized from info.abfd in
cskg_gdbarch_init.
Now, they are just used to find a candidate among the list of pre-declared
architectures
Later, they will be used in gdbarch_return_value and gdbarch_push_dummy_call
for funtions described below:
fpu_abi: to check if the bfd is using VAL_CSKY_FPU_ABI_HARD or
VAL_CSKY_FPU_ABI_SOFT
fpu_hardfp: to check if the bfd is using VAL_CSKY_FPU_HARDFP_SINGLE
or VAL_CSKY_FPU_HARDFP_DOUBLE
vdsp_version: to check if a function is returned with CSKY_VRET_REGNUM
Alan Modra [Wed, 1 Jun 2022 01:14:01 +0000 (10:44 +0930)]
Re: use libiberty xmalloc in bfd/doc/chew.c
We can't use libiberty.a in chew. libiberty is a host library, chew
a build program. Partly revert commit
7273d78f3f7a, instead define
local versions of the libiberty functions. ansidecl.h also isn't
needed.
* doc/chew.c: Don't include libiberty.h or ansidecl.h.
(xmalloc, xrealloc, xstrdup): New functions.
* doc/local.mk (LIBIBERTY): Don't define or use.
* Makefile.in: Regenerate.
GDB Administrator [Wed, 1 Jun 2022 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Tue, 31 May 2022 22:38:19 +0000 (15:38 -0700)]
x86: Properly handle IFUNC function pointer reference
Update
commit
68c4956b1401de70173848a6bdf620cb42fa9358
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Tue Apr 26 09:08:54 2022 -0700
x86: Properly handle function pointer reference
to properly handle IFUNC function pointer reference. Since IFUNC symbol
value is only known at run-time, set pointer_equality_needed for IFUNC
function pointer reference in PDE so that it will be resolved to its PLT
entry directly.
bfd/
PR ld/29216
* elf32-i386.c (elf_i386_scan_relocs): Set pointer_equality_needed
for IFUNC function pointer reference in PDE.
* elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise.
ld/
PR ld/29216
* testsuite/ld-ifunc/ifunc.exp: Run PR ld/29216 test.
* testsuite/ld-ifunc/pr29216.c: New file.
H.J. Lu [Tue, 31 May 2022 21:55:41 +0000 (14:55 -0700)]
i386: Ajdust more tests for opcodes/i386: remove trailing whitespace
This fixes:
FAIL: Build ifunc-1a with -z ibtplt
FAIL: Build ifunc-1a with PIE -z ibtplt
FAIL: Build libno-plt-1b.so
FAIL: No PLT (dynamic 1a)
FAIL: No PLT (dynamic 1b)
FAIL: No PLT (dynamic 1c)
FAIL: No PLT (static 1d)
FAIL: No PLT (PIE 1e)
FAIL: No PLT (PIE 1f)
FAIL: No PLT (PIE 1g)
FAIL: No PLT (dynamic 1h)
FAIL: No PLT (dynamic 1i)
FAIL: No PLT (static 1j)
* ld-i386/libno-plt-1b.dd: Remove trailing whitespaces.
* ld-i386/no-plt-1a.dd: Likewise.
* ld-i386/no-plt-1b.dd: Likewise.
* ld-i386/no-plt-1c.dd: Likewise.
* ld-i386/no-plt-1d.dd: Likewise.
* ld-i386/no-plt-1e.dd: Likewise.
* ld-i386/no-plt-1f.dd: Likewise.
* ld-i386/no-plt-1g.dd: Likewise.
* ld-i386/no-plt-1h.dd: Likewise.
* ld-i386/no-plt-1i.dd: Likewise.
* ld-i386/no-plt-1j.dd: Likewise.
* ld-i386/plt-main-ibt.dd: Likewise.
* ld-i386/plt-pie-ibt.dd: Likewise.
Tom Tromey [Sat, 21 May 2022 15:50:13 +0000 (09:50 -0600)]
Use unique_ptr for objfiles
A while back, I changed objfiles to be held via a shared_ptr. The
idea at the time was that this was a step toward writing to the index
cache in the background, and this would let gdb keep a reference alive
to do so. However, since then we've rewritten the DWARF reader, and
the new index can do this without requiring a shared pointer -- in
fact there are patches pending to implement this.
This patch switches objfile management to unique_ptr, which makes more
sense now.
Regression tested on x86-64 Fedora 34.
Nils-Christian Kempke [Tue, 31 May 2022 14:43:45 +0000 (16:43 +0200)]
gdb/testsuite: fixup common-block.exp for intel compilers
The order in which the variables in info common and info locals are
displayed is compiler (and dwarf) dependent. While all symbols should
be displayed the order is not fixed.
I added a gdb_test_multiple that lets ifx and ifort pass in cases where
only the order differs.
Nils-Christian Kempke [Tue, 31 May 2022 14:43:45 +0000 (16:43 +0200)]
gdb, testsuite, fortran: fixup mixed-lang-stack for Intel/LLVM compilers
When value-printing a pointer within GDB by default GDB will look for
defined symbols residing at the address of the pointer. For the given
test the Intel/LLVM compiler stacks both display a symbol associated
with a printed pointer while the gnu stack does not. This leads to
failures in the test when running the test with CC_FOR_TARGET='clang'
CXX_FOR_TARGET='clang' F90_FOR_TARGET='flang'"
(gdb) b 37
(gdb) r
(gdb) f 6
(gdb) info args
a = 1
b = 2
c = 3
d = 4 + 5i
f = 0x419ed0 "abcdef"
g = 0x4041a0 <.BSS4>
or CC_FOR_TARGET='icx' CXX_FOR_TARGET='icpx' F90_FOR_TARGET='ifx'"
(gdb) b 37
(gdb) r
(gdb) f 6
(gdb) info args
a = 1
b = 2
c = 3
d = 4 + 5i
f = 0x52eee0 "abcdef"
g = 0x4ca210 <mixed_func_1a_$OBJ>
For the compiled binary the Intel/LLVM compilers both decide to move the
local variable g into the .bss section of their executable. The gnu
stack will keep the variable locally on the stack and not define a
symbol for it.
Since the behavior for Intel/LLVM is actually expected I adapted the
testcase at this point to be a bit more allowing for other outputs.
I added the optional "<SYMBOLNAME>" to the regex testing for g.
The given changes reduce the test fails for Intel/LLVM stack by 4 each.
Nils-Christian Kempke [Tue, 31 May 2022 14:43:45 +0000 (16:43 +0200)]
gdb, testsuite, fortran: fix double free in mixed-lang-stack.exp
While testing mixed-lang-stack I realized that valgrind actually
complained about a double free in the test.
All done
==
2503051==
==
2503051== HEAP SUMMARY:
==
2503051== in use at exit: 0 bytes in 0 blocks
==
2503051== total heap usage: 26 allocs, 27 frees, 87,343 bytes allocated
==
2503051==
==
2503051== All heap blocks were freed -- no leaks are possible
==
2503051==
==
2503051== For lists of detected and suppressed errors, rerun with: -s
==
2503051== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Reason for this is that in mixed-lang-stack.cpp in mixed_func_1f an
object "derived_type obj" goes on the stack which is then passed-by-value
(so copied) to mixed_func_1g. The default copy-ctor will be called but,
since derived_type contains a heap allocated string and the copy
constructor is not implemented it will only be able to shallow copy the
object. Right after each of the functions the object gets freed - on the
other hand the d'tor of derived_type actually is implemented and calls
free on the heap allocated string which leads to a double free. Instead
of obeying the rule of 3/5 I just got rid of all that since it does not
serve the test. The string is now just a const char* = ".." object
member.
Nils-Christian Kempke [Tue, 31 May 2022 14:43:45 +0000 (16:43 +0200)]
testsuite, fortran: allow additional completions in module.exp
For ifort, ifx, and flang the tests "complete modm" and "complete
modmany" fail. This is because all three emit additional completion
suggestions. These additional suggestions have their origin in symbols
emitted by the compilers which can also be completed from the respective
incomplete word (modm or modmany). For this specific example gfortran
does not emit any additional symbols.
For example, in this test the linkage name for var_a in ifx is
"modmany_mp_var_a_" while gfortran uses "__modmany_MOD_var_a" instead.
Since modmany_mp_var_a can be completed from modm and also modmany they
will get displayed, while gfortran's symbol starts with "__" and thus will
be ignored (it cannot be a completion of a word starting with "m").
Similar things happen in flang and ifort. Some example output is shown
below:
FLANG
(gdb) complete p modm
p modmany
p modmany::var_a
p modmany::var_b
p modmany::var_c
p modmany::var_i
p modmany_
IFX/IFORT
(gdb) complete p modm
p modmany
p modmany._
p modmany::var_a
p modmany::var_b
p modmany::var_c
p modmany::var_i
p modmany_mp_var_a_
p modmany_mp_var_b_
p modmany_mp_var_c_
p modmany_mp_var_i_
GFORTRAN
(gdb) complete p modm
p modmany
p modmany::var_a
p modmany::var_b
p modmany::var_c
p modmany::var_i
I want to emphasize: for Fortran (and also C/C++) the complete command
does not actually check whether its suggestions make sense - all it does
is look for any symbol (in the minimal symbols, partial symbols etc.)
that a given substring can be completed to (meaning that the given substring
is the beginning of the symbol). One can easily produce a similar
output for the gfortran compiled executable. For this look at the
slightly modified "complete p mod" in gfortran:
(gdb) complete p mod
p mod1
p mod1::var_const
...
p mod_1.c
p modcounter
p mode_t
p modf
...
p modify_ldt
p modmany
p modmany::var_a
p modmany::var_b
p modmany::var_c
p modmany::var_i
p module
p module.f90
p module_entry
p moduse
p moduse::var_x
p moduse::var_y
Many of the displayed symbols do not actually work with print:
(gdb) p mode_t
Attempt to use a type name as an expression
(gdb) p mod_1.c
No symbol "mod_1" in current context.
(gdb)
I think that in the given test the output for gfortran only looks nice
"by chance" rather than is actually expected. Expected is any output
that also contains the completions
p modmany
p modmany::var_a
p modmany::var_b
p modmany::var_c
p modmany::var_i
while anythings else can be displayed as well (depending on the
compiler and its emitted symbols).
This, I'd consider all three outputs as valid and expected - one is just
somewhat lucky that gfortran does not produce any additional symbols that
got matched.
The given patch improves test performance for all three compilers
by allowing additional suggested completions inbetween and after
the two given blocks in the test. I did not allow additional print
within the modmany_list block since the output is ordered alphabetically
and there should normally not appear any additional symbols there.
For flang/ifx/ifort I each see 2 failures less (which are exactly the two
complete tests).
As a side note and since I mentioned C++ in the beginning: I also tried
the gdb.cp/completion.exp. The output seems a bit more reasonable,
mainly since C++ actually has a demangler in place and linkage symbols
do not appear in the output of complete. Still, with a poor enough
to-be-completed string one can easily produce similar results:
(gdb) complete p t
...
p typeinfo name for void
p typeinfo name for void const*
p typeinfo name for void*
p typeinfo name for wchar_t
p typeinfo name for wchar_t const*
p typeinfo name for wchar_t*
p t *** List may be truncated, max-completions reached. ***
(gdb) p typeinfo name for void*
No symbol "typeinfo" in current context.
(gdb) complete p B
p BACK_SLASH
p BUF_FIRST
p BUF_LAST
...
p Base
p Base::Base()
p Base::get_foo()
p bad_key_err
p buf
p buffer
p buffer_size
p buflen
p bufsize
p build_charclass.isra
(gdb) p bad_key_err
No symbol "bad_key_err" in current context.
(compiled with gcc/g++ and breaking at main).
This patch is only about making the referenced test more 'fair' for the
other compilers. Generally, I find the behavior of complete a bit
confusing and maybe one wants to change this at some point but this
would be a bigger task.
Nils-Christian Kempke [Tue, 31 May 2022 14:43:45 +0000 (16:43 +0200)]
testsuite, fortran: fix info-types for intel compilers
This info-types.exp test case had a few issues that this patch fixes.
First, the emitted symbol character(kind=1)/character*1 (different
compilers use different naming converntions here) which is checkedin the
test is not actually expected given the test program. There is no
variable of that type in the test. Still, gfortran emits it for every
Fortran program there is. The reason is the way gfortran handles Fortran's
named main program. It generates a wrapper around the Fortran program
that is quite similar to a C main function. This C-like wrapper has
argc and argv arguments for command line argument passing and the argv
pointer type has a base type character(kind=1) DIE emitted at CU scope.
Given the program
program prog
end program prog
the degbug info gfortran emits looks somewhat like
<0><c>: Abbrev Number: 3 (DW_TAG_compile_unit)
...
<1><2f>: Abbrev Number: 4 (DW_TAG_subprogram)
<30> DW_AT_external : 1
<30> DW_AT_name : (indirect string, ...): main
...
<2><51>: Abbrev Number: 1 (DW_TAG_formal_parameter)
<52> DW_AT_name : (indirect string, ...): argc
...
<2><5d>: Abbrev Number: 1 (DW_TAG_formal_parameter)
<5e> DW_AT_name : (indirect string, ...): argv
...
<62> DW_AT_type : <0x77>
...
<2><6a>: Abbrev Number: 0
...
<1><77>: Abbrev Number: 6 (DW_TAG_pointer_type)
<78> DW_AT_byte_size : 8
<79> DW_AT_type : <0x7d>
<1><7d>: Abbrev Number: 2 (DW_TAG_base_type)
<7e> DW_AT_byte_size : 1
<7f> DW_AT_encoding : 8 (unsigned char)
<80> DW_AT_name : (indirect string, ...): character(kind=1)
<1><84>: Abbrev Number: 7 (DW_TAG_subprogram)
<85> DW_AT_name : (indirect string, ...): prog
...
Ifx and flang do not emit any debug info for a wrapper main method so
the type is missing here. There was the possibility of actually adding
a character*1 type variable to the Fortran executable, but both, ifx and
gfortran chose to emit this variable's type as a DW_TAG_string_type of
length one (instead of a character(kind=1), or whatever the respective
compiler naming convention is). While string types are printed as
character*LENGHT in the fortran language part (e.g. when issuing a
'ptype') they do not generate any symbols inside GDB. In read.c it says
/* These dies have a type, but processing them does not create
a symbol or recurse to process the children. Therefore we can
read them on-demand through read_type_die. */
So they did not add any output to 'info types'. Only flang did emit a
character type here.
As adding a type would have a) not solved the problem for ifx and would
have b) somehow hidden the curious behavior of gfortran, instead, the
check for this character type was chagened to optional with the
check_optional_entry to allow for the symbols's absence and to allow
flang and ifx to pass this test as well.
Second, the line checked for s1 was hardcoded as 37 in the test. Given
that the type is actually defined on line 41 (which is what is emitted by
ifx) it even seems wrong. The line check for s1 was changed to actually
check for 41 and a gfortran bug has been filed here
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105454
The test is now marked as xfail for gfortran.
Third, the whole test of checking for the 'Type s1' in info types seemed
questionable. The type s1 is declared iside the scope of the Fortran
program info_types_test. Its DIE however is emitted as a child of the
whole compilation unit making it visible outside of the program's scope.
The 'info types' command checks for types stored in the GLOBAL_BLOCK,
or STATIC_BLOCKm wgucm according to block.h
The GLOBAL_BLOCK contains all the symbols defined in this compilation
whose scope is the entire program linked together.
The STATIC_BLOCK contains all the symbols whose scope is the
entire compilation excluding other separate compilations.
so for gfortran, the type shows up in the output of 'info types'. For
flang and ifx on the other hand this is not the case. The two compilers
emit the type (correctly) as a child of the Fortran program, thus not
adding it to either, the GLOBAL_BLOCK nor the LOCAL_BLOCK. A bug has
been opened for the gfortran scoping issue:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105454
While the most correct change might have been removing the check for s1,
the change made here was to only check for this type in case of gfortran
being used as the compiler, as this check also covers the declaration
line issue mentioned above. A comment was added to maybe remove this
check once the scoping issue is resolved (and it starts to fail with
newer gfortran versions). The one used to test these changes was 13.0.
Nils-Christian Kempke [Tue, 31 May 2022 14:43:44 +0000 (16:43 +0200)]
testsuite/lib: add check_optional_entry for GDBInfoSymbols
There was already a similar functionality for the GDBInfoModuleSymbols.
This just extends the GDBInfoSymbols. We will use this feature in a
later commit to make a testcase less GNU specific and more flexible for
other compilers.
Namely, in gdb.fortran/info-types.exp currenlty
GDBInfoSymbols::check_entry is used to verify and test the output of the
info symbols command. The test, however was written with gfortran as a
basis and some of the tests are not fair with e.g. ifx and ifort as
they test for symbols that are not actually required to be emitted. The
lines
GDBInfoSymbols::check_entry "${srcfile}" "" "${character1}"
and
GDBInfoSymbols::check_entry "${srcfile}" "37" "Type s1;"
check for types that are either not used in the source file (character1)
or should not be emitted by the compiler at global scope (s1) thus no
appearing in the info symbols command. In order to fix this we will
later use the newly introduced check_optional_entry over check_entry.
Nils-Christian Kempke [Tue, 31 May 2022 14:43:44 +0000 (16:43 +0200)]
testsuite, fortran: Add '-debug-parameters all' when using ifx/ifort
In order for ifx and ifort to emit all debug entries, even for unused
parameters in modules we have to define the '-debug-parameters all' flag.
This commit adds it to the ifx-*/ifort-* specific flags in gdb.exp.
Nils-Christian Kempke [Tue, 31 May 2022 14:43:44 +0000 (16:43 +0200)]
testsuite, fortran: add compiler dependent types to dynamic-ptype-whatis
The test was earlier not using the compiler dependent type print system
in fortran.exp. I changed this. It should generally improve the test
performance for different compilers. For ifx and gfortran I do not see
any failures.
Nils-Christian Kempke [Tue, 31 May 2022 14:43:44 +0000 (16:43 +0200)]
testsuite, fortran: add required external keyword
Currenlty, ifx/ifort cannot compile the given executable as it is not
valid Fortran. It is missing the external keyword on the
no_arg_subroutine. Gfortran compiles the example but this is actually
a bug and there is an open gcc ticket for this here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50377
Adding the keyword does not change the gfortran compiling of the example.
It will, however, prevent a future fail once 50377 has been addressed.
Nils-Christian Kempke [Tue, 31 May 2022 14:43:44 +0000 (16:43 +0200)]
gdb/testsuite: disable charset.exp for intel compilers
The test specifically tests for the Fortran CHARACTER(KIND=4) which is
not available in ifx/ifort.
Since the other characters are also printed elsewhere, we disable this
test for the unsupported compilers.
Nils-Christian Kempke [Tue, 31 May 2022 14:43:44 +0000 (16:43 +0200)]
gdb/testsuite: rename intel next gen c/cpp compilers
The name for icx and icpx in the testsuite was earlier set to 'intel-*'
by the compiler identification. This commit changes this to 'icx-*'.
Note, that currently these names are not used within the testsuite so no
tests have to be adapted here.
Cristian Sandu [Tue, 31 May 2022 14:43:44 +0000 (16:43 +0200)]
gdb/testsuite: add Fortran compiler identification to GDB
This commit adds a separate Fortran compiler identification mechanism to
the testsuite, similar to the existing one for C/C++. Before this
change, the options and version for the Fortran compiler specified when
running the testsuite with F90_FOR_TARGET set, was detected via its
respective C compiler. So running the testsuite as
make check TEST=gdb.fortran/*.exp CC_FOR_TARGET=gcc F90_FOR_TARGET=ifx
or even
make check TEST=gdb.fortran/*.exp F90_FOR_TARGET=ifx
would use the gcc compiler inside the procedures get_compiler_info and
test_compiler_info to identify compiler flags and the compiler version.
This could sometimes lead to unpredictable outputs. It also limited
testsuite execution to combinations where C and Fortran compiler would
come from the same family of compiers (gcc/gfortran, icc/ifort, icx/ifx,
clang/flang ..). This commit enables GDB to detect C and Fortran
compilers independently of each other.
As most/nearly all Fortran compilers have a mechanism for preprocessing
files in a C like fashion we added the exact same meachnism that already
existed for C/CXX. We let GDB preprocess a file with the compilers
Fortran preprocessor and evaluate the preprocessor defined macros in that
file.
This enables GDB to properly run heterogeneous combinations of C and
Fortran compilers such as
CC_FOR_TARGET='gcc' and F90_FOR_TARGET='ifort'
or enables one to run the testsuite without specifying a C compiler as in
make check TESTS=gdb.fortran/*.exp F90_FOR_TARGET='ifx'
make check TESTS=gdb.fortran/*.exp F90_FOR_TARGET='flang'
On the other hand this also requires one to always specify a
identification mechanism for Fortran compilers in the compiler.F90 file.
We added identification for GFORTRAN, FLANG (CLASSIC and LLVM) IFX,
IFORT, and ARMFLANG for now.
Classic and LLVM flang were each tested with their latest releases on
their respective release pages. Both get recognized by the new compiler
identification and we introduced the two names flang-classic and
flang-llvm to distinguish the two. While LLVM flang is not quite mature
enough yet for running the testsuite we still thought it would be a good
idea to include it already. For this we added a case for the fortran_main
procedure. LLVM flang uses 'MAIN__' as opposed to classic flang which
uses 'MAIN_' here.
We did not have the possibility to test ARMFLANG - the versioning scheme
here was extracted from its latest online documentation.
We changed the test_compiler_info procedure to take another optional
argument, the language string, which will be passed though to the
get_compiler_info procedure. Passing 'f90' or 'c++' here will then
trigger the C++/Fortran compiler identification within
get_compiler_info. The latter procedure was extended to also handle
the 'f90' argument (similarly to the already existing 'c++' one).
Co-authored-by: Nils-Christian Kempke <nils-christian.kempke@intel.com>
Nils-Christian Kempke [Tue, 31 May 2022 14:43:43 +0000 (16:43 +0200)]
gdb/testsuite: move getting_compiler_info to front of gdb_compile
The procedure gdb_compile queries its options via
[lsearch -exact $options getting_compiler_info]
to check whether or not it was called in with the option
getting_compiler_info. If it was called with this option it would
preprocess some test input to try and figure out the actual compiler
version of the compiler used. While doing this we cannot again try to
figure out the current compiler version via the 'getting_compiler_info'
option as this would cause infinite recursion. As some parts of the
procedure do recursively test for the compiler version to e.g. set
certain flags, at several places gdb_compile there are checks for the
getting_compiler_info option needed.
In the procedure, there was already a variable 'getting_compiler_info'
which was set to the result of the 'lsearch' query and used instead of
again and again looking for getting_compiler_info in the procedure
options. But, this variable was actually set too late within the code.
This lead to a mixture of querying 'getting_compiler_info' or
doing an lserach on the options passed to the procedure.
I found this inconsistent and instead moved the variable
getting_compiler_info to the front of the procedure. It is set to true
or false depending on whether or not the argument is found in the
procedure's options (just as before) and queried instead of doing an
lsearch on the procedure options in the rest of the procedure.
Felix Willgerodt [Tue, 31 May 2022 14:43:43 +0000 (16:43 +0200)]
gdb/testsuite: Fix fortran types for Intel compilers.
Newer Intel compilers emit their dwarf type name in a slightly different
format. Therefore, this needs adjustment to make more tests pass in the
Fortran testsuite.
Co-authored-by: Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
Co-authored-by: Nils-Christian Kempke <nils-christian.kempke@intel.com>
Abdul Basit Ijaz [Tue, 31 May 2022 14:43:43 +0000 (16:43 +0200)]
gdb/testsuite: Use -module option for Intel Fortran compilers
The '-J' option is not supported in Intel compilers (ifx and ifort).
The Intel version of the flag is '-module' which serves the same purpose.
Nils-Christian Kempke [Tue, 31 May 2022 14:43:43 +0000 (16:43 +0200)]
gdb/testsuite: remove F77_FOR_TARGET support
The last uses of the F77_FOR_TARGET via passing f77 to GDB's compile
procedure were removed in this commit
commit
0ecee54cfd04a60e7ca61ae07c72b20e21390257
Author: Tom Tromey <tromey@redhat.com>
Date: Wed Jun 29 17:50:47 2011 +0000
over 10 years ago. The last .f files in the testsuite by now are all
being compiled by passing 'f90' to the GDB compile, thus only actually
using F90_FOR_TARGET (array-element.f, block-data.f, subarray.f).
Gfortran in this case is backwards compatible with most f77 code as
claimed on gcc.gnu.org/fortran.
The reason we'd like to get rid of this now is, that we'll be
implementing a Fortran compiler identification mechanism, similar to the
C/Cpp existing ones. It would be using the Fortran preprocessor macro
defines to identify the Fortran compiler version at hand. We found it
inconsequent to only implement this for f90 but, on the other hand, f77
seems deprecated. So, with this commit we remove the remaining lines for
its support.
Pedro Alves [Tue, 31 May 2022 09:54:17 +0000 (10:54 +0100)]
Improve clear command's documentation
Co-Authored-By: Eli Zaretskii <eliz@gnu.org>
Change-Id: I9440052fd28f795d6f7c93a4576beadd21f28885
Pedro Alves [Tue, 31 May 2022 12:36:32 +0000 (13:36 +0100)]
Clarify why we unit test matching symbol names with 0xff characters
In the name matching unit tests in gdb/dwarf2/read.c, explain better
why we test symbols with \377 / 0xff characters (Latin1 'ÿ').
Change-Id: I517f13adfff2e4d3cd783fec1d744e2b26e18b8e
Pedro Alves [Tue, 31 May 2022 11:18:49 +0000 (12:18 +0100)]
Improve break-range's documentation
Change-Id: Iac26e1d2e7d8dc8a7d9516e6bdcc5c3fc4af45c8
Pedro Alves [Tue, 31 May 2022 11:06:50 +0000 (12:06 +0100)]
Explicitly mention yet-unloaded shared libraries in location spec examples
Change-Id: I05639ddb3bf620c7297b57ed286adc3aa926b7b6
Alan Modra [Tue, 31 May 2022 11:29:04 +0000 (20:59 +0930)]
sparc64 segfault in finish_dynamic_symbol
SYMBOL_REFERENCES_LOCAL can return true for undefined symbols. This
can result in a segfault when running sparc64 ld/testsuite/ld-vsb
tests that expect a failure.
* elfxx-sparc.c (_bfd_sparc_elf_finish_dynamic_symbol): Don't
access u.def.section on non-default visibility undefined symbol.
Alan Modra [Tue, 31 May 2022 11:26:39 +0000 (20:56 +0930)]
ia64 gas: Remove unnecessary init
The whole struct is cleared by alloc_record.
* config/tc-ia64.c (output_prologue, output_prologue_gr): Don't
zero r.record.r.mask.
Alan Modra [Tue, 31 May 2022 11:22:42 +0000 (20:52 +0930)]
v850_elf_set_note prototype
v850_elf_set_note is declared using an unsigned int note param in
elf32-v850.h but defined with enum c850_notes note in elf32-v850.c.
Current mainline gcc is warning about this. Huh.
* elf32-v850.c (v850_elf_set_note): Make "note" param an
unsigned int.
Alan Modra [Tue, 31 May 2022 07:29:12 +0000 (16:59 +0930)]
Import libiberty from gcc
PR 29200
include/
* ansidecl.h,
* demangle.h: Import from gcc.
libiberty/
* cp-demangle.c,
* testsuite/demangle-expected: Import from gcc.
Andrew Burgess [Tue, 31 May 2022 08:21:20 +0000 (09:21 +0100)]
gdb/testsuite: resolve duplicate test name in gdb.trace/signal.exp
Spotted a duplicate test name in gdb.trace/signal.exp, resolved in
this commit by making use of 'with_test_prefix'.
Alan Modra [Tue, 31 May 2022 01:49:03 +0000 (11:19 +0930)]
Ajdust more tests for opcodes/i386: remove trailing whitespace
git commit
202be274a4 also missed adjusting a few testsuite files.
This fixes
i686-vxworks +FAIL: VxWorks shared library test 1
i686-vxworks +FAIL: VxWorks executable test 1 (dynamic)
Alan Modra [Tue, 31 May 2022 01:37:37 +0000 (11:07 +0930)]
Trailing spaces in objdump -r header
git commit
202be274a4 went a little wild in removing trailing spaces
in gas/testsuite/gas/i386/{secidx.d,secrel.d}, causing
x86_64-w64-mingw32 +FAIL: i386 secrel reloc
x86_64-w64-mingw32 +FAIL: i386 secidx reloc
I could have just replaced the trailing space, but let's fix the
objdump output instead. Touches lots of testsuite files.
GDB Administrator [Tue, 31 May 2022 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Mon, 30 May 2022 16:54:47 +0000 (12:54 -0400)]
gdb/testsuite: fix gdb.trace/signal.exp on x86
Patch
202be274a41a ("opcodes/i386: remove trailing whitespace from insns with zero operands")
causes this regression:
FAIL: gdb.trace/signal.exp: find syscall insn in kill
It's because the test still expects to match a whitespace after the
instruction, which the patch mentioned above removed. Remove the
whitespaces for the regexp.
Change-Id: Ie194273cc942bfd91332d4035f6eec55b7d3a428
Pedro Alves [Tue, 17 May 2022 12:12:04 +0000 (13:12 +0100)]
gdb/manual: Introduce location specs
The current "Specify Location" section of the GDB manual starts with:
"Several @value{GDBN} commands accept arguments that specify a location
of your program's code."
And then, such commands are documented as taking a "location"
argument. For example, here's a representative subset:
@item break @var{location}
@item clear @var{location}
@item until @var{location}
@item list @var{location}
@item edit @var{location}
@itemx info line @var{location}
@item info macros @var{location}
@item trace @var{location}
@item info scope @var{location}
@item maint agent @r{[}-at @var{location}@r{,}@r{]} @var{expression}
The issue here is that "location" isn't really correct for most of
these commands. Instead, the "location" argument is really a
placeholder that represent an umbrella term for all of the
"linespecs", "explicit location", and "address location" input
formats. GDB parses these and then finds the actual code locations
(plural) in the program that match. For example, a "location"
specified like "-function func" will actually match all the code
locations in the program that correspond to the address/file/lineno of
all the functions named "func" in all the loaded programs and shared
libraries of all the inferiors. A location specified like "-function
func -label lab" matches all the addresses of C labels named "lab" in
all functions named "func". Etc.
This means that several of the commands that claim they accept a
"location", actually end up working with multiple locations, and the
manual doesn't explain that all that well. In some cases, the command
will work with all the resolved locations. In other cases, the
command aborts with an error if the location specification resolves to
multiple locations in the program. In other cases, GDB just
arbitrarily and silently picks whatever is the first resolved code
location (which sounds like should be improved).
To clarify this, I propose we use the term "Location Specification",
with shorthand "locaction spec", when we're talking about the user
input, the argument or arguments that is/are passed to commands to
instruct GDB how to find locations of interest. This is distinct from
the actual code locations in the program, which are what GDB finds
based on the user-specified location spec. Then use "location
specification or the shorter "location spec" thoughout instead of
"location" when we're talking about the user input.
Thus, this commit does the following:
- renames the "Specify Location" section of the manual to "Location
Specifications".
- It then introduces the term "Location Specification", with
corresponding shorthand "location spec", as something distinct from
an actual code location in the program. It explains what a concrete
code location is. It explains that a location specification may be
incomplete, and that may match multiple code locations in the
program, or no code location at all. It gives examples. Some
pre-existing examples were moved from the "Set Breaks" section, and
a few new ones that didn't exist yet were added. I think it is
better to have these centralized in this "Location Specification"
section, since all the other commands that accept a location spec
have an xref that points there.
- Goes through the manual, and where "@var{location}" was used for a
command argument, updated it to say "@var{locspec}" instead. At the
same time, tweaks the description of the affected commands to
describe what happens when the location spec resolves to more than
one location. Most commands just did not say anything about that.
One command -- "maint agent -at @var{location}" -- currently says it
accepts a "location", suggesting it can accept address and explicit
locations too, but that's incorrect. In reality, it only accepts
linespecs, so fix it accordingly.
One MI command -- "-trace-find line" -- currently says it accepts a
"line specification", but it can accept address and explicit
locations too, so fix it accordingly.
Special thanks goes to Eli Zaretskii for reviews and rewording
suggestions.
Change-Id: Ic42ad8565e79ca67bfebb22cbb4794ea816fd08b
Luis Machado [Wed, 27 Apr 2022 14:49:04 +0000 (15:49 +0100)]
Move 64-bit BFD files from ALL_TARGET_OBS to ALL_64_TARGET_OBS
Doing a 32-bit build with "--enable-targets=all --disable-sim" fails to link
properly.
--
loongarch-tdep.o: In function `loongarch_gdbarch_init':
binutils-gdb/gdb/loongarch-tdep.c:443: undefined reference to `loongarch_r_normal_name'
loongarch-tdep.o: In function `loongarch_fetch_instruction':
binutils-gdb/gdb/loongarch-tdep.c:37: undefined reference to `loongarch_insn_length'
loongarch-tdep.o: In function `loongarch_scan_prologue(gdbarch*, unsigned long long, unsigned long long, frame_info*, trad_frame_cache*) [clone .isra.4]':
binutils-gdb/gdb/loongarch-tdep.c:87: undefined reference to `loongarch_insn_length'
binutils-gdb/gdb/loongarch-tdep.c:88: undefined reference to `loongarch_decode_imm'
binutils-gdb/gdb/loongarch-tdep.c:89: undefined reference to `loongarch_decode_imm'
binutils-gdb/gdb/loongarch-tdep.c:90: undefined reference to `loongarch_decode_imm'
binutils-gdb/gdb/loongarch-tdep.c:91: undefined reference to `loongarch_decode_imm'
binutils-gdb/gdb/loongarch-tdep.c:92: undefined reference to `loongarch_decode_imm'
--
Given the list of 64-bit BFD files in
opcodes/Makefile.am:TARGET64_LIBOPCODES_CFILES, it looks like GDB's
ALL_TARGET_OBS list is including files that should be included in
ALL_64_TARGET_OBS instead.
This patch accomplishes this and enables a 32-bit build with
"--enable-targets=all --disable-sim" to complete.
Moving the bpf, tilegx and loongarch files to the correct list means GDB can
find the correct disassembler function instead of finding a null pointer.
We still need the "--disable-sim" switch (or "--enable-64-bit-bfd") to
make a 32-bit build with "--enable-targets=all" complete correctly
Luis Machado [Tue, 24 May 2022 18:11:35 +0000 (19:11 +0100)]
Fix failing test for armeb-gnu-eabi
The following test fails on the armeb-gnu-eabi target:
FAIL: Unwind information for Armv8.1-M.Mainline PACBTI extension
This patch adjusts the expected output for big endian.
Alan Modra [Mon, 30 May 2022 07:34:53 +0000 (17:04 +0930)]
Use a union to avoid casts in bfd/doc/chew.c
This fixes -Wpedantic warnings in chew.c. Conversion between function
and object pointers is not guaranteed. They can even be different
sizes, not that we're likely to encounter build machines like that
nowadays.
PR 29194
* doc/chew.c (pcu): New union typedef.
(dict_type, pc): Use it here. Adjust uses of pc.
(add_to_definition): Make "word" param a pcu. Adjust all uses
of function.
(stinst_type): Delete.
Alan Modra [Mon, 30 May 2022 07:34:39 +0000 (17:04 +0930)]
use libiberty xmalloc in bfd/doc/chew.c
Catch out of memory.
* doc/chew.c: Include libibery.h.
(init_string_with_size, nextword): Replace malloc with xmalloc.
(newentry, add_to_definition): Likewise.
(catchar, catbuf): Replace realloc with xrealloc.
(add_intrinsic): Replace strdup with xstrdup.
* doc/local.mk (LIBIBERTY): Define.
(chew): Link against libiberty.
* Makefile.in: Regenerate.
Alan Modra [Mon, 30 May 2022 07:33:52 +0000 (17:03 +0930)]
Update K&R functions in bfd/doc/chew.c
* doc/chew.c: Update function definitions to ISO C, remove
now unnecessary prototypes.
Alan Modra [Mon, 30 May 2022 07:32:01 +0000 (17:02 +0930)]
Reorganise bfd/doc/chew.c a little
This also removes some unused variables, and deletes support for the
"var" keyword which isn't used and was broken. (No means to set
variables, and add_var used push_number inconsistent with its use
elsewhere.)
* doc/chew.c: Move typedefs before variables, variables before
functions.
(die): Move earlier.
(word_type, sstack, ssp): Delete.
(dict_type): Delete var field.
(add_var): Delete.
(compile): Remove "var" support.
jiawei [Mon, 30 May 2022 02:35:02 +0000 (10:35 +0800)]
RISC-V: Add zhinx extension supports.
The zhinx extension is a sub-extension in zfinx, corresponding to
zfh extension but use GPRs instead of FPRs.
This patch expanded the zfh insn class define, since zfh and zhinx
use the same opcodes, thanks for Nelson's works.
changelog in V2: Add missing classes of 'zfh' and 'zhinx' in
"riscv_multi_subset_supports_ext".
bfd/ChangeLog:
* elfxx-riscv.c (riscv_multi_subset_supports): New extensions.
(riscv_multi_subset_supports_ext): New extensions.
gas/ChangeLog:
* testsuite/gas/riscv/fp-zhinx-insns.d: New test.
* testsuite/gas/riscv/fp-zhinx-insns.s: New test.
include/ChangeLog:
* opcode/riscv.h (enum riscv_insn_class): New INSN classes.
opcodes/ChangeLog:
* riscv-opc.c: Modify INSN_CLASS.
GDB Administrator [Mon, 30 May 2022 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 29 May 2022 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
Andrew Burgess [Mon, 16 May 2022 18:26:54 +0000 (19:26 +0100)]
gdb/python: improve formatting of help text for user defined commands
Consider this command defined in Python (in the file test-cmd.py):
class test_cmd (gdb.Command):
"""
This is the first line.
Indented second line.
This is the third line.
"""
def __init__ (self):
super ().__init__ ("test-cmd", gdb.COMMAND_OBSCURE)
def invoke (self, arg, from_tty):
print ("In test-cmd")
test_cmd()
Now, within a GDB session:
(gdb) source test-cmd.py
(gdb) help test-cmd
This is the first line.
Indented second line.
This is the third line.
(gdb)
I think there's three things wrong here:
1. The leading blank line,
2. The trailing blank line, and
3. Every line is indented from the left edge slightly.
The problem of course, is that GDB is using the Python doc string
verbatim as its help text. While the user has formatted the help text
so that it appears clear within the .py file, this means that the text
appear less well formatted when displayed in the "help" output.
The same problem can be observed for gdb.Parameter objects in their
set/show output.
In this commit I aim to improve the "help" output for commands and
parameters.
To do this I have added gdbpy_fix_doc_string_indentation, a new
function that rewrites the doc string text following the following
rules:
1. Leading blank lines are removed,
2. Trailing blank lines are removed, and
3. Leading whitespace is removed in a "smart" way such that the
relative indentation of lines is retained.
With this commit in place the above example now looks like this:
(gdb) source ~/tmp/test-cmd.py
(gdb) help test-cmd
This is the first line.
Indented second line.
This is the third line.
(gdb)
Which I think is much neater. Notice that the indentation of the
second line is retained. Any blank lines within the help text (not
leading or trailing) will be retained.
I've added a NEWS entry to note that there has been a change in
behaviour, but I didn't update the manual. The existing manual is
suitably vague about how the doc string is used, so I think the new
behaviour is covered just as well by the existing text.
Andrew Burgess [Sat, 14 May 2022 09:55:59 +0000 (10:55 +0100)]
gdb: use gdb::unique_xmalloc_ptr<char> for docs in cmdpy_init
Make use of gdb::unique_xmalloc_ptr<char> to hold the documentation
string in cmdpy_init (when creating a custom GDB command in Python).
I think this is all pretty straight forward, the only slight weirdness
is the removal of the call to free toward the end of this function.
Prior to this commit, if an exception was thrown after the GDB command
was created then we would (I think) end up freeing the documentation
string even though the command would remain registered with GDB, which
would surely lead to undefined behaviour.
After this commit we release the doc string at the point that we hand
it over to the command creation routines. If we throw _after_ the
command has been created within GDB then the doc string will be left
live. If we throw during the command creation itself (either from
add_prefix_cmd or add_cmd) then it is up to those functions to free
the doc string (I suspect we don't, but I think in general the
commands are pretty bad at cleaning up after themselves, so I don't
think this is a huge problem).
Vladimir Mezentsev [Sat, 28 May 2022 02:54:26 +0000 (19:54 -0700)]
gprofng: fix build with -mx32
gprofng/ChangeLog
2022-05-27 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
PR gprofng/28983
PR gprofng/29143
* src/Experiment.cc (write_header): Fix argument for ctime.
Fix -Wformat= warnings.
* src/Dbe.cc: Likewise.
* src/DwarfLib.h: Fix [-Wsign-compare] warnings.
* src/Experiment.h: Likewise.
* src/ipc.cc: Fix -Wformat= warnings.
GDB Administrator [Sat, 28 May 2022 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Fri, 27 May 2022 13:52:16 +0000 (07:52 -0600)]
Fix crash with "maint print arc"
Luis noticed that "maint print arc" would crash, because the command
handler did not find "show" in the command name, violating an
invariant. This patch fixes the bug by changing the registration to
use add_basic_prefix_cmd instead.
Andrew Burgess [Thu, 26 May 2022 12:11:11 +0000 (13:11 +0100)]
opcodes/i386: remove trailing whitespace from insns with zero operands
While working on another patch[1] I had need to touch this code in
i386-dis.c:
ins->obufp = ins->mnemonicendp;
for (i = strlen (ins->obuf) + prefix_length; i < 6; i++)
oappend (ins, " ");
oappend (ins, " ");
(*ins->info->fprintf_styled_func)
(ins->info->stream, dis_style_mnemonic, "%s", ins->obuf);
What this code does is add whitespace after the instruction mnemonic
and before the instruction operands.
The problem I ran into when working on this code can be seen by
assembling this input file:
.text
nop
retq
Now, when I disassemble, here's the output. I've replaced trailing
whitespace with '_' so that the issue is clearer:
Disassembly of section .text:
0000000000000000 <.text>:
0: 90 nop
1: c3 retq___
Notice that there's no trailing whitespace after 'nop', but there are
three spaces after 'retq'!
What happens is that instruction mnemonics are emitted into a buffer
instr_info::obuf, then instr_info::mnemonicendp is setup to point to
the '\0' character at the end of the mnemonic.
When we emit the whitespace, this is then added starting at the
mnemonicendp position. Lets consider 'retq', first the buffer is
setup like this:
'r' 'e' 't' 'q' '\0'
Then we add whitespace characters at the '\0', converting the buffer
to this:
'r' 'e' 't' 'q' ' ' ' ' ' ' '\0'
However, 'nop' is actually an alias for 'xchg %rax,%rax', so,
initially, the buffer is setup like this:
'x' 'c' 'h' 'g' '\0'
Then in NOP_Fixup we spot that we have an instruction that is an alias
for 'nop', and adjust the buffer to this:
'n' 'o' 'p' '\0' '\0'
The second '\0' is left over from the original buffer contents.
However, when we rewrite the buffer, we don't afjust mnemonicendp,
which still points at the second '\0' character.
Now, when we insert whitespace we get:
'n' 'o' 'p' '\0' ' ' ' ' ' ' ' ' '\0'
Notice the whitespace is inserted after the first '\0', so, when we
print the buffer, the whitespace is not printed.
The fix for this is pretty easy, I can change NOP_Fixup to adjust
mnemonicendp, but now a bunch of tests start failing, we now produce
whitespace after the 'nop', which the tests don't expect.
So, I could update the tests to expect the whitespace....
...except I'm not a fan of trailing whitespace, so I'd really rather
not.
Turns out, I can pretty easily update the whitespace emitting code to
spot instructions that have zero operands and just not emit any
whitespace in this case. So this is what I've done.
I've left in the fix for NOP_Fixup, I think updating mnemonicendp is
probably a good thing, though this is not really required any more.
I've then updated all the tests that I saw failing to adjust the
expected patterns to account for the change in whitespace.
[1] https://sourceware.org/pipermail/binutils/2022-April/120610.html
Alan Modra [Fri, 27 May 2022 05:58:34 +0000 (15:28 +0930)]
Replace bfd_hostptr_t with uintptr_t
bfd_hostptr_t is defined as a type large enough to hold either a long
or a pointer. It mostly appears in the coff backend code in casts.
include/coff/internal.h struct internal_syment and union
internal_auxent have the only uses in data structures, where
comparison with include/coff/external.h and other code reveals that
the type only needs to be large enough for a 32-bit integer or a
pointer. That should mean replacing with uintptr_t is OK.
Alan Modra [Fri, 27 May 2022 04:40:17 +0000 (14:10 +0930)]
Remove much of BFD_HOST configury
This patch removes the definition of bfd_uint64_t and bfd_int64_t as
well as most BFD_HOST_* which are now unused.
Alan Modra [Fri, 27 May 2022 03:07:21 +0000 (12:37 +0930)]
Remove use of bfd_uint64_t and similar
Requiring C99 means that uses of bfd_uint64_t can be replaced with
uint64_t, and similarly for bfd_int64_t, BFD_HOST_U_64_BIT, and
BFD_HOST_64_BIT. This patch does that, removes #ifdef BFD_HOST_*
and tidies a few places that print 64-bit values.
Vladimir Mezentsev [Fri, 27 May 2022 01:38:33 +0000 (18:38 -0700)]
gprofng: fix build with --disable-shared
gprofng/ChangeLog
2022-05-26 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
* libcollector/configure.ac: Use AC_MSG_WARN instead of AC_MSG_ERROR
* libcollector/configure: Rebuild.
Jan Beulich [Fri, 27 May 2022 06:48:58 +0000 (08:48 +0200)]
x86/Intel: allow MASM representation of embedded rounding / SAE
MASM doesn't support the separate operand form; the modifier belongs
after the instruction instead. Accept this form alongside the original
(now legacy) one. Short of having access to a MASM version to actually
check in how far "after the instruction" is a precise statement in their
documentation, allow both that and the SDM mandated form where the
modifier is on the last register operand (with a possible immediate
operand following).
Sadly the split out function, at least for the time being, needs to cast
away constness at some point, as the two callers disagree in this
regard.
Adjust some, but not all of the testcases.
Jan Beulich [Fri, 27 May 2022 06:48:09 +0000 (08:48 +0200)]
x86: re-work AVX512 embedded rounding / SAE
As a preparatory step to allowing proper non-operand forms of specifying
embedded rounding / SAE, convert the internal representation to non-
operand form. While retaining properties (and in a few cases perhaps
providing more meaningful diagnostics), this means doing away with a few
hundred standalone templates, thus - as a nice side effect - reducing
memory consumption / cache occupancy.
Jan Beulich [Fri, 27 May 2022 06:47:28 +0000 (08:47 +0200)]
x86/Intel: adjust representation of embedded rounding / SAE
MASM doesn't consider {sae} and alike a separate operand; it is attached
to the last register operand instead, just like spelled out by the SDM.
Make the disassembler follow this first, before also adjusting the
assembler (such that it'll be easy to see that the assembler change
doesn't alter generated code).
Jan Beulich [Fri, 27 May 2022 06:46:29 +0000 (08:46 +0200)]
x86/Intel: allow MASM representation of embedded broadcast
MASM doesn't support the {1to<n>} form; DWORD BCST (paralleling
DWORD PTR) and alike are to be used there instead. Accept these forms
alongside the original (now legacy) ones.
Acceptance of the original {1to<n>} operand suffix is retained both for
backwards compatibility and to disambiguate VFPCLASSP{S,D,H} and vector
conversions with shrinking element sizes. I have no insight (yet) into
how MASM expects those to be disambiguated.
Adjust some, but not all of the testcases.
Jan Beulich [Fri, 27 May 2022 06:45:56 +0000 (08:45 +0200)]
x86/Intel: adjust representation of embedded broadcast
MASM doesn't support the {1to<n>} form; DWORD BCST (paralleling
DWORD PTR) and alike are to be used there instead. Make the disassembler
follow this first, before also adjusting the assembler (such that it'll
be easy to see that the assembler change doesn't alter generated code).
For VFPCLASSP{S,D,H} and vector conversions with shrinking element sizes
the original {1to<n>} operand suffix is retained, to disambiguate
output. I have no insight (yet) into how MASM expects those to be
disambiguated.
Vladimir Mezentsev [Thu, 26 May 2022 19:59:19 +0000 (12:59 -0700)]
gprofng: fix build with -mx32
gprofng/ChangeLog
2022-05-26 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
PR gprofng/28983
* libcollector/libcol_util.h (__collector_getsp, __collector_getfp,
__collector_getpc): Adapt for build with -mx32
* libcollector/heaptrace.c: Fix -Wpointer-to-int-cast warnings.
* libcollector/hwprofile.h: Likewise.
* libcollector/mmaptrace.c: Likewise.
* libcollector/synctrace.c: Likewise.
* libcollector/unwind.c: Likewise.
GDB Administrator [Fri, 27 May 2022 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in
Hans-Peter Nilsson [Thu, 26 May 2022 22:31:52 +0000 (00:31 +0200)]
ld: cris*-elf: Default to --no-warn-rwx-segment
ld:
configure.tgt (cris-*-*, crisv32-*-* sans *-aout and *-linux): Unless
specified through the --enable-* -option, default to
--no-warn-rwx-segment.
Change-Id: I846bcd3e6762da807b17215a9fe337461ea0d710
Hans-Peter Nilsson [Thu, 26 May 2022 17:48:25 +0000 (19:48 +0200)]
cris: bfd: Correct default to no execstack
In the now-historical CRIS glibc port, the default stack permission
was no-exec as in "#define DEFAULT_STACK_PERMS (PF_R|PF_W)", and the
gcc port only emits the executable-stack marker when needed; when
emitting code needing it. In other words, the binutils setting
mismatches. It doesn't matter much, except being confusing and
defaulting to "off" is more sane.
ld:
* testsuite/ld-elf/elf.exp (target_defaults_to_execstack): Switch to 0
for cris*-*-*.
bfd:
* elf32-cris.c (elf_backend_default_execstack): Define to 0.
Change-Id: I52f37598f119b19111c7a6546c00a627fca0f396
John Baldwin [Thu, 26 May 2022 21:14:46 +0000 (14:14 -0700)]
aarch64-fbsd-nat: Move definition of debug_regs_probed under HAVE_DBREG.
This fixes the build on older FreeBSD systems without support for
hardware breakpoints/watchpoints.
Lancelot SIX [Tue, 24 May 2022 12:32:18 +0000 (13:32 +0100)]
gdb: Change psymbol_functions::require_partial_symbols to partial_symbols
The previous patch ensured that partial symbols are read before calling
most of the quick_function's methods.
The psymbol_functions class has the require_partial_symbols method which
serves this exact purpose, and does not need to do it anymore.
This patch renames this method to partial_symbols and makes it an accessor
which asserts that partial symbols have been read at this point.
Regression tested on x86_64-linux.
Lancelot SIX [Tue, 24 May 2022 12:32:18 +0000 (13:32 +0100)]
gdb: Require psymtab before calling quick_functions in objfile
The recent DWARF indexer rewrite introduced a regression when debugging
a forking program.
Here is a way to reproduce the issue (there might be other ways, but one
is enough and this one mimics the situation we encountered). Consider a
program which forks, and the child loads a shared library and calls a
function in this shared library:
if (fork () == 0)
{
void *solib = dlopen (some_solib, RTLD_NOW);
void (*foo) () = dlsym (some_solib, "foo");
foo ();
}
Suppose that this program is compiled without debug info, but the shared
library it loads has debug info enabled.
When debugging such program with the following options:
- set detach-on-fork off
- set follow-fork-mode child
we see something like:
(gdb) b foo
Function "foo" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (foo) pending.
(gdb) run
Starting program: a.out
[Attaching after process 19720 fork to child process 19723]
[New inferior 2 (process 19723)]
[Switching to process 19723]
Thread 2.1 "a.out" hit Breakpoint 1, 0x00007ffff7fc3101 in foo () from .../libfoo.so
(gdb) list
Fatal signal: Segmentation fault
----- Backtrace -----
0x55a278f77d76 gdb_internal_backtrace_1
../../gdb/bt-utils.c:122
0x55a278f77f83 _Z22gdb_internal_backtracev
../../gdb/bt-utils.c:168
0x55a27940b83b handle_fatal_signal
../../gdb/event-top.c:914
0x55a27940bbb1 handle_sigsegv
../../gdb/event-top.c:987
0x7effec0343bf ???
/build/glibc-sMfBJT/glibc-2.31/nptl/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x55a27924c9d3 _ZNKSt15__uniq_ptr_implI18dwarf2_per_cu_data26dwarf2_per_cu_data_deleterE6_M_ptrEv
/usr/include/c++/9/bits/unique_ptr.h:154
0x55a279248bc9 _ZNKSt10unique_ptrI18dwarf2_per_cu_data26dwarf2_per_cu_data_deleterE3getEv
/usr/include/c++/9/bits/unique_ptr.h:361
0x55a2792ae718 _ZN27dwarf2_base_index_functions23find_last_source_symtabEP7objfile
../../gdb/dwarf2/read.c:3164
0x55a279afb93e _ZN7objfile23find_last_source_symtabEv
../../gdb/symfile-debug.c:139
0x55a279aa3040 _Z20select_source_symtabP6symtab
../../gdb/source.c:365
0x55a279aa22a1 _Z34set_default_source_symtab_and_linev
../../gdb/source.c:268
0x55a27903c44c list_command
../../gdb/cli/cli-cmds.c:1185
0x55a279051233 do_simple_func
../../gdb/cli/cli-decode.c:95
0x55a27905f221 _Z8cmd_funcP16cmd_list_elementPKci
../../gdb/cli/cli-decode.c:2514
0x55a279c3b0ba _Z15execute_commandPKci
../../gdb/top.c:660
0x55a27940a6c3 _Z15command_handlerPKc
../../gdb/event-top.c:598
0x55a27940b032 _Z20command_line_handlerOSt10unique_ptrIcN3gdb13xfree_deleterIcEEE
../../gdb/event-top.c:797
0x55a279caf401 tui_command_line_handler
../../gdb/tui/tui-interp.c:278
0x55a279409098 gdb_rl_callback_handler
../../gdb/event-top.c:230
0x55a279ed5df2 rl_callback_read_char
../../../readline/readline/callback.c:281
0x55a279408bd8 gdb_rl_callback_read_char_wrapper_noexcept
../../gdb/event-top.c:188
0x55a279408de7 gdb_rl_callback_read_char_wrapper
../../gdb/event-top.c:205
0x55a27940a061 _Z19stdin_event_handleriPv
../../gdb/event-top.c:525
0x55a27a23771e handle_file_event
../../gdbsupport/event-loop.cc:574
0x55a27a237f5f gdb_wait_for_event
../../gdbsupport/event-loop.cc:700
0x55a27a235d81 _Z16gdb_do_one_eventv
../../gdbsupport/event-loop.cc:237
0x55a2796c2ef0 start_event_loop
../../gdb/main.c:418
0x55a2796c3217 captured_command_loop
../../gdb/main.c:478
0x55a2796c717b captured_main
../../gdb/main.c:1340
0x55a2796c7217 _Z8gdb_mainP18captured_main_args
../../gdb/main.c:1355
0x55a278d0b381 main
../../gdb/gdb.c:32
---------------------
A fatal error internal to GDB has been detected, further
debugging is not possible. GDB will now terminate.
This is a bug, please report it. For instructions, see:
<https://www.gnu.org/software/gdb/bugs/>.
The first issue observed is in the message printed when hitting the
breakpoint. It says that there was a break in the .so file as if there
was no debug info associated with it, but there is. Later, if we try to
display the source where the execution stopped, we have a segfault.
Note that not having the debug info on the main binary is not strictly
required to encounter some issues, it only is to encounter the segfault.
If the main binary has debug information, GDB shows some source form the
main binary, unrelated to where we stopped.
The core of the issue is that GDB never loads the psymtab for the
library. It is not loaded when we first see the .so because in case of
detach-on-fork off, follow-fork-mode child, infrun.c sets
child_inf->symfile_flags = SYMFILE_NO_READ to delay the psymtab loading
as much as possible. If we compare to what was done to handle this
before the new indexer was activated, the psymatb construction for the
shared library was done under
psymbol_functions::expand_symtabs_matching:
bool
psymbol_functions::expand_symtabs_matching (...)
{
for (partial_symtab *ps : require_partial_symbols (objfile))
...
}
The new indexer's expand_symtabs_matching callback does not have a call
to the objfile's require_partial_symbols, so if the partial symbol table
is not loaded at this point, there is no mechanism to fix this.
Instead of requiring each implementation of the quick_functions to check
that partial symbols have been read, I think it is safer to enforce this
when calling the quick functions. The general pattern for calling the
quick functions is:
for (auto *iter : qf)
iter->the_actual_method_call (...)
This patch proposes to wrap the access of the `qf` field with an accessor
which ensures that partial symbols have been read before iterating:
qf_require_partial_symbols. All calls to quick functions are updated
except:
- quick_functions::dump
- quick_functions::read_partial_symbols (from
objfile::require_partial_symbols)
- quick_functions::can_lazily_read_symbols and quick_functions::has_symbols
(from objfile::has_partial_symbols)
Regression tested on x86_64-gnu-linux.
Change-Id: I39a13a937fdbaae613a5cf68864b021000554546
Tom Tromey [Thu, 12 May 2022 22:37:52 +0000 (16:37 -0600)]
Fix crash in new DWARF indexer
PR gdb/29128 points out a crash in the new DWARF index code. This
happens if the aranges for a CU claims a PC, but the symtab that is
created during CU expansion does not actually contain the PC. This
can only occur due to bad debuginfo, but at the same time, gdb should
not crash.
This patch fixes the bug and further merges some code into
dwarf2_base_index_functions. This merger helps prevent the same issue
from arising from the other index implementations.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29128
Tom Tromey [Fri, 13 May 2022 19:46:52 +0000 (13:46 -0600)]
Finalize each cooked index separately
After DWARF has been scanned, the cooked index code does a
"finalization" step in a worker thread. This step combines all the
index entries into a single master list, canonicalizes C++ names, and
splits Ada names to synthesize package names.
While this step is run in the background, gdb will wait for the
results in some situations, and it turns out that this step can be
slow. This is PR symtab/29105.
This can be sped up by parallelizing, at a small memory cost. Now
each index is finalized on its own, in a worker thread. The cost
comes from name canonicalization: if a given non-canonical name is
referred to by multiple indices, there will be N canonical copies (one
per index) rather than just one.
This requires changing the users of the index to iterate over multiple
results. However, this is easily done by introducing a new "chained
range" class.
When run on gdb itself, the memory cost seems rather low -- on my
current machine, "maint space 1" reports no change due to the patch.
For performance testing, using "maint time 1" and "file" will not show
correct results. That approach measures "time to next prompt", but
because the patch only affects background work, this shouldn't (and
doesn't) change. Instead, a simple way to make gdb wait for the
results is to set a breakpoint.
Before:
$ /bin/time -f%e ~/gdb/install/bin/gdb -nx -q -batch \
-ex 'break main' /tmp/gdb
Breakpoint 1 at 0x43ec30: file ../../binutils-gdb/gdb/gdb.c, line 28.
2.00
After:
$ /bin/time -f%e ./gdb/gdb -nx -q -batch \
-ex 'break main' /tmp/gdb
Breakpoint 1 at 0x43ec30: file ../../binutils-gdb/gdb/gdb.c, line 28.
0.65
Regression tested on x86-64 Fedora 34.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29105
Alan Modra [Sun, 22 May 2022 04:30:06 +0000 (14:00 +0930)]
bit-rot in target before_parse function
Copy initialisation over from the elf.em before_parse. Commit
ba951afb999 2022-05-03 changed behaviour on arm and score regarding
exec stack. This patch restores the previous behaviour.
* emultempl/aarch64elf.em (before_parse): Init separate_code,
warn_execstack, no_warn_rwx_segments and default_execstack.
* emultempl/armelf.em (before_parse): Likewise.
* emultempl/scoreelf.em (before_parse): Likewise.
* testsuite/ld-elf/elf.exp (target_defaults_to_execstack): Return
true for arm and nacl.
Richard Earnshaw [Thu, 26 May 2022 10:05:59 +0000 (11:05 +0100)]
arm: avoid use of GNU builtin function in s_arm_unwind_save_mixed
Whilst reviewing Luis' proposed change to s_arm_unwind_save_mixed
yesterday I noticed that we were making use of __builting_clzl
directly within the main function, which is not guaranteed to be
portable. Whilst studying the code further, I also realized that it
could be rewritten without using it and also reworked to remove a lot
of unnecessary iterations steps. So this patch does that (and also
removes the source of the warning that Luis was trying to fix).
Finally, with the rewrite we can also simplify the caller of this
routine as the new version can handle all the cases directly.
* config/tc-arm.c (s_arm_unwind_save_mixed): Rewrite without
using __builtin_clzl.
(s_arm_unwind_save): Simplify logic for simple/mixed register saves.
Lancelot SIX [Wed, 25 May 2022 08:37:54 +0000 (09:37 +0100)]
gdb/linux-nat: xfer_memory_partial return E_IO on error
When accessing /proc/PID/mem, if pread64/pwrite64/read/write encounters
an error and return -1, linux_proc_xfer_memory_partial return
TARGET_XFER_EOF.
I think it should return TARGET_XFER_E_IO in this case. TARGET_XFER_EOF
is returned when pread64/pwrite64/read/frite returns 0, which indicates
that the address space is gone and the whole process has exited or
execed.
This patch makes this change.
Regression tested on x86_64-linux-gnu.
Change-Id: I6030412459663b8d7933483fdda22a6c2c5d7221
Lancelot SIX [Wed, 25 May 2022 13:38:57 +0000 (14:38 +0100)]
gdb/testsuite: prefer gdb_test in gdb.dwarf2/calling-convention
Since
ed01945057c "Make gdb_test's question non-optional if specified",
if the question and response parameters are given to gdb_test, the
framework enforces that GDB asks the question. Before this patch, tests
needed to use gdb_test_multiple to enforce this.
This patch updates the gdb.dwarf2/calling-convention.exp testcase to use
gdb_test to check that GDB asks a question. This replaces the more
complicated gdb_test_multiple based implementation.
Tested on x86_64-gnu-linux.
Change-Id: I7216e822ca68f2727e0450970097d74c27c432fe
Potharla, Rupesh [Tue, 24 May 2022 00:01:49 +0000 (00:01 +0000)]
bfd: Add Support for DW_FORM_strx* and DW_FORM_addrx*
Luca Boccassi [Wed, 25 May 2022 13:41:47 +0000 (14:41 +0100)]
ld: add --package-metadata
Generate a .note.package FDO package metadata ELF note, following
the spec: https://systemd.io/ELF_PACKAGE_METADATA/
If the jansson library is available at build time (and it is explicitly
enabled), link ld to it, and use it to validate that the input is
correct JSON, to avoid writing garbage to the file. The
configure option --enable-jansson has to be used to explicitly enable
it (error out when not found). This allows bootstrappers (or others who
are not interested) to seamlessly skip it without issues.
GDB Administrator [Thu, 26 May 2022 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in
Natarajan, Kavitha [Wed, 25 May 2022 15:10:38 +0000 (16:10 +0100)]
Re: Add bionutils support for DWARF v5's DW_OP_addrx
Testsuite files belonging to commit
3ac9da49378c.
Pedro Alves [Tue, 24 May 2022 18:30:10 +0000 (19:30 +0100)]
Show enabled locations with disabled breakpoint parent as "y-"
Currently, breakpoint locations that are enabled while their parent
breakpoint is disabled are displayed with "y" in the Enb colum of
"info breakpoints":
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep n <MULTIPLE>
1.1 y 0x00000000000011b6 in ...
1.2 y 0x00000000000011c2 in ...
1.3 n 0x00000000000011ce in ...
Such locations won't trigger a break, so to avoid confusion, show "y-"
instead. For example:
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep n <MULTIPLE>
1.1 y- 0x00000000000011b6 in ...
1.2 y- 0x00000000000011c2 in ...
1.3 n 0x00000000000011ce in ...
The "-" sign is inspired on how the TUI represents breakpoints on the
left side of the source window, with "b-" for a disabled breakpoint.
Change-Id: I9952313743c51bf21b4b380c72360ef7d4396a09
Natarajan, Kavitha [Wed, 25 May 2022 15:10:38 +0000 (16:10 +0100)]
Add bionutils support for DWARF v5's DW_OP_addrx.
Pedro Alves [Wed, 18 May 2022 12:22:02 +0000 (13:22 +0100)]
gdb: Fix DUPLICATE and PATH regressions throughout
The previous patch to add -prompt/-lbl to gdb_test introduced a
regression: Before, you could specify an explicit empty message to
indicate you didn't want to PASS, like so:
gdb_test COMMAND PATTERN ""
After said patch, gdb_test no longer distinguishes
no-message-specified vs empty-message, so tests that previously would
be silent on PASS, now started emitting PASS messages based on
COMMAND. This in turn introduced a number of PATH/DUPLICATE
violations in the testsuite.
This commit fixes all the regressions I could see.
This patch uses the new -nopass feature introduced in the previous
commit, but tries to avoid it if possible. Most of the patch fixes
DUPLICATE issues the usual way, of using with_test_prefix or explicit
unique messages.
See previous commit's log for more info.
In addition to looking for DUPLICATEs, I also looked for cases where
we would now end up with an empty message in gdb.sum, due to a
gdb_test being passed both no message and empty command. E.g., this
in gdb.ada/bp_reset.exp:
gdb_run_cmd
gdb_test "" "Breakpoint $decimal, foo\\.nested_sub \\(\\).*"
was resulting in this in gdb.sum:
PASS: gdb.ada/bp_reset.exp:
I fixed such cases by passing an explicit message. We may want to
make such cases error out.
Tested on x86_64 GNU/Linux, native and native-extended-gdbserver. I
see zero PATH cases now. I get zero DUPLICATEs with native testing
now. I still see some DUPLICATEs with native-extended-gdbserver, but
those were preexisting, unrelated to the gdb_test change.
Change-Id: I5375f23f073493e0672190a0ec2e847938a580b2
Pedro Alves [Wed, 18 May 2022 12:22:02 +0000 (13:22 +0100)]
Add -nopass option to gdb_test/gdb_test_multiple
The previous patch to add -prompt/-lbl to gdb_test introduced a
regression: Before, you could specify an explicit empty message to
indicate you didn't want to PASS, like so:
gdb_test COMMAND PATTERN ""
After said patch, gdb_test no longer distinguishes
no-message-specified vs empty-message, so tests that previously would
be silent on PASS, now started emitting PASS messages based on
COMMAND. This in turn introduced a number of PATH/DUPLICATE
violations in the testsuite.
I think that not issuing a PASS should be restricted to only a few
cases -- namely in shared routines exported by gdb.exp, which happen
to use gdb_test internally. In tests that iterate an unknown number
of tests exercising some racy scenario. In the latter case, if we
emit PASSes for each iteration, we run into the situation where
different testsuite runs emit a different number of PASSes.
Thus, this patch preserves the current behavior, and, instead, adds a
new "-nopass" option to gdb_test and gdb_test_no_output. Compared to
the old way of supressing PASS with an empty message, this has the
advantage that you can specify a FAIL message that is distinct from
the command string, and, it's also more explicit.
Change-Id: I5375f23f073493e0672190a0ec2e847938a580b2
Tsukasa OI [Sun, 27 Feb 2022 08:51:04 +0000 (17:51 +0900)]
RISC-V: Fix RV32Q conflict
This commit makes RV32 + 'Q' extension (version 2.2 or later) not
conflicting since this combination is no longer prohibited by the
specification.
bfd/ChangeLog:
* elfxx-riscv.c (riscv_parse_check_conflicts): Remove conflict
detection that prohibits RV32Q on 'Q' version 2.2 or later.
gas/ChangeLog:
* testsuite/gas/riscv/march-fail-rv32iq.d: Removed.
* testsuite/gas/riscv/march-fail-rv32iq.l: Likewise.
* testsuite/gas/riscv/march-fail-rv32iq2p0.d: New test
showing RV32IQ fails on 'Q' extension version 2.0.
* testsuite/gas/riscv/march-fail-rv32iq2p0.l: Likewise.
* testsuite/gas/riscv/march-fail-rv32iq2.d: Likewise.
* testsuite/gas/riscv/march-fail-rv32iq-isa-2p2.d: New test
showing RV32IQ fails on ISA specification version 2.2.
* testsuite/gas/riscv/march-ok-rv32iq2p2.d: New test
showing RV32IQ succesds on 'Q' extension version 2.2.
* testsuite/gas/riscv/march-ok-rv32iq-isa-
20190608.d: New test
showing RV32IQ succesds on ISA specification
20190608.
Dmitry Selyutin [Tue, 24 May 2022 13:46:35 +0000 (13:46 +0000)]
opcodes: introduce BC field; fix isel
Per Power ISA Version 3.1B 3.3.12, isel uses BC field rather than CRB
field present in binutils sources. Also, per 1.6.2, BC has the same
semantics as BA and BB fields, so this should keep the same flags and
mask, only with the different offset.
opcodes/
* ppc-opc.c
(BC): Define new field, with the same definition as CRB field,
but with the PPC_OPERAND_CR_BIT flag present.
gas/
* testsuite/gas/ppc/476.d: Update.
* testsuite/gas/ppc/a2.d: Update.
* testsuite/gas/ppc/e500.d: Update.
* testsuite/gas/ppc/power7.d: Update.
Dmitry Selyutin [Thu, 12 May 2022 07:32:11 +0000 (10:32 +0300)]
ppc: extend opindex to 16 bits
With the upcoming SVP64 extension[0] to PowerPC architecture, it became
evident that PowerPC operand indices no longer fit 8 bits. This patch
switches the underlying type to uint16_t, also introducing a special
typedef so that any future extension goes even smoother.
[0] https://libre-soc.org
include/
* opcode/ppc.h (ppc_opindex_t): New typedef.
(struct powerpc_opcode): Use it.
(PPC_OPINDEX_MAX): Define.
gas/
* write.h (struct fix): Increase size of fx_pcrel_adjust.
Reorganise.
* config/tc-ppc.c (insn_validate): Use ppc_opindex_t for operands.
(md_assemble): Likewise.
(md_apply_fix): Likewise. Mask fx_pcrel_adjust with PPC_OPINDEX_MAX.
(ppc_setup_opcodes): Adjust opcode index assertion.
opcodes/
* ppc-dis.c (skip_optional_operands): Use ppc_opindex_t for
operand pointer.
(lookup_powerpc, lookup_prefix, lookup_vle, lookup_spe2): Likewise.
(print_insn_powerpc): Likewise.
GDB Administrator [Wed, 25 May 2022 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Tue, 24 May 2022 20:41:45 +0000 (22:41 +0200)]
[gdb/testsuite] Fix gdb.opt/clobbered-registers-O2.exp with clang
When running test-case gdb.opt/clobbered-registers-O2.exp with clang 12.0.1, I
get:
...
(gdb) run ^M
Starting program: clobbered-registers-O2 ^M
^M
Program received signal SIGSEGV, Segmentation fault.^M
gen_movsd (operand0=<optimized out>, operand1=<optimized out>) at \
clobbered-registers-O2.c:31^M
31 return *start_sequence(operand0, operand1);^M
(gdb) FAIL: gdb.opt/clobbered-registers-O2.exp: runto: run to start_sequence
...
The problem is that the breakpoint in start_sequence doesn't trigger, because:
- the call to start_sequence in gen_movsd is optimized away, despite the
__attribute__((noinline)), so the actual function start_sequence doesn't get
called, and
- the debug info doesn't contain inlined function info, so there's only one
breakpoint location.
Adding noclone and noipa alongside the noinline attribute doesn't fix this.
Adding the clang-specific attribute optnone in start_sequence does, but since
it inhibits all optimization, that's not a preferred solution in a gdb.opt
test-case, and it would work only for clang and not other compilers that
possibly have the same issue.
Fix this by moving functions start_sequence and gen_movsd into their own
files, as a way of trying harder to enforce noinline/noipa/noclone.
Tested on x86_64-linux.
Tom de Vries [Tue, 24 May 2022 20:41:45 +0000 (22:41 +0200)]
[gdb/testsuite] Fix gdb.opt/clobbered-registers-O2.exp with gcc-12
When running test-case gdb.opt/clobbered-registers-O2.exp with gcc-12, I run
into:
...
(gdb) PASS: gdb.opt/clobbered-registers-O2.exp: backtracing
print operand0^M
$1 = (unsigned int *) 0x7fffffffd070^M
(gdb) print *operand0^M
$2 =
4195541^M
(gdb) FAIL: gdb.opt/clobbered-registers-O2.exp: print operand0
...
The problem is that starting gcc-12, the assignments to x and y in main are
optimized away:
...
int main(void)
{
unsigned x, y;
x = 13;
y = 14;
return (int)gen_movsd (&x, &y);
...
Fix this by making x and y volatile.
Note that the test-case intends to check the handling of debug info for
optimized code in function gen_movsd, so inhibiting optimization in main
doesn't interfere with that.
Tested on x86_64-linux.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29161
Tiezhu Yang [Tue, 24 May 2022 09:46:26 +0000 (17:46 +0800)]
gdb: LoongArch: Define LOONGARCH_LINUX_NUM_GREGSET as 45
LOONGARCH_LINUX_NUM_GREGSET should be defined as 45 (32 + 1 + 1 + 11)
due to reserved 11 for extension in glibc, otherwise when execute:
make check-gdb TESTS="gdb.base/corefile.exp"
there exists the following failed testcase:
(gdb) core-file /home/loongson/build.git/gdb/testsuite/outputs/gdb.base/corefile/corefile.core
[New LWP 7742]
warning: Unexpected size of section `.reg/7742' in core file.
Core was generated by `/home/loongson/build.git/gdb/testsuite/outputs/gdb.base/corefile/corefile'.
Program terminated with signal SIGABRT, Aborted.
warning: Unexpected size of section `.reg/7742' in core file.
#0 0x000000fff76f4e24 in raise () from /lib/loongarch64-linux-gnu/libc.so.6
(gdb) FAIL: gdb.base/corefile.exp: core-file warning-free
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Christophe Lyon [Wed, 27 Apr 2022 15:29:32 +0000 (16:29 +0100)]
AArch64: add support for DFP (Decimal Floating point)
This small patch adds support for TYPE_CODE_DECFLOAT in
aapcs_is_vfp_call_or_return_candidate_1 and pass_in_v_vfp_candidate,
so that GDB for AArch64 knows how to pass DFP parameters and how to
read DFP results when calling a function.
Tested on aarch64-linux-gnu, with a GCC with DFP support in the PATH,
all of GDB's DFP tests pass.
Christophe Lyon [Wed, 27 Apr 2022 15:32:42 +0000 (16:32 +0100)]
Merge config/ changes from GCC, to enable DFP on AArch64
2022-04-28 Christophe Lyon <christophe.lyon@arm.com>
config/
* dfp.m4 (enable_decimal_float): Enable BID for AArch64.
libdecnumber/
* configure: Regenerate.
Alan Modra [Tue, 24 May 2022 01:17:35 +0000 (10:47 +0930)]
PR29171, invalid read causing SIGSEGV
The fix here is to pass "section" down to read_and_display_attr_value.
The test in read_and_display_attr_value is a little bit of hardening.
PR 29171
* dwarf.c (display_debug_macro, display_debug_names): Pass section
to read_and_display_attr_value2.
(read_and_display_attr_value): Don't attempt to check for .dwo
section name when section is NULL.
Alan Modra [Tue, 24 May 2022 00:52:50 +0000 (10:22 +0930)]
PR29170, divide by zero displaying fuzzed .debug_names
PR 29170
* dwarf.c (display_debug_names): Don't attempt to display bucket
clashes when bucket count is zero.