aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2025-09-04Don't require "Bss=" in qOffsets responseTom Tromey1-2/+0
The "Bss=" part of the qOffsets response is documented as being optional, but gdb in fact requires it. This patch fixes the bug. I couldn't find a straightforward way to test this. gdbserver does send 'Bss=' -- but this code is only enabled for a fairly specific setup: #if (defined(__UCLIBC__) \ && defined(HAS_NOMMU) \ && defined(PT_TEXT_ADDR) \ && defined(PT_DATA_ADDR) \ && defined(PT_TEXT_END_ADDR)) #define SUPPORTS_READ_OFFSETS #endif I also considered changing gdbserver to not send Bss=, but decided against this, reasoning that we may as well not break compatibility with older versions of gdb. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33319 Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-09-04gdb/testsuite: fix possible TCL errors in gdb.threads/threadcrash.expGuinevere Larsen1-2/+3
The test gdb.threads/threadcrash.exp, among other things, creates a list of the threads seen in the order that the "thread apply all backtrace" would generate them, tests that this list is the same size as GDB's count of threads, and then loops over the list to check that each thread has the expected backtrace. A problem occurs because the loop iterates on GDB's internal count of threads, rather than the size of the list, but then attempts to acces the n-th element of the list. If the list size is smaller than GDB's internal thread count, it'll access past the end of the list and generate TCL errors. This commit fixes this by using the list's length instead. Approved-By: Tom Tromey <tom@tromey.com>
2025-09-04gdb: remove most global core file accesses from fbsd-tdep.cAndrew Burgess1-32/+25
This commit removes many places in fbsd-tdep.c where we access the current core file via current_program_space, and replaces these accesses with a function argument that is passed in. There are still two uses of 'current_program_space->core_bfd ()' in the file, these will be addressed in future work (not in this series though). There should be no user visible changes after this commit. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-09-04gdb: pass core file to gdbarch_core_xfer_siginfoAndrew Burgess6-23/+26
Another patch that aims to remove 'current_program_space->core_bfd ()' from GDB. This time I'm passing the core file BFD as an argument to the gdbarch method gdbarch_core_xfer_siginfo. In corelow.c the core file is being passed, this does introduce a new instance of 'current_program_space->core_bfd ()', but this is OK. My long term plan is to move the core bfd into core_target, in which case the call to gdbarch_core_xfer_siginfo will have access to the core bfd as a member variable. For now though, this patch moves the accesses via global state up the call stack, and consolidates the two calls from fbsd-tdep.c and linux-tdep.c into the one call in corelow.c. There should be no user visible changes after this commit. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-09-04gdb: remove most global core file accesses from record-full.cAndrew Burgess1-39/+28
This commit continues my ongoing work to reduce the number of global accesses to the current core file BFD in GDB. The global accesses I'm working on removing look like 'current_program_space->core_bfd ()'. This commit targets record-full.c. All global accesses are removed except for two in record_full_open, which is used to implements the two commands 'target record-full' and 'record full restore'. All other global accesses to the core file are removed by passing the core file through as an argument from this one top level function. As I followed the code through I noticed that record_full_restore, which currently includes this check: if (current_program_space->core_bfd () == nullptr) return; could never actually be called without a core file being set. As the argument is now 'struct bfd &', then there is no longer an option for the incoming argument to be NULL, and the above check is removed. There should be no user visible changes after this commit. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-09-04gdb: remove some dead code from core_target_openAndrew Burgess1-7/+8
In core_target_open we call target_preopen which pops all targets above the file_stratum, this will include the core_target, if the core target is currently loaded. Currently, the core file BFD is stored in the program_space of an inferior. The only way to set the core file BFD is by creating a core_target (in core_target_open). And when a core_target is closed the core file BFD within the program_space is reset to nullptr (see core_target::close and core_target::clear_core, both in corelow.c). What this means is that, if there is no core_target loaded then there will be no core file BFD in the program_space. And in core_target_open, after the call to target_preopen, there will be no core_target loaded, and thus, no core file BFD in the program_space. There is currently code in core_target_open which checks to see if there is a core file BFD set in the current program space. For the reasons given above, I believe this is dead code and can be removed. I've added some asserts to validate my assumptions. There should be no user visible changes after this commit. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-09-04[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.arch/*.expTom de Vries9-10/+19
Fix clean_restart <absolute filename> in gdb.arch/*.exp. The fixed test-cases are supported on archs sh, ia64, mips, pa and sparc. I haven't tested these.
2025-09-04[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.arch/powerpc*.expTom de Vries27-31/+47
Fix clean_restart <absolute filename> in gdb.arch/powerpc*.exp. Likewise in gdb.arch/ppc*.exp, gdb.arch/altivec*.exp, gdb.arch/e500*.exp and gdb.arch/vsx*.exp. Tested on ppc64le-linux. The following test-cases only run on 32-bit ppc: - gdb.arch/e500-abi.exp - gdb.arch/e500-prologue.exp - gdb.arch/e500-regs.exp - gdb.arch/powerpc-aix-prologue.exp - gdb.arch/powerpc-prologue.exp - gdb.arch/powerpc-prologue-frame.exp - gdb.arch/powerpc-trap.exp so these haven't been tested.
2025-09-04[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.arch/thumb*.expTom de Vries3-3/+3
Fix clean_restart <absolute filename> in gdb.arch/thumb*.exp. Likewise in test-case gdb.arch/pr25124.exp. Tested on arm-linux, target boards unix/-marm and unix/-mthumb.
2025-09-04[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.arch/arm*.expTom de Vries3-3/+3
Fix clean_restart <absolute filename> in gdb.arch/arm*.exp. Tested on: - arm-linux, target boards unix/-marm and unix/-mthumb - aarch64-linux
2025-09-04[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.arch/aarch64*.expTom de Vries7-14/+27
Fix clean_restart <absolute filename> in gdb.arch/aarch64*.exp. Tested on aarch64-linux, M1 system. There's a large number (44) of unsupported, for the following reasons: - allow_aarch64_gcs_tests - allow_aarch64_mops_tests - allow_aarch64_sve_tests / target does not support SVE - memory tagging unsupported Consequently, we mostly use the simple substitution: ... clean_restart $binfile -> clean_restart gdb_load $binfile ...
2025-09-04[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.arch/i386*.expTom de Vries14-15/+15
Fix clean_restart <absolute filename> in gdb.arch/i386*.exp. Tested on x86_64-linux, with target board unix/-m32 and gcc 15. The only unsupported test-case is gdb.arch/i386-avx512.exp, which isn't changed by this commit.
2025-09-04[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.arch/amd64*.expTom de Vries12-22/+23
Fix clean_restart <absolute filename> in gdb.arch/amd64*.exp. Tested on x86_64-linux, with kernel version 6.16.3. The only unsupported test-case is gdb.arch/amd64-lam.exp, which isn't changed by this commit.
2025-09-04[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.adaTom de Vries18-18/+18
Fix clean_restart <absolute filename> in the test-cases in gdb.ada. Tested on x86_64-linux with gcc 14.
2025-09-03gdb/testsuite] Fix clean_restart <absolute filename> in gdb.compileTom de Vries2-4/+5
Fix clean_restart <absolute filename> in the test-cases in gdb.compile. Tested on x86_64-linux, fedora rawhide.
2025-09-03[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.cpTom de Vries8-10/+11
Fix clean_restart <absolute filename> in the test-cases in gdb.cp. Tested on x86_64-linux.
2025-09-03[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.debuginfodTom de Vries3-11/+12
Fix clean_restart <absolute filename> in the test-cases in gdb.debuginfod. Tested on x86_64-linux.
2025-09-03[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.disasmTom de Vries4-4/+4
Fix clean_restart <absolute filename> in the test-cases in gdb.disasm. The changed test-cases: - gdb.disasm/am33.exp - gdb.disasm/hppa.exp - gdb.disasm/mn10300.exp - gdb.disasm/sh3.exp are unsupported for me, but the changes are trivial.
2025-09-03[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.dwarf2Tom de Vries25-31/+38
Fix clean_restart <absolute filename> in the test-cases in gdb.dwarf2. Tested on x86_64-linux using gcc-14. Tested these test-cases on x86_64-linux with target board unix/-m32: - gdb.dwarf2/valop.exp - gdb.dwarf2/callframecfa.exp - gdb.dwarf2/implptr.exp - gdb.dwarf2/watch-notconst.exp - gdb.dwarf2/pieces.exp - gdb.dwarf2/pieces-optimized-out.exp Tested these test-cases on x86_64-linux with target board fission-dwp: - gdb.dwarf2/dwp-symlink.exp - gdb.dwarf2/dwp-sepdebug.exp Tested test-case gdb.dwarf2/gdb-index-tilde.exp on x86_64-linux by disabling a too strict home directory check, see PR testsuite/33364.
2025-09-03[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.fortranTom de Vries4-5/+5
Fix clean_restart <absolute filename> in the test-cases in gdb.fortran. Tested on x86_64-linux, with gcc 14.
2025-09-03[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.gdbTom de Vries2-2/+3
Fix clean_restart <absolute filename> in the test-cases in gdb.gdb. Tested on x86_64-linux.
2025-09-03[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.guileTom de Vries4-6/+9
Fix clean_restart <absolute filename> in the test-cases in gdb.guile. Tested on x86_64-linux.
2025-09-03[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.linespecTom de Vries2-2/+2
Fix clean_restart <absolute filename> in the test-cases in gdb.linespec. Tested on x86_64-linux.
2025-09-03[gdb/testsuite] Fix mi_clean_restart <absolute filename> in gdb.miTom de Vries91-97/+97
Fix mi_clean_restart <absolute filename> in the test-cases in gdb.mi. Tested on x86_64-linux. Also tested test-case gdb.mi/mi-dprintf.exp with target boards native-gdbserver and native-extended-gdbserver. Since test-case gdb.mi/mi-regs.exp requires istarget "sparc-*-*", I didn't test the trivial change in that test-case.
2025-09-03[gdb/testsuite] Fix mi_clean_restart <absolute filename> in gdb.traceTom de Vries5-15/+9
Fix mi_clean_restart <absolute filename> in the test-cases in gdb.trace. Tested on x86_64-linux, with target boards unix, native-gdbserver and native-extended-gdbserver.
2025-09-03gdb: LoongArch: Restrict breakpoint outside of atomic sequenceTiezhu Yang1-7/+31
We can't put a breakpoint in the middle of a ll/sc atomic sequence, so look for the end of the sequence and put the breakpoint there, it has been handled in the commit 208b57e53ed9 ("gdb: LoongArch: Deal with atomic sequence"). Especially, maybe there is a conditional branch instruction in the middle of a ll/sc atomic sequence, its destination address may be current pc + 4 which is inside the atomic sequence, it should not put a breakpoint in its destination address in this case, this has been handled in the commit a4242dc3f5fa ("gdb: LoongArch: Improve the handling of atomic sequence"). Additionally, if there is a conditional branch instruction in the middle of a ll/sc atomic sequence, its destination address may be not current pc + 4 but still inside the atomic sequence, it should not put a breakpoint in its destination address in this case. So in order to avoid putting a breakpoint in the middle of a ll/sc atomic sequence in any case, just look for the start and end of the sequence, and restrict the breakpoint outside of the atomic sequence. Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2025-09-03gdb: LoongArch: Add and use cond_branch_destination_address()Tiezhu Yang1-1/+34
In the current loongarch_deal_with_atomic_sequence(), it is just a loop through a ll/sc atomic instruction sequence, the instructions before the condition branch are not actually executed, thus the condition register value is not proper to determine the destination address. Add a new function cond_branch_destination_address() to calculate the destination address of a condition branch instruction under an assumed true condition, then only put a breakpoint at this address when it is outside of the ll/sc atomic instruction sequence. Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2025-09-03[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.multiTom de Vries15-26/+29
Fix clean_restart <absolute filename> in the test-cases in gdb.multi. Tested on x86_64-linux.
2025-09-03[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.objcTom de Vries3-3/+3
Fix clean_restart <absolute filename> in the test-cases in gdb.objc. Tested on x86_64-linux, using 'lappend options "nowarnings"' in gdb_compile_shlib_pthreads. See also PR testsuite/24807.
2025-09-03[gdb/testsuite] Fix clean_restart in gdb.opencl/callfuncs.expTom de Vries1-3/+4
In test-case gdb.opencl/callfuncs.exp I noticed: ... clean_restart [standard_testfile $testfile] ... This doesn't have the desired effect of starting gdb with $testfile because standard_testfile doesn't return anything. Fix this by using "clean_restart $testfile". While we're at it: - move standard_testfile to the start of the file - drop the redundant 'set testfile "callfuncs"' - use standard_testfile .cl to properly define $srcfile - use $srcfile instead of $testfile.cl Tested on x86_64-linux, using the demonstrator patch in PR testsuite/33363. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33363
2025-09-03gdb/testsuite: Fix gdb.base/gcore-memory-usage with address sanitizerGuinevere Larsen1-11/+14
The test gdb.base/gcore-memory-usage is meant to show that the memory requirements of GDB's gcore command don't grow with the memory usage of the inferior. It was using hardcoded values for memory, but the values were too small when building GDB with address sanitizer. This commit fixes one of the failures by increasing the limit on the first gcore call. But, rather than just increasing the hardcoded limit for the second call, we instead save the amount of memory used in the first call and ensure that the second call doesn't use more memory than the first. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33148 Approved-By: Tom de Vries <tdevries@suse.de>
2025-09-03[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.optTom de Vries3-6/+6
Fix clean_restart <absolute filename> in the test-cases in gdb.opt. Tested on x86_64-linux using gcc 14.
2025-09-03[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.perfTom de Vries6-6/+6
Fix clean_restart <absolute filename> in the test-cases in gdb.perf. Tested on x86_64-linux using check-perf.
2025-09-03[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.pythonTom de Vries18-33/+46
Fix clean_restart <absolute filename> in the test-cases in gdb.python. Tested on x86_64-linux.
2025-09-02gdb/remote: call target_pre_inferior in remote_target::remote_add_inferiorSimon Marchi1-1/+15
Since commit 3cb6bc13e328 ("gdb/progspace: add solib_ops pointer in program_space"), and with the previous patch applied ("gdb/remote: use scoped_restore_current_program_space in remote_unpush_target"), we get this failure: $ make check TESTS="gdb.server/extended-remote-restart.exp" RUNTESTFLAGS="--target_board=native-extended-gdbserver" In gdb.log: (gdb) PASS: gdb.server/extended-remote-restart.exp: kill: 0, follow-child 1: disconnect target extended-remote localhost:2348 Remote debugging using localhost:2348 /home/smarchi/src/binutils-gdb/gdb/progspace.h:240: internal-error: set_solib_ops: Assertion `m_solib_ops == nullptr' failed. When connecting to a remote that has one or more inferior already running, the remote target (the GDB-side code) tries to re-use existing GDB inferiors that are unused. The problem is that the program space of the inferior that gets re-used unexpectedly has its solib_ops set. I think that the problem is that when connecting to a remote target that has multiple inferiors, target_pre_inferior only gets called for the currently selected (client-side) inferior. It happens here: #0 target_pre_inferior () at /home/smarchi/src/wt/amd/gdb/target.c:2454 #1 0x0000559c832a350a in target_preopen (from_tty=1) at /home/smarchi/src/wt/amd/gdb/target.c:2510 #2 0x0000559c82e1b8f1 in remote_target::open_1 (name=0x50200006eb58 ":2345", from_tty=1, extended_p=1) at /home/smarchi/src/wt/amd/gdb/remote.c:6171 #3 0x0000559c82e18a5d in extended_remote_target::open (name=0x50200006eb58 ":2345", from_tty=1) at /home/smarchi/src/wt/amd/gdb/remote.c:5446 #4 0x0000559c8329a43e in open_target (args=0x50200006eb58 ":2345", from_tty=1, command=0x512000072c40) at /home/smarchi/src/wt/amd/gdb/target.c:839 I think that target_pre_inferior should be called for the other inferiors that gain execution as a result of connecting to the remote target, to make sure inferior or program space-specific data from previous executions gets cleared. target_pre_inferior is what clears any previous solib_ops. It is possible to observe the problem by adding this print in target_pre_inferior: printf (">>> target_pre_inferior called for inferior %d\n", current_inferior ()->num); Then, starting a gdbserver: $ gdbserver --multi localhost:2345 Then, this gdb command that starts two remote inferiors, disconnects (leaving gdbserver and the inferiors running), then reconnects: $ ./gdb -nx --data-directory=data-directory -q \ -ex 'set sysroot /' \ -ex 'target extended-remote :2345' \ -ex 'file testsuite/outputs/gdb.server/extended-remote-restart/extended-remote-restart' \ -ex 'set remote exec-file testsuite/outputs/gdb.server/extended-remote-restart/extended-remote-restart' \ -ex 'b main' \ -ex r \ -ex 'add-inferior' \ -ex 'inferior 2' \ -ex 'file testsuite/outputs/gdb.server/extended-remote-restart/extended-remote-restart' \ -ex 'run' \ -ex 'inferior 1' \ -ex 'disconnect' \ -ex 'echo About to reconnect\n' \ -ex 'target extended-remote :2345' >>> target_pre_inferior called for inferior 1 Remote debugging using :2345 Reading symbols from /home/smarchi/build/wt/amd/gdb/testsuite/outputs/gdb.server/extended-remote-restart/extended-remote-restart... Breakpoint 1 at 0x11fc: file /home/smarchi/src/wt/amd/gdb/testsuite/gdb.server/extended-remote-restart.c, line 50. >>> target_pre_inferior called for inferior 1 Starting program: /home/smarchi/build/wt/amd/gdb/testsuite/outputs/gdb.server/extended-remote-restart/extended-remote-restart Breakpoint 1, main () at /home/smarchi/src/wt/amd/gdb/testsuite/gdb.server/extended-remote-restart.c:50 50 pid = fork (); [New inferior 2] Added inferior 2 on connection 1 (extended-remote :2345) [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/smarchi/build/wt/amd/gdb/testsuite/outputs/gdb.server/extended-remote-restart/extended-remote-restart... >>> target_pre_inferior called for inferior 2 Starting program: /home/smarchi/build/wt/amd/gdb/testsuite/outputs/gdb.server/extended-remote-restart/extended-remote-restart Thread 2.1 "extended-remote" hit Breakpoint 1.2, main () at /home/smarchi/src/wt/amd/gdb/testsuite/gdb.server/extended-remote-restart.c:50 50 pid = fork (); [Switching to inferior 1 [process 2591936] (/home/smarchi/build/wt/amd/gdb/testsuite/outputs/gdb.server/extended-remote-restart/extended-remote-restart)] [Switching to thread 1.1 (Thread 2591936.2591936)] #0 main () at /home/smarchi/src/wt/amd/gdb/testsuite/gdb.server/extended-remote-restart.c:50 50 pid = fork (); Ending remote debugging. About to reconnect >>> target_pre_inferior called for inferior 1 Remote debugging using :2345 main () at /home/smarchi/src/wt/amd/gdb/testsuite/gdb.server/extended-remote-restart.c:50 50 pid = fork (); We can see that target_pre_inferior is only called for inferior 1 when reconnecting (after the "About to reconnect" message). After adding the call to target_pre_inferior in remote_add_inferior, we get (just the last bit): About to reconnect >>> target_pre_inferior called for inferior 1 Remote debugging using :2345 >>> target_pre_inferior called for inferior 1 >>> target_pre_inferior called for inferior 2 Reading symbols from /lib/x86_64-linux-gnu/libc.so.6... (No debugging symbols found in /lib/x86_64-linux-gnu/libc.so.6) Reading symbols from /lib64/ld-linux-x86-64.so.2... (No debugging symbols found in /lib64/ld-linux-x86-64.so.2) main () at /home/smarchi/src/wt/amd/gdb/testsuite/gdb.server/extended-remote-restart.c:50 50 pid = fork (); The duplicate calls to target_pre_inferior for inferior 1 are due to the existing call in target_preopen. It might be possible to get rid of it: with the call I added in remote_target::remote_add_inferior, I presume it's now unnecessary for the remote target to have the call in target_preopen as well. But since target_preopen is used by other targets, I prefer to leave it there to be safe, for the moment. Calling target_pre_inferior multiple times should not be a problem, as it should be idempotent. However, once I added that, test gdb.server/stop-reply-no-thread.exp started failing, with this in the logs: target remote localhost:2347 Remote debugging using localhost:2347 Remote 'g' packet reply is too long (expected 560 bytes, got 820 bytes): 000000... <truncated> It became apparent that the new call to target_pre_inferior would wipe a previously fetched target description. I fixed that by adding calls to target_find_description in two callers of remote_add_inferior. I'm not 100% sure of what I'm doing here, but it seems somewhat correct that when we map a remote inferior to an existing client-side inferior, we wipe out any previous target description (which would have been left by a previous execution) and fetch a new one. The other call to remote_add_inferior is in extended_remote_target::attach, where there is already a call to target_find_description shortly after. Change-Id: I85426bfff286a67d5fb74bbf978df80060ee6deb
2025-09-02gdb/remote: use scoped_restore_current_program_space in remote_unpush_targetSimon Marchi1-0/+1
Since commit 3cb6bc13e328 ("gdb/progspace: add solib_ops pointer in program_space"), this fails with an internal error: $ make check TESTS="gdb.server/extended-remote-restart.exp" RUNTESTFLAGS="--target_board=native-extended-gdbserver" In gdb.log: (gdb) PASS: gdb.server/extended-remote-restart.exp: kill: 1, follow-child 0: disconnect target extended-remote localhost:2347 Remote debugging using localhost:2347 /home/smarchi/src/binutils-gdb/gdb/progspace.h:240: internal-error: set_solib_ops: Assertion `m_solib_ops == nullptr' failed. The issue is that remote_unpush_target uses scoped_restore_current_inferior to save the context, which only restores the current inferior on exit. But it then uses switch_to_inferior_no_thread, which switches the inferior and the program space. The program space is therefore left unrestored. This can leave the current inferior and current program space out of sync. With two inferiors, let's say we enter with current inferior == 1 and current program space == 1. When calling switch_to_inferior_no_thread for inferior 2, we set the current inferior to 2 and current program space to 2. On exit, only the original inferior is restored, so we end up with current inferior == 1 and current program space == 2. The problem can be observed manually by starting two remote inferiors and disconnecting while inferior 1 is selected: $ ./gdb -nx --data-directory=data-directory -q \ -ex 'set sysroot /' \ -ex 'target extended-remote | gdbserver --multi --once -' \ -ex 'file /home/smarchi/build/wt/amd/gdb/testsuite/outputs/gdb.server/extended-remote-restart/extended-remote-restart' \ -ex 'set remote exec-file /home/smarchi/build/wt/amd/gdb/testsuite/outputs/gdb.server/extended-remote-restart/extended-remote-restart' \ -ex 'b main' \ -ex r \ -ex 'add-inferior' \ -ex 'inferior 2' \ -ex 'file /home/smarchi/build/wt/amd/gdb/testsuite/outputs/gdb.server/extended-remote-restart/extended-remote-restart' \ -ex 'run' \ -ex 'inferior 1' \ -ex 'disconnect' Then, connecting top-gdb to that gdb, we see the inconsistency: (top-gdb) p current_inferior_.m_obj.num $1 = 1 (top-gdb) p current_program_space.num $2 = 2 When the test tries to connect to a remote target again, GDB maps the remote inferior to inferior 1, but tries to set the solib_ops of program space 2, which already has an solib_ops set, causing the internal error. Fix this by using scoped_restore_current_program_space in addition to scoped_restore_current_inferior. With this patch applied, we get: (top-gdb) p current_inferior_.m_obj.num $1 = 1 (top-gdb) p current_program_space.num $2 = 1 With this patch, we then hit another internal error, fixed by the following patch. Change-Id: If916f581a223d6611f7f23a9cbbf1825d2cdd0ba Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
2025-09-02[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.replayTom de Vries1-4/+2
Fix clean_restart <absolute filename> in the test-case in gdb.replay. Tested on x86_64-linux, with target boards unix, native-gdbserver and native-extended-gdbserver.
2025-09-02[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.reverseTom de Vries6-6/+7
Fix clean_restart <absolute filename> in the test-cases in gdb.reverse. Tested on: - x86_64-linux, target boards unix and unix/-m32 - aarch64-linux - ppc64le-linux - s390x-linux
2025-09-02[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.rocmTom de Vries9-9/+18
Fix clean_restart <absolute filename> in the test-cases in gdb.rocm. Since these test-cases are unsupported for me, do the simple substitution: ... clean_restart $binfile -> clean_restart gdb_load $binfile ...
2025-09-02[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.serverTom de Vries13-13/+14
Fix clean_restart <absolute filename> in the test-cases in gdb.server. Tested on x86_64-linux.
2025-09-02[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.testsuiteTom de Vries3-8/+16
Fix clean_restart <absolute filename> in the test-cases in gdb.testsuite. Tested on x86_64-linux.
2025-09-02[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.threadsTom de Vries78-91/+95
Fix clean_restart <absolute filename> in the test-cases in gdb.threads. Tested on x86_64-linux.
2025-09-02Fix host_file_normalize_mingwPedro Alves2-3/+41
Tom de Vries ran the testsuite on msys2-ucrt64 with mount point map: ... /bin C:/msys64/usr/bin /c C: / C:/msys64 ... and ran into the problem that host_file_normalize didn't translate: ... /home/user/gdb/build/gdb/testsuite/temp/n/x ... into: ... C:/msys64/home/user/gdb/build/gdb/testsuite/temp/n/x ... The problem is that host_file_normalize_mingw mishandles a file/directory under the root mount point. A simpler reproducer is "/foo". If we add that as a test to gdb.testsuite/mount-point-map.exp, we see: input: /foo expected: C:/msys64/foo/ got: /foo FAIL: gdb.testsuite/mount-point-map.exp: /foo For a mount point that ends in /, this line in host_file_normalize_mingw: } elseif {[string index $filename $mount_len] eq "/"} { ... is always false, because the character at $mount_len is the one _after_ the slash. Notice that the "/" mount point is the only one that ends in "/". This is even if you try to create one explicitly with a trailing /. On MSYS2: $ mount c:/foo /foo/ mount: warning - /foo/ does not exist. $ mount C:/foo on /foo type ntfs (binary,user) ... So fix this by special casing the "/" mount point. And then... while playing with fixing this, I noticed I had done something strange with this case: if {[string length $filename] == $mount_len} { return "$win_filename/" The intent was to append the slash when the mount is a drive letter, like 'cygpath -ma' does: $ cygpath -ma /c C:/ Other cases do not get a trailing slash: $ cygpath -ma /c/foo C:/foo I think this is because on Windows, every drive letter has a current directory, and really "C:" means "current directory of drive letter C:", not "root of C:". Resolving it to "C:/" makes it unambiguous. However, I mishandled that in a63213cd374d ('MSYS2+MinGW testing: Unix <-> Windows path conversion'). The original version of that patch when I posted it to the mailing list only supported drive mounts, which turned out incorrect, and then I generalized it to work with all mount points before it was merged. In the process, I inadvertently made the code append the slash whenever the input filename matches a mount exactly, any mount. I also now noticed that TCL's "file normalize" on Linux always removes the trailing slash, and since host_file_normalize is an abstraction for it, I think host_file_normalize_mingw should do the same. Likewise for duplicate slashes, "file normalize" gets rid of them. Fix all this in host_file_normalize_mingw, and add corresponding tests to gdb.testsuite/mount-point-map.exp. I smoke tested this here with a few of the testcases that required tweaking in the patch that added host_file_normalize, like gdb.base/source-dir.exp and gdb.base/fullname.exp and they still pass. Tom ran gdb.testsuite/mount-point-map.exp on both x86_64-linux and msys2-ucrt64, and it passed in both cases. Change-Id: I852a8662f0cb8b0ee4e683e9b157618cf6955477
2025-09-02Add gdb.testsuite/mount-point-map.expTom de Vries2-22/+65
Proc host_file_normalize is structured like this: ... proc host_file_normalize {filename} { if {[ishost *-*-mingw*]} { ... } return [file normalize $filename] ... so a testcase exercising the mingw specific part can only be run on a mingw host. Factor out a new proc host_file_normalize_mingw, which can be used on any host platform. Add testcase gdb.testsuite/mount-point-map.exp, exercising host_file_normalize_mingw. Tested on aarch64-linux, x86-64-linux, msys2-ucrt64, and msys2-mingw. Co-Authored-By: Pedro Alves <pedro@palves.net> Change-Id: Ia130de5c12c940852b6367c422d04896863bfc02
2025-09-02[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.traceTom de Vries12-26/+26
Fix clean_restart <absolute filename> in the test-cases in gdb.trace. Tested on x86_64-linux, with target boards unix, native-gdbserver and native-extended-gdbserver.
2025-09-02[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.tuiTom de Vries6-9/+9
Fix clean_restart <absolute filename> in the test-cases in gdb.tui. Tested on x86_64-linux.
2025-09-01[gdb] Fix handling of aborted inferior callTom de Vries2-3/+46
PR gdb/33069 reports the following behavior: ... $ gdb -q ls -ex starti -ex "b *1" Reading symbols from ls... (No debugging symbols found in ls) Starting program: /usr/bin/ls Program stopped. 0x00007ffff7fe4f00 in _start () from /lib64/ld-linux-x86-64.so.2 Breakpoint 1 at 0x1 (gdb) p (int)strlen("abc") Warning: Cannot insert breakpoint 1. Cannot access memory at address 0x1 Command aborted. An error occurred while in a function called from GDB. Evaluation of the expression containing the function (malloc@plt) will be abandoned. When the function is done executing, GDB will silently stop. [1]+ Stopped gdb -q ls -ex starti -ex "b *1" $ fg gdb -q ls -ex starti -ex "b *1" (gdb) ... with gdb being unresponsive to further input. PR gdb/33068 reports a similar problem, but using gdbserver, and in that case gdb doesn't go into the background, but is likewise unresponsive. This is a regression since commit b1c0ab20809 ("gdb: avoid double stop after failed breakpoint condition check"), and consequently since release gdb 14.1. The commit changed this in run_inferior_call: ... if (current_ui->prompt_state == PROMPT_BLOCKED) - current_ui->unregister_file_handler (); - else - current_ui->register_file_handler (); + { + if (call_thread->thread_fsm ()->finished_p ()) + async_disable_stdin (); + else + async_enable_stdin (); + } ... which means current_ui->register_file_handler is no longer called in the current_ui->prompt_state == PROMPT_NEEDED case. Fix this by: - restoring this behavior, fixing the unresponsiveness, and - adding target_terminal::ours alongside it, fixing the problem that gdb goes into the background. Add a new test-case gdb.base/infcall-failure-2.exp, a regression test for the unresponsiveness issue. The problem of gdb going into the background did not reproduce in the test-case. Tested on x86_64-linux. Reviewed-By: Keith Seitz <keiths@redhat.com> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33068 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33069
2025-08-30gdb: fix include guard in arch/aarch64-gcs-linux.hSimon Marchi1-3/+3
Fix: $ gdb/check-include-guards.py gdb/arch/aarch64-gcs-linux.h gdb/arch/aarch64-gcs-linux.h:20: wrong symbol in ifndef Change-Id: I7586d5c22abe11501f59439df2b4a73bff7d201e
2025-08-30gdb/testsuite: run black on gdb.base/inline-frame-cycle-unwind.pySimon Marchi1-1/+1
Change-Id: Ib15ecd6c03fce9d50a0121bbcb910e2fa05cc5f9
2025-08-30gdb/testsuite: remove leftover debug printSimon Marchi1-1/+0
Change-Id: Ifb1dab85891200cadb4b4f59661450a03b0c6abd