Alan Modra [Thu, 12 May 2022 02:14:04 +0000 (11:44 +0930)]
cgen: increase buffer for hash_insn_list
As was done for hash_insn_array in commit
d3d1cc7b13b4.
* cgen-dis.c (hash_insn_list): Increase size of buf. Assert
size is large enough.
Alan Modra [Thu, 12 May 2022 02:08:05 +0000 (11:38 +0930)]
PR29142, segv in ar with empty archive and libdeps specified
PR 29142
* ar.c (main): Properly handle libdeps for zero file_count.
Alan Modra [Thu, 12 May 2022 01:45:24 +0000 (11:15 +0930)]
Re: IBM zSystems: Accept (. - 0x100000000) PCRel32 operands
The new test failed on s390-linux due to bfd_sprintf_vma trimming
output to 32 bits for 32-bit targets. The test was faulty anyway,
expecting zero as the min end of the range is plainly wrong, but
that's what you get if you cast min to int.
* config/tc-s390.c (s390_insert_operand): Print range error using
PRId64.
* testsuite/gas/s390/zarch-z900-err.l: Correct expected output.
GDB Administrator [Thu, 12 May 2022 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Wed, 11 May 2022 13:48:23 +0000 (15:48 +0200)]
[gdb/testsuite] Fix gdb.base/catch-syscall.exp with --with-expat=no
When doing a gdb build with --with-expat=no, I run into:
...
(gdb) PASS: gdb.base/catch-syscall.exp: determine pipe syscall: \
continue to breakpoint: before pipe call
catch syscall pipe^M
Unknown syscall name 'pipe'.^M
(gdb) PASS: gdb.base/catch-syscall.exp: determine pipe syscall: \
catch syscall pipe
catch syscall pipe2^M
Unknown syscall name 'pipe2'.^M
(gdb) PASS: gdb.base/catch-syscall.exp: determine pipe syscall: \
catch syscall pipe2
continue^M
Continuing.^M
[Detaching after vfork from child process 18538]^M
[Inferior 1 (process 18537) exited normally]^M
(gdb) FAIL: gdb.base/catch-syscall.exp: determine pipe syscall: continue
...
This is a regression since recent commit
5463a15c18b ("[gdb/testsuite] Handle
pipe2 syscall in gdb.base/catch-syscall.exp").
Fix this by using pipe/pipe2 syscall numbers instead.
Tested on x86_64-linux.
Nick Clifton [Wed, 11 May 2022 12:54:30 +0000 (13:54 +0100)]
nm: use -U as an alias for --defines-only, in line with llvm-nm
Tom de Vries [Wed, 11 May 2022 11:30:33 +0000 (13:30 +0200)]
[gdb/testsuite] Fix gdb.base/catch-syscall.exp without --enable-targets
When doing a gdb build without --enable-targets, I run into:
...
(gdb) UNSUPPORTED: gdb.base/catch-syscall.exp: multiple targets: \
s390:31-bit vs s390:64-bit: set architecture s390:64-bit
delete breakpoints^M
(gdb) info breakpoints^M
No breakpoints or watchpoints.^M
(gdb) break -qualified main^M
No symbol table is loaded. Use the "file" command.^M
Make breakpoint pending on future shared library load? (y or [n]) n^M
(gdb) FAIL: gdb.base/catch-syscall.exp: gdb_breakpoint: set breakpoint at main
...
The problem is that due to recent commit
e21d8399303 ("[gdb/testsuite] Remove
target limits in gdb.base/catch-syscall.exp") "clean_restart $binfile" no
longer is called at the end of test_catch_syscall_multi_arch.
Fix this by moving "clean_restart $binfile" back to
test_catch_syscall_multi_arch.
Tested on x86_64-linux.
Tom de Vries [Wed, 11 May 2022 09:14:18 +0000 (11:14 +0200)]
[gdb/testsuite] Fix gdb.base/maint.exp on powerpc64le
On powerpc64le-linux, I ran into:
...
FAIL: gdb.base/maint.exp: maint print objfiles: symtabs
...
The problem is that:
- the "Cooked index in use" line occurs twice in the gdb output:
- once for exec maint, and
- once for "Object file system-supplied DSO".
- the matching of the second "Cooked index in use" also consumes
the "Symtabs:" string, and consequently the corresponding
clause does not trigger and $symtabs remains 0.
Fix this by limiting the output of the command to the exec.
Tested on x86_64-linux and powerpcle-linux.
Tom de Vries [Wed, 11 May 2022 07:46:23 +0000 (09:46 +0200)]
[gdb/tdep] Update syscalls/{ppc64,ppc}-linux.xml
Regenerate syscalls/{ppc64,ppc}-linux.xml on a system with 5.14 kernel.
Tom de Vries [Wed, 11 May 2022 07:32:58 +0000 (09:32 +0200)]
[gdb/testsuite] Remove target limits in gdb.base/catch-syscall.exp
In test-case gdb.base/catch-syscall.exp, proc test_catch_syscall_multi_arch we
test for supported targets using istarget, like so:
...
if { [istarget "i*86-*-*"] || [istarget "x86_64-*-*"] } {
...
} elseif { [istarget "powerpc-*-linux*"] \
|| [istarget "powerpc64*-linux*"] } {
...
...
but the tests excercised there can all be executed if gdb is configured with
--enable-targets=all.
Rewrite the proc to iterate over all cases, and check if the test is supported
by trying "set arch $arch1" and "set arch $arch2".
Tested on x86_64-linux, with:
- a gdb build with --enable-targets=all, and
- a gdb build build with my usual --enable-targets setting (too long to
include here) which means the sparc vs sparc:v9 case is unsupported.
Tom de Vries [Wed, 11 May 2022 06:35:33 +0000 (08:35 +0200)]
[gdb/record] Handle statx system call
When running test-case gdb.reverse/fstatat-reverse.exp with target board
unix/-m32 on openSUSE Tumbleweed, I run into:
...
(gdb) PASS: gdb.reverse/fstatat-reverse.exp: set breakpoint at marker2
continue^M
Continuing.^M
Process record and replay target doesn't support syscall number 383^M
Process record: failed to record execution log.^M
^M
Program stopped.^M
0xf7fc5555 in __kernel_vsyscall ()^M
(gdb) FAIL: gdb.reverse/fstatat-reverse.exp: continue to breakpoint: marker2
...
The problems is that while with native we're trying to record these syscalls
(showing strace output):
...
openat(AT_FDCWD, "/", O_RDONLY|O_PATH) = 3
newfstatat(3, ".", {st_mode=S_IFDIR|0755, st_size=146, ...}, 0) = 0
...
with unix/-m32 we have instead:
...
openat(AT_FDCWD, "/", O_RDONLY|O_PATH) = 3
statx(3, ".", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT, STATX_BASIC_STATS, \
{stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=STATX_ATTR_MOUNT_ROOT, \
stx_mode=S_IFDIR|0755, stx_size=146, ...}) = 0
...
and statx is not supported.
Fix this by adding support for recording syscall statx.
Tested on x86_64-linux.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28461
Alan Modra [Mon, 9 May 2022 23:22:07 +0000 (08:52 +0930)]
opcodes cgen: remove use of PTR
Note that opcodes is regenerated with cgen commit
d1dd5fcc38e reverted,
due to failure of bpf to compile with that patch applied.
.../opcodes/bpf-opc.c:57:11: error: conversion from ‘long unsigned int’ to ‘unsigned int’ changes value from ‘
18446744073709486335’ to ‘
4294902015’ [-Werror=overflow]
57 | 64, 64, 0xffffffffffff00ff, { { F (F_IMM32) }, { F (F_OFFSET16) }, { F (F_SRCLE) }, { F (F_OP_CODE) }, { F (F_DSTLE) }, { F (F_OP_SRC) }, { F (F_OP_CLASS) }, { 0 } }
plus other similar errors.
cpu/
* mep.opc (print_tpreg, print_spreg): Delete unnecessary
forward declarations. Replace PTR with void *.
* mt.opc (print_dollarhex, print_pcrel): Delete forward decls.
opcodes/
* bpf-desc.c, * bpf-dis.c, * cris-desc.c,
* epiphany-desc.c, * epiphany-dis.c,
* fr30-desc.c, * fr30-dis.c, * frv-desc.c, * frv-dis.c,
* ip2k-desc.c, * ip2k-dis.c, * iq2000-desc.c, * iq2000-dis.c,
* lm32-desc.c, * lm32-dis.c, * m32c-desc.c, * m32c-dis.c,
* m32r-desc.c, * m32r-dis.c, * mep-desc.c, * mep-dis.c,
* mt-desc.c, * mt-dis.c, * or1k-desc.c, * or1k-dis.c,
* xc16x-desc.c, * xc16x-dis.c,
* xstormy16-desc.c, * xstormy16-dis.c: Regenerate.
GDB Administrator [Wed, 11 May 2022 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
Youling Tang [Tue, 10 May 2022 21:07:04 +0000 (22:07 +0100)]
gdb: mips: Fix large-frame.exp test case failure
$ objdump -d outputs/gdb.base/large-frame/large-frame-O2
0000000120000b20 <func>:
120000b20:
67bdbff0 daddiu sp,sp,-16400
120000b24:
ffbc4000 sd gp,16384(sp)
120000b28:
3c1c0002 lui gp,0x2
120000b2c:
679c8210 daddiu gp,gp,-32240
120000b30:
0399e02d daddu gp,gp,t9
120000b34:
df998058 ld t9,-32680(gp)
120000b38:
ffbf4008 sd ra,16392(sp)
120000b3c:
0411ffd8 bal
120000aa0 <blah>
...
The disassembly of the above func function shows that we may use
instructions such as daddiu/daddu, so add "daddiu $gp,$gp,n",
"daddu $gp,$gp,$t9" and "daddu $gp,$t9,$gp" to the mips32_scan_prologue
function to fix the large-frame.exp test case.
Before applying the patch:
backtrace
#0 blah (a=0xfffffee220) at .../gdb/testsuite/gdb.base/large-frame-1.c:24
#1 0x0000000120000b44 in func ()
Backtrace stopped: frame did not save the PC
(gdb) FAIL: gdb.base/large-frame.exp: optimize=-O2: backtrace
# of expected passes 5
# of unexpected failures 1
After applying the patch:
# of expected passes 6
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
Tiezhu Yang [Tue, 10 May 2022 11:50:31 +0000 (19:50 +0800)]
gdb: LoongArch: Use GDB style to check readbuf and writebuf
The GDB style is to write 'if (readbuf != nullptr)', and the same for
writebuf.
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Tom Tromey [Mon, 9 May 2022 17:48:40 +0000 (11:48 -0600)]
Fix --disable-threading build
PR build/29110 points out that GDB fails to build on mingw when the
"win32" thread model is in use. It turns out that the Fedora cross
tools using the "posix" thread model, which somehow manages to support
std::future, whereas the win32 model does not.
While looking into this, I found that the configuring with
--disable-threading will also cause a build failure.
This patch fixes this build by introducing a compatibility wrapper for
std::future.
I am not able to test the win32 thread model build, but I'm going to
ask the reporter to try this patch.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29110
Pedro Alves [Fri, 29 Apr 2022 22:21:18 +0000 (23:21 +0100)]
Fix "b f(std::string)" when current language is C
If you try to set a breakpoint at a function such as "b
f(std::string)", and the current language is C, the breakpoint fails
to be set, like so:
(gdb) set language c
break f(std::string)
Function "f(std::string)" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb)
The problem is that the code in GDB that expands the std::string
typedef hits this in c-typeprint.c:
/* If we have "typedef struct foo {. . .} bar;" do we want to
print it as "struct foo" or as "bar"? Pick the latter for
C++, because C++ folk tend to expect things like "class5
*foo" rather than "struct class5 *foo". We rather
arbitrarily choose to make language_minimal work in a C-like
way. */
if (language == language_c || language == language_minimal)
{
if (type->code () == TYPE_CODE_UNION)
gdb_printf (stream, "union ");
else if (type->code () == TYPE_CODE_STRUCT)
{
if (type->is_declared_class ())
gdb_printf (stream, "class ");
else
gdb_printf (stream, "struct ");
}
else if (type->code () == TYPE_CODE_ENUM)
gdb_printf (stream, "enum ");
}
I.e., std::string is expanded to "class std::..." instead of just
"std::...", and then the "f(class std::..." symbol doesn't exist.
Fix this by making cp-support.c:inspect_type print the expanded
typedef type using the language of the symbol whose type we're
expanding the typedefs for -- in the example in question, the
"std::string" typedef symbol, which is a C++ symbol.
Use type_print_raw_options as it seems to me that in this scenario we
always want raw types, to match the real symbol names.
Adjust the gdb.cp/break-f-std-string.exp testcase to try setting a
breakpoint at "f(std::string)" in both C and C++.
Change-Id: Ib54fab4cf0fd307bfd55bf1dd5056830096a653b
Pedro Alves [Fri, 29 Apr 2022 22:21:18 +0000 (23:21 +0100)]
Always pass an explicit language down to c_type_print
The next patch will want to do language->print_type(type, ...), to
print a type in a given language, avoiding a dependency on the current
language. That doesn't work correctly currently, however, because
most language implementations of language_defn::print_type call
c_print_type without passing down the language. There are two
overloads of c_print_type, one that takes a language, and one that
does not. The one that does not uses the current language, defeating
the point of calling language->print_type()...
This commit removes the c_print_type overload that does not take a
language, and adjusts the codebase throughout to always pass down a
language. In most places, there's already an enum language handy.
language_defn::print_type implementations naturally pass down
this->la_language. In a couple spots, like in ada-typeprint.c and
rust-lang.c there's no enum language handy, but the code is written
for a specific language, so we just hardcode the language.
In gnuv3_print_method_ptr, I wasn't sure whether we could hardcode C++
here, and we don't have an enum language handy, so I made it use the
current language, just like today. Can always be improved later.
Change-Id: Ib54fab4cf0fd307bfd55bf1dd5056830096a653b
Pedro Alves [Fri, 29 Apr 2022 22:21:18 +0000 (23:21 +0100)]
Fix "b f(std::string)", always use DMGL_VERBOSE
Currently, on any remotely modern GNU/Linux system,
gdb.cp/no-dmgl-verbose.exp fails like so:
break 'f(std::string)'
Function "f(std::string)" not defined.
(gdb) FAIL: gdb.cp/no-dmgl-verbose.exp: gdb_breakpoint: set breakpoint at 'f(std::string)'
break 'f(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
Function "f(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)" not defined.
(gdb) PASS: gdb.cp/no-dmgl-verbose.exp: DMGL_VERBOSE-demangled f(std::string) is not defined
This testcase was added back in 2011, here:
[patch] Remove DMGL_VERBOSE
https://sourceware.org/pipermail/gdb-patches/2011-June/083081.html
Back then, the testcase would pass cleanly. It turns out that the
reason it fails today is that the testcase is exercising something in
GDB that only makes sense if the program is built for the pre-C++11
libstc++ ABI. Back then the C++11 ABI didn't exist yet, but nowadays,
you need to compile with -D_GLIBCXX_USE_CXX11_ABI=0 to use the old
ABI. See "Dual ABI" in the libstdc++ manual, at
<https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html>.
If we tweak the gdb.cp/no-dmgl-verbose.exp testcase to force the old
ABI with -D_GLIBCXX_USE_CXX11_ABI=0, then it passes cleanly.
So why is it that setting a breakpoint at "f(std::string)" fails with
modern ABI, but passes with old ABI?
This is where libiberty demangler's DMGL_VERBOSE option comes in. The
Itanium ABI mangling scheme has a shorthand form for std::string (and
some other types). See
<https://itanium-cxx-abi.github.io/cxx-abi/abi.html>:
"In addition, the following catalog of abbreviations of the form "Sx" are used:
<substitution> ::= St # ::std::
<substitution> ::= Sa # ::std::allocator
<substitution> ::= Sb # ::std::basic_string
<substitution> ::= Ss # ::std::basic_string < char,
::std::char_traits<char>,
::std::allocator<char> >
<substitution> ::= Si # ::std::basic_istream<char, std::char_traits<char> >
<substitution> ::= So # ::std::basic_ostream<char, std::char_traits<char> >
<substitution> ::= Sd # ::std::basic_iostream<char, std::char_traits<char> >
"
When the libiberty demangler encounters such a abbreviation, by
default, it expands it to the user-friendly typedef "std::string",
"std::iostream", etc.. If OTOH DMGL_VERBOSE is specified, the
abbreviation is expanded to the underlying, non-typedefed fullname
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >"
etc. as documented in the Itanium ABI, and pasted above. You can see
the standard abbreviations/substitutions in
libiberty/cp-demangle.c:standard_subs.
Back before Jan's patch in 2011, there were parts of GDB that used
DMGL_VERBOSE, and others that did not, leading to mismatches. The
solution back then was to stop using DMGL_VERBOSE throughout.
GDB has code in place to let users set a breakpoint at a function with
typedefs in its parameters, like "b f(uint32_t)". Demangled function
names as they appear in the symbol tables almost (more on this is in a
bit) never have typedefs in them, so when processing "b f(uint32_t)"
GDB first replaces "uint32_t" for its underlying type, and then sets a
breakpoint on the resulting prototype, in this case "f(unsigned int)".
Now, if DMGL_VERBOSE is _not_ used, then the demangler demangles the
mangled name of a function such as "void f(std::string)" that was
mangled using the standard abbreviations mentioned above really as:
"void f(std::string)".
For example, the mangled name of "void f(std::string)" if you compile
with old pre-C++11 ABI is "_Z1fSs". That uses the abbreviation "Ss",
so if you demangle that without DMGL_VERBOSE, you get:
$ echo "_Z1fSs" | c++filt --no-verbose
f(std::string)
while with DMGL_VERBOSE you'd get:
$ echo "_Z1fSs" | c++filt
f(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)
If, when the user sets a breakpoint at "f(std::string)", GDB would
replace the std::string typedef for its underlying type using the same
mechanism I mentioned for the "f(uint32_t)" example above, then GDB
would really try to set a breakpoint at "f(std::basic_string<char,
std::char_traits<char>, std::allocator<char> >)", and that would fail,
as the function symbol GDB knows about for that function, given no
DMGL_VERBOSE, is "f(std::string)".
For this reason, the code that expands typedefs in function parameter
names has an exception for std::string (and other standard
abbreviation types), such that "std::string" is never
typedef-expanded.
And here lies the problem when you try to do "b f(std::string)" with a
program compiled with the C++11 ABI. In that case, std::string
expands to a different underlying type, like so:
f(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
and this symbol naturally mangles differently, as:
_Z1fNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
and then because this doesn't use the shorthand mangling abbreviation
for "std::string" anymore, it always demangles as:
f(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
Now, when using the C++11 ABI, and you set a breakpoint at
"f(std::string)", GDB's typedefs-in-parameters expansion code hits the
exception for "std::string" and doesn't expand it, so the breakpoint
fails to be inserted, because the symbol that exists is really the
f(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
one, not "f(std::string)".
So to fix things for C++11 ABI, clearly we need to remove the
"std::string" exception from the typedef-in-parameters expansion
logic. If we do just that, then "b f(std::string)" starts working
with the C++11 ABI.
However, if we do _just_ that, and nothing else, then we break
pre-C++11 ABI...
The solution is then to in addition switch GDB to always use
DMGL_VERBOSE. If we do this, then pre-C++11 ABI symbols works the
same as C++11 ABI symbols overall -- the demangler expands the
standard abbreviation for "std::string" as "std::basic_string<char,
std::char_traits<char>, std::allocator<char> >" and letting GDB expand
the "std::string" typedef (etc.) too is no longer a problem.
To avoid getting in the situation where some parts of GDB use
DMGL_VERBOSE and others not, this patch adds wrappers around the
demangler's entry points that GDB uses, and makes those force
DMGL_VERBOSE.
The point of the gdb.cp/no-dmgl-verbose.exp testcase was to try to
ensure that DMGL_VERBOSE doesn't creep back in:
gdb_test {break 'f(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'} \
{Function ".*" not defined\.} \
"DMGL_VERBOSE-demangled f(std::string) is not defined"
This obviously no longer makes sense to have, since we now depend on
DMGL_VERBOSE. So the patch replaces gdb.cp/no-dmgl-verbose.exp with a
new gdb.cp/break-f-std-string.exp testcase whose purpose is to make
sure that setting a breakpoint at "f(std::string)" works. It
exercises both pre-C++11 ABI and C++11 ABI.
Change-Id: Ib54fab4cf0fd307bfd55bf1dd5056830096a653b
Nils-Christian Kempke [Wed, 20 Apr 2022 10:30:48 +0000 (12:30 +0200)]
gdb/testsuite: fix testsuite regressions for unix/-m32 board
This commit fixes two regressions introduced by
891e4190ba705373eec7b374209478215fff5401.
Reason for the failures was, that on a 32 bit machine the maximum
array length as well as the maximum allocatable memory for arrays
(in bytes) both seem to be limited by the maximum value of a 4
byte (signed) Fortran integer. This lead to compiler errors/unexpected
behavior when compiling/running the test with the -m32 board. This
behavior is compiler dependent and can differ for different compiler
implementations, but generally, it seemed like a good idea to simply
avoid such situations.
The affected tests check for GDB's overflow behavior when using KIND
parameters with GDB implemented Fortran intrinsic functions. If these
KIND parameters are too small to fit the actual intrinsic function's
result, an overflow is expected. This was done for 1, 2, and 4
byte overflows. The last one caused problems, as it tried to allocate
arrays of length/byte-size bigger than the 4 byte signed integers which
would then be used with the LBOUND/UBOUND/SIZE intrinsics.
The tests were adapted to only execute the 4 byte overflow tests when
running on targets with 64 bit. For this, the compiled tests evaluate the
byte size of a C_NULL_PTR via C_SIZEOF, both defined in the ISO_C_BINDING
module. The ISO_C_BINDING constant C_NULL_PTR is a Fortran 2003, the
C_SIZEOF a Fortran 2008 extension. Both have been implemented in their
respective compilers for while (e.g. C_SIZEOF is available since
gfortran 4.6). If this byte size evaluates to less than 8 we skip the
4 byte overflow tests in the compiled tests of size.f90 and
lbound-ubound.f90. Similarly, in the lbound-ubound.exp testsfile we skip
the 4 byte overflow tests if the procedure is_64_target evaluates to false.
In size.f90, additionally, the to-be-allocated amount of bytes did not
fit into 4 byte signed integers for some of the arrays, as it was
approximately 4 times the maximum size of a 4 byte signed integer. We
adapted the dimensions of the arrays in question as the meaningfulness
of the test does not suffer from this.
With this patch both test run fine with the unix/-m32 board and
gcc/gfortran (9.4) as well as the standard board file.
We also thought about completely removing the affected test from the
testsuite. We decided against this as the 32 bit identification comes
with Fortran 2008 and removing tests would have decreased coverage.
A last change that happened with this patch was due to gfortran's and
ifx's type resolution when assigning big constants to Fortran Integer*8
variables. Before the above changes this happened in a parameter
statement. Here, both compilers happily accepted a line like
integer*8, parameter :: var =
2147483647 + 5.
After this change the assignment is not done as a parameter
anymore, as this triggered compile time overflow errors. Instead,
the assignment is done dynamically, depending on the kind of machine one
is on. Sadly, just changing this line to
integer*8 :: var
var =
2147483647 + 5
does not work with ifx (or flang for that matter, they behave similarly
here). It will create an integer overflow in the addition as ifx deduces
the type the additon is done in as Integer*4. So var will actually
contain the value -
2147483644 after this. The lines
integer*8 :: var
var =
2147483652
on the other hand fail to compile with gfortran (9.4.0) as the compiler
identifies an Integer overflow here. Finally, to make this work with
all three compilers an additional parameter has been introduced
integer*8, parameter :: helper =
2147483647
integer*8 :: var
var = helper + 5.
This works on all 3 compilers as expected.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29053
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29054
Pedro Alves [Fri, 6 May 2022 15:28:37 +0000 (16:28 +0100)]
Move non-dependent gdb::observers::observable::visit_state outside template
The other day, while looking at the symbols that end up in a GDB
index, I noticed that the gdb::observers::observable::visit_state enum
class appears a number of times:
$ grep VISIT gdb-index-symbol-names.txt
gdb::observers::observable<bpstat*, int>::visit_state::NOT_VISITED
gdb::observers::observable<bpstat*, int>::visit_state::VISITED
gdb::observers::observable<bpstat*, int>::visit_state::VISITING
gdb::observers::observable<breakpoint*>::visit_state::NOT_VISITED
gdb::observers::observable<breakpoint*>::visit_state::VISITED
gdb::observers::observable<breakpoint*>::visit_state::VISITING
gdb::observers::observable<char const*, char const*>::visit_state::NOT_VISITED
gdb::observers::observable<char const*, char const*>::visit_state::VISITED
gdb::observers::observable<char const*, char const*>::visit_state::VISITING
gdb::observers::observable<char const*>::visit_state::NOT_VISITED
gdb::observers::observable<char const*>::visit_state::VISITED
gdb::observers::observable<char const*>::visit_state::VISITING
gdb::observers::observable<enum_flags<user_selected_what_flag> >::visit_state::NOT_VISITED
gdb::observers::observable<enum_flags<user_selected_what_flag> >::visit_state::VISITED
gdb::observers::observable<enum_flags<user_selected_what_flag> >::visit_state::VISITING
gdb::observers::observable<frame_info*, int>::visit_state::NOT_VISITED
gdb::observers::observable<frame_info*, int>::visit_state::VISITED
gdb::observers::observable<frame_info*, int>::visit_state::VISITING
gdb::observers::observable<gdbarch*>::visit_state::NOT_VISITED
gdb::observers::observable<gdbarch*>::visit_state::VISITED
gdb::observers::observable<gdbarch*>::visit_state::VISITING
gdb::observers::observable<gdb_signal>::visit_state::NOT_VISITED
gdb::observers::observable<gdb_signal>::visit_state::VISITED
gdb::observers::observable<gdb_signal>::visit_state::VISITING
[... snip ...]
$ grep VISIT gdb-index-symbol-names.txt | wc -l
72
enum class visit_state is defined inside the class template
observable, but it doesn't have to be, as it does not depend on the
template parameters. This commit moves it out, so that only one such
type exists. This reduces the size of a -O0 -g3 build for me by
around 0.6%, like so:
$ du -b gdb.before gdb.after
164685280 gdb.before
163707424 gdb.fixed
and codesize by some 0.5%.
Change-Id: I405f4ef27b8358fdd22158245b145d849b45658e
Nick Clifton [Tue, 10 May 2022 11:41:56 +0000 (12:41 +0100)]
Fix compiling binutils/resbin.c with Clang version 14
Vladimir Mezentsev [Mon, 9 May 2022 22:44:41 +0000 (15:44 -0700)]
gprofng: include percentages in default metrics list
gprofng/ChangeLog
2022-05-09 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
* src/gprofng.rc: Include percentages in default metrics list.
Alan Modra [Mon, 9 May 2022 23:23:17 +0000 (08:53 +0930)]
gprof: remove use of PTR
* basic_blocks.c: Replace uses of PTR with void * throughout.
* cg_arcs.c: Likewise.
* cg_print.c: Likewise.
* hist.c: Likewise.
* source.h: Likewise.
* symtab.c: Likewise.
Alan Modra [Mon, 9 May 2022 23:22:58 +0000 (08:52 +0930)]
gas: remove use of PTR
* config/obj-evax.c (evax_symbol_new_hook): Don't cast to PTR.
Alan Modra [Mon, 9 May 2022 23:47:30 +0000 (09:17 +0930)]
opcodes: remove use of PTR
The non-cgen parts of opcodes.
* cr16-dis.c (print_arg): Replace PTR with void *.
* crx-dis.c (print_arg): Likewise.
* rl78-dis.c (print_insn_rl78_common): Don't use PTR cast.
* rx-dis.c (print_insn_rx): Likewise.
* visium-dis.c (print_insn_visium): Likewise.
* z8k-dis.c (print_insn_z8k): Likewise.
Alan Modra [Mon, 9 May 2022 23:22:39 +0000 (08:52 +0930)]
bfd: remove use of PTR
* coffcode.h (coff_write_object_contents): Don't cast to PTR.
* elf32-csky.c (csky_elf_link_hash_traverse): Remove use of PTR
and PARAMS.
(csky_allocate_dynrelocs): Don't use PTR cast.
* elf32-nios2.c (adjust_dynrelocs, allocate_dynrelocs): Replace
PTR with void *.
* elf32-visium.c (visium_elf_howto_parity_reloc): Likewise.
* elfxx-ia64.c (ia64_elf_reloc): Likewise.
* plugin.c (bfd_plugin_bfd_print_private_bfd_data): Likewise.
Alan Modra [Tue, 10 May 2022 00:19:43 +0000 (09:49 +0930)]
include: remove use of PTR
* hashtab.h (HTAB_EMPTY_ENTRY): Replace PTR with void *.
(HTAB_DELETED_ENTRY): Likewise.
GDB Administrator [Tue, 10 May 2022 00:00:17 +0000 (00:00 +0000)]
Automatic date update in version.in
Ilya Leoshkevich [Mon, 9 May 2022 19:57:28 +0000 (21:57 +0200)]
IBM zSystems: Accept (. - 0x100000000) PCRel32 operands
as does not accept instructions like brasl %r0,.-0x100000000, because
of two problems with the generic overflow check:
1. PCRel32 operands are signed, but are treated as unsigned.
2. The allowed range for these operands is [-(1 << 32), (1 << 32) - 1],
and not [-(1 << 31), (1 << 31) - 1].
Fix both by disabling the generic overflow check - it's not needed,
because s390_insert_operand () performs its own.
gas/
* config/tc-s390.c (md_gather_operands): Set fx_no_overflow.
* testsuite/gas/s390/s390.exp: Add zarch-z900-err.
* testsuite/gas/s390/esa-z900.d: New test.
* testsuite/gas/s390/esa-z900.s: New test.
* testsuite/gas/s390/zarch-z900-err.l: New test.
* testsuite/gas/s390/zarch-z900-err.s: New test.
Andrew Burgess [Mon, 9 May 2022 15:49:03 +0000 (16:49 +0100)]
gdb/testsuite: fix occasional failure in gdb.mi/mi-multi-commands.exp
In bug PR gdb/29036, another failure was reported for the test
gdb.mi/mi-multi-commands.exp. This test sends two commands to GDB as
a single write, and then checks that both commands are executed.
The problem that was encountered here is that the output of the first
command, which looks like this:
^done,value="\"FIRST COMMAND\""
Is actually produced in parts, first the '^done' is printed, then the
',value="\"FIRST COMMAND\"" is printed.
What was happening is that some characters from the second command
were being echoed after the '^done' had been printed, but before the
value part had been printed. To avoid this issue I've relaxed the
pattern that checks for the first command a little. With this fix in
place the occasional failure in this test is no longer showing up.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29036
Tom de Vries [Mon, 9 May 2022 15:22:23 +0000 (17:22 +0200)]
[gdb] Update syscalls/{amd64,i386}-linux.xml
- Add a script syscalls/gen-header.py, based on syscalls/arm-linux.py.
- Add a script syscalls/update-linux.sh (alongside update-freebsd.sh and
update-netbsd.sh).
- Use syscalls/update-linux.sh to update syscalls/{amd64,i386}-linux.xml.in.
- Regenerate syscalls/{amd64,i386}-linux.xml using syscalls/Makefile.
In gdb/syscalls/i386-linux.xml.in, updating has the following notable effect:
...
- <syscall name="madvise1" number="220"/>
- <syscall name="getdents64" number="221"/>
- <syscall name="fcntl64" number="222"/>
+ <syscall name="getdents64" number="220"/>
+ <syscall name="fcntl64" number="221"/>
...
I've verified in ./arch/x86/entry/syscalls/syscall_32.tbl that the numbers are
correct.
Tested on x86_64-linux.
Tom de Vries [Mon, 9 May 2022 14:44:48 +0000 (16:44 +0200)]
[gdb] Add gdb/syscalls/Makefile
Add a Makefile in gdb/syscalls that can be used to translate
gdb/syscalls/*.xml.in into gdb/syscalls/*.xml.
Calling make reveals that bfin-linux.xml is missing, so add it.
Tested on x86_64-linux.
Tiezhu Yang [Mon, 9 May 2022 08:26:47 +0000 (16:26 +0800)]
gdb: LoongArch: Implement the return_value gdbarch method
When execute the following command on LoongArch:
make check-gdb TESTS="gdb.base/async.exp"
there exist the following failed testcases:
FAIL: gdb.base/async.exp: finish& (timeout)
FAIL: gdb.base/async.exp: jump& (timeout)
FAIL: gdb.base/async.exp: until& (timeout)
FAIL: gdb.base/async.exp: set exec-done-display off (GDB internal error)
we can see the following messages in gdb/testsuite/gdb.log:
finish&
Run till exit from #0 foo () at /home/loongson/gdb.git/gdb/testsuite/gdb.base/async.c:9
(gdb) /home/loongson/gdb.git/gdb/gdbarch.c:2646: internal-error: gdbarch_return_value: Assertion `gdbarch->return_value != NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
In order to fix the above failed testcases, implement the return_value
gdbarch method on LoongArch.
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Andrew Burgess [Wed, 20 Apr 2022 13:08:49 +0000 (14:08 +0100)]
gdb: fix for gdb.base/eof-exit.exp test failures
This fix relates to PR gdb/29032, this makes the test more stable by
ensuring that the Ctrl-D is only sent once the prompt has been
displayed. This issue was also discussed on the mailing list here:
https://sourceware.org/pipermail/gdb-patches/2022-April/187670.html
The problem identified in the bug report is that sometimes the Ctrl-D
(that the test sends to GDB) arrives while GDB is processing a
command. When this happens the Ctrl-D is handled differently than if
the Ctrl-D is sent while GDB is waiting for input at a prompt.
The original intent of the test was that the Ctrl-D be sent while GDB
was waiting at a prompt, and that is the case the occurs most often,
but, when the Ctrl-D arrives during command processing, then GDB will
ignore the Ctrl-D, and the test will fail.
This commit ensures the Ctrl-D is always sent while GDB is waiting at
a prompt, which makes this test stable.
But, that still leaves an open question, what should happen when the
Ctrl-D arrives while GDB is processing a command? This commit doesn't
attempt to answer that question, which is while bug PR gdb/29032 will
not be closed once this commit is merged.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29032
Tom de Vries [Mon, 9 May 2022 13:14:56 +0000 (15:14 +0200)]
[gdb] Make btrace maintainer entry more clear
Do:
...
-record btrace <name> <email>
+record
+ btrace <name> <email>
...
to clarify that the listed maintainer is only maintainer of the btrace part of
record.
Martin Liska [Mon, 9 May 2022 11:59:37 +0000 (13:59 +0200)]
ansidecl.h: sync from GCC
include/ChangeLog:
* ansidecl.h: Sync from GCC.
Tom de Vries [Mon, 9 May 2022 10:22:02 +0000 (12:22 +0200)]
[gdb/tdep] Support catch syscall pipe2 for i386
With test-case gdb.base/catch-syscall.exp and target board unix/-m32, we run
into:
...
(gdb) catch syscall pipe2^M
Unknown syscall name 'pipe2'.^M
(gdb) FAIL: gdb.base/catch-syscall.exp: determine pipe syscall: catch syscall pipe2
...
Fix this by:
- adding a pipe2 entry in gdb/syscalls/i386-linux.xml.in, and
- regenerating gdb/syscalls/i386-linux.xml using
"xsltproc --output i386-linux.xml apply-defaults.xsl i386-linux.xml.in".
Tested on x86_64-linux with native and unix/-m32.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29056
Tom de Vries [Mon, 9 May 2022 10:01:42 +0000 (12:01 +0200)]
[gdb/testsuite] Handle pipe2 syscall in gdb.base/catch-syscall.exp
When running test-case gdb.reverse/pipe-reverse.exp on openSUSE Tumbleweed,
I run into:
...
(gdb) continue^M
Continuing.^M
^M
Catchpoint 2 (returned from syscall pipe2), in pipe () from /lib64/libc.so.6^M
(gdb) FAIL: gdb.base/catch-syscall.exp: without arguments: \
syscall pipe has returned
...
The current glibc on Tumbleweed is 2.35, which contains commit
"linux: Implement pipe in terms of __NR_pipe2", and consequently syscall pipe2
is used instead of syscall pipe.
Fix this by detecting whether syscall pipe or pipe2 is used before running the
tests.
Tested on x86_64-linux, specifically on:
- openSUSE Tumbleweed (with glibc 2.35), and
- openSUSE Leap 15.3 (with glibc 2.31).
On openSUSE Tumbleweed + target board unix/-m32, this exposes:
...
(gdb) catch syscall pipe2^M
Unknown syscall name 'pipe2'.^M
...
which will be fixed in a folllow-up patch.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29056
Tom de Vries [Mon, 9 May 2022 08:42:16 +0000 (10:42 +0200)]
[gdb/tdep] Handle pipe2 syscall for amd64
When running test-case gdb.reverse/pipe-reverse.exp on openSUSE Tumbleweed,
I run into:
...
(gdb) continue^M
Continuing.^M
Process record and replay target doesn't support syscall number 293^M
Process record: failed to record execution log.^M
^M
Program stopped.^M
0x00007ffff7daabdb in pipe () from /lib64/libc.so.6^M
(gdb) FAIL: gdb.reverse/pipe-reverse.exp: continue to breakpoint: marker2
...
The current glibc on Tumbleweed is 2.35, which contains commit
"linux: Implement pipe in terms of __NR_pipe2", and consequently syscall pipe2
is used in stead of syscall pipe.
There is already support added for syscall pipe2 for aarch64 (which only has
syscall pipe2, not syscall pipe), so enable the same for amd64, by:
- adding amd64_sys_pipe2 in enum amd64_syscall
- translating amd64_sys_pipe2 to gdb_sys_pipe2 in amd64_canonicalize_syscall
Tested on x86_64-linux, specifically on:
- openSUSE Tumbleweed (with glibc 2.35), and
- openSUSE Leap 15.3 (with glibc 2.31).
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29056
GDB Administrator [Mon, 9 May 2022 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Sun, 8 May 2022 17:47:40 +0000 (19:47 +0200)]
[gdb/testsuite] Fix gdb.tui/scroll.exp with read1
When running test-case gdb.tui/scroll.exp, I get:
...
Box Dump (80 x 8) @ (0, 0):
0 $17 = 16
1 (gdb) p 17
2 $18 = 17
3 (gdb) p 18
4 $19 = 18
5 (gdb) p 19
6 $20 = 19
7 (gdb)
PASS: gdb.tui/scroll.exp: check cmd window in flip layout
...
but with check-read1 I get instead:
...
Box Dump (80 x 8) @ (0, 0):
0 (gdb) 15
1 (gdb) p 16
2 $17 = 16
3 (gdb) p 17
4 $18 = 17
5 (gdb) p 18
6 $19 = 18
7 (gdb) p 19
FAIL: gdb.tui/scroll.exp: check cmd window in flip layout
...
The "p 19" command is handled by Term::command, which sends the command and then
does Term::wait_for "^$gdb_prompt [string_to_regexp $cmd]", which:
- matches the line with "(gdb) p 19", and
- tries to match the following prompt "(gdb) "
The problem is that scrolling results in reissuing output before the "(gdb) p
19", and the second matching triggers on that. Consequently, wait_for no
longer translates gdb output into screen actions, and the screen does not
reflect the result of "p 19".
Fix this by using a new proc wait_for_region_contents, which in contrast to
wait_for can handle a multi-line regexp.
Tested on x86_64-linux with make targets check and check-read1.
Tom de Vries [Sun, 8 May 2022 17:38:13 +0000 (19:38 +0200)]
[gdb/testsuite] Fix gdb.cp/casts.exp with -m32
When running test-case gdb.cp/casts.exp with target board unix/-m32, I run
into:
...
(gdb) print (unsigned long long) &gd == gd_value^M
$31 = false^M
(gdb) FAIL: gdb.cp/casts.exp: print (unsigned long long) &gd == gd_value
...
With some additional printing, we can see in more detail why the comparison
fails:
...
(gdb) print /x &gd^M
$31 = 0xffffc5c8^M
(gdb) PASS: gdb.cp/casts.exp: print /x &gd
print /x (unsigned long long)&gd^M
$32 = 0xffffc5c8^M
(gdb) PASS: gdb.cp/casts.exp: print /x (unsigned long long)&gd
print /x gd_value^M
$33 = 0xffffffffffffc5c8^M
(gdb) PASS: gdb.cp/casts.exp: print /x gd_value
print (unsigned long long) &gd == gd_value^M
$34 = false^M
(gdb) FAIL: gdb.cp/casts.exp: print (unsigned long long) &gd == gd_value
...
The gd_value is set by this assignment:
...
unsigned long long gd_value = (unsigned long long) &gd;
...
The problem here is directly casting from a pointer to a non-pointer-sized
integer.
Fix this by adding an intermediate cast to std::uintptr_t.
Tested on x86_64-linux with native and target board unix/-m32.
Tom de Vries [Sun, 8 May 2022 16:32:05 +0000 (18:32 +0200)]
[gdb/testsuite] Handle init errors in gdb.mi/user-selected-context-sync.exp
In OBS, on aarch64-linux, with a gdb 11.1 based package, I run into:
...
(gdb) builtin_spawn -pty^M
new-ui mi /dev/pts/5^M
New UI allocated^M
(gdb) =thread-group-added,id="i1"^M
(gdb) ERROR: MI channel failed
warning: Error detected on fd 11^M
thread 1.1^M
Unknown thread 1.1.^M
(gdb) UNRESOLVED: gdb.mi/user-selected-context-sync.exp: mode=non-stop: \
test_cli_inferior: reset selection to thread 1.1
...
with many more UNRESOLVED following.
The ERROR is a common problem, filed as
https://sourceware.org/bugzilla/show_bug.cgi?id=28561 .
But the many UNRESOLVEDs are due to not checking whether the setup as done in
the test_setup function succeeds or not.
Fix this by:
- making test_setup return an error upon failure
- handling test_setup error at the call site
- adding a "setup done" pass/fail to be turned into an unresolved
in case of error during setup.
Tested on x86_64-linux, by manually triggering the error in
mi_gdb_start_separate_mi_tty.
Tom de Vries [Sun, 8 May 2022 12:05:27 +0000 (14:05 +0200)]
[gdb/testsuite] Fix gdb.ada/catch_ex_std.exp with remote-gdbserver-on-localhost
When running test-case gdb.ada/catch_ex_std.exp on target board
remote-gdbserver-on-localhost, I run into:
...
(gdb) continue^M
Continuing.^M
[Inferior 1 (process 15656) exited with code 0177]^M
(gdb) FAIL: gdb.ada/catch_ex_std.exp: runto: run to main
Remote debugging from host ::1, port 49780^M
/home/vries/foo: error while loading shared libraries: libsome_package.so: \
cannot open shared object file: No such file or directory^M
...
Fix this by adding the usual shared-library + remote-target helper
"gdb_load_shlib $sofile".
Tested on x86_64-linux with native and target board
remote-gdbserver-on-localhost.
Tom de Vries [Sun, 8 May 2022 11:53:41 +0000 (13:53 +0200)]
[gdb/testsuite] Fix gdb.threads/fork-plus-threads.exp with check-readmore
When running test-case gdb.threads/fork-plus-threads.exp with check-readmore,
I run into:
...
[Inferior 11 (process 7029) exited normally]^M
[Inferior 1 (process 6956) exited normally]^M
FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: \
inferior 1 exited (timeout)
...
The problem is that the regexp consuming the "Inferior exited normally"
messages:
- consumes more than one of those messages at a time, but
- counts only one of those messages.
Fix this by adopting a line-by-line approach, which deals with those messages
one at a time.
Tested on x86_64-linux with native, check-read1 and check-readmore.
GDB Administrator [Sun, 8 May 2022 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Sat, 7 May 2022 16:07:36 +0000 (10:07 -0600)]
Fix "catch syscall"
Simon pointed out that some recent patches of mine broke "catch
syscall". Apparently I forgot to finish the conversion of this code
when removing init_catchpoint. This patch completes the conversion
and fixes the bug.
Andrew Burgess [Tue, 26 Apr 2022 14:08:02 +0000 (15:08 +0100)]
gdb/readline: fix extra 'quit' message problem
After these two commits:
commit
4fb7bc4b147fd30b781ea2dad533956d0362295a
Date: Mon Mar 7 13:49:21 2022 +0000
readline: back-port changes needed to properly detect EOF
commit
91395d97d905c31ac38513e4aaedecb3b25e818f
Date: Tue Feb 15 17:28:03 2022 +0000
gdb: handle bracketed-paste-mode and EOF correctly
It was observed that, if a previous command is selected at the
readline prompt using the up arrow key, then when the command is
accepted (by pressing return) an unexpected 'quit' message will be
printed by GDB. Here's an example session:
(gdb) p 123
$1 = 123
(gdb) p 123
quit
$2 = 123
(gdb)
In this session the second 'p 123' was entered not by typing 'p 123',
but by pressing the up arrow key to select the previous command. It
is important that the up arrow key is used, typing Ctrl-p will not
trigger the bug.
The problem here appears to be readline's EOF detection when handling
multi-character input sequences. I have raised this issue on the
readline mailing list here:
https://lists.gnu.org/archive/html/bug-readline/2022-04/msg00012.html
a solution has been proposed here:
https://lists.gnu.org/archive/html/bug-readline/2022-04/msg00016.html
This patch includes a test for this issue as well as a back-port of
(the important bits of) readline commit:
commit
2ef9cec8c48ab1ae3a16b1874a49bd1f58eaaca1
Date: Wed May 4 11:18:04 2022 -0400
fix for setting RL_STATE_EOF in callback mode
That commit also includes some updates to the readline documentation
and tests that I have not included in this commit.
With this commit in place the unexpected 'quit' messages are resolved.
Alan Modra [Sat, 7 May 2022 07:40:53 +0000 (17:10 +0930)]
Fix multiple ubsan warnings in i386-dis.c
Commit
39fb369834a3 "opcodes: Make i386-dis.c thread-safe" introduced
a number of casts to bfd_signed_vma that cause undefined behaviour
with a 32-bit libbfd. Revert those changes.
* i386-dis.c (OP_E_memory): Do not cast disp to bfd_signed_vma
for negation.
(get32, get32s): Don't use bfd_signed_vma here.
Alan Modra [Sat, 7 May 2022 04:06:15 +0000 (13:36 +0930)]
Re: Fix new linker testsuite failures due to rwx segment test problems
Fix it some more.
bfd/
* elfnn-loongarch.c: Remove commented out elf_backend_* defines.
ld/
* testsuite/ld-elf/elf.exp (target_defaults_to_execstack): Match
arm*. Delete loongarch.
GDB Administrator [Sat, 7 May 2022 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
Carl Love [Thu, 5 May 2022 21:45:18 +0000 (16:45 -0500)]
PowerPC fix for gdb.server/sysroot.exp
On PowerPC, the stop in the printf function is of the form:
Breakpoint 2, 0x00007ffff7c6ab08 in printf@@GLIBC_2.17 () from /lib64/libc.so.6
On other architectures the output looks like:
Breakpoint 2, 0x0000007fb7ea29ac in printf () from /lib/aarch64-linux-gnu/libc.so.6
The following patch modifies the printf test by matchine any character
starting immediately after the printf. The test now works for PowerPC
output as well as the output from other architectures.
The test has been run on a Power 10 system and and Intel x86_64 system.
Nick Clifton [Fri, 6 May 2022 19:30:06 +0000 (20:30 +0100)]
Fix new linker testsuite failures due to rwx segment test problems
Tom Tromey [Sun, 1 May 2022 22:11:26 +0000 (16:11 -0600)]
Introduce catchpoint class
This introduces a catchpoint class that is used as the base class for
all catchpoints. init_catchpoint is rewritten to be a constructor
instead.
This changes the hierarchy a little -- some catchpoints now inherit
from base_breakpoint whereas previously they did not. This isn't a
problem, as long as re_set is redefined in catchpoint.
Tom Tromey [Mon, 2 May 2022 03:02:01 +0000 (21:02 -0600)]
Add initializers to tracepoint
This adds some initializers to tracepoint. I think right now these
may not be needed, due to obscure rules about zero initialization.
However, this will change in the next patch, and anyway it is clearer
to be explicit.
Tom Tromey [Sun, 1 May 2022 17:20:34 +0000 (11:20 -0600)]
Remove init_raw_breakpoint_without_location
This removes init_raw_breakpoint_without_location, replacing it with a
constructor on 'breakpoint' itself. The subclasses and callers are
all updated.
Tom Tromey [Sun, 1 May 2022 06:28:35 +0000 (00:28 -0600)]
Disable copying for breakpoint
It seems to me that breakpoint should use DISABLE_COPY_AND_ASSIGN.
This patch does this.
Tom Tromey [Sat, 30 Apr 2022 20:24:21 +0000 (14:24 -0600)]
Add constructor to exception_catchpoint
This adds a constructor to exception_catchpoint and simplifies the
caller.
Tom Tromey [Sat, 30 Apr 2022 20:21:45 +0000 (14:21 -0600)]
Add constructor to syscall_catchpoint
This adds a constructor to syscall_catchpoint and simplifies the
caller.
Tom Tromey [Sat, 30 Apr 2022 20:20:53 +0000 (14:20 -0600)]
Add constructor to signal_catchpoint
This adds a constructor to signal_catchpoint and simplifies the
caller.
Tom Tromey [Sat, 30 Apr 2022 20:19:44 +0000 (14:19 -0600)]
Add constructor to solib_catchpoint
This adds a constructor to solib_catchpoint and simplifies the caller.
Tom Tromey [Sat, 30 Apr 2022 18:52:51 +0000 (12:52 -0600)]
Add constructor to fork_catchpoint
This adds a constructor to fork_catchpoint and simplifies the caller.
Tom Tromey [Sat, 30 Apr 2022 18:51:17 +0000 (12:51 -0600)]
Remove unnecessary line from catch_exec_command_1
catch_exec_command_1 clears the new catchpoint's "exec_pathname"
field, but this is already done by virtue of calling "new".
Tom Tromey [Sat, 30 Apr 2022 18:36:08 +0000 (12:36 -0600)]
Constify breakpoint::print_recreate
This constifies breakpoint::print_recreate.
Tom Tromey [Sat, 30 Apr 2022 18:31:15 +0000 (12:31 -0600)]
Constify breakpoint::print_mention
This constifies breakpoint::print_mention.
Tom Tromey [Sat, 30 Apr 2022 18:25:36 +0000 (12:25 -0600)]
Constify breakpoint::print_one
This constifies breakpoint::print_one.
Tom Tromey [Sat, 30 Apr 2022 18:20:10 +0000 (12:20 -0600)]
Constify breakpoint::print_it
This constifies breakpoint::print_it. Doing this pointed out some
code in ada-lang.c that can be simplified a little as well.
Tom Tromey [Sat, 30 Apr 2022 14:06:39 +0000 (08:06 -0600)]
Move works_in_software_mode to watchpoint
works_in_software_mode is only useful for watchpoints. This patch
moves it from breakpoint to watchpoint, and changes it to return bool.
Tom Tromey [Sat, 30 Apr 2022 14:04:30 +0000 (08:04 -0600)]
Boolify breakpoint::explains_signal
This changes breakpoint::explains_signal to return bool.
Tom Tromey [Sat, 30 Apr 2022 14:02:36 +0000 (08:02 -0600)]
Remove breakpoint::ops
The breakpoint::ops field is set but never used. This removes it.
Tom Tromey [Sat, 30 Apr 2022 13:49:11 +0000 (07:49 -0600)]
Change print_recreate_thread to a method
This changes print_recreate_thread to be a method on breakpoint. This
function is only used as a helper by print_recreate methods, so I
thought this transformation made sense.
Carl Love [Fri, 6 May 2022 17:45:58 +0000 (17:45 +0000)]
PowerPC: bp-permanent.exp, kill-after-signal fix
The break point after the stepi on Intel is the entry point of the user
signal handler function test_signal_handler. The code at the break point
looks like:
0x<hex address> <test_signal_handler>: endbr64
On PowerPC with a Linux 5.9 kernel or latter, the address where gdb stops
after the stepi is in the vdso code inserted by the kernel. The code at the
breakpoint looks like:
0x<hex address> <__kernel_start_sigtramp_rt64>: bctrl
This is different from other architectures. As discussed below, recent
kernel changes involving the vdso for PowerPC have been made changes to the
signal handler code flow. PowerPC is now stopping in function
__kernel_start_sigtramp_rt64. PowerPC now requires an additional stepi to
reach the user signal handler unlike other architectures.
The bp-permanent.exp and kill-after-signal tests run fine on PowerPC with an
kernel that is older than Linux 5.9.
The PowerPC 64 signal handler was updated by the Linux kernel 5.9-rc1:
commit id:
0138ba5783ae0dcc799ad401a1e8ac8333790df9
powerpc/64/signal: Balance return predictor stack in signal trampoline
An additional change to the PowerPC 64 signal handler was made in Linux
kernel version 5.11-rc7 :
commit id:
24321ac668e452a4942598533d267805f291fdc9
powerpc/64/signal: Fix regression in __kernel_sigtramp_rt64() semantics
The first kernel change, puts code into the user space signal handler (in
the vdso) as a performance optimization to prevent the call/return stack
from getting out of balance. The patch ensures that the entire
user/kernel/vdso cycle is balanced with the addition of the "brctl"
instruction.
The second patch, fixes the semantics of __kernel_sigtramp_rt64(). A new
symbol is introduced to serve as the jump target from the kernel to the
trampoline which now consists of two parts.
The above changes for PowerPC signal handler, causes gdb to stop in the
kernel code not the user signal handler as expected. The kernel dispatches
to the vdso code which in turn calls into the signal handler. PowerPC is
special in that the kernel is using a vdso instruction (bctrl) to enter the
signal handler.
I do not have access to a system with the first patch but not the second. I did
test on Power 9 with the Linux 5.15.0-27-generic kernel. Both tests fail on
this Power 9 system. The two tests also fail on Power 10 with the Linux
5.14.0-70.9.1.el9_0.ppc64le kernel.
The following patch fixes the issue by checking if gdb stopped at "signal
handler called". If gdb stopped there, the tests verifies gdb is in the kernel
function __kernel_start_sigtramp_rt64 then does an additional stepi to reach the
user signal handler. With the patch below, the tests run without errors on both
the Power 9 and Power 10 systems with out any failures.
Alan Modra [Thu, 5 May 2022 23:15:46 +0000 (08:45 +0930)]
bfd targmatch.h makefile rule
I hit this just now with a make -j build after touching config.bfd.
mv: cannot stat 'targmatch.new': No such file or directory
make[2]: *** [Makefile:2336: targmatch.h] Error 1
make[2]: *** Waiting for unfinished jobs....
Fix that by not removing the target of the rule, a practice that seems
likely to cause parallel running of the rule recipe. The bug goes
back to 1997, the initial
c0734708814c commit.
* Makefile.am (targmatch.h): rm the temp file, not targmatch.h.
* Makefile.in: Regenerate.
Tom de Vries [Fri, 6 May 2022 02:51:43 +0000 (04:51 +0200)]
[gdb/testsuite] Fix gdb.dwarf2/locexpr-data-member-location.exp with nopie
When running test-case gdb.dwarf2/locexpr-data-member-location.exp with
target board unix/-fno-PIE/-no-pie/-m32 I run into:
...
(gdb) step^M
26 return 0;^M
(gdb) FAIL: gdb.dwarf2/locexpr-data-member-location.exp: step into foo
...
The problem is that the test-case tries to mimic some gdb_compile_shlib
behaviour using:
...
set flags {additional_flags=-fpic debug}
get_func_info foo $flags
...
but this doesn't work with the target board setting, because we end up doing:
...
gcc locexpr-data-member-location-lib.c -fpic -g -lm -fno-PIE -no-pie -m32 \
-o func_addr23029.x
...
while gdb_compile_shlib properly filters out the -fno-PIE -no-pie.
Consequently, the address for foo determined by get_func_info doesn't match
the actual address of foo.
Fix this by printing the address of foo using the result of gdb_compile_shlib.
GDB Administrator [Fri, 6 May 2022 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Wed, 4 May 2022 12:14:22 +0000 (08:14 -0400)]
gdb: use gdb::function_view for gdbarch_iterate_over_objfiles_in_search_order callback
A rather straightforward patch to change an instance of callback +
void pointer to gdb::function_view, allowing pasing lambdas that
capture, and eliminating the need for the untyped pointer.
Change-Id: I73ed644e7849945265a2c763f79f5456695b0037
Vladimir Mezentsev [Thu, 5 May 2022 07:08:19 +0000 (00:08 -0700)]
gprofng: use $host instead $target
By mistake, $target was used instead of $host to configure the gprogng build.
gprofng/ChangeLog
2022-04-28 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
PR gprofng/29113
PR gprofng/29116
* configure.ac: Use $host instead $target.
* libcollector/configure.ac: Likewise.
* configure: Rebuild.
* libcollector/configure: Rebuild.
Simon Marchi [Thu, 5 May 2022 13:54:59 +0000 (09:54 -0400)]
gdb: make regcache's cooked_write_test selftest work with native-extended-gdbserver board
Running
$ make check TESTS="gdb.gdb/unittest.exp" RUNTESTFLAGS="--target_board=native-extended-gdbserver"
I get some failures:
Running selftest regcache::cooked_write_test::i386.^M
Self test failed: target already pushed^M
Running selftest regcache::cooked_write_test::i386:intel.^M
Self test failed: target already pushed^M
Running selftest regcache::cooked_write_test::i386:x64-32.^M
Self test failed: target already pushed^M
Running selftest regcache::cooked_write_test::i386:x64-32:intel.^M
Self test failed: target already pushed^M
Running selftest regcache::cooked_write_test::i386:x86-64.^M
Self test failed: target already pushed^M
Running selftest regcache::cooked_write_test::i386:x86-64:intel.^M
Self test failed: target already pushed^M
Running selftest regcache::cooked_write_test::i8086.^M
Self test failed: target already pushed^M
This is because the native-extended-gdbserver automatically connects GDB
to a GDBserver on startup, and therefore pushes a remote target on the
initial inferior. cooked_write_test is currently written in a way that
errors out if the current inferior has a process_stratum_target pushed.
Rewrite it to use scoped_mock_context, so it doesn't depend on the
current inferior (the current one upon entering the function).
Change-Id: I0357f989eacbdecc4bf88b043754451b476052ad
Luis Machado [Tue, 3 May 2022 14:07:26 +0000 (15:07 +0100)]
Move TILE-Gx files to TARGET64_LIBOPCODES_CFILES
TILE-Gx is a 64-bit core, so we should include those files in the
TARGET64_LIBOPCODES_CFILES as opposed to TARGET32_LIBOPCODES_CFILES.
Luis Machado [Tue, 3 May 2022 10:28:59 +0000 (11:28 +0100)]
Don't define ARCH_cris for BFD64
I believe it is a mistake to define ARCH_cris when BFD64 is defined. It is
a 32-bit architecture, so should be placed outside of the BFD64 block.
Xi Ruoyao [Thu, 28 Apr 2022 17:25:20 +0000 (01:25 +0800)]
loongarch: Don't check ABI flags if no code section
Various packages (glib and gtk4 for example) produces data-only objects
using `ld -r -b binary` or `objcopy`, with no elf header flags set. But
these files also have no code sections, so they should be compatible
with all ABIs.
bfd/
* elfnn-loongarch.c (elfNN_loongarch_merge_private_bfd_data):
Skip ABI checks if the input has no code sections.
Reported-by: Wu Xiaotian <yetist@gmail.com>
Suggested-by: Wang Xuerui <i@xen0n.name>
Signed-off-by: Xi Ruoyao <xry111@mengyan1223.wang>
Andreas Krebbel [Thu, 5 May 2022 05:56:31 +0000 (07:56 +0200)]
IBM zSystems: mgrk, mg first operand requires register pair
opcodes/
* s390-opc.c (INSTR_RRF_R0RER): New instruction type.
(MASK_RRF_R0RER): Define mask for new instruction type.
* s390-opc.txt: Use RRF_R0RER for mgrk and RXY_RERRD for mg.
H.J. Lu [Thu, 5 May 2022 00:00:15 +0000 (17:00 -0700)]
bfd: Check NULL pointer before setting ref_real
PR ld/29086
* linker.c (bfd_wrapped_link_hash_lookup): Check NULL pointer
before setting ref_real.
GDB Administrator [Thu, 5 May 2022 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Mon, 25 Apr 2022 17:51:39 +0000 (10:51 -0700)]
LTO: Handle __real_SYM reference in IR
When an IR symbol SYM is referenced in IR via __real_SYM, its resolution
should be LDPR_PREVAILING_DEF, not PREVAILING_DEF_IRONLY, since LTO
doesn't know that __real_SYM should be resolved by SYM.
bfd/
PR ld/29086
* linker.c (bfd_wrapped_link_hash_lookup): Mark SYM is referenced
via __real_SYM.
include/
PR ld/29086
* bfdlink.h (bfd_link_hash_entry): Add ref_real.
ld/
PR ld/29086
* plugin.c (get_symbols): Resolve SYM definition to
LDPR_PREVAILING_DEF for __real_SYM reference.
* testsuite/ld-plugin/lto.exp: Run PR ld/29086 test.
* testsuite/ld-plugin/pr29086.c: New file.
Alan Modra [Wed, 4 May 2022 22:28:29 +0000 (07:58 +0930)]
cris bfd config
cris support will be built into a 32-bit bfd if using --enable-targets=all
on a 32-bit host, so we may as well make targmatch.h include cris.
* config.bfd (cris): Remove #idef BFD64.
Alan Modra [Wed, 4 May 2022 06:30:28 +0000 (16:00 +0930)]
PowerPC64 check_relocs
Tidy the dynamic reloc handling code in check_relocs, removing
leftover comments and code from when check_relocs was called as each
object file was read in.
* elf64-ppc.c (ppc64_elf_check_relocs): Tidy dynamic reloc
handling code.
(dec_dynrel_count): Do the same here.
Tom Tromey [Thu, 21 Apr 2022 17:20:22 +0000 (11:20 -0600)]
Fix crash when creating index from index
My patches yesterday to unify the DWARF index base classes had a bug
-- namely, I did the wholesale dynamic_cast-to-static_cast too hastily
and introduced a crash. This can be seen by trying to add an index to
a file that has an index, or by running a test like gdb-index-cxx.exp
using the cc-with-debug-names.exp target board.
This patch fixes the crash by introducing a new virtual method and
removing some of the static casts.
Luis Machado [Wed, 4 May 2022 14:07:42 +0000 (15:07 +0100)]
Fix build failure for aarch64 gdbserver
We're missing an argument.
Mark Wielaard [Tue, 3 May 2022 23:17:31 +0000 (23:17 +0000)]
gdb: Workaround stringop-overread warning in debuginfod-support.c on s390x
For some reason g++ 11.2.1 on s390x produces a spurious warning for
stringop-overread in debuginfod_is_enabled for url_view. Add a new
DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD macro to suppress this warning.
include/ChangeLog:
* diagnostics.h (DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD): New
macro.
gdb/ChangeLog:
* debuginfod-support.c (debuginfod_is_enabled): Use
DIAGNOSTIC_IGNORE_STRINGOP_OVERREAD on s390x.
Pedro Alves [Wed, 4 May 2022 10:09:07 +0000 (11:09 +0100)]
Fix GDBserver Aarch64 Linux regression
Luis noticed that the recent changes to gdbserver to make it track
process and threads independently regressed a few gdb.multi/*.exp
tests for aarch64-linux.
We started seeing the following internal error for
gdb.multi/multi-target-continue.exp for example:
Starting program: binutils-gdb/gdb/testsuite/outputs/gdb.multi/multi-target-continue/multi-target-continue ^M
Error in re-setting breakpoint 2: Remote connection closed^M
../../../repos/binutils-gdb/gdb/thread.c:85: internal-error: inferior_thread: Assertion `current_thread_ != nullptr' failed.^M
A problem internal to GDB has been detected,^M
further debugging may prove unreliable.
A backtrace looks like:
#0 thread_regcache_data (thread=thread@entry=0x0) at ../../../repos/binutils-gdb/gdbserver/inferiors.cc:120
#1 0x0000aaaaaaabf0e8 in get_thread_regcache (thread=0x0, fetch=fetch@entry=0) at ../../../repos/binutils-gdb/gdbserver/regcache.cc:31
#2 0x0000aaaaaaad785c in is_64bit_tdesc () at ../../../repos/binutils-gdb/gdbserver/linux-aarch64-low.cc:194
#3 0x0000aaaaaaad8a48 in aarch64_target::sw_breakpoint_from_kind (this=<optimized out>, kind=4, size=0xffffffffef04) at ../../../repos/binutils-gdb/gdbserver/linux-aarch64-low.cc:3226
#4 0x0000aaaaaaabe220 in bp_size (bp=0xaaaaaab6f3d0) at ../../../repos/binutils-gdb/gdbserver/mem-break.cc:226
#5 check_mem_read (mem_addr=
187649984471104, buf=buf@entry=0xaaaaaab625d0 "\006", mem_len=mem_len@entry=56) at ../../../repos/binutils-gdb/gdbserver/mem-break.cc:1862
#6 0x0000aaaaaaacc660 in read_inferior_memory (memaddr=<optimized out>, myaddr=0xaaaaaab625d0 "\006", len=56) at ../../../repos/binutils-gdb/gdbserver/target.cc:93
#7 0x0000aaaaaaac3d9c in gdb_read_memory (len=56, myaddr=0xaaaaaab625d0 "\006", memaddr=
187649984471104) at ../../../repos/binutils-gdb/gdbserver/server.cc:1071
#8 gdb_read_memory (memaddr=
187649984471104, myaddr=0xaaaaaab625d0 "\006", len=56) at ../../../repos/binutils-gdb/gdbserver/server.cc:1048
#9 0x0000aaaaaaac82a4 in process_serial_event () at ../../../repos/binutils-gdb/gdbserver/server.cc:4307
#10 handle_serial_event (err=<optimized out>, client_data=<optimized out>) at ../../../repos/binutils-gdb/gdbserver/server.cc:4520
#11 0x0000aaaaaaafbcd0 in gdb_wait_for_event (block=block@entry=1) at ../../../repos/binutils-gdb/gdbsupport/event-loop.cc:700
#12 0x0000aaaaaaafc0b0 in gdb_wait_for_event (block=1) at ../../../repos/binutils-gdb/gdbsupport/event-loop.cc:596
#13 gdb_do_one_event () at ../../../repos/binutils-gdb/gdbsupport/event-loop.cc:237
#14 0x0000aaaaaaacacb0 in start_event_loop () at ../../../repos/binutils-gdb/gdbserver/server.cc:3518
#15 captured_main (argc=4, argv=<optimized out>) at ../../../repos/binutils-gdb/gdbserver/server.cc:3998
#16 0x0000aaaaaaab66dc in main (argc=<optimized out>, argv=<optimized out>) at ../../../repos/binutils-gdb/gdbserver/server.cc:4084
This sequence of functions is invoked due to a series of conditions:
1 - The probe-based breakpoint mechanism failed (for some reason) so ...
2 - ... gdbserver has to know what type of architecture it is dealing
with so it can pick the right breakpoint kind, so it wants to
check if we have a 64-bit target.
3 - To determine the size of a register, we currently fetch the
current thread's register cache, and the current thread pointer
is now nullptr.
In #3, the current thread is nullptr because gdb_read_memory clears it
on purpose, via set_desired_process, exactly to expose code relying on
the current thread when it shouldn't. It was always possible to end
up in this situation (when the current thread exits), but it was
harder to reproduce before.
This commit fixes it by tweaking is_64bit_tdesc to look at the current
process's tdesc instead of the current thread's tdesc.
Note that the thread's tdesc is itself filled from the process's
tdesc, so this should be equivalent:
struct regcache *
get_thread_regcache (struct thread_info *thread, int fetch)
{
struct regcache *regcache;
regcache = thread_regcache_data (thread);
...
if (regcache == NULL)
{
struct process_info *proc = get_thread_process (thread);
gdb_assert (proc->tdesc != NULL);
regcache = new_register_cache (proc->tdesc);
set_thread_regcache_data (thread, regcache);
}
...
Change-Id: Ibc809d7345e70a2f058b522bdc5cdbdca97e2cdc
Simon Marchi [Sat, 30 Apr 2022 03:21:15 +0000 (23:21 -0400)]
gdb/remote: send qSymbol to all inferiors on startup
start_remote_1 calls remote_check_symbols after things are set up to
give the remote side a chance to look up symbols. One call to
remote_check_symbols sets the "general thread", if needed, and sends one
qSymbol packet. However, a remote target could have more than one
process on initial connection, and this would send a qSymbol for only
one of these processes.
Change it to iterate on all the target's inferiors and send a qSymbol
packet for each one.
I tested this by changing gdbserver to spawn two processes on startup:
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index
33c42714e72..
9b682e9f85f 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -3939,6 +3939,7 @@ captured_main (int argc, char *argv[])
/* Wait till we are at first instruction in program. */
target_create_inferior (program_path.get (), program_args);
+ target_create_inferior (program_path.get (), program_args);
/* We are now (hopefully) stopped at the first instruction of
the target process. This assumes that the target process was
Instead of hacking GDBserver, it should also be possible to test this by
starting manually two inferiors on an "extended-remote" connection,
disconnecting from GDBserver (with the disconnect command), and
re-connecting.
I was able to see qSymbol being sent for each inferior:
[remote] Sending packet: $Hgp828dc.828dc#1f
[remote] Packet received: OK
[remote] Sending packet: $qSymbol::#5b
[remote] Packet received: qSymbol:
6764625f6167656e745f6764625f74705f686561705f627566666572
[remote] Sending packet: $qSymbol::
6764625f6167656e745f6764625f74705f686561705f627566666572#1e
[remote] Packet received: qSymbol:
6e70746c5f76657273696f6e
[remote] Sending packet: $qSymbol::
6e70746c5f76657273696f6e#4d
[remote] Packet received: OK
[remote] Sending packet: $Hgp828dd.828dd#21
[remote] Packet received: OK
[remote] Sending packet: $qSymbol::#5b
[remote] Packet received: qSymbol:
6764625f6167656e745f6764625f74705f686561705f627566666572
[remote] Sending packet: $qSymbol::
6764625f6167656e745f6764625f74705f686561705f627566666572#1e
[remote] Packet received: qSymbol:
6e70746c5f76657273696f6e
[remote] Sending packet: $qSymbol::
6e70746c5f76657273696f6e#4d
[remote] Packet received: OK
Note that there would probably be more work to be done to fully support
this scenario, more things that need to be done for each discovered
inferior instead of just for one.
Change-Id: I21c4ecf6367391e2e389b560f0b4bd906cf6472f
Simon Marchi [Sat, 30 Apr 2022 03:21:14 +0000 (23:21 -0400)]
gdb/remote: iterate on pspace inferiors in remote_new_objfile
Commit
152a17495663 ("gdb: prune inferiors at end of
fetch_inferior_event, fix intermittent failure of
gdb.threads/fork-plus-threads.exp") broke some tests with the
native-gdbserver board, such as:
(gdb) PASS: gdb.base/step-over-syscall.exp: detach-on-fork=off: follow-fork=child: break cond on target : vfork: break marker
continue^M
Continuing.^M
terminate called after throwing an instance of 'gdb_exception_error'^M
I can manually reproduce the issue by running (just the commands that
the test does as a one liner):
$ ./gdb -q --data-directory=data-directory \
testsuite/outputs/gdb.base/step-over-syscall/step-over-vfork \
-ex "tar rem | ../gdbserver/gdbserver - testsuite/outputs/gdb.base/step-over-syscall/step-over-vfork" \
-ex "b main" \
-ex c \
-ex "d 1" \
-ex "set displaced-stepping off" \
-ex "b *0x7ffff7d7ac5a if main == 0" \
-ex "set detach-on-fork off" \
-ex "set follow-fork-mode child" \
-ex c \
-ex "inferior 1" \
-ex "b marker" \
-ex c
... where 0x7ffff7d7ac5a is the exact address of the vfork syscall
(which can be found by looking at gdb.log).
The important part of the above is that a vfork syscall creates inferior
2, then inferior 2 executes until exit, then we switch back to inferior
1 and try to resume it.
The uncaught exception happens here:
#4 0x00005596969d81a9 in error (fmt=0x559692da9e40 "Cannot execute this command while the target is running.\nUse the \"interrupt\" command to stop the target\nand then try again.")
at /home/simark/src/binutils-gdb/gdbsupport/errors.cc:43
#5 0x0000559695af6f66 in remote_target::putpkt_binary (this=0x617000038080, buf=0x559692da4380 "qSymbol::", cnt=9) at /home/simark/src/binutils-gdb/gdb/remote.c:9560
#6 0x0000559695af6aaf in remote_target::putpkt (this=0x617000038080, buf=0x559692da4380 "qSymbol::") at /home/simark/src/binutils-gdb/gdb/remote.c:9518
#7 0x0000559695ab50dc in remote_target::remote_check_symbols (this=0x617000038080) at /home/simark/src/binutils-gdb/gdb/remote.c:5141
#8 0x0000559695b3cccf in remote_new_objfile (objfile=0x0) at /home/simark/src/binutils-gdb/gdb/remote.c:14600
#9 0x0000559693bc52a9 in std::__invoke_impl<void, void (*&)(objfile*), objfile*> (__f=@0x61b0000167f8: 0x559695b3cb1d <remote_new_objfile(objfile*)>) at /usr/include/c++/11.2.0/bits/invoke.h:61
#10 0x0000559693bb2848 in std::__invoke_r<void, void (*&)(objfile*), objfile*> (__fn=@0x61b0000167f8: 0x559695b3cb1d <remote_new_objfile(objfile*)>) at /usr/include/c++/11.2.0/bits/invoke.h:111
#11 0x0000559693b8dddf in std::_Function_handler<void (objfile*), void (*)(objfile*)>::_M_invoke(std::_Any_data const&, objfile*&&) (__functor=..., __args#0=@0x7ffe0bae0590: 0x0) at /usr/include/c++/11.2.0/bits/std_function.h:291
#12 0x00005596956374b2 in std::function<void (objfile*)>::operator()(objfile*) const (this=0x61b0000167f8, __args#0=0x0) at /usr/include/c++/11.2.0/bits/std_function.h:560
#13 0x0000559695633c64 in gdb::observers::observable<objfile*>::notify (this=0x55969ef5c480 <gdb::observers::new_objfile>, args#0=0x0) at /home/simark/src/binutils-gdb/gdb/../gdbsupport/observable.h:150
#14 0x0000559695df6cc2 in clear_symtab_users (add_flags=...) at /home/simark/src/binutils-gdb/gdb/symfile.c:2873
#15 0x000055969574c263 in program_space::~program_space (this=0x6120000c8a40, __in_chrg=<optimized out>) at /home/simark/src/binutils-gdb/gdb/progspace.c:154
#16 0x0000559694fc086b in delete_inferior (inf=0x61700003bf80) at /home/simark/src/binutils-gdb/gdb/inferior.c:205
#17 0x0000559694fc341f in prune_inferiors () at /home/simark/src/binutils-gdb/gdb/inferior.c:390
#18 0x0000559695017ada in fetch_inferior_event () at /home/simark/src/binutils-gdb/gdb/infrun.c:4293
#19 0x0000559694f629e6 in inferior_event_handler (event_type=INF_REG_EVENT) at /home/simark/src/binutils-gdb/gdb/inf-loop.c:41
#20 0x0000559695b3b0e3 in remote_async_serial_handler (scb=0x6250001ef100, context=0x6170000380a8) at /home/simark/src/binutils-gdb/gdb/remote.c:14466
#21 0x0000559695c59eb7 in run_async_handler_and_reschedule (scb=0x6250001ef100) at /home/simark/src/binutils-gdb/gdb/ser-base.c:138
#22 0x0000559695c5a42a in fd_event (error=0, context=0x6250001ef100) at /home/simark/src/binutils-gdb/gdb/ser-base.c:189
#23 0x00005596969d9ebf in handle_file_event (file_ptr=0x60700005af40, ready_mask=1) at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:574
#24 0x00005596969da7fa in gdb_wait_for_event (block=0) at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:700
#25 0x00005596969d8539 in gdb_do_one_event () at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:212
If I enable "set debug infrun" just before the last continue, we see:
(gdb) continue
Continuing.
[infrun] clear_proceed_status_thread: 965604.965604.0
[infrun] proceed: enter
[infrun] proceed: addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT
[infrun] scoped_disable_commit_resumed: reason=proceeding
[infrun] start_step_over: enter
[infrun] start_step_over: stealing global queue of threads to step, length = 0
[infrun] operator(): step-over queue now empty
[infrun] start_step_over: exit
[infrun] resume_1: step=0, signal=GDB_SIGNAL_0, trap_expected=0, current thread [965604.965604.0] at 0x7ffff7d7ac5c
[infrun] do_target_resume: resume_ptid=965604.0.0, step=0, sig=GDB_SIGNAL_0
[infrun] prepare_to_wait: prepare_to_wait
[infrun] reset: reason=proceeding
[infrun] maybe_set_commit_resumed_all_targets: enabling commit-resumed for target remote
[infrun] maybe_call_commit_resumed_all_targets: calling commit_resumed for target remote
[infrun] proceed: exit
[infrun] fetch_inferior_event: enter
[infrun] scoped_disable_commit_resumed: reason=handling event
[infrun] do_target_wait: Found 2 inferiors, starting at #1
[infrun] random_pending_event_thread: None found.
[infrun] print_target_wait_results: target_wait (-1.0.0 [process -1], status) =
[infrun] print_target_wait_results: 965604.965604.0 [Thread 965604.965604],
[infrun] print_target_wait_results: status->kind = VFORK_DONE
[infrun] handle_inferior_event: status->kind = VFORK_DONE
[infrun] context_switch: Switching context from 0.0.0 to 965604.965604.0
[infrun] handle_vfork_done: not waiting for a vfork-done event
[infrun] start_step_over: enter
[infrun] start_step_over: stealing global queue of threads to step, length = 0
[infrun] operator(): step-over queue now empty
[infrun] start_step_over: exit
[infrun] resume_1: step=0, signal=GDB_SIGNAL_0, trap_expected=0, current thread [965604.965604.0] at 0x7ffff7d7ac5c
[infrun] do_target_resume: resume_ptid=965604.0.0, step=0, sig=GDB_SIGNAL_0
[infrun] prepare_to_wait: prepare_to_wait
[infrun] reset: reason=handling event
[infrun] maybe_set_commit_resumed_all_targets: enabling commit-resumed for target remote
[infrun] maybe_call_commit_resumed_all_targets: calling commit_resumed for target remote
terminate called after throwing an instance of 'gdb_exception_error'
What happens is:
- After doing the "continue" on inferior 1, the remote target gives us
a VFORK_DONE event. The core ignores it and resumes inferior 1.
- Since prune_inferiors is now called after each handled event, in
fetch_inferior_event, it is called after we handled that VFORK_DONE
event and resumed inferior 1.
- Inferior 2 is pruned, which (see backtrace above) causes its program
space to be deleted, which clears the symtabs for that program space,
which calls the new_objfile observable and remote_new_objfile
observer (with a nullptr objfile, to indicate that the previously
loaded symbols have been discarded), which calls
remote_check_symbols.
remote_check_symbols is the function that sends the qSymbol packet, to
let the remote side ask for symbol addresses. The problem is that the
remote target is working in all-stop / sync mode and is currently
resumed. It has sent a vCont packet to resume the target and is waiting
for a stop reply. It can't send any packets in the mean time. That
causes the exception to be thrown.
This wasn't a problem before, when prune_inferiors was called in
normal_stop, because it was always called at a time the target was not
resumed.
An important observation here is that the new_objfile observable is
invoked for a change in inferior 2's program space (inferior 2's program
space is the current program space). Inferior 2 isn't bound to any
process on the remote side (it has exited, that's why it's being
pruned). It doesn't make sense to try to send a qSymbol packet for a
process that doesn't exist on the remote side. remote_check_symbols
actually attempts to avoid that:
/* The remote side has no concept of inferiors that aren't running
yet, it only knows about running processes. If we're connected
but our current inferior is not running, we should not invite the
remote target to request symbol lookups related to its
(unrelated) current process. */
if (!target_has_execution ())
return;
The problem here is that while inferior 2's program space is the current
program space, inferior 1 is the current inferior. So the check above
passes, since inferior has execution. We therefore try to send a
qSymbol packet for inferior 1 in reaction to a change in inferior 2's
program space, that's wrong.
This exposes a conceptual flaw in remote_new_objfile. The "new_objfile"
event concerns a specific program space, which can concern multiple
inferiors, as inferiors can share a program space. We shouldn't
consider the current inferior at all, but instead all inferiors bound to
the affected program space. Especially since the current inferior can
be unrelated to the current program space at that point.
To be clear, we are in this state because ~program_space sets itself as
the current program space, but there is no more inferior having that
program space to switch to, inferior 2 has already been unlinked.
To fix this, make remote_new_objfile iterate on all inferiors bound to
the affected program space. Remove the target_has_execution check from
remote_check_symbols, replace it with an assert. All callers must
ensure that the current inferior has execution before calling it.
Change-Id: Ica643145bcc03115248290fd310cadab8ec8371c
Jan Beulich [Wed, 4 May 2022 06:36:14 +0000 (08:36 +0200)]
Dwarf: rename yet another instance of "index"
As before, on sufficiently old glibc this conflicts with a global
identifier in the library headers. While there also zap the unusual
padding by blanks.
Martin Liska [Wed, 4 May 2022 06:25:37 +0000 (08:25 +0200)]
LTO plugin: sync header file with GCC
include/ChangeLog:
* plugin-api.h (enum ld_plugin_tag): Sync with GCC.
Alan Modra [Wed, 30 Mar 2022 21:11:03 +0000 (07:41 +1030)]
PowerPC32 treatment of absolute symbols
As already done for PowerPC64, fix dynamic relocs for absolute symbols.
The patch also tidies the dynamic reloc handling code in check_relocs,
removing leftover comments and code from when check_relocs was called
as each object file was read in.
bfd/
* elf32-ppc.c (ppc_elf_check_relocs): Set isym and ifunc earlier.
Rearrange tests for dynamic relocs, handling absolute symbols.
(allocate_dynrelocs): Don't allocate dynamic relocs for locally
defined absolute symbols.
(ppc_elf_size_dynamic_sections): Similarly.
(ppc_elf_relocate_section): Similarly.
ld/
* testsuite/ld-powerpc/abs32-pie.d,
* testsuite/ld-powerpc/abs32-pie.r,
* testsuite/ld-powerpc/abs32-reloc.s,
* testsuite/ld-powerpc/abs32-shared.d,
* testsuite/ld-powerpc/abs32-shared.r,
* testsuite/ld-powerpc/abs32-static.d,
* testsuite/ld-powerpc/abs32-static.r: New tests.
* testsuite/ld-powerpc/powerpc.exp: Run them.
John Baldwin [Wed, 4 May 2022 04:38:12 +0000 (21:38 -0700)]
gdbserver: Fix build after adding tls feature to arm tdesc.
GDB Administrator [Wed, 4 May 2022 00:00:17 +0000 (00:00 +0000)]
Automatic date update in version.in
John Baldwin [Tue, 3 May 2022 23:05:11 +0000 (16:05 -0700)]
NEWS: Add a note for TLS support on FreeBSD/arm and FreeBSD/Aarch64.