aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
AgeCommit message (Collapse)AuthorFilesLines
2022-11-10gdb: make "start" breakpoint inferior-specificSimon Marchi3-0/+126
I saw this failure on a CI: (gdb) add-inferior [New inferior 2] Added inferior 2 (gdb) PASS: gdb.threads/vfork-multi-inferior.exp: method=non-stop: add-inferior inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] (gdb) PASS: gdb.threads/vfork-multi-inferior.exp: method=non-stop: inferior 2 kill The program is not being run. (gdb) file /home/jenkins/workspace/binutils-gdb_master_linuxbuild/platform/jammy-amd64/target_board/unix/tmp/tmp.GYATAXR8Ku/gdb/testsuite/outputs/gdb.threads/vfork-multi-inferior/vfork-multi-inferior-sleep Reading symbols from /home/jenkins/workspace/binutils-gdb_master_linuxbuild/platform/jammy-amd64/target_board/unix/tmp/tmp.GYATAXR8Ku/gdb/testsuite/outputs/gdb.threads/vfork-multi-inferior/vfork-multi-inferior-sleep... (gdb) run & Starting program: /home/jenkins/workspace/binutils-gdb_master_linuxbuild/platform/jammy-amd64/target_board/unix/tmp/tmp.GYATAXR8Ku/gdb/testsuite/outputs/gdb.threads/vfork-multi-inferior/vfork-multi-inferior-sleep (gdb) PASS: gdb.threads/vfork-multi-inferior.exp: method=non-stop: run inferior 2 inferior 1 [Switching to inferior 1 [<null>] (<noexec>)] (gdb) PASS: gdb.threads/vfork-multi-inferior.exp: method=non-stop: inferior 1 kill The program is not being run. (gdb) file /home/jenkins/workspace/binutils-gdb_master_linuxbuild/platform/jammy-amd64/target_board/unix/tmp/tmp.GYATAXR8Ku/gdb/testsuite/outputs/gdb.threads/vfork-multi-inferior/vfork-multi-inferior Reading symbols from /home/jenkins/workspace/binutils-gdb_master_linuxbuild/platform/jammy-amd64/target_board/unix/tmp/tmp.GYATAXR8Ku/gdb/testsuite/outputs/gdb.threads/vfork-multi-inferior/vfork-multi-inferior... (gdb) break should_break_here Breakpoint 1 at 0x11b1: file /home/jenkins/workspace/binutils-gdb_master_linuxbuild/platform/jammy-amd64/target_board/unix/src/binutils-gdb/gdb/testsuite/gdb.threads/vfork-multi-inferior.c, line 25. (gdb) PASS: gdb.threads/vfork-multi-inferior.exp: method=non-stop: break should_break_here [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". start Temporary breakpoint 2 at 0x11c0: -qualified main. (2 locations) Starting program: /home/jenkins/workspace/binutils-gdb_master_linuxbuild/platform/jammy-amd64/target_board/unix/tmp/tmp.GYATAXR8Ku/gdb/testsuite/outputs/gdb.threads/vfork-multi-inferior/vfork-multi-inferior [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Thread 2.1 "vfork-multi-inf" hit Temporary breakpoint 2, main () at /home/jenkins/workspace/binutils-gdb_master_linuxbuild/platform/jammy-amd64/target_board/unix/src/binutils-gdb/gdb/testsuite/gdb.threads/vfork-multi-inferior-sleep.c:23 23 sleep (30); (gdb) FAIL: gdb.threads/vfork-multi-inferior.exp: method=non-stop: start inferior 1 What happens is: 1. We start inferior 2 with "run&", it runs very slowly, takes time to get to main 2. We switch to inferior 1, and run "start" 3. The temporary breakpoint inserted by "start" applies to all inferiors 4. Inferior 2 hits that breakpoint and GDB reports that hit To avoid this, breakpoints inserted by "start" should be inferior-specific. However, we don't have a nice way to make inferior-specific breakpoints yet. It's possible to make pspace-specific breakpoints (for example how the internal_breakpoint constructor does) by creating a symtab_and_line manually. However, inferiors can share program spaces (usually on particular embedded targets), so we could have a situation where two inferiors run the same code in the same program space. In that case, it would just not be possible to insert a breakpoint in one inferior but not the other. A simple solution that should work all the time is to add a condition to the breakpoint inserted by "start", to check the inferior reporting the hit is the expected one. This is what this patch implements. Add a test that does: - start in background inferior 1 that sleeps before reaching its main function (using a sleep in a global C++ object's constructor) - start inferior 2 with the "start" command, which also sleeps before reaching its main function - validate that we hit the breakpoint in inferior 2 Without the fix, we hit the breakpoint in inferior 1 pretty much all the time. There could be some unfortunate scheduling causing the test not to catch the bug, for instance if the scheduler decides not to schedule inferior 1 for a long time, but it would be really rare. If the bug is re-introduced, the test will catch it much more often than not, so it will be noticed. Reviewed-By: Bruno Larsen <blarsen@redhat.com> Approved-By: Pedro Alves <pedro@palves.net> Change-Id: Ib0148498a476bfa634ed62353c95f163623c686a
2022-11-10gdb: add prepare_reinflate/reinflate around print_frame_args in ↵Simon Marchi1-0/+8
info_frame_command_core I noticed this crash: $ ./gdb --data-directory=data-directory -nx -q \ testsuite/outputs/gdb.python/pretty-print-call-by-hand/pretty-print-call-by-hand \ -x testsuite/outputs/gdb.python/pretty-print-call-by-hand/pretty-print-call-by-hand.py \ -ex "b g" -ex r (gdb) info frame Stack level 0, frame at 0x7fffffffdd80: rip = 0x555555555160 in g (/home/simark/src/binutils-gdb/gdb/testsuite/gdb.python/pretty-print-call-by-hand.c:41); saved rip = 0x5555555551a3 called by frame at 0x7fffffffdda0 source language c. Arglist at 0x7fffffffdd70, args: mt=mytype is 0x555555556004 "hello world", depth=10 Fatal signal: Segmentation fault This is another case of frame_info being invalidated under a function's feet. The stack trace when the frame_info get invalidated looks like: ... many frames to pretty print the arg, that eventually invalidate the frame_infos ... #35 0x00005568d0a8ab24 in print_frame_arg (fp_opts=..., arg=0x7ffc3216bcb0) at /home/simark/src/binutils-gdb/gdb/stack.c:489 #36 0x00005568d0a8cc75 in print_frame_args (fp_opts=..., func=0x621000233210, frame=..., num=-1, stream=0x60b000000300) at /home/simark/src/binutils-gdb/gdb/stack.c:898 #37 0x00005568d0a9536d in info_frame_command_core (fi=..., selected_frame_p=true) at /home/simark/src/binutils-gdb/gdb/stack.c:1682 print_frame_args knows that print_frame_arg can invalidate frame_info objects, and therefore calls prepare_reinflate/reinflate. However, info_frame_command_core has a separate frame_info_ptr instance (it is passed by value / copy). So info_frame_command_core needs to know that print_frame_args can invalidate frame_info objects, and therefore needs to prepare_reinflate/reinflate as well. Add those calls, and enhance the gdb.python/pretty-print-call-by-hand.exp test to test that command. Reviewed-By: Bruno Larsen <blarsen@redhat.com> Change-Id: I9edaae06d62e97ffdb30938d364437737238a960
2022-11-10gdb/c++: Improve error messages in overload resolutionBruno Larsen2-0/+228
When resolving overloaded functions, GDB relies on knowing relationships between types, i.e. if a type inherits from another. However, some compilers may not add complete information for given types as a way to reduce unnecessary debug information. In these cases, GDB would just say that it couldn't resolve the method or function, with no extra information. The problem is that sometimes the user may not know that the type information is incomplete, and may just assume that there is a bug in GDB. To improve the user experience, we attempt to detect if the overload match failed because of an incomplete type, and warn the user of this. This commit also adds a testcase confirming that the message is only triggered in the correct scenario. This test was not developed as an expansion of gdb.cp/overload.cc because it needed the dwarf assembler, and porting all of overload.cc seemed unnecessary. Approved-By: Tom Tromey <tom@tromey.com>
2022-11-10gdb/testsuite: allowed for function_range to deal with mangled functionsBruno Larsen1-1/+1
When calling get_func_info inside a test case, it would cause failures if the function was printed using a C++ style mangled name. The current patch fixes this by allowing for mangled names along with the current rules. Approved-By: Tom Tromey <tom@tromey.com>
2022-11-10gdb/testsuite: Fix rtld-step-nodebugsym.expLancelot SIX1-1/+3
The test case introduced in bafcc335266 (Fix stepping in rtld without debug symbol) fails on some systems as reported by PR/29768. This can be seen if the system does not have debug info for the libc: (gdb) step^M Single stepping until exit from function main,^M which has no line number information.^M hello world[Inferior 1 (process 48203) exited normally]^M (gdb) PASS: gdb.base/rtld-step-nodebugsym.exp: step continue^M The program is not being run.^M (gdb) FAIL: gdb.base/rtld-step-nodebugsym.exp: continue until exit (the program is no longer running) Without glibc debug info, GDB steps until the program finishes, and then "gdb_continue_to_end" fails. As this test was designed to check that GDB does not crash in the "step" command, the continue does not carry real meaning to the test. Replace it by "print 0" so we still check that after the step command GDB is still alive, which is what we care about. Tested on Ubuntu-22.04 x86_64, with and without libc6-dbg. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29768 Approved-By: Simon Marchi <simon.marchi@efficios.com>
2022-11-09Fix stepping in rtld without debug symbolLancelot SIX2-0/+57
Commit be6276e0aed "Allow debugging of runtime loader / dynamic linker" introduced a small regression when stepping into the runtime loader / dynamic linker from function we do not have debug information for. This is reported in PR/29747. This can be shown by the following example (given by Simon Marchi in buzilla bug report): $ cat test.c #include <stdio.h> int main() { printf("Hi\n"); return 0; } $ gcc test.c -O0 -o test $ ./gdb -q -nx --data-directory=data-directory test -ex start -ex s Reading symbols from test... (No debugging symbols found in test) Temporary breakpoint 1 at 0x1151 Starting program: .../binutils-gdb/gdb/test [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Temporary breakpoint 1, 0x0000555555555151 in main () Single stepping until exit from function main, which has no line number information. /home/smarchi/src/binutils-gdb/gdb/infrun.c:6960:64: runtime error: member call on null pointer of type 'struct symbol' The crash happens here: #0 __sanitizer::Die () at ../../../../src/libsanitizer/sanitizer_common/sanitizer_termination.cpp:50 #1 0x00007ffff5dd7128 in __ubsan::__ubsan_handle_type_mismatch_v1_abort (Data=<optimized out>, Pointer=<optimized out>) at ../../../../src/libsanitizer/ubsan/ubsan_handlers.cpp:148 #2 0x000055556183e1a7 in process_event_stop_test (ecs=0x7fffffffccd0) at .../binutils-gdb/gdb/infrun.c:6960 #3 0x0000555561838ea4 in handle_signal_stop (ecs=0x7fffffffccd0) at .../binutils-gdb/gdb/infrun.c:6615 #4 0x000055556182f77b in handle_inferior_event (ecs=0x7fffffffccd0) at .../binutils-gdb/gdb/infrun.c:5866 When evaluating: 6956 if (execution_direction != EXEC_REVERSE 6957 && ecs->event_thread->control.step_over_calls == STEP_OVER_UNDEBUGGABLE 6958 && in_solib_dynsym_resolve_code (ecs->event_thread->stop_pc ()) 6959 && !in_solib_dynsym_resolve_code ( 6961 ecs->event_thread->control.step_start_function->value_block () 6962 ->entry_pc ())) we dereference, ecs->event_thread->control.step_start_function which is nullptr. This patch changes this condition so it evaluates to true if ecs->event_thread->control.step_start_function is nullptr since this matches the behaviour before be6276e0aed. Tested on ubuntu-22.04 x86_64. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29747 Reviewed-By: Bruno Larsen <blarsen@redhat.com> Approved-By: Kevin Buettner <kevinb@redhat.com>
2022-11-09Allow 'ptype/o' for assemblyTom Tromey1-0/+13
PR exp/28359 points out that 'ptype/o' does not work when the current language is "asm". I tracked this down to a hard-coded list of languages in typeprint.c. This patch replaces this list with a method on 'language_defn' instead. If all languages are ever updated to have this feature, the method could be removed; but in the meantime this lets each language control what happens. I looked at having each print_type method simply modify the flags itself, but this doesn't work very well with the feature that disables method-printing by default (but allows it via a flag). Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28359 Approved-By: Andrew Burgess <aburgess@redhat.com> Approved-By: Keith Seitz <keiths@redhat.com>
2022-11-08[gdb/cli] Make quit really quit after remote connection closedTom de Vries1-0/+81
Consider a hello world a.out, started using gdbserver: ... $ gdbserver --once 127.0.0.1:2345 ./a.out Process ./a.out created; pid = 15743 Listening on port 2345 ... that we can connect to using gdb: ... $ gdb -ex "target remote 127.0.0.1:2345" Remote debugging using 127.0.0.1:2345 Reading /home/vries/a.out from remote target... ... 0x00007ffff7dd4550 in _start () from target:/lib64/ld-linux-x86-64.so.2 (gdb) ... After that, we can for instance quit with confirmation: ... (gdb) quit A debugging session is active. Inferior 1 [process 16691] will be killed. Quit anyway? (y or n) y $ ... Or, kill with confirmation and quit: ... (gdb) kill Kill the program being debugged? (y or n) y [Inferior 1 (process 16829) killed] (gdb) quit $ ... Or, monitor exit, kill with confirmation, and quit: ... (gdb) monitor exit (gdb) kill Kill the program being debugged? (y or n) y Remote connection closed (gdb) quit $ ... But when doing monitor exit followed by quit with confirmation, we get the gdb prompt back, requiring us to do quit once more: ... (gdb) monitor exit (gdb) quit A debugging session is active. Inferior 1 [process 16944] will be killed. Quit anyway? (y or n) y Remote connection closed (gdb) quit $ ... So, the first quit didn't quit. This happens as follows: - quit_command calls query_if_trace_running - a TARGET_CLOSE_ERROR is thrown - it's caught in remote_target::get_trace_status, but then rethrown because it's TARGET_CLOSE_ERROR - catch_command_errors catches the error, at which point the quit command has been aborted. The TARGET_CLOSE_ERROR is defined as: ... /* Target throwing an error has been closed. Current command should be aborted as the inferior state is no longer valid. */ TARGET_CLOSE_ERROR, ... so in a way this is expected behaviour. But aborting quit because the inferior state (which we've already confirmed we're not interested in) is no longer valid, and having to type quit again seems pointless. Furthermore, the purpose of not catching errors thrown by query_if_trace_running as per commit 2f9d54cfcef ("make -gdb-exit call disconnect_tracing too, and don't lose history if the target errors on "quit""), was to make sure that error (_("Not confirmed.") had effect. Fix this in quit_command by catching only the TARGET_CLOSE_ERROR exception during query_if_trace_running and reporting it: ... (gdb) monitor exit (gdb) quit A debugging session is active. Inferior 1 [process 19219] will be killed. Quit anyway? (y or n) y Remote connection closed $ ... Tested on x86_64-linux. PR server/15746 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=15746 Approved-By: Tom Tromey <tom@tromey.com>
2022-11-08[gdb/testsuite] Remove test-case from test nameTom de Vries7-33/+33
Remove test-cases from test-names, such that we don't have the redundant: ... PASS: gdb.base/corefile.exp: backtrace in corefile.exp ... but simply: ... PASS: gdb.base/corefile.exp: backtrace ... Fixed all instances found using: ... $ grep ":.*:.*\.exp" gdb.sum ... Tested on x86_64-linux.
2022-11-08[gdb/testsuite] Fix find_core_file for core named coreTom de Vries1-1/+2
With test-case gdb.base/bigcore.exp I run into: ... (gdb) PASS: gdb.base/bigcore.exp: get inferior pid signal SIGABRT^M Continuing with signal SIGABRT.^M ^M Program terminated with signal SIGABRT, Aborted.^M The program no longer exists.^M (gdb) PASS: gdb.base/bigcore.exp: signal SIGABRT UNTESTED: gdb.base/bigcore.exp: can't generate a core file ... due to find_core_file returning "". There is a core file name core: ... $ ls ./outputs/gdb.base/bigcore bigcore bigcore.corefile core gdb.cmd.1 gdb.in.1 gdbserver.cmd.1 ... but it's not found. The problem is this statement: ... lappend files [list ${::testfile}.core core] ... which adds a single list item "${::testfile}.core core". Fix this in the most readable way: ... lappend files ${::testfile}.core lappend files core ... Tested on x86_64-linux.
2022-11-07gdb/testsuite: use a more unique name in ↵Simon Marchi2-8/+8
gdb.mi/mi-breakpoint-multiple-locations.exp I see failures in this test, due to the function name "add" being too generic, and unexpected breakpoint locations being found in my libstdc++, such as (wrapped for readability): { number="2.4",enabled="y",addr="0x00007ffff7d67e68", func="(anonymous namespace)::fast_float::bigint::add", file="/usr/src/debug/gcc/libstdc++-v3/src/c++17/fast_float/fast_float.h", fullname="/usr/src/debug/gcc/libstdc++-v3/src/c++17/fast_float/fast_float.h", line="1815", thread-groups=["i1"] } Change the test to use a more unique name. Change-Id: I91de781be62d246eb41c73eaa410ebdd12633d1d
2022-11-04[testsuite] gdb.base/dlmopen: Fix test name and use gdb_attachLancelot SIX1-1/+3
One test name in gdb.base/dlmopen.exp changes from run to run since it includes a process id: PASS: gdb.base/dlmopen.exp: attach 3442682 This is not convenient do diff gdb.sum files to compare test runs. Fix by using gdb_attach helper function to handle attaching to the process as it produce a constant test name. While at it also check gdb_attach's return value to only run the rest of the test if the attach was successful. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2022-11-04PowerPC update comments for the MMA instruction name changes.Carl Love2-0/+13
The mnemonics for the pmxvf16ger*, pmxvf32ger*,pmxvf64ger*, pmxvi4ger8*, pmxvi8ger4*, and pmxvi16ger2* instructions were officially changed to pmdmxbf16ger*, pmdmxvf32ger*, pmdmxvf64ger*, pmdmxvi4ger8*, pmdmxvi8ger4*, pmdmxvi16ger* respectively. The old mnemonics are still supported by the assembler as extended mnemonics. The disassembler generates the new mnemonics. The name changes occurred in commit: commit bb98553cad4e017f1851153fa5de91f2cee98fb2 Author: Peter Bergner <bergner@linux.ibm.com> Date: Sat Oct 8 16:19:51 2022 -0500 PowerPC: Add support for RFC02658 - MMA+ Outer-Product Instructions gas/ * config/tc-ppc.c (md_assemble): Only check for prefix opcodes. * testsuite/gas/ppc/rfc02658.s: New test. * testsuite/gas/ppc/rfc02658.d: Likewise. * testsuite/gas/ppc/ppc.exp: Run it. opcodes/ * ppc-opc.c (XMSK8, P_GERX4_MASK, P_GERX2_MASK, XX3GERX_MASK): New. (powerpc_opcodes): Add dmxvi8gerx4pp, dmxvi8gerx4, dmxvf16gerx2pp, dmxvf16gerx2, dmxvbf16gerx2pp, dmxvf16gerx2np, dmxvbf16gerx2, dmxvi8gerx4spp, dmxvbf16gerx2np, dmxvf16gerx2pn, dmxvbf16gerx2pn, dmxvf16gerx2nn, dmxvbf16gerx2nn, pmdmxvi8gerx4pp, pmdmxvi8gerx4, pmdmxvf16gerx2pp, pmdmxvf16gerx2, pmdmxvbf16gerx2pp, pmdmxvf16gerx2np, pmdmxvbf16gerx2, pmdmxvi8gerx4spp, pmdmxvbf16gerx2np, pmdmxvf16gerx2pn, pmdmxvbf16gerx2pn, pmdmxvf16gerx2nn, pmdmxvbf16gerx2nn. This patch updates the comments in the various gdb files to reflect the name changes. There are no functional changes made by this patch. The older instruction names are still used in the test gdb.reverse/ppc_record_test_isa_3_1.exp for backwards compatibility. Patch has been tested on Power 10 with no regressions.
2022-11-04PowerPC fix for the gdb.arch/powerpc-power10.exp test.Carl Love2-416/+416
The mnemonics for the pmxvf16ger*, pmxvf32ger*,pmxvf64ger*, pmxvi4ger8*, pmxvi8ger4*, pmxvi16ger2* instructions were officially changed to pmdmxvf16ger*, pmdmxvf32ger*, pmdmxvf64ger*, pmdmxvi4ger8*, pmdmxvi8ger4*, pmdmxvi16ger* respectively. The old mnemonics are still supported by the assembler as extended mnemonics. The disassembler generates the new mnemonics. The name changes occurred in commit: commit bb98553cad4e017f1851153fa5de91f2cee98fb2 Author: Peter Bergner <bergner@linux.ibm.com> Date: Sat Oct 8 16:19:51 2022 -0500 PowerPC: Add support for RFC02658 - MMA+ Outer-Product Instructions gas/ * config/tc-ppc.c (md_assemble): Only check for prefix opcodes. * testsuite/gas/ppc/rfc02658.s: New test. * testsuite/gas/ppc/rfc02658.d: Likewise. * testsuite/gas/ppc/ppc.exp: Run it. opcodes/ * ppc-opc.c (XMSK8, P_GERX4_MASK, P_GERX2_MASK, XX3GERX_MASK): New. (powerpc_opcodes): Add dmxvi8gerx4pp, dmxvi8gerx4, dmxvf16gerx2pp, dmxvf16gerx2, dmxvbf16gerx2pp, dmxvf16gerx2np, dmxvbf16gerx2, dmxvi8gerx4spp, dmxvbf16gerx2np, dmxvf16gerx2pn, dmxvbf16gerx2pn, dmxvf16gerx2nn, dmxvbf16gerx2nn, pmdmxvi8gerx4pp, pmdmxvi8gerx4, pmdmxvf16gerx2pp, pmdmxvf16gerx2, pmdmxvbf16gerx2pp, pmdmxvf16gerx2np, pmdmxvbf16gerx2, pmdmxvi8gerx4spp, pmdmxvbf16gerx2np, pmdmxvf16gerx2pn, pmdmxvbf16gerx2pn, pmdmxvf16gerx2nn, pmdmxvbf16gerx2nn. The above commit results in about 224 failures on Power 10 since the disassembled names do not match the expected names in the test. This patch updates the expected names in the test to match the values produced by the disassembler. This patch updates file gdb.arch/powerpc-power10.exp with the new expected values to the instructions. The comment giving the name of the instruction for each binary value in the file gdb.arch/powerpc-power10.c is updated with the new name. There are no functional changes in file gdb.arch/powerpc-power10.c.
2022-11-04Powerpc fix for gdb.base/unwind-on-each-insn.expCarl Love1-0/+22
The test disassembles function foo and searches for the line "End of assembler dump" to determing the last address in the function. The assumption is the last instruction will be given right before the line "End of assembler dump". This assumption fails on PowerPC. The PowerPC disassembly of the function foo looks like: Dump of assembler code for function foo: # => 0x00000000100006dc <+0>: std r31,-8(r1) # 0x00000000100006e0 <+4>: stdu r1,-48(r1) # 0x00000000100006e4 <+8>: mr r31,r1 # 0x00000000100006e8 <+12>: nop # 0x00000000100006ec <+16>: addi r1,r31,48 # 0x00000000100006f0 <+20>: ld r31,-8(r1) # 0x00000000100006f4 <+24>: blr # 0x00000000100006f8 <+28>: .long 0x0 # 0x00000000100006fc <+32>: .long 0x0 # 0x0000000010000700 <+36>: .long 0x1000180 # End of assembler dump. The blr instruction is the last instruction in function foo. The lines with .long following the blr instruction need to be ignored. This patch adds a new condition to the gdb_test_multiple "disassemble foo" test to ignore the lines with the .long. The patch has been tested on PowerPC and Intel X86-64.
2022-11-04gdb/testsuite: add KFAILs to gdb.reverse/step-reverse.expBruno Larsen1-0/+15
Recent changes to gdb.reverse/step-reverse.exp revealed the latent bug PR record/29745, where we can't skip one funcion forward if we're using native-gdbserver. This commit just adds kfails to the test. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29745 Approved-By: Simon Marchi <simon.marchi@efficios.com>
2022-11-03gdb: Fix issue with Clang CLI macrosBruno Larsen3-5/+118
Clang up to version 15 (current) adds macros that were defined in the command line or by "other means", according to the Dwarf specification, after the last DW_MACRO_end_file, instead of before the first DW_MACRO_start_file, as the specification dictates. When GDB reads the macros after the last file is closed, the macros never end up "in scope" and so we can't print them. This has been submitted as a bug to Clang developers (https://github.com/llvm/llvm-project/issues/54506), and PR macros/29034 was opened for GDB to keep track of this. Seeing as there is no expected date for it to be fixed, add a workaround for all current versions of Clang. The workaround detects when the main file would be closed and if the producer is Clang, and turns that operation into a noop, so we keep a reference to the current_file as those macros are read. A test case was added to confirm the functionality, and the KFAIL for running gdb.base/macro-source-path when using clang. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29034 Approved-By: Simon Marchi <simon.marchi@efficios.com>
2022-10-31Fix regression in pointer-to-member printingTom Tromey2-0/+12
PR c++/29243 points out that "info func" on a certain C++ executable will cause an infinite loop in gdb. I tracked this down to a bug introduced by commit 6b5a7bc76 ("Handle member pointers directly in generic_value_print"). Before this commit, the C++ code to print a member pointer would wind up calling value_print_scalar_formatted; but afterward it simply calls generic_value_print and gets into a loop. This patch restores the previous behavior and adds a regression test.
2022-10-31gdb/testsuite: fix gdb.cp/converts.exp to run with clangBruno Larsen1-1/+1
Clang attempts to minimize the size of the debug-info by not adding complete information about types that aren't constructed in a given file. Specifically, this meant that there was minimal information about class B in the test gdb.cp/converts.exp. To fix this, we just need to construct any object of type B in that file. Approved-By: Andrew Burgess <aburgess@redhat.com>
2022-10-31gdb/testsuite: add XFAIL to gdb.cp/ptype-flags.exp when using clangBruno Larsen1-0/+12
When running gdb.cp/ptype-flags.exp using Clang, we get an unexpected failure when printing the type of a class with an internal typedef. This happens because Clang doesn't add accessibility information for typedefs inside classes (see https://github.com/llvm/llvm-project/issues/57608 for more info). To help with Clang testing, an XFAIL was added to this test.
2022-10-29gdb/testsuite: Wrap `param_integer_error' in gdb.guile/scm-parameter.expMaciej W. Rozycki1-1/+3
Wrap an overlong line in the definition of `param_integer_error' in gdb.guile/scm-parameter.exp. No functional change.
2022-10-29[gdb/testsuite] Use ssh -t in remote-*.expTom de Vries2-0/+24
When running test-case gdb.server/multi-ui-errors.exp on target board remote-gdbserver-on-localhost.exp, I run into: ... (gdb) PASS: gdb.server/multi-ui-errors.exp: connect to gdbserver continue^M Continuing.^M PASS: gdb.server/multi-ui-errors.exp: continue - extra UI Remote debugging from host ::1, port 35466^M FAIL: gdb.server/multi-ui-errors.exp: ensure inferior is running ... The problem is that the target board uses ssh -T, which fails to guarantee that output from the inferior will be available. Fix this by copying proc ${board}_spawn from local-remote-host.exp, which ensures using ssh -t. [ It would be nice to define an ssh base board to get rid of the copies, but I'm not addressing that in this commit. ] Likewise for target board remote-stdio-gdbserver.exp. Tested on x86_64-linux.
2022-10-29[gdb/testsuite] Fix gdb.server/multi-ui-errors.exp with local-remote-host-nottyTom de Vries1-0/+8
With test-case gdb.server/multi-ui-errors.exp and host board local-remote-host-notty, I run into: ... (gdb) PASS: gdb.server/multi-ui-errors.exp: interact with GDB's main UI Executing on target: kill -9 29666 (timeout = 300) builtin_spawn -ignore SIGHUP kill -9 29666^M echo^M Remote connection closed^M (gdb) (gdb) FAIL: gdb.server/multi-ui-errors.exp: \ main UI, prompt after gdbserver dies (timeout) ... In contrast, with local-remote-host (so, everything the same but editing off): ... (gdb) PASS: gdb.server/multi-ui-errors.exp: interact with GDB's main UI Executing on target: kill -9 31245 (timeout = 300) builtin_spawn -ignore SIGHUP kill -9 31245^M Remote connection closed^M (gdb) echo^M (gdb) PASS: gdb.server/multi-ui-errors.exp: main UI, prompt after gdbserver dies ... The test-case issues a kill, which results in a "Remote connection closed" message and a prompt. The problem is that the prompt is not consumed, so the subsequent echo may be issued before that prompt, which causes a mismatch when matching the result of the echo. Fix this by consuming the "Remote connection closed" message and prompt. Tested on x86_64-linux.
2022-10-29[gdb/testsuite] Consume output asap in gdb.server/multi-ui-errors.expTom de Vries1-1/+7
With test-case gdb.server/multi-ui-errors.exp we see: ... (gdb) PASS: multi-ui-errors.exp: main UI, prompt after gdbserver dies continue^M Continuing.^M echo^M (gdb) PASS: multi-ui-errors.exp: extra UI, prompt after gdbserver dies ... The continue is issued earlier in the test-case, but the output has not been consumed, which makes it show up much later. Consume the continue output asap, to make it clear when the continue is issued: ... (gdb) PASS: gdb.server/multi-ui-errors.exp: connect to gdbserver continue^M Continuing.^M PASS: gdb.server/multi-ui-errors.exp: continue - extra UI ... Tested on x86_64-linux.
2022-10-29[gdb/testsuite] Remove REMOTE_PORTNUM in remote-stdio-gdbserver.expTom de Vries1-12/+3
The usage for board remote-stdio-gdbserver.exp is advertised as: ... # bash$ make check RUNTESTFLAGS="--target_board=remote-stdio-gdbserver \ # REMOTE_USERNAME=... REMOTE_HOSTNAME=... REMOTE_PORTNUM=... \ # [REMOTE_TMPDIR=${remote_dir}] [GDBSERVER=${remote_gdbserver}]" ... but when adding REMOTE_PORTNUM=22, I run into: ... Running stop-reply-no-thread-multi.exp ... ERROR: tcl error sourcing stop-reply-no-thread-multi.exp. ERROR: couldn't execute "/usr/bin/ssh -p22": no such file or directory while executing "builtin_spawn {/usr/bin/ssh -p22} -l vries localhost {/usr/bin/gdbserver \ --once localhost:2346 \ /home/vries/gdb_versions/devel/build/gdb/testsuite/outp..." ... Fix this by simply removing REMOTE_PORTNUM. Tested on x86_64-linux.
2022-10-27[gdb/testsuite] Remove address from test namesTom de Vries3-3/+5
I noticed an address in a test name: ... PASS: gdb.base/eh_return.exp: gdb_breakpoint: \ set breakpoint at *0x000000000040071b ... Stabilize the test name by using "set breakpoint on address" instead. Likewise in two other test-cases. Tested on x86_64-linux.
2022-10-27[gdb/testsuite] Disable styling in host board local-remote-host-native.expTom de Vries1-0/+4
Propagate fix from commit 17c68d98f74 ("[gdb/testsuite] Disable styling in host board local-remote-host.exp") to local-remote-host-native.exp. Tested on x86_64-linux.
2022-10-27[gdb/testsuite] Fix silent timeouts in gdb.mi/mi-exec-run.exp with remote hostTom de Vries2-1/+3
I noticed that running test-case gdb.mi/mi-exec-run.exp with host board local-remote-host.exp takes about 44 seconds. I found two silent timeouts responsible for this. The first is in mi_gdb_exit, where we have: ... if { [is_remote host] && [board_info host exists fileid] } { send_gdb "999-gdb-exit\n" gdb_expect 10 { -re "y or n" { send_gdb "y\n" exp_continue } -re "Undefined command.*$gdb_prompt $" { send_gdb "quit\n" exp_continue } -re "DOSEXIT code" { } } } ... so in gdb.log we see: ... 999-gdb-exit^M 999^exit^M =thread-exited,id="1",group-id="i1"^M =thread-group-exited,id="i1"^M ... after which expect just waits for the timeout. Fix this by adding a gdb_expect clause to parse the exit: ... -re "\r\n999\\^exit\r\n" { } ... Note that we're not parsing the thread-exited/thread-group-exited messages, because they may not be present: ... $ gdb -i=mi =thread-group-added,id="i1" (gdb) 999-gdb-exit 999^exit $ ... After fixing that, we have: ... (gdb) ^M saw mi error PASS: gdb.mi/mi-exec-run.exp: inferior-tty=separate: mi=separate: \ force-fail=1: run failure detected quit^M &"quit\n"^M ... What seems to be happening is that default_gdb_exit sends a cli interpreter quit command to an mi interpreter, after which again expect just waits for the timeout. Fix this by adding mi_gdb_exit to the end of the test-case, as in many other gdb.mi/*.exp test-cases. After these two fixes, the test-case takes about 4 seconds. Tested on x86_64-linux.
2022-10-27[gdb/testsuite] Use remote_exec chmod instead of remote_spawnTom de Vries2-2/+2
I build gdb using -O2, and ran the testsuite using taskset -c 0, and ran into: ... (gdb) PASS: gdb.server/connect-with-no-symbol-file.exp: sysroot=: \ action=delete: setup: adjust sysroot builtin_spawn gdbserver --once localhost:2385 /connect-with-no-symbol-file^M /bin/bash: connect-with-no-symbol-file: Permission denied^M /bin/bash: line 0: exec: connect-with-no-symbol-file: cannot execute: \ Permission denied^M During startup program exited with code 126.^M Exiting^M target remote localhost:2385^M `connect-with-no-symbol-file' has disappeared; keeping its symbols.^M localhost:2385: Connection timed out.^M (gdb) FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: \ action=delete: connection to GDBserver succeeded ... The expected series of events is (skipping disconnect and detach as I don't think they're relevant to the problem): - enter scenario "permission" - cp $exec.bak $exec - gdbserver start with $exec - chmod 000 $exec - connect to gdbserver - enter scenario "delete" - cp $exec.bak $exec - gdbserver start with $exec - delete $exec - connect to gdbserver The problem is that the chmod is executed using remote_spawn: ... } elseif { $action == "permission" } { remote_spawn target "chmod 000 $target_exec" } ... without waiting on the resulting spawn id, so we're not sure when the chmod will have effect. The FAIL we're seeing above is explained by the chmod having effect during the delete scenario, after the "cp $exec.bak $exec" and before the "gdbserver start with $exec". Fix this by using remote_exec instead. Likewise, fix a similar case in gdb.mi/mi-exec-run.exp. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29726
2022-10-26gdb/testsuite: fix gdb.guile/scm-parameter.exp "wrong type argument" test ↵Simon Marchi1-4/+4
pattern for Guile >= 2.2 Since commit 90319cefe3 ("GDB/Guile: Don't assert that an integer value is boolean"), I see: FAIL: gdb.guile/scm-parameter.exp: kind=PARAM_ZINTEGER: test-PARAM_ZINTEGER-param: guile (set-parameter-value! test-PARAM_ZINTEGER-param #:unlimited) FAIL: gdb.guile/scm-parameter.exp: kind=PARAM_ZUINTEGER: test-PARAM_ZUINTEGER-param: guile (set-parameter-value! test-PARAM_ZUINTEGER-param #:unlimited) This comes from the fact that GDB outputs this: ERROR: In procedure set-parameter-value!: In procedure gdbscm_set_parameter_value_x: Wrong type argument in position 2 (expecting integer): #:unlimited Error while executing Scheme code. while the test expects an additional "ERROR:" on the second line, something like this: ERROR: In procedure set-parameter-value!: ERROR: In procedure gdbscm_set_parameter_value_x: Wrong type argument in position 2 (expecting integer): #:unlimited Error while executing Scheme code. Guile 2.0 outputs the `ERROR:` on the second line, while later versions do not. Change the pattern to accept both outputs. This is similar to commit 6bbe1a929c6 ("[gdb/testsuite] Fix gdb.guile/scm-breakpoint.exp with guile 3.0"). Change-Id: I9dc45e7492a4f08340cad974610242ed689de959
2022-10-25gdb/testsuite: make sure to consume the prompt in ↵Simon Marchi1-10/+2
gdb.base/unwind-on-each-insn.exp This test fails quite reliably for me when ran as: $ taskset -c 1 make check TESTS="gdb.base/unwind-on-each-insn.exp" RUNTESTFLAGS="--target_board=native-gdbserver" or more simply: $ make check-read1 TESTS="gdb.base/unwind-on-each-insn.exp" The problem is that the gdb_test_multiple call that grabs the frame id from "maint print frame-id" does not consume the prompt. Well, it does sometimes due to the trailing .*, but not always. If the prompt is not consumed, the tests that follow get confused: FAIL: gdb.base/unwind-on-each-insn.exp: gdb_breakpoint: set breakpoint at *foo FAIL: gdb.base/unwind-on-each-insn.exp: disassemble foo FAIL: gdb.base/unwind-on-each-insn.exp: get $sp and frame base in foo: get hexadecimal valueof "$sp" ... many more ... Use -wrap to make gdb_test_multiple consume the prompt. While at it, remove the bit that consumes the command name and do exp_continue, it's not really necessary. And for consistency, do the same changes to the gdb_test_multiple that consumes the stack address, although that one was fine, it did consume the prompt explicitly. Change-Id: I2b7328c8844c7e98921ea494c4c05107162619fc Reviewed-By: Bruno Larsen <blarsen@redhat.com>
2022-10-25[gdb/testsuite] Handle missing .note.GNU-stackTom de Vries137-0/+139
On openSUSE Tumbleweed I run into this for the dwarf assembly test-cases, and some hardcoded assembly test-cases: ... Running gdb.dwarf2/fission-absolute-dwo.exp ... gdb compile failed, ld: warning: fission-absolute-dwo.o: \ missing .note.GNU-stack section implies executable stack ld: NOTE: This behaviour is deprecated and will be removed in a future \ version of the linker === gdb Summary === # of untested testcases 1 ... Fix the dwarf assembly test-cases by adding the missing .note.GNU-stack in proc Dwarf::assemble. Fix the hard-coded test-cases using this command: ... $ for f in $(find gdb/testsuite/gdb.* -name *.S); do if ! grep -q note.GNU-stack $f; then echo -e "\t.section\t.note.GNU-stack,\"\",@progbits" >> $f; fi; done ... Likewise for .s files, and gdb/testsuite/lib/my-syscalls.S. The idiom for arm seems to be to use %progbits instead, see commit 9a5911c08be ("gdb/testsuite/gdb.dwarf2: Replace @ with % for ARM compatability"), so hand-edit gdb/testsuite/gdb.arch/arm-disp-step.S to use %progbits instead. Note that dwarf assembly testcases use %progbits as decided by proc _section. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29674
2022-10-25[gdb/testsuite] Add missing skip_gdbserver_tests in ↵Tom de Vries1-0/+4
gdb.multi/attach-no-multi-process.exp I build gdb without gdbserver, and ran into: ... (gdb) PASS: gdb.multi/attach-no-multi-process.exp: target_non_stop=off: \ switch to inferior 2 spawn of --once --multi localhost:2346 failed ERROR: tcl error sourcing attach-no-multi-process.exp. ERROR: tcl error code NONE ERROR: Timeout waiting for gdbserver response. ... Add the missing skip_gdbserver_tests. Tested on x86_64-linux.
2022-10-24[gdb/testsuite] Add skip_python_tests in gdb.python/tui-window-names.expTom de Vries1-0/+5
I did a gdb build without python support, and during testing ran into FAILs in test-case gdb.python/tui-window-names.exp. Fix this by adding the missing skip_python_test. Tested on x86_64-linux.
2022-10-22gdb/testsuite: add max number of instructions check in ↵Simon Marchi1-0/+7
gdb.base/unwind-on-each-insn.exp This test sends my CI in an infinite loop of failures. We expect to have a handful of iterations (5 on my development machine, where the test passes fine)but the log shows that it went up to 104340 iterations: FAIL: gdb.base/unwind-on-each-insn.exp - instruction 104340: maint print frame-id DUPLICATE: gdb.base/unwind-on-each-insn.exp - instruction 104340: maint print frame-id FAIL: gdb.base/unwind-on-each-insn.exp - instruction 104340: [string equal $fid $main_fid] FAIL: gdb.base/unwind-on-each-insn.exp - instruction 104340: get hexadecimal valueof "$pc" Add a max instruction check, exit the loop if we reach 100 iterations. This should allow the test to fail fast if there's a problem, but 100 iterations should be more than enough for when things are working. Change-Id: I77978d593aca046068f9209272d82e1675ba17c2
2022-10-21Fix crash in value_print_array_elementsTom Tromey1-0/+13
A user noticed that gdb would crash when printing a packed array after doing "set lang c". Packed arrays don't exist in C, but it's occasionally useful to print things in C mode when working in a non-C language -- this lets you see under the hood a little bit. The bug here is that generic value printing does not handle packed arrays at all. This patch fixes the bug by introducing a new function to extract a value from a bit offset and width. The new function includes a hack to avoid problems with some existing test cases when using -fgnat-encodings=all. Cleaning up this code looked difficult, and since "all" is effectively deprecated, I thought it made sense to simply work around the problems.
2022-10-21Fix bug in Ada packed array handlingTom Tromey2-0/+20
A user found a bug where an array of packed arrays was printed incorrectly. The bug here is that the packed array has a bit stride, but the outer array does not -- and should not. However, update_static_array_size does not distinguish between an array of packed arrays and a multi-dimensional packed array, and for the latter, only the innermost array will end up with a stride. This patch fixes the problem by adding a flag to indicate whether a given array type is a constituent of a multi-dimensional array.
2022-10-21gdb/reverse: Fix stepping over recursive functionsBruno Larsen3-7/+73
Currently, when using GDB to do reverse debugging, if we try to use the command "reverse next" to skip a recursive function, instead of skipping all of the recursive calls and stopping in the previous line, we stop at the second to last recursive call, and need to manually step backwards until we leave the first call. This is well documented in PR gdb/16678. This bug happens because when GDB notices that a reverse step has entered into a function, GDB will add a step_resume_breakpoint at the start of the function, then single step out of the prologue once that breakpoint is hit. The problem was happening because GDB wouldn't give that step_resume_breakpoint a frame-id, so the first time the breakpoint was hit, the inferior would be stopped. This is fixed by giving the current frame-id to the breakpoint. This commit also changes gdb.reverse/step-reverse.c to contain a recursive function and attempt to both, skip it altogether, and to skip the second call from inside the first call, as this setup broke a previous version of the patch.
2022-10-21Change calculation of frame_id by amd64 epilogue unwinderBruno Larsen3-0/+201
When GDB is stopped at a ret instruction and no debug information is available for unwinding, GDB defaults to the amd64 epilogue unwinder, to be able to generate a decent backtrace. However, when calculating the frame id, the epilogue unwinder generates information as if the return instruction was the whole frame. This was an issue especially when attempting to reverse debug, as GDB would place a step_resume_breakpoint from the epilogue of a function if we were to attempt to skip that function, and this breakpoint should ideally have the current function's frame_id to avoid other problems such as PR record/16678. This commit changes the frame_id calculation for the amd64 epilogue, so that it is always the same as the dwarf2 unwinder's frame_id. It also adds a test to confirm that the frame_id will be the same, regardless of using the epilogue unwinder or not, thanks to Andrew Burgess. Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
2022-10-21GDB/Python: Make `None' stand for `unlimited' in setting integer parametersMaciej W. Rozycki1-6/+15
Similarly to booleans and following the fix for PR python/29217 make `gdb.parameter' accept `None' for `unlimited' with parameters of the PARAM_UINTEGER, PARAM_INTEGER, and PARAM_ZUINTEGER_UNLIMITED types, as `None' is already returned by parameters of the two former types, so one might expect to be able to feed it back. It also makes it possible to avoid the need to know what the internal integer representation is for the special setting of `unlimited'. Expand the testsuite accordingly. Approved-By: Simon Marchi <simon.marchi@polymtl.ca>
2022-10-21GDB/testsuite: Expand Python integer parameter coverage across all typesMaciej W. Rozycki1-16/+181
Also verify PARAM_UINTEGER, PARAM_INTEGER, and PARAM_ZINTEGER parameter types, in addition to PARAM_ZUINTEGER and PARAM_ZUINTEGER_UNLIMITED already covered, and verify a choice of existing GDB parameters. Add verification for reading parameters via `<parameter>.value' in addition to `gdb.parameter('<parameter>')' as this covers different code paths. Approved-By: Simon Marchi <simon.marchi@polymtl.ca>
2022-10-21GDB/Guile: Don't assert that an integer value is booleanMaciej W. Rozycki1-0/+176
Do not assert that a value intended for an integer parameter, of either the PARAM_UINTEGER or the PARAM_ZUINTEGER_UNLIMITED type, is boolean, causing error messages such as: ERROR: In procedure make-parameter: ERROR: In procedure gdbscm_make_parameter: Wrong type argument in position 15 (expecting integer or #:unlimited): 3 Error while executing Scheme code. when initialization with a number is attempted. Instead assert that it is integer. Keep matching `#:unlimited' keyword as an alternative. Add suitable test cases. Approved-By: Simon Marchi <simon.marchi@polymtl.ca>
2022-10-21[gdb/testsuite] Silence compilation fail in gdb.base/rtld-step.expTom de Vries1-0/+8
With gcc 7.5.0 and test-case gdb.base/rtld-step.exp, I run into: ... gdb compile failed, gcc: error: unrecognized command line option \ '-static-pie'; did you mean '-static'? ... Silence this by checking in the test-case that -static-pie is supported, and emitting instead: ... UNTESTED: gdb.base/rtld-step.exp: \ failed to compile (-static-pie not supported or static libc missing) ... Tested on x86_64-linux, with: - gcc 7.5.0: UNTESTED - gcc 12.2.1 with static glibc not installed: UNTESTED - gcc 12.2.1 with static glibc installed: PASS
2022-10-20[gdb/testsuite] Fix gdb.debuginfod/fetch_src_and_symbols.exp with check-read1Tom de Vries1-3/+6
With test-case gdb.debuginfod/fetch_src_and_symbols.exp and check-read1, I run into: ... (gdb) FAIL: gdb.debuginfod/fetch_src_and_symbols.exp: local_url: \ file fetch_src_and_symbols (got interactive prompt) ... The problem is that this output: ... Enable debuginfod for this session? (y or [n]) y^M ... is matched using regexp "Enable debuginfod?.*" with matches only the first two words of the output, after which an implicit clause in gdb_test_multiple triggers on the second part containing the interactive prompt. Fix this by included the interactive prompt in the regexp. Tested on x86_64-linux.
2022-10-20[gdb/testsuite] Fix gdb.mi/mi-disassemble.exp with check-read1Tom de Vries2-2/+2
With test-case gdb.mi/mi-disassemble.exp and check-read1 I run into: ... FAIL: gdb.mi/mi-disassemble.exp: disassemble /b main FAIL: gdb.mi/mi-disassemble.exp: get valueof "*((unsigned char *) 0x400549)" ... The problem for both FAILs is that the output is parsed using gdb_test_multiple, which has implicit clauses using $gdb_prompt, which can match before the explicit clauses using $mi_gdb_prompt. Fix this by passing -prompt "$mi_gdb_prompt$" to gdb_test_multiple. Tested on x86-64-linux.
2022-10-19Test stepping within a runtime loader / dynamic linkerKevin Buettner3-0/+227
See the remarks in rtld-step.exp for a description of what this test is about. This test case has been tested using gcc on the following x86-64 Linux distributions/releases: Fedora 28 Fedora 32 Fedora 33 Fedora 34 Fedora 35 Fedora 36 Fedora 37 rawhide (f38) RHEL 9.1 Ubuntu 22.04.1 LTS It's also been tested (and found to be working) with RUNTESTFLAGS="CC_FOR_TARGET=clang" on all of the above expect for Fedora 28. The (old) version of clang available on F28 did not accept the -static-pie option. I also tried to make this test work on FreeBSD 13.1. While I think I made significant progress, I was ultimately stymied by this message which occurs when attempting to run the main program which has been set to use the fake/pretend RTLD as the ELF interpreter: ELF interpreter /path/to/rtld-step-rtld not found, error 22 I have left one of the flags (-static) in place which I believe to be needed for FreeBSD (though since I never got it to work, I don't know for sure.) I've also left some declarations needed for FreeBSD in rtld-step-rtld.c. They're currently disabled via a #if 0; you'll need to enable them if you want to try to make it work on FreeBSD.
2022-10-19gdb/testsuite: avoid temporary file in gdb/testsuite (unittest.exp)Andrew Burgess2-19/+137
I spotted that the gdb.gdb/unittest.exp script causes a temporary file inserters_extractors-2.txt to be created in build/gdb/testsuite/ instead of in build/gdb/testsuite/output/gdb.gdb/unittest/. This is because some of the 'maint selftest' tests create temporary files in GDB's current directory, specifically, the two source files: gdb/unittests/basic_string_view/inserters/wchar_t/2.cc gdb/unittests/basic_string_view/inserters/char/2.cc both create a temporary file called inserters_extractors-2.txt, though we only run the second of these as part of GDB's selftests. I initially proposed just using GDB's 'cd' command in unittest.exp to switch to the test output directory before running the selftests, however, Pedro pointed out that there was a risk here that, if GDB crashed during shutdown, the generated core file would be left in the test output directory rather than in the testsuite directory. As a result, our clever core file spotting logic would fail to spot the core file and alert the user. Instead, I propose this slightly more involved solution. I've added a new with_gdb_cwd directory proc, used like this: with_gdb_cwd $directory { # Tests here... } The new proc temporarily switches to $directory and then runs the tests within the block. After running the tests the previous current working directory is restored. Additionally, after switching back to the previous cwd, we check that GDB is still responsive. This means that if GDB crashed immediately prior to restoring the previous directory, and left the core file in the wrong place, then the responsiveness check will fail, and a FAIL will be emitted, this should be enough to alert the user that something has gone wrong. With this commit in place the unittest.exp script now leaves its temporary file in the test output directory.
2022-10-19gdb/testsuite: avoid creating files in gdb/testsuite directoryAndrew Burgess1-1/+1
I spotted that the test gdb.dwarf2/dw2-using-debug-str.exp was creating an output file called debug_str_section in the root build/gdb/testsuite directory instead of using the build/gdb/testsuite/output/gdb.dwarf2/dw2-using-debug-str/ directory. This appears to be caused by a missing '$' character. We setup a variable debug_str_section which contains a path within the output directory, but then when we build the objcopy command we use 'debug_str_section' without a '$' prefix, as a result, we create the debug_str_section file. This commit adds the missing '$', the file is now created in the output directory.
2022-10-19[gdb/testsuite] Fix ERROR in gdb.python/py-breakpoint.expTom de Vries1-0/+2
With test-case gdb.python/py-breakpoint.exp I run into: ... (gdb) ERROR: tcl error sourcing gdb.python/py-breakpoint.exp. ERROR: can't read "skip_hw_watchpoint_tests_p": no such variable while executing "if {$skip_hw_watchpoint_tests_p} { gdb_test_no_output "set can-use-hw-watchpoints 0" "" }" ... Fix this by adding the missing "global skip_hw_watchpoint_tests_p" in two procs. Tested on x86_64-linux.
2022-10-18Update tests to use skip_hw_watchpoint_tests to test for HW watchpoint support.Carl Love16-23/+143
The hardware watchpoint check has been updated in a couple of recent patches. This patch updates the hardware watchpoint test in the remaining gdb tests. The issue is the PowerPC processors support hardware watchpoints with the exception of Power 9. The hardware watchpoint support is disabled on Power 9. The test skip_hw_watchpoint_tests must be used to correctly determine if the PowerPC processor supports hardware watchpoints. This patch fixes 6 test failures in test gdb.threads/watchpoint-fork.exp. Test gdb.base/watch-vfork.exp runs with can-use-hw-watchpoints set to true and false. When the test is run with can-use-hw-watchpoints set to true, gdb just falls back to using software watchpoints. The patch reduces the number of expected passes by 2 since because it now only runs once with can-use-hw-watchpoints set to false. Test gdb.mi/mi-watch.exp runs the test with argument hw and sw. If the argument is hw and hardware watchpoints are not supported the test exits. The number of expected passes is cut in half with the patch as it now only runs the test using software breakpoints. Previously the pass to use hardware watchpoints was not skipped and the test actually ran using software watchpoints. The following tests run the same with and without the patch. The tests are supposed to execute the gdb command "set can-use-hw-watchpoints 0" if the processor does not support hardware bwatchpoints. However the command was not being executed and gdb was falling back to using software watchpoints since the Power 9 watchpoint resource check fails. With the patch, the tests now execute the command and the test runs using software watchpoints as it did previously. The tests are: gdb.base/commands.exp gdb.base/cond-eval-mode.exp gdb.base/display.exp gdb.base/gdb11531.exp gdb.base/recurse.exp gdb.base/value-double-free.exp gdb.base/watch-bitfields.exp gdb.base/watch-cond-infcall.exp gdb.base/watch-cond.exp gdb.base/watchpoint-solib.exp gdb.base/watchpoints.exp The following two tests are not supported on the Power 9 system used to test the changes. The patch does not change the tests results for these tests: gdb.python/py-breakpoint.exp gdb.mi/mi-watch-nonstop.exp