binutils-gdb.git
20 months ago[gdb/python] Avoid queue.SimpleQueue for python 3.6
Tom de Vries [Thu, 5 Jan 2023 16:35:41 +0000 (17:35 +0100)]
[gdb/python] Avoid queue.SimpleQueue for python 3.6

On openSUSE Leap 15.4 with python 3.6, the gdb.dap/basic-dap.exp test-case
fails as follows:
...
ERROR: eof reading json header
    while executing
"error "eof reading json header""
    invoked from within
"expect {
-i exp19 -timeout 10
        -re "^Content-Length: (\[0-9\]+)\r\n" {
            set length $expect_out(1,string)
            exp_continue
        }
        -re "^(\[^\r\n\]+)..."
    ("uplevel" body line 1)
    invoked from within
"uplevel $body" NONE eof reading json header
UNRESOLVED: gdb.dap/basic-dap.exp: startup - initialize
...

Investigation using a "catch throw" shows that:
...
(gdb)
    at gdb/python/py-utils.c:396
396             error (_("Error occurred in Python: %s"), msg.get ());
(gdb) p msg.get ()
$1 = 0x2b91d10 "module 'queue' has no attribute 'SimpleQueue'"
...

The python class queue.SimpleQueue was introduced in python 3.7.

Fix this by falling back to queue.Queue for python <= 3.6.

Tested on x86_64-linux, by successfully running the test-case:
...
 # of expected passes            47
...

20 months agoAdd type to expression dump of symbol
Tom Tromey [Mon, 2 Jan 2023 17:24:26 +0000 (10:24 -0700)]
Add type to expression dump of symbol

I recently had cause to dump some expressions from gdb.  I got output
like this:

 Operation: BINOP_GTR
  Operation: OP_VAR_VALUE
   Block symbol:
    Symbol: small_value
    Block: 0x39b4c20
  Operation: OP_LONG
   Operation: OP_LONG
    Type: int
    Constant: 0x0000000000000014

This is ok, but it would have been handy to see the type of the
symbol.  This patch adds this information.

Reviewed-By: Bruno Larsen <blarsen@redhat.com>
20 months agoRemove Stephen Casner as the PDP11 maintainer.
Nick Clifton [Thu, 5 Jan 2023 14:40:16 +0000 (14:40 +0000)]
Remove Stephen Casner as the PDP11 maintainer.

20 months agoAdd an extra emulation called arm64pe to the aarch64pe emulation.
Nick Clifton [Thu, 5 Jan 2023 11:00:35 +0000 (11:00 +0000)]
Add an extra emulation called arm64pe to the aarch64pe emulation.

20 months agoUn xfail the PR19719 test for the AArch64 architecture
Andreas K. Huettel [Thu, 5 Jan 2023 08:35:18 +0000 (08:35 +0000)]
Un xfail the PR19719 test for the AArch64 architecture

20 months agoUpdated Bulgarian and Russian translations for the gprof subdirectory
Nick Clifton [Thu, 5 Jan 2023 08:27:35 +0000 (08:27 +0000)]
Updated Bulgarian and Russian translations for the gprof subdirectory

20 months agoPR29963, PDP11 link produces spurious relocation truncated messages
Paul Koning [Wed, 4 Jan 2023 22:29:00 +0000 (22:29 +0000)]
PR29963, PDP11 link produces spurious relocation truncated messages

PDP11 is a 16-bit processor with 16-bit logical addresses.  Therefore
wrapping should be allowed on the 16-bit relocs, and may as well be
allowed for the 32-bit reloc too.

PR 29963
* pdp11.c (howto_table_pdp11): Use complain_overflow_dont.

20 months agosim: mips: add multi source to built sources
Mike Frysinger [Tue, 3 Jan 2023 06:58:23 +0000 (01:58 -0500)]
sim: mips: add multi source to built sources

The multirun generation mode is a bit of a mess as generated run files
depend on generate igen files, all with unknown names ahead of time.
In the multirun mode, be lazy and declare all of these generated source
files as built sources so they'll be created early on.

20 months agosim: Move getopt checking inside SIM_AC_PLATFORM
Tsukasa OI [Wed, 4 Jan 2023 01:33:29 +0000 (01:33 +0000)]
sim: Move getopt checking inside SIM_AC_PLATFORM

This commit moves getopt declaration checker originally in sim/
configure.ac; added in commit 340aa4f6872c ("sim: Check known getopt
definition existence") to sim/m4/sim_ac_platform.m4 (inside the
SIM_AC_PLATFORM macro).

It also regenerates configuration files using the maintainer mode.

20 months agosim: bpf: fix testsuite due to linker warnings [PR sim/29954]
Guillermo E. Martinez [Wed, 4 Jan 2023 21:41:09 +0000 (15:41 -0600)]
sim: bpf: fix testsuite due to linker warnings [PR sim/29954]

On a bpf-*-* testsuite fails:
./ld/ld-new: warning: test has a LOAD segment with RWX permissions

Adjusting `--memory-size=10Mb' to the simulator bpf testsuite passes.

Tested on bpf-*-*:

Bug: https://sourceware.org/PR29954

sim/testsuite:
* bpf/allinsn.exp (SIMFLAGS_FOR_TARGET): Adjust sim flags.

20 months agoAutomatic date update in version.in
GDB Administrator [Thu, 5 Jan 2023 00:00:22 +0000 (00:00 +0000)]
Automatic date update in version.in

20 months agoMAINTAINERS: add myself as maintainer of libsframe
Indu Bhagat [Wed, 4 Jan 2023 00:45:17 +0000 (16:45 -0800)]
MAINTAINERS: add myself as maintainer of libsframe

binutils/
* MAINTAINERS: Add myself as maintainer of libsframe.

20 months agox86: Remove duplicated I386_PCREL_TYPE_P/X86_64_PCREL_TYPE_P
H.J. Lu [Wed, 4 Jan 2023 19:09:50 +0000 (11:09 -0800)]
x86: Remove duplicated I386_PCREL_TYPE_P/X86_64_PCREL_TYPE_P

I386_PCREL_TYPE_P and X86_64_PCREL_TYPE_P are defined twice.  Remove
the duplications.

* elfxx-x86.h (I386_PCREL_TYPE_P): Remove duplication.
(X86_64_PCREL_TYPE_P): Likewise.

20 months agogdb: ensure test_name is initialized in gdb_breakpoint
Lancelot SIX [Wed, 4 Jan 2023 17:58:08 +0000 (17:58 +0000)]
gdb: ensure test_name is initialized in gdb_breakpoint

A refactoring in 4b9728bec15 (gdb: use gdb_test_multiple in
gdb_breakpoint) left the $test_name variable undefined.

This patch fixes this.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
20 months agoUse first_opcode in another spot
Tom Tromey [Mon, 19 Dec 2022 18:15:55 +0000 (11:15 -0700)]
Use first_opcode in another spot

I found one place that could use expression::first_opcode.

Reviewed-By: Lancelot Six <lancelot.six@amd.com>
20 months agoConvert exp_uses_objfile to a method of expression
Tom Tromey [Mon, 19 Dec 2022 18:14:02 +0000 (11:14 -0700)]
Convert exp_uses_objfile to a method of expression

This changes the exp_uses_objfile function to be a method of
'expression'.

Reviewed-By: Lancelot Six <lancelot.six@amd.com>
20 months agogdb: use gdb_test_multiple in gdb_breakpoint
Simon Marchi [Tue, 3 Jan 2023 19:22:16 +0000 (14:22 -0500)]
gdb: use gdb_test_multiple in gdb_breakpoint

When running the testsuite in a non-optimized build on a slow machine, I
sometimes get:

    UNTESTED: gdb.gdb/selftest.exp: Cannot set breakpoint at captured_main, skipping testcase.

do_self_tests, in lib/selftest-support.exp, uses `with_timeout_factor
10`, to account for the fact that reading the debug info of the gdb
binary (especially in a non-optimized GDB) can take time.  But then it
ends up calling gdb_breakpoint, which uses gdb_expect with a hard-coded
timeout of 30 seconds.

Fix this by making gdb_breakpoint use gdb_test_multiple, which is a
desired change anyway for this kind of simple command / expected
output case.

Change-Id: I9b06ce991cc584810d8cc231b2b4893980b8be75
Reviewed-By: Lancelot Six <lancelot.six@amd.com>
20 months agoRe: Avoid unaligned pointer reads in PEP .idata section
Alan Modra [Wed, 4 Jan 2023 13:20:12 +0000 (23:50 +1030)]
Re: Avoid unaligned pointer reads in PEP .idata section

Fix testsuite fallout.

* testsuite/ld-pe/cfi.d: Adjust for changed .idata padding.
* testsuite/ld-pe/secidx_64.d: Likewise.
* testsuite/ld-pe/secrel_64.d: Likewise.

20 months agoobjcopy fuzzed pe out of memory
Alan Modra [Wed, 4 Jan 2023 12:30:12 +0000 (23:00 +1030)]
objcopy fuzzed pe out of memory

This occurs when attempting to read back a section from the output
file in _bfd_XX_bfd_copy_private_bfd_data_common.  The copy of the
section failed size sanity checking, thus it won't be written.

* objcopy.c (copy_object): Return false if copy_section or
copy_relocations_in_section fails.

20 months agofuzzed file timeout
Alan Modra [Wed, 4 Jan 2023 11:16:06 +0000 (21:46 +1030)]
fuzzed file timeout

objcopy of archive, element containing an object with a fuzzed section
size far exceeding the element size.  copy_section detects this, but
the temp file is laid out for the large section.  It can take a long
time to write terabytes of sparse file, a waste of time when it will
be deleted.

* objcopy.c (copy_archive): Don't write element contents after
bad status result from copy_object.

20 months agoasan: segv in parse_module
Alan Modra [Wed, 4 Jan 2023 11:13:54 +0000 (21:43 +1030)]
asan: segv in parse_module

* vms-alpha.c (parse_module): Ignore DST__K_SRC_SETFILE data
if out of range.

20 months agoaddr2line out of memory on fuzzed file
Alan Modra [Wed, 4 Jan 2023 11:09:54 +0000 (21:39 +1030)]
addr2line out of memory on fuzzed file

Another case of fuzzers finding the section size sanity checks are
avoided with SHT_NOBITS sections.

* dwarf2.c (read_section): Check that the DWARF section being
read has contents.

20 months agogdb: fix some #ifdef logic in bt-utils.h
Andrew Burgess [Wed, 4 Jan 2023 11:36:57 +0000 (11:36 +0000)]
gdb: fix some #ifdef logic in bt-utils.h

In passing I spotted some incorrect #ifdef logic in bt-utils.h.  The
logic in question has existed since the file was originally added in
commit:

  commit abbbd4a3e0ca51132e7fb31a43f896d29894dae0
  Date:   Wed Aug 11 13:24:33 2021 +0100

      gdb: use libbacktrace to create a better backtrace for fatal signals

The code is trying to select between using libbacktrace or using the
execinfo supplied backtrace API.

First we check to see if we can use libbacktrace.  If we can then we
include some header files, and then set some defines to indicate that
libbacktrace is being used.

Then we check if execinfo is available, if it is then we include
<execinfo.h> and set some alternative defines.

In theory the second block of logic should not trigger if the first
block (that uses libbacktrace) has also triggered, but we incorrectly
check the define 'PRINT_BACKTRACE_ON_FATAL_SIGNAL' instead of checking
for 'GDB_PRINT_INTERNAL_BACKTRACE_USING_LIBBACKTRACE', so the second
block triggers more than it should.  The
'PRINT_BACKTRACE_ON_FATAL_SIGNAL' define is not defined anywhere, this
was a mistake in the original commit.

In reality this is harmless, we include <execinfo.h> when we don't
need too, but in by-utils.c the libbacktrace define is always checked
for before the execinfo define, so we never actually end up using the
execinfo path (when libbacktrace is available).  But I figure its
still worth cleaning this up.

I've tested GDB in a "default" build where libbacktrace is used, and
when configuring with --disable-libbacktrace which causes the execinfo
backtrace API to be used instead, both still appear to work fine.

There should be no user visible changes after this commit.

20 months agogdb: add 'maintenance print record-instruction' command
Bruno Larsen [Thu, 3 Nov 2022 09:17:36 +0000 (10:17 +0100)]
gdb: add 'maintenance print record-instruction' command

While chasing some reverse debugging bugs, I found myself wondering what
was recorded by GDB to undo and redo a certain instruction. This commit
implements a simple way of printing that information.

If there isn't enough history to print the desired instruction (such as
when the user hasn't started recording yet or when they request 2
instructions back but only 1 was recorded), GDB warns the user like so:

(gdb) maint print record-instruction
Not enough recorded history

If there is enough, GDB prints the instruction like so:

(gdb) maint print record-instruction
4 bytes of memory at address 0x00007fffffffd5dc changed from: 01 00 00 00
Register eflags changed: [ IF ]
Register rip changed: (void (*)()) 0x401115 <main+15>

Approved-by: Eli Zaretskii <eliz@gnu.org>
Reviewed-by: Alexandra Hajkova <ahajkova@redhat.com>
Reviewed-by: Lancelot Six <lsix@lancelotsix.com>
Approved-by: Tom Tromey <tom@tromey.com>
20 months agoFix AArch64 linker testsuite failures trigeered by differences in build environments.
Andreas K. Huettel [Wed, 4 Jan 2023 09:30:14 +0000 (09:30 +0000)]
Fix AArch64 linker testsuite failures trigeered by differences in build environments.

PR 29843
* testsuite/ld-aarch64/bti-plt-5.d: Relax regxps slightly to allow
for differences in build environments.
* testsuite/ld-aarch64/tls-relax-gdesc-le-now.d: Likewise.

20 months agoAvoid unaligned pointer reads in PEP .idata section
Mark Harmstone [Sat, 31 Dec 2022 20:55:46 +0000 (20:55 +0000)]
Avoid unaligned pointer reads in PEP .idata section

This is something I discovered when working on aarch64, though it's
relevant to x86_64 too.

The PE32+ imports are located in the .idata section, which starts off
with a 20-byte structure for each DLL, containing offsets into the rest
of the section. This is the Import Directory Table in
https://learn.microsoft.com/en-us/windows/win32/debug/pe-format, which
is a concatenation of the .idata$2 sections. This is then followed by an
20 zero bytes generated by the linker script, which calls this .idata$3.

After this comes the .idata$4 entries for each function, which the
loader overwrites with the function pointers. Because there's no padding
between .idata$3 and .idata$4, this means that if there's an even number
of DLLs, the function pointers won't be aligned on an 8-byte boundary.

Misaligned reads are slower on x86_64, but this is more important on
aarch64, as the e.g. `ldr x0, [x0, :lo12:__imp__func]` the compiler
might generate requires __imp__func (the .idata$4 entry) to be aligned
to 8 bytes. Without this you get IMAGE_REL_ARM64_PAGEOFFSET_12L overflow
errors.

20 months agoMerge config/picflag.m4 from gcc
Alan Modra [Wed, 4 Jan 2023 02:52:55 +0000 (13:22 +1030)]
Merge config/picflag.m4 from gcc

and regen libiberty/configure

20 months agosim: Regenerate using the maintainer mode
Tsukasa OI [Wed, 4 Jan 2023 01:38:30 +0000 (01:38 +0000)]
sim: Regenerate using the maintainer mode

Those files have changed by regenerating using the maintainer mode.
The first line of sim/ppc/pk.h have changed by an effect of the commit
319e41e83a40 ("sim: ppc: inline the sim-packages option").

20 months agoAutomatic date update in version.in
GDB Administrator [Wed, 4 Jan 2023 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in

20 months agoopcodes: xtensa: fix jump visualization for FLIX
Max Filippov [Tue, 3 Jan 2023 06:56:28 +0000 (22:56 -0800)]
opcodes: xtensa: fix jump visualization for FLIX

opcodes/
* xtensa-dis.c (print_insn_xtensa): Add local variables
insn_type, target and imm_pcrel to track control flow across
multiple slots.

20 months agoopcodes: xtensa: implement styled disassembly
Max Filippov [Tue, 3 Jan 2023 05:17:53 +0000 (21:17 -0800)]
opcodes: xtensa: implement styled disassembly

opcodes/
* xtensa-dis.c (print_xtensa_operand)
(print_insn_xtensa): Replace fprintf_func with
fprintf_styled_func.

20 months agoAdd test case for "finish" with variably-sized types
Tom Tromey [Thu, 8 Sep 2022 16:35:09 +0000 (10:35 -0600)]
Add test case for "finish" with variably-sized types

This adds a test case for "finish" with variably-sized types, and for
inferior calls as well.  This also extends the "runto" proc to handle
temporary breakpoints.

20 months agoUse value_at_non_lval in get_call_return_value
Tom Tromey [Wed, 7 Sep 2022 20:01:13 +0000 (14:01 -0600)]
Use value_at_non_lval in get_call_return_value

get_call_return_value can handle RETURN_VALUE_STRUCT_CONVENTION,
because the call is completely managed by gdb.  However, it does not
handle variably-sized types correctly.  The simplest way to fix this
is to use value_at_non_lval, which does type resolution.

20 months agoFix inferior calls with variably-sized return type
Tom Tromey [Wed, 7 Sep 2022 15:52:44 +0000 (09:52 -0600)]
Fix inferior calls with variably-sized return type

This patch updates the gdbarch_return_value_as_value implementations
to work correctly with variably-sized return types.

20 months agoConvert selected architectures to gdbarch_return_value_as_value
Tom Tromey [Fri, 9 Sep 2022 12:39:56 +0000 (06:39 -0600)]
Convert selected architectures to gdbarch_return_value_as_value

This converts a few selected architectures to use
gdbarch_return_value_as_value rather than gdbarch_return_value.  The
architectures are just the ones that I am able to test.  This patch
should not introduce any behavior changes.

20 months agoDon't let property evaluation affect the current language
Tom Tromey [Thu, 15 Sep 2022 18:06:02 +0000 (12:06 -0600)]
Don't let property evaluation affect the current language

On PPC, we saw that calling an inferior function could sometimes
change the current language, because gdb would select the call dummy
frame -- associated with _start.

This patch changes gdb so that the current language is never affected
by DWARF property evaluation.

20 months agoIntroduce value_at_non_lval
Tom Tromey [Fri, 9 Sep 2022 18:50:33 +0000 (12:50 -0600)]
Introduce value_at_non_lval

In some cases, while a value might be read from memory, gdb should not
record the value as being equivalent to that memory.

In Ada, the inferior call code will call ada_convert_actual -- and
here, if the argument is already in memory, that address will simply
be reused.  However, for a call like "f(g())", the result of "g" might
be on the stack and thus overwritten by the call to "f".

This patch introduces a new function that is like value_at but that
ensures that the result is non-lvalue.

20 months agoDon't emit gdbarch_return_value
Tom Tromey [Wed, 7 Sep 2022 14:58:18 +0000 (08:58 -0600)]
Don't emit gdbarch_return_value

The previous patch introduced a new overload of gdbarch_return_value.
The intent here is that this new overload always be called by the core
of gdb -- the previous implementation is effectively deprecated,
because a call to the old-style method will not work with any
converted architectures (whereas calling the new-style method is will
delegate when needed).

This patch changes gdbarch.py so that the old gdbarch_return_value
wrapper function can be omitted.  This will prevent any errors from
creeping in.

20 months agoAdd new overload of gdbarch_return_value
Tom Tromey [Wed, 7 Sep 2022 14:39:52 +0000 (08:39 -0600)]
Add new overload of gdbarch_return_value

The gdbarch "return_value" can't correctly handle variably-sized
types.  The problem here is that the TYPE_LENGTH of such a type is 0,
until the type is resolved, which requires reading memory.  However,
gdbarch_return_value only accepts a buffer as an out parameter.

Fixing this requires letting the implementation of the gdbarch method
resolve the type and return a value -- that is, both the contents and
the new type.

After an attempt at this, I realized I wouldn't be able to correctly
update all implementations (there are ~80) of this method.  So,
instead, this patch adds a new method that falls back to the current
method, and it updates gdb to only call the new method.  This way it's
possible to incrementally convert the architectures that I am able to
test.

20 months agoFix crash in amd64-tdep.c
Tom Tromey [Tue, 6 Sep 2022 14:44:52 +0000 (08:44 -0600)]
Fix crash in amd64-tdep.c

amd64-tdep.c could crash when 'finish'ing from a function whose return
type had variable length.  In this situation, the value will be passed
by reference, and this patch avoids the crash.

(Note that this does not fully fix the bug reported, but it does fix
the crash, so it seems worthwhile to land independently.)

20 months ago[gdb/testsuite] Add xfail in gdb.arch/i386-pkru.exp
Tom de Vries [Tue, 3 Jan 2023 15:41:05 +0000 (16:41 +0100)]
[gdb/testsuite] Add xfail in gdb.arch/i386-pkru.exp

On a x86_64-linux machine with pkru register, I run into:
...
(gdb) PASS: gdb.arch/i386-pkru.exp: set pkru value
info register pkru^M
pkru           0x12345678          305419896^M
(gdb) FAIL: gdb.arch/i386-pkru.exp: read value after setting value
...

This is a regression due to kernel commit e84ba47e313d ("x86/fpu: Hook up PKRU
onto ptrace()").  This is fixed by recent kernel commit 4a804c4f8356
("x86/fpu: Allow PKRU to be (once again) written by ptrace.").

The regression occurs for kernel versions v5.14-rc1 (the first tag containing
the regression) up to but excluding v6.2-rc1 (the first tag containing the fix).

Fix this by adding an xfail for the appropriate kernel versions.

Tested on x86_64-linux.

PR testsuite/29790
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29790

20 months agoDo not use PyObject_CallNoArgs
Tom Tromey [Tue, 3 Jan 2023 14:13:01 +0000 (07:13 -0700)]
Do not use PyObject_CallNoArgs

PyObject_CallNoArgs was introduced in Python 3.9, so avoid it in favor
of PyObject_CallObject.

20 months agoFix a potential problem in the BFD library when accessing the Windows' nul device...
Himal [Tue, 3 Jan 2023 12:07:16 +0000 (12:07 +0000)]
Fix a potential problem in the BFD library when accessing the Windows' nul device driver.

PR 29947
* bfdio.c (_bfd_real_fopen): Do not add a prefix to the Windows'
nul device filename.

20 months agoFix a translation problem in the x86 assembler.
Nick Clifton [Tue, 3 Jan 2023 12:03:02 +0000 (12:03 +0000)]
Fix a translation problem in the x86 assembler.

PR 29952
* config/tc-i386.c (md_assemble): Avoid constructing translatable
strings.

20 months agoUpdated translations for various languages and sub-directories
Nick Clifton [Tue, 3 Jan 2023 11:32:42 +0000 (11:32 +0000)]
Updated translations for various languages and sub-directories

20 months agoAdd new NT_ARM_ZA and NT_ARM_SSVE register set constants.
Luis Machado [Tue, 3 Jan 2023 11:15:26 +0000 (11:15 +0000)]
Add new NT_ARM_ZA and NT_ARM_SSVE register set constants.

20 months ago[gdb] Fix segfault during inferior call to ifunc
Andrew Burgess [Tue, 3 Jan 2023 09:18:48 +0000 (10:18 +0100)]
[gdb] Fix segfault during inferior call to ifunc

With a simple test-case:
...
$ cat test.c
char *p = "a";
int main (void) {
  return strlen (p);
}
$ gcc -g test.c
...
we run into this segfault:
...
$ gdb -q -batch a.out -ex start -ex "p strlen (p)"
Temporary breakpoint 1 at 0x1151: file test.c, line 4.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Temporary breakpoint 1, main () at test.c:4
4   return strlen (p);

Fatal signal: Segmentation fault
...

The strlen is an ifunc, and consequently during the call to
call_function_by_hand_dummy for "p strlen (p)" another call
to call_function_by_hand_dummy is used to resolve the ifunc.

This invalidates the get_current_frame () result in the outer call.

Fix this by using prepare_reinflate and reinflate.

Note that this series (
https://inbox.sourceware.org/gdb-patches/20221214033441.499512-1-simon.marchi@polymtl.ca/ )
should address this problem, but this patch is a simpler fix which is easy to
backport.

Tested on x86_64-linux.

Co-Authored-By: Tom de Vries <tdevries@suse.de>
PR gdb/29941
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29941

20 months agosim: sh: move some generated source files to built sources
Mike Frysinger [Tue, 3 Jan 2023 03:48:13 +0000 (22:48 -0500)]
sim: sh: move some generated source files to built sources

This should have been part of the previous commit 80636a54bcfa2bca3dc8f
("sim: build: move generated headers to built sources"), but they were
missed because they're .c files effectively treated as .h files.

20 months agosim: build: add var for tracking sim enable directly
Mike Frysinger [Tue, 3 Jan 2023 03:40:49 +0000 (22:40 -0500)]
sim: build: add var for tracking sim enable directly

Rather than rely on SIM_SUBDIRS being set, add a dedicated variable
to track whether to enable the sim.  While the current code works
fine, it won't work as we remove the recursive make logic (i.e. the
SIM_SUBDIRS variable).

20 months agosim: common: drop libcommon.a linkage
Mike Frysinger [Mon, 2 Jan 2023 19:17:56 +0000 (14:17 -0500)]
sim: common: drop libcommon.a linkage

All of these objects should be in libsim.a already, so don't link to
it too.  In practice it never gets used, but no point in listing it.

20 months agosim: build: move generated headers to built sources
Mike Frysinger [Tue, 3 Jan 2023 02:16:19 +0000 (21:16 -0500)]
sim: build: move generated headers to built sources

Automake's automatic header deptracking has a bootstrap problem where
it can't detect generated headers when compiling.  We've been handling
that by adding a custom SIM_ALL_RECURSIVE_DEPS variable, but that only
works when building objects recursively in subdirs.  As we move those
out to the top-level, we don't have any recursive steps anymore.  The
Automake approach is to declare those headers in BUILT_SOURCES.

This isn't completely foolproof as the Automake manual documents: it
only activates for `make all`, not `make foo.o`, but that shouldn't be
a huge limitation as it only affects the initial compile.  After that,
rebuilds should work fine.

20 months agosim: cgen: drop common subdir build rules
Mike Frysinger [Mon, 2 Jan 2023 02:35:08 +0000 (21:35 -0500)]
sim: cgen: drop common subdir build rules

Now that everything has been hoisted to the top-level, we can delete
this unused logic.

20 months agosim: or1k: hoist cgen rules to top-level
Mike Frysinger [Mon, 2 Jan 2023 02:32:29 +0000 (21:32 -0500)]
sim: or1k: hoist cgen rules to top-level

20 months agosim: m32r: hoist cgen rules to top-level
Mike Frysinger [Mon, 2 Jan 2023 02:31:01 +0000 (21:31 -0500)]
sim: m32r: hoist cgen rules to top-level

20 months agosim: lm32: hoist cgen rules to top-level
Mike Frysinger [Mon, 2 Jan 2023 02:29:19 +0000 (21:29 -0500)]
sim: lm32: hoist cgen rules to top-level

20 months agosim: iq2000: hoist cgen rules to top-level
Mike Frysinger [Mon, 2 Jan 2023 02:20:36 +0000 (21:20 -0500)]
sim: iq2000: hoist cgen rules to top-level

20 months agosim: frv: hoist cgen rules to top-level
Mike Frysinger [Mon, 2 Jan 2023 02:18:50 +0000 (21:18 -0500)]
sim: frv: hoist cgen rules to top-level

20 months agosim: cris: hoist cgen rules to top-level
Mike Frysinger [Mon, 2 Jan 2023 02:15:02 +0000 (21:15 -0500)]
sim: cris: hoist cgen rules to top-level

20 months agosim: bpf: hoist cgen rules to top-level
Mike Frysinger [Mon, 2 Jan 2023 02:00:12 +0000 (21:00 -0500)]
sim: bpf: hoist cgen rules to top-level

20 months agosim: cgen: hoist rules to the top-level build
Mike Frysinger [Mon, 2 Jan 2023 01:11:01 +0000 (20:11 -0500)]
sim: cgen: hoist rules to the top-level build

The rules seem to generate the same output as existing subdir cgen
rules with cgen ports, so hopefully this should be correct.  These
are the last set of codegen rules that we run in subdirs, so this
will help unblock killing off subdir builds entirely.

20 months agosim: build: use Automake include vars
Mike Frysinger [Tue, 3 Jan 2023 00:30:22 +0000 (19:30 -0500)]
sim: build: use Automake include vars

Rather than define our own hack for emitting an include statement,
use the existing Automake include variables.  These have the nice
side-effect of being more portable.

20 months agoAutomatic date update in version.in
GDB Administrator [Tue, 3 Jan 2023 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in

20 months agoSimplify debug_exp
Tom Tromey [Mon, 2 Jan 2023 17:37:15 +0000 (10:37 -0700)]
Simplify debug_exp

debug_exp should call expression::dump rather than using the 'op'
member.

20 months agoInitial implementation of Debugger Adapter Protocol
Tom Tromey [Thu, 23 Jun 2022 17:11:36 +0000 (11:11 -0600)]
Initial implementation of Debugger Adapter Protocol

The Debugger Adapter Protocol is a JSON-RPC protocol that IDEs can use
to communicate with debuggers.  You can find more information here:

    https://microsoft.github.io/debug-adapter-protocol/

Frequently this is implemented as a shim, but it seemed to me that GDB
could implement it directly, via the Python API.  This patch is the
initial implementation.

DAP is implemented as a new "interp".  This is slightly weird, because
it doesn't act like an ordinary interpreter -- for example it doesn't
implement a command syntax, and doesn't use GDB's ordinary event loop.
However, this seemed like the best approach overall.

To run GDB in this mode, use:

    gdb -i=dap

The DAP code will accept JSON-RPC messages on stdin and print
responses to stdout.  GDB redirects the inferior's stdout to a new
pipe so that output can be encapsulated by the protocol.

The Python code uses multiple threads to do its work.  Separate
threads are used for reading JSON from the client and for writing JSON
to the client.  All GDB work is done in the main thread.  (The first
implementation used asyncio, but this had some limitations, and so I
rewrote it to use threads instead.)

This is not a complete implementation of the protocol, but it does
implement enough to demonstrate that the overall approach works.

There is a rudimentary test suite.  It uses a JSON parser written in
pure Tcl.  This parser is under the same license as Tcl itself, so I
felt it was acceptable to simply import it into the tree.

There is also a bit of documentation -- just documenting the new
interpreter name.

20 months agoFix target remote pipe command for MinGW
Jonas Hoerberg [Thu, 22 Dec 2022 15:22:17 +0000 (15:22 +0000)]
Fix target remote pipe command for MinGW

The cced7cacecad104fff0 ("gdb: preserve `|` in connection details string")
commit added '|' detection and removal to ser-pipe.c, but missed to add it
to ser-mingw.c.

This results in the error message below for MinGW hosts:
error starting child process '| <executable> <args>': CreateProcess: No such file or directory

This commit add the missing '|' detection and removal to ser-mingw.c.

20 months agoRemove target: prefix from gdb_sysroot in find_separate_debug_file
Tom Tromey [Wed, 21 Dec 2022 20:57:45 +0000 (13:57 -0700)]
Remove target: prefix from gdb_sysroot in find_separate_debug_file

I noticed that, when using gdbserver, gdb might print:

Reading /usr/lib/debug/lib64//libcap.so.2.48-2.48-4.fc36.x86_64.debug from remote target...
Reading target:/usr/lib/debug/lib64//libcap.so.2.48-2.48-4.fc36.x86_64.debug from remote target...

The second line has the "target:" prefix, but from the code it's clear
that this string is being passed verbatim to gdbserver -- which seems
wrong.

I filed PR remote/29929 for this.

The problem here is that find_separate_debug_file uses gdb_sysroot
without checking to see if it starts with the "target:" prefix.  This
patch changes this code to be a little more careful.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29929

20 months ago[gdb/testsuite] Fix gdb.python/py-breakpoint.exp with libstdc++ debug info
Tom de Vries [Mon, 2 Jan 2023 10:59:17 +0000 (11:59 +0100)]
[gdb/testsuite] Fix gdb.python/py-breakpoint.exp with libstdc++ debug info

On x86_64-linux, I run into:
...
(gdb) python hbp1 = gdb.Breakpoint("add", type=gdb.BP_HARDWARE_BREAKPOINT)^M
Hardware assisted breakpoint 2 at 0x40072e: add. (7 locations)^M
(gdb) FAIL: gdb.python/py-breakpoint.exp: test_hardware_breakpoints: \
  Set hardware breakpoint
...
due to libstdc++ debug info:
...
$ gdb -q -batch outputs/gdb.python/py-breakpoint/py-breakpoint \
  -ex start \
  -ex "b add" \
  -ex "info break"
Temporary breakpoint 1 at 0x40076a: file py-breakpoint.c, line 50.

Temporary breakpoint 1, main (argc=1, argv=$hex) at py-breakpoint.c:50
50        int foo = 5;
Breakpoint 2 at 0x40072e: add. (7 locations)
Num     Type           Disp Enb Address            What
2       breakpoint     keep y   <MULTIPLE>
2.1                         y   0x000000000040072e in add(int) at \
  py-breakpoint.c:39
2.2                         y   0x00007ffff7b131de in \
  (anonymous namespace)::fast_float::bigint::add at \
  ../../../../../libstdc++-v3/src/c++17/fast_float/fast_float.h:1815
  ...
2.7                         y   0x00007ffff7b137e4 in \
  (anonymous namespace)::fast_float::bigint::add at \
  ../../../../../libstdc++-v3/src/c++17/fast_float/fast_float.h:1815
...

Fix this by using qualified=True.

Tested on x86_64-linux.
PR testsuite/29910
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29910

20 months agosim: replace -I$srcroot/bfd include with -I$srcroot
Mike Frysinger [Sun, 1 Jan 2023 15:07:28 +0000 (10:07 -0500)]
sim: replace -I$srcroot/bfd include with -I$srcroot

Clean up includes a bit by making ports include bfd/ headers
explicitly.  This matches other projects, and makes it more clear
where these headers are coming from.

20 months agosim: replace -I$srcroot/opcodes include with -I$srcroot
Mike Frysinger [Sun, 1 Jan 2023 14:55:07 +0000 (09:55 -0500)]
sim: replace -I$srcroot/opcodes include with -I$srcroot

Clean up includes a bit by making ports include opcodes/ headers
explicitly.  This matches other projects, and makes it more clear
where these headers are coming from.

20 months agoobsolete target tidy
Alan Modra [Fri, 23 Dec 2022 07:13:21 +0000 (17:43 +1030)]
obsolete target tidy

Delete a few files only used for obsolete targets, and tidy config,
xfails and other pieces of support specific to those targets.  And
since I was editing target triplets in test files, fix the nm
alpha-linuxecoff fails.

20 months agoAutomatic date update in version.in
GDB Administrator [Mon, 2 Jan 2023 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

20 months agosim: build: drop unused SIM_EXTRA_LIBS
Mike Frysinger [Sun, 1 Jan 2023 22:46:15 +0000 (17:46 -0500)]
sim: build: drop unused SIM_EXTRA_LIBS

Now that all run binaries are linked in the topdir, this subdir libs
variable isn't used anywhere, so punt it.

20 months agosim: erc32: drop -I$(srcroot)
Mike Frysinger [Sun, 1 Jan 2023 22:43:25 +0000 (17:43 -0500)]
sim: erc32: drop -I$(srcroot)

Since the port doesn't actually use this include, drop it.
No other port is doing this either.

20 months agosim: drop mention of & support for subdir configure
Mike Frysinger [Sun, 1 Jan 2023 22:35:16 +0000 (17:35 -0500)]
sim: drop mention of & support for subdir configure

Now that no ports use these common configure APIs, delete the logic
and remove it from the documentation.

20 months agosim: refresh copyright dates a bit
Mike Frysinger [Sun, 1 Jan 2023 20:09:19 +0000 (15:09 -0500)]
sim: refresh copyright dates a bit

Update a few files that were missed, and revert the generated Automake
output that uses dates from Automake itself.

20 months agosim: or1k: drop unused rules
Mike Frysinger [Sun, 1 Jan 2023 19:40:03 +0000 (14:40 -0500)]
sim: or1k: drop unused rules

These rules are the same as the common ones, so drop them to simplify.

20 months agosim: iq2000: drop unused cpu define logic
Mike Frysinger [Sun, 1 Jan 2023 19:05:57 +0000 (14:05 -0500)]
sim: iq2000: drop unused cpu define logic

These defines seem to have been added in anticipation of adding another
cpu port (IQ10BF?), but that was over 20 years ago, and that port has
yet to materialize.  So drop these compile flags since they don't do
anything to the generated code.  If another port ever shows up, it's
easy enough to readd things as needed.

20 months agomanual copyright year range of various GDB files to add 2023
Joel Brobecker [Sun, 1 Jan 2023 12:52:30 +0000 (16:52 +0400)]
manual copyright year range of various GDB files to add 2023

This commit updates the following file...

   gdb/doc/gdb.texinfo
   gdb/doc/refcard.tex
   gdb/syscalls/update-netbsd.sh

... by hand as instructed by the gdb/copyright.py script.
The update by hand is needed because the copyright headers
to update are actually nested inside those files, rather
than located at the start of the file.

20 months agoUpdate copyright year range in header of all files managed by GDB
Joel Brobecker [Sun, 1 Jan 2023 12:49:04 +0000 (16:49 +0400)]
Update copyright year range in header of all files managed by GDB

This commit is the result of running the gdb/copyright.py script,
which automated the update of the copyright year range for all
source files managed by the GDB project to be updated to include
year 2023.

20 months agogdb/copyright.py: Adjust following rename of sim/ppc/ppc-instructions...
Joel Brobecker [Sun, 1 Jan 2023 12:47:26 +0000 (16:47 +0400)]
gdb/copyright.py: Adjust following rename of sim/ppc/ppc-instructions...

... to sim/ppc/powerpc.igen

This file is in the NOT_FSF_LIST because this file has a copyright
which is not assigned to the FSF. Since the file got renamed,
the corresponding entry in NOT_FSF_LIST needs to be renamed as well.

20 months agoUpdate copyright year in help message of gdb, gdbserver, gdbreplay
Joel Brobecker [Sun, 1 Jan 2023 12:43:39 +0000 (16:43 +0400)]
Update copyright year in help message of gdb, gdbserver, gdbreplay

This commit updates the copyright year displayed by gdb, gdbserver
and gdbreplay's help message from 2022 to 2023, as per our Start
of New Year procedure. The corresponding source files' copyright
header are also updated accordingly.

20 months agoUpdate year range in gprofng copyright notices
Alan Modra [Sun, 1 Jan 2023 12:31:20 +0000 (23:01 +1030)]
Update year range in gprofng copyright notices

This adds 'Innovative Computing Labs' as an external author to
update-copyright.py, to cover the copyright notice in
gprofng/common/opteron_pcbe.c, and uses that plus another external
author 'Oracle and' to update gprofng copyright dates.  I'm not going
to commit 'Oracle and' as an accepted author, but that covers the
string "Copyright (c) 2006, 2012, Oracle and/or its affiliates. All
rights reserved." found in gprofng/testsuite/gprofng.display/jsynprog
files.

20 months agoUpdate year range in copyright notice of binutils files
Alan Modra [Sun, 1 Jan 2023 06:08:42 +0000 (16:38 +1030)]
Update year range in copyright notice of binutils files

The newer update-copyright.py fixes file encoding too, removing cr/lf
on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and
embedded cr in binutils/testsuite/binutils-all/ar.exp string match.

20 months agoUpdate etc/update-copyright.py
Alan Modra [Sun, 1 Jan 2023 06:03:14 +0000 (16:33 +1030)]
Update etc/update-copyright.py

This picks up some improvements from gcc/contrib.  exceptions must
derive from BaseException, port to python3, retain original file mode,
fix name of script in examples.

Adds libsframe to list of default dirs.  I would have added gprofng
too but there are some files claiming copyright by authors other than
the Free Software Foundation.

20 months agoAutomatic date update in version.in
GDB Administrator [Sun, 1 Jan 2023 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in

20 months agoUpdate version numbers in howto-make-a-release document
Nick Clifton [Sat, 31 Dec 2022 13:01:40 +0000 (13:01 +0000)]
Update version numbers in howto-make-a-release document

20 months agoUpdate version number and regenerate files
Nick Clifton [Sat, 31 Dec 2022 12:23:00 +0000 (12:23 +0000)]
Update version number and regenerate files

20 months agoAdd markers for 2.40 branch
Nick Clifton [Sat, 31 Dec 2022 12:05:28 +0000 (12:05 +0000)]
Add markers for 2.40 branch

20 months agosync libiberty sources with gcc mainline
Nick Clifton [Sat, 31 Dec 2022 12:03:16 +0000 (12:03 +0000)]
sync libiberty sources with gcc mainline

20 months ago[gdb/cli] Add maintenance ignore-probes
Tom de Vries [Sat, 31 Dec 2022 09:23:06 +0000 (10:23 +0100)]
[gdb/cli] Add maintenance ignore-probes

There's a command "disable probes", but SystemTap probes, for instance
libc:longjmp cannot be disabled:
...
$ gdb -q -batch a.out -ex start -ex "disable probes libc ^longjmp$"
  ...
Probe libc:longjmp cannot be disabled.
Probe libc:longjmp cannot be disabled.
Probe libc:longjmp cannot be disabled.
...

Add a command "maintenance ignore-probes" that ignores probes during
get_probes, such that we can easily pretend to use a libc without the
libc:longjmp probe:
...
(gdb) maint ignore-probes -verbose libc ^longjmp$
ignore-probes filter has been set to:
PROVIDER: 'libc'
PROBE_NAME: '^longjmp$'
OBJNAME: ''
(gdb) start ^M
  ...
Ignoring SystemTap probe libc longjmp in /lib64/libc.so.6.^M
Ignoring SystemTap probe libc longjmp in /lib64/libc.so.6.^M
Ignoring SystemTap probe libc longjmp in /lib64/libc.so.6.^M
...

The "Ignoring ..." messages can be suppressed by not using -verbose.

Note that as with "disable probes", running simply "maint ignore-probes"
ignores all probes.

The ignore-probes filter can be reset by using:
...
(gdb) maint ignore-probes -reset
ignore-probes filter has been reset
...

For now, the command is only supported for SystemTap probes.

PR cli/27159
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27159

20 months agold/testsuite: Don't add index to sizes in pdb.exp
Mark Harmstone [Mon, 26 Dec 2022 20:47:51 +0000 (20:47 +0000)]
ld/testsuite: Don't add index to sizes in pdb.exp

20 months agold: Handle LF_VFTABLE types in PDBs
Mark Harmstone [Mon, 26 Dec 2022 20:47:50 +0000 (20:47 +0000)]
ld: Handle LF_VFTABLE types in PDBs

20 months agold: Handle extended-length data structures in PDB types
Mark Harmstone [Mon, 26 Dec 2022 20:47:49 +0000 (20:47 +0000)]
ld: Handle extended-length data structures in PDB types

A few fixes to minor issues I've discovered in my PDB patches.

* If sizes or offsets are greater than 0x8000, they get encoded as
extended values in the same way as for enum values - e.g. a LF_ULONG
.short followed by a .long.

* I've managed to coax MSVC to produce another type, LF_VFTABLE, which
is seen when dealing with COM. I don't think LLVM emits this. Note that
we can't just implement everything in Microsoft's header files, as most
of it is obsolete.

* Fixes a stupid bug in the test program, where I was adding an index to
a size. The index was hard-coded to 0, so this didn't cause any actual
issues.

20 months agoUpdated Romanian translation for the binutils sub-directory
Nick Clifton [Sat, 31 Dec 2022 08:55:31 +0000 (08:55 +0000)]
Updated Romanian translation for the binutils sub-directory

20 months ago[gdb/python] Fix gdb.python/py-finish-breakpoint2.exp for -m32
Tom de Vries [Sat, 31 Dec 2022 07:51:40 +0000 (08:51 +0100)]
[gdb/python] Fix gdb.python/py-finish-breakpoint2.exp for -m32

[ Partial resubmission of an earlier submission by Andrew (
https://sourceware.org/pipermail/gdb-patches/2012-September/096347.html ), so
listing him as co-author. ]

With x86_64-linux and target board unix/-m32, we have:
...
(gdb) continue^M
Continuing.^M
Exception #10^M
^M
Breakpoint 3, throw_exception_1 (e=10) at py-finish-breakpoint2.cc:23^M
23        throw new int (e);^M
(gdb) FAIL: gdb.python/py-finish-breakpoint2.exp: \
  check FinishBreakpoint in catch()
...

The following scenario happens:
- set breakpoint in throw_exception_1, a function that throws an exception
- continue
- hit breakpoint, with call stack main.c:38 -> throw_exception_1
- set a finish breakpoint
- continue
- hit the breakpoint again, with call stack main.c:48 -> throw_exception
  -> throw_exception_1

Due to the exception, the function call did not properly terminate, and the
finish breakpoint didn't trigger.  This is expected behaviour.

However, the intention is that gdb detects this situation at the next stop
and calls the out_of_scope callback, which would result here in this test-case
in a rather confusing "exception did not finish" message.  So the problem is
that this message doesn't show up, in other words, the out_of_scope callback
is not called.

[ Note that the fact that the situation is detected only at the next stop
(wherever that happens to be) could be improved upon, and the earlier
submission did that by setting a longjmp breakpoint.  But I'm considering this
problem out-of-scope for this patch. ]

Note that the message does show up later, at thread exit:
...
[Inferior 1 (process 20046) exited with code 0236]^M
exception did not finish ...^M
...

The decision on whether to call the out_of_scope call back is taken in
bpfinishpy_detect_out_scope_cb, and the interesting bit is here:
...
             if (b->pspace == current_inferior ()->pspace
                 && (!target_has_registers ()
                     || frame_find_by_id (b->frame_id) == NULL))
               bpfinishpy_out_of_scope (finish_bp);
...

In the case of the thread exit, the callback triggers because
target_has_registers () == 0.

So why doesn't the callback trigger in the case of the breakpoint?

Well, the b->frame_id is the frame_id of the frame of main (the frame
in which the finish breakpoint is supposed to trigger), so AFAIU
frame_find_by_id (b->frame_id) == NULL will only be true once we've
left main, at which point I guess we don't stop till thread exit.

Fix this by saving the frame in which the finish breakpoint was created, and
using frame_find_by_id () == NULL on that frame instead, such that we have:
...
(gdb) continue^M
Continuing.^M
Exception #10^M
^M
Breakpoint 3, throw_exception_1 (e=10) at py-finish-breakpoint2.cc:23^M
23        throw new int (e);^M
exception did not finish ...^M
(gdb) FAIL: gdb.python/py-finish-breakpoint2.exp: \
  check FinishBreakpoint in catch()
...

Still, the test-case is failing because it's setup to match the behaviour that
we get on x86_64-linux with target board unix/-m64:
...
(gdb) continue^M
Continuing.^M
Exception #10^M
stopped at ExceptionFinishBreakpoint^M
(gdb) PASS: gdb.python/py-finish-breakpoint2.exp: \
  check FinishBreakpoint in catch()
...

So what happens here?  Again, due to the exception, the function call did not
properly terminate, but the finish breakpoint still triggers.  This is somewhat
unexpected.  This happens because it just so happens to be that the frame
return address at which the breakpoint is set, is also the first instruction
after the exception has been handled.  This is a know problem, filed as
PR29909, so KFAIL it, and modify the test-case to expect the out_of_scope
callback.

Also add a breakpoint after setting the finish breakpoint but before throwing
the exception, to check that we don't call the out_of_scope callback too early.

Tested on x86_64-linux, with target boards unix/-m32.

Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
PR python/27247
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27247

20 months ago[gdb/testsuite] Fix gdb.base/print-symbol-loading.exp on ubuntu 22.04.1
Tom de Vries [Sat, 31 Dec 2022 06:35:56 +0000 (07:35 +0100)]
[gdb/testsuite] Fix gdb.base/print-symbol-loading.exp on ubuntu 22.04.1

On ubuntu 22.04.1 x86_64, I run into:
...
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib off: \
  set print symbol-loading off
sharedlibrary .*^M
Symbols already loaded for /lib/x86_64-linux-gnu/libc.so.6^M
Symbols already loaded for /lib/x86_64-linux-gnu/libpthread.so.0^M
(gdb) FAIL: gdb.base/print-symbol-loading.exp: shlib off: load shared-lib
...

The test-case expects the libc.so line, but not the libpthread.so line.

However, we have:
...
$ ldd /lib/x86_64-linux-gnu/libc.so.6
linux-vdso.so.1 (0x00007ffd7f7e7000)
libgtk3-nocsd.so.0 => /lib/x86_64-linux-gnu/libgtk3-nocsd.so.0 (0x00007f4468c00000)
/lib64/ld-linux-x86-64.so.2 (0x00007f4469193000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f4468f3e000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f4468f39000)
...
so it's not unexpected that libpthread.so is loaded if libc.so is loaded.

Fix this by accepting the libpthread.so line.

Tested on x86_64-linux.

PR testsuite/29919
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29919

20 months ago[gdb/testsuite] Replace deprecated pthread_yield in gdb.threads/watchpoint-fork.exp
Tom de Vries [Sat, 31 Dec 2022 06:31:17 +0000 (07:31 +0100)]
[gdb/testsuite] Replace deprecated pthread_yield in gdb.threads/watchpoint-fork.exp

On Ubuntu 22.04.1 x86_64, with glibc 2.35 I run into:
...
watchpoint-fork-mt.c: In function 'start':^M
watchpoint-fork-mt.c:67:7: warning: 'pthread_yield' is deprecated: \
  pthread_yield is deprecated, use sched_yield instead \
  [-Wdeprecated-declarations]^M
   67 |       i = pthread_yield ();^M
      |       ^^M
...

Fix this as suggested, by using sched_yield instead.

Tested on x86_64-linux.

20 months ago[gdb/testsuite] Fix gdb.base/corefile.exp with glibc 2.35
Tom de Vries [Sat, 31 Dec 2022 06:26:53 +0000 (07:26 +0100)]
[gdb/testsuite] Fix gdb.base/corefile.exp with glibc 2.35

On Ubuntu 22.04.1 x86_64 (with glibc 2.35), I run into:
...
(gdb) PASS: gdb.base/corefile.exp: $_exitcode is void
bt^M
 #0  __pthread_kill_implementation (...) at ./nptl/pthread_kill.c:44^M
 #1  __pthread_kill_internal (...) at ./nptl/pthread_kill.c:78^M
 #2  __GI___pthread_kill (...) at ./nptl/pthread_kill.c:89^M
 #3  0x00007f4985e1a476 in __GI_raise (...) at ../sysdeps/posix/raise.c:26^M
 #4  0x00007f4985e007f3 in __GI_abort () at ./stdlib/abort.c:79^M
 #5  0x0000556b4ea4b504 in func2 () at gdb.base/coremaker.c:153^M
 #6  0x0000556b4ea4b516 in func1 () at gdb.base/coremaker.c:159^M
 #7  0x0000556b4ea4b578 in main (...) at gdb.base/coremaker.c:171^M
(gdb) PASS: gdb.base/corefile.exp: backtrace
up^M
 #1  __pthread_kill_internal (...) at ./nptl/pthread_kill.c:78^M
 78      in ./nptl/pthread_kill.c^M
(gdb) FAIL: gdb.base/corefile.exp: up
...

The problem is that the regexp used here:
...
gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up"
...
does not fit the __pthread_kill_internal line which lacks the instruction
address due to inlining.

Fix this by making the regexp less strict.

Tested on x86_64-linux.

20 months agoAutomatic date update in version.in
GDB Administrator [Sat, 31 Dec 2022 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in

20 months ago[gdb/testsuite] Fix gdb.threads/dlopen-libpthread.exp for upstream glibc
Tom de Vries [Fri, 30 Dec 2022 15:53:51 +0000 (16:53 +0100)]
[gdb/testsuite] Fix gdb.threads/dlopen-libpthread.exp for upstream glibc

On ubuntu 22.04.1 x86_64, I run into:
...
(gdb) info probes all rtld rtld_map_complete^M
No probes matched.^M
(gdb) XFAIL: gdb.threads/dlopen-libpthread.exp: info probes all rtld rtld_map_complete
UNTESTED: gdb.threads/dlopen-libpthread.exp: no matching probes
...
This has been filed as PR testsuite/17016.

The problem is that the name rtld_map_complete is used, which was only
available in Fedora 17, and upstream the name map_complete was used.

In the email thread discussing a proposed patch (
https://sourceware.org/legacy-ml/gdb-patches/2014-09/msg00712.html ) it was
suggested to make the test-case handle both names.

So, handle both names: map_complete and rtld_map_complete.

This exposes the following FAIL:
...
(gdb) info sharedlibrary^M
From To    Syms Read Shared Object Library^M
$hex $hex  Yes       /lib64/ld-linux-x86-64.so.2^M
$hex $hex  Yes (*)   /lib/x86_64-linux-gnu/libgtk3-nocsd.so.0^M
$hex $hex  Yes       /lib/x86_64-linux-gnu/libc.so.6^M
$hex $hex  Yes       /lib/x86_64-linux-gnu/libdl.so.2^M
$hex $hex  Yes       /lib/x86_64-linux-gnu/libpthread.so.0^M
(*): Shared library is missing debugging information.^M
(gdb) FAIL: gdb.threads/dlopen-libpthread.exp: libpthread.so not found
...
due to using a glibc (v2.35) that has libpthread integrated into libc.

Fix this by changing the FAIL into UNSUPPORTED.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17016