aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
AgeCommit message (Collapse)AuthorFilesLines
2020-05-16Fix gdb.multi/multi-re-run.exp with native-gdbserverPedro Alves2-0/+12
The new exec-file-mismatch feature reveals that when running gdb.multi/multi-re-run.exp against --target_board=native-gdbserver, we've been starting gdbserver with the wrong program: (gdb) spawn /home/pedro/brno/pedro/gdb/binutils-gdb/build/gdb/testsuite/../../gdbserver/gdbserver --once localhost:2347 /home/pedro/brno/pedro/gdb/binutils-gdb/build/gdb/te stsuite/outputs/gdb.multi/multi-re-run/multi-re-run-2 Process /home/pedro/brno/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.multi/multi-re-run/multi-re-run-2 created; pid = 6280 Listening on port 2347 target remote localhost:2347 Remote debugging using localhost:2347 warning: Mismatch between current exec-file /home/pedro/brno/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.multi/multi-re-run/multi-re-run-1 and automatically determined exec-file /home/pedro/brno/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.multi/multi-re-run/multi-re-run-2 exec-file-mismatch handling is currently "ask" Load new symbol table from "/home/pedro/brno/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.multi/multi-re-run/multi-re-run-2"? (y or n) Quit (gdb) FAIL: gdb.multi/multi-re-run.exp: re_run_inf=1: iter=1: running to all_started in runto The problem is that gdb_reload uses the last loaded file as binary to spawn, but we load the program for inferior 2 and then switch to inferior 1 and run it, so the last loaded file is the program for inferior 2. Fix this by tweaking last_loaded_file. gdb/testsuite/ChangeLog: 2020-05-16 Pedro Alves <palves@redhat.com> * gdb.multi/multi-re-run.exp (test_re_run): Switch LAST_LOADED_FILE accordingly.
2020-05-15Ensure class_alias is only used for user-defined aliases.Philippe Waroquiers2-1/+8
This commit finally does the (small) change that started this patch series. It ensures that the class_alias is only used for user-defined aliases. So, the few GDB pre-defined aliases that were using the 'class_alias' class are now using a real help class, typically the class of the aliased command. gdb/ChangeLog 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * command.h (enum command_class): Improve comments, document that class_alias is for user-defined aliases, give the class name for each class, remove unused class_xdb. * cli/cli-decode.c (add_com_alias): Document THECLASS intended usage. * breakpoint.c (_initialize_breakpoint): Replace class_alias by a precise class. * infcmd.c (_initialize_infcmd): Likewise. * reverse.c (_initialize_reverse): Likewise. * stack.c (_initialize_stack): Likewise. * symfile.c (_initialize_symfile): Likewise. * tracepoint.c (_initialize_tracepoint): Likewise. gdb/testsuite/ChangeLog 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/alias.exp: Verify 'help aliases' shows user defined aliases.
2020-05-15Fix/improve 'apropos' outputPhilippe Waroquiers2-22/+35
Similarly to 'help CLASS', apropos possibly shows several times the same help (for the command and for each of its aliases). This patch changes 'apropos' so that the help for a command and all its aliases is shown once. So, apropos_cmd now skips all aliases/abbreviations, as these are printed as part of the help of the aliased command. When 'apropos' prints the help of a command, function 'help_cmd' now unconditionally print the command name and its possible aliases (as we must indicate to the user the command/aliases for which the help is printed). When 'help somecommand' prints the help of a command, if the command is not aliased, the command name is not printed (to avoid a useless first line), but if it has aliases, then the command name and all its aliases are now printed. In addition to provide to the user the choice of the best way to type a command, it also avoids the strange behaviour that the output of 'help somealias' does not mention somealias. gdb/ChangeLog 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli/cli-decode.c (apropos_cmd): Produce output for aliases when their aliased command is traversed. (help_cmd): Add fput_command_names_styled call to output command name and aliases when command has an alias. gdb/testsuite/ChangeLog 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/help.exp: Test apropos and help for commands having aliases. Fixed comments not starting with an upper-case letter or not finishing with a dot.
2020-05-15Fix/improve 'help CLASS' outputPhilippe Waroquiers2-1/+5
Currently, help CLASS possibly shows several times the same help, as it shows it once for the command, and once for each alias. The final objective of this patch series is to have class_alias used only for user defined aliases, not anymore for aliases predefined by GDB. The command 'help aliases' will then only show the user defined aliases. So, the idea is that GDB predefined aliases will be shown together with their aliased command. This commit changes 'help CLASS' so that a command is shown once in the output, with all its aliases. This ensures: * that the user has only to read once the same help text * and sees the command and all its aliases in a glance, a.o. allowing the user to choose the preferred way (e.g. the shortest one, or the most mnemonic one) to type the command. For example, the old output: (gdb) help stack ... List of commands: backtrace -- Print backtrace of all stack frames, or innermost COUNT frames. bt -- Print backtrace of all stack frames, or innermost COUNT frames. ... (note that 'where' is not shown in this output) becomes (gdb) help stack ... List of commands: backtrace, where, bt -- Print backtrace of all stack frames, or innermost COUNT frames. ... The output layout chosen is to have the command first, followed by all its aliases separated by a comma. Note that the command and alias names are title-styled. For sure, other layouts could be discussed, but this one is IMO readable and compact. The function 'help_cmd_list' can be simplified by removing the prefix argument, as the prefixname of a command can now be retrieved in the GDB command tree structure. This also fixes the fact that 'help aliases' wrongly shows a long list of (non-alias) when defining an alias for a prefix command. For example, after: (gdb) alias montre = show then (gdb) help aliases shows hundreds of sub-commands starting with the non aliased command, such as: montre -- Generic command for showing things about the debugger. show ada -- Generic command for showing Ada-specific settings. show ada print-signatures -- Show whether the output of formal ... .... 'help_cmd_list' is also made static, as it is only used inside cli-decode.c. Note that the 'help CLASS' is somewhat broken, in the sense that it sometimes shows too many commands (commands not belonging to CLASS) and sometimes shows not enough commands (not showing some commands belonging to CLASS). For example, 'help breakpoints' shows the command 'disable pretty-printer' and 'disable unwinder', not related to breakpoints. On the other end, 'help stack' does not show 'disable unwinder' while 'disable unwinder' is defined in unwinders.py as belonging to class_stack. Fixing the missing commands is easy to do, but fixing the excess commands is not straightforward, as many subcommands have a class 'no_class' or 'all_class'. Possibly, some of this might be improved/fixed in another patch series. With this patch series, the 'abbrev flag' has as only remaining purpose to avoid having the abbreviation alias appearing in the completion list, so change 'help alias' accordingly. gdb/ChangeLog 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli/cli-decode.h (help_cmd_list): Remove declaration. * cli/cli-decode.c (help_cmd_list): Declare as static, remove prefix argument, use bool for recurse arg, rework to show the aliases of a command together with the command. (fput_command_name_styled, fput_command_names_styled): New functions. (print_help_for_command): Remove prefix arg, use bool for recurse arg, use fput_command_name_styled. (help_list, help_all): Update callers to remove prefix arg and use bool recurse. * cli/cli-cmds.c (_initialize_cli_cmds): Update alias_command doc. gdb/testsuite/ChangeLog 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/alias.exp: Update help output check.
2020-05-15Fix inconsistent output of prefix and bugs in 'show' commandPhilippe Waroquiers2-2/+6
cmd_show_list function implements the 'show' command. cmd_show_list output is inconsistent: it sometimes shows a prefix and sometimes does not. For example, in the below, you see that there is a prefix before each value, except for 'enabled'. (gdb) show style style address background: The "address" style background color is: none style address foreground: The "address" style foreground color is: blue style address intensity: The "address" style display intensity is: normal enabled: CLI output styling is enabled. style filename background: The "filename" style background color is: none ... There are other inconsistencies or bugs e.g. in the below we see twice insn-number-max, once with a prefix and once without prefix : last line, just before the value of instruction-history-size which is itself without prefix. (gdb) show record record btrace bts buffer-size: The record/replay bts buffer size is 65536. record btrace cpu: btrace cpu is 'auto'. record btrace pt buffer-size: The record/replay pt buffer size is 16384. record btrace replay-memory-access: Replay memory access is read-only. record full insn-number-max: Record/replay buffer limit is 200000. record full memory-query: Whether query if PREC cannot record memory change of next instruction is off. record full stop-at-limit: Whether record/replay stops when record/replay buffer becomes full is on. function-call-history-size: Number of functions to print in "record function-call-history" is 10. insn-number-max: instruction-history-size: Number of instructions to print in "record instruction-history" is 10. (gdb) Also, some values are output several times due to some aliases, so avoid outputting duplicated values by skipping all aliases. Now that the command structure has a correct 'back-pointer' from a command to its prefix command, we can simplify cmd_show_list by removing its prefix argument and at the same time fix the output inconsistencies and bugs. gdb/ChangeLog 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli/cli-setshow.h (cmd_show_list): Remove prefix argument. * cli/cli-decode.c (do_show_prefix_cmd): Likewise. * command.h (cmd_show_list): Likewise. * dwarf2/index-cache.c (show_index_cache_command): Likewise. * cli/cli-setshow.c (cmd_show_list): Use the prefix to produce the output. Skip aliases. gdb/testsuite/ChangeLog 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/default.exp: Update output following fixes.
2020-05-15Fix problem that alias can be defined or not depending on the order.Philippe Waroquiers2-0/+11
When an alias name starts with the name of another alias, GDB was accepting to define the aliases in one order (short first, long after), but refused it the other way around. So, fix the logic to recognise an already existing alias by using lookup_cmd_composition. Also, this revealed a bug in lookup_cmd_composition: when the searched command is a prefix command, lookup_cmd_composition was not returning the fact that a command was found even if the TEXT to parse was fully consumed. gdb/ChangeLog YYYY-MM-DD Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli/cli-cmds.c (alias_command): Check for an existing alias using lookup_cmd_composition, as valid_command_p is too strict and forbids aliases that are the prefix of an existing alias or command. * cli/cli-decode.c (lookup_cmd_composition): Ensure a prefix command is properly recognised as a valid command. gdb/testsuite/ChangeLog 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/alias.exp: Test aliases starting with a prefix of another alias.
2020-05-15Fix "control reaches end of non-void function" errors in testsuiteGary Benson16-1/+39
When running the testsuite with clang, a number of testcases fail to build with the following errors: warning: control reaches end of non-void function [-Wreturn-type] warning: control may reach end of non-void function [-Wreturn-type] This prevents a number of testcases from executing. This commit fixes. gdb/testsuite/ChangeLog: * gdb.base/info-os.c (main): Add return statement. * gdb.base/info_minsym.c (minsym_fun): Likewise. * gdb.base/large-frame-2.c (func): Likewise. * gdb.base/pr10179-a.c (foo1, bar1): Likewise. * gdb.base/pr10179-b.c (foo2): Likewise. * gdb.base/valgrind-disp-step.c (foo): Likewise. * gdb.base/watch-cond.c (func): Likewise. * gdb.multi/goodbye.c (verylongfun): Likewise. * gdb.multi/hello.c (commonfun): Likewise. * gdb.python/py-finish-breakpoint.c (call_longjmp): Likewise. * gdb.threads/fork-plus-threads.c (thread_func): Likewise. * gdb.threads/forking-threads-plus-breakpoint.c (thread_forks): Likewise. * gdb.threads/hand-call-new-thread.c (foo): Likewise. * gdb.threads/interrupt-while-step-over.c (child_function): Likewise. * gdb.trace/actions-changed.c (end): Likewise.
2020-05-15Don't silently skip tests if OpenCL is unsupportedGary Benson6-0/+13
A number of tests silently exit if OpenCL support is not detected. This commit fixes. gdb/testsuite/ChangeLog: * gdb.opencl/callfuncs.exp: Report when test skipped. * gdb.opencl/convs_casts.exp: Likewise. * gdb.opencl/datatypes.exp: Likewise. * gdb.opencl/operators.exp: Likewise. * gdb.opencl/vec_comps.exp: Likewise.
2020-05-15[gdb/testsuite] Rename *.exp.in to *.exp.tclTom de Vries33-24/+67
Say we have some common tcl code that we want to include in test-cases t1.exp and t1.exp. We could put the common code into a file common.exp alongside the test-cases, but that will make dejagnu treat that file as another test-case. To prevent this, we use a suffix, currently .in, in other words we put the common code in a file common.exp.in. The .in suffix however is also used in autoconf, which might cause confusion. Change the suffix from .in to .tcl. gdb/testsuite/ChangeLog: 2020-05-15 Tom de Vries <tdevries@suse.de> * gdb.base/align.exp.in: Rename to ... * gdb.base/align.exp.tcl: ... this. * gdb.base/align-c++.exp: Update. * gdb.base/align-c.exp: Update. * gdb.base/all-architectures.exp.in: Rename to ... * gdb.base/all-architectures.exp: ... this. * gdb.base/all-architectures-0.exp: Update. * gdb.base/all-architectures-1.exp: Update. * gdb.base/all-architectures-2.exp: Update. * gdb.base/all-architectures-3.exp: Update. * gdb.base/all-architectures-4.exp: Update. * gdb.base/all-architectures-5.exp: Update. * gdb.base/all-architectures-6.exp: Update. * gdb.base/all-architectures-7.exp: Update. * gdb.base/infcall-nested-structs.exp.in: Rename to ... * gdb.base/infcall-nested-structs.exp.tcl: ... this. * gdb.base/infcall-nested-structs-c++.exp: Update. * gdb.base/infcall-nested-structs-c.exp: Update. * gdb.base/info-types.exp.in: Rename to ... * gdb.base/info-types.exp.tcl: ... this. * gdb.base/info-types-c++.exp: Update. * gdb.base/info-types-c.exp: Update. * gdb.base/max-depth.exp.in: Rename to ... * gdb.base/max-depth.exp.tcl: ... this. * gdb.base/max-depth-c++.exp: Update. * gdb.base/max-depth-c.exp: Update. * gdb.cp/cpexprs.exp.in: Rename to ... * gdb.cp/cpexprs.exp.tcl: ... this. * gdb.cp/cpexprs-debug-types.exp: Update. * gdb.cp/cpexprs.exp: Update. * gdb.cp/infcall-nodebug.exp.in: Rename to ... * gdb.cp/infcall-nodebug.exp.tcl: ... this. * gdb.cp/infcall-nodebug-c++-d0.exp: Update. * gdb.cp/infcall-nodebug-c++-d1.exp: Update. * gdb.cp/infcall-nodebug-c-d0.exp: Update. * gdb.cp/infcall-nodebug-c-d1.exp: Update. * gdb.dwarf2/clang-debug-names.exp.in: Rename to ... * gdb.dwarf2/clang-debug-names.exp.tcl: ... this. * gdb.dwarf2/clang-debug-names-2.exp: Update. * gdb.dwarf2/clang-debug-names.exp: Update.
2020-05-15gdb/testsuite: Revert commit 843f4d93576eef02139f7b1b3fa1cea7b0f286f1Andrew Burgess2-20/+5
Revert this commit: commit 843f4d93576eef02139f7b1b3fa1cea7b0f286f1 Date: Tue May 12 17:38:17 2020 +0100 gdb/testsuite: Disable path and duplicate checks when parallel testing Now that this commit has landed: commit c959562d9ba0b2eaf240c601b2c2fd49c42c1f2f Date: Fri May 15 11:23:59 2020 +0100 contrib: Update dg-extract-results.* from gcc We can now make use of the mechanism for detecting paths in test names and duplicate test names, even when we run tests in parallel. gdb/testsuite/ChangeLog: * lib/check-test-names.exp: Remove code that prevents this file loading when tests are run in parallel.
2020-05-15Fix gdb.multi/multi-kill.expPedro Alves2-5/+12
The previous patch misssed declaring the 'testpid' array as namespace variable. While it at, might as well go back to having start_inferior refer to the "global" testpid, using "variable" too. gdb/testsuite/ChangeLog: 2020-05-15 Pedro Alves <palves@redhat.com> * gdb.multi/multi-kill.exp (start_inferior): Remove 'testpid' parameter. Refer to namespace variable directly. (testpid): Declare as namespace variable.
2020-05-15Fix global variable collision in gdb.multi/multi-kill.expPedro Alves2-5/+22
The new gdb.multi/multi-kill.exp testcase added an 'testpid' array, which may conflict with other global 'testpid' variables used by other testcases, resulting in: ... ERROR: tcl error sourcing /data/gdb_versions/devel/src/gdb/testsuite/gdb.multi/multi-kill.exp. ERROR: can't set "testpid(1)": variable isn't array while executing "set testpid($num) [get_integer_valueof "pid" -1]" or $ runtest gdb.threads/check-libthread-db.exp gdb.multi/multi-kill.exp ... Running /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.multi/multi-kill.exp ... Running /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.threads/check-libthread-db.exp ... ERROR: tcl error sourcing /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.threads/check-libthread-db.exp. ERROR: can't set "testpid": variable is array while executing "set testpid [spawn_id_get_pid $test_spawn_id]" ("uplevel" body line 8) Fix this with a namespace, like gdb.linespec/explicit.exp does. gdb/testsuite/ChangeLog: 2020-05-15 Pedro Alves <palves@redhat.com> * gdb.multi/multi-kill.exp: Wrap in namespace. (start_inferior): Add TESTPID parameter. Use it instead of the testpid global. (top level): Define empty TESTPID array, and pass it down to start_inferior.
2020-05-14[gdb/testsuite] Fix gdb.fortran/nested-funcs-2.exp with gdbserverTom de Vries2-1/+6
When running test-case gdb.fortran/nested-funcs-2.exp with target board native-gdbserver, we have: ... (gdb) call contains_keyword::subroutine_to_call()^M (gdb) FAIL: gdb.fortran/nested-funcs-2.exp: src_prefix=0: nest_prefix=1: \ call contains_keyword::subroutine_to_call() ... This is caused by the fact that we're trying to match inferior output using gdb_test. Fix this by using gdb_test_stdio instead. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-14 Tom de Vries <tdevries@suse.de> * gdb.fortran/nested-funcs-2.exp: Use gdb_test_stdio to test inferior output.
2020-05-14[gdb/testsuite] Split up multi-exec test-casesTom de Vries18-105/+307
With test-case gdb.base/align.exp and target board native-gdbserver, we run into: ... (gdb) file outputs/gdb.base/align/c/align^M Reading symbols from outputs/gdb.base/align/c/align...^M (gdb) delete breakpoints^M (gdb) info breakpoints^M No breakpoints or watchpoints.^M (gdb) break main^M Breakpoint 1 at 0x4004ab: file outputs/gdb.base/align/c/align.c, line 838.^M (gdb) kill^M The program is not being run.^M (gdb) spawn gdbserver --once localhost:2592 outputs/gdb.base/align/align^M Process outputs/gdb.base/align/align created; pid = 6946^M Listening on port 2592^M target remote localhost:2592^M Remote debugging using localhost:2592^M warning: Mismatch between current exec-file outputs/gdb.base/align/c/align^M and automatically determined exec-file outputs/gdb.base/align/align^M exec-file-mismatch handling is currently "ask"^M Load new symbol table from "outputs/gdb.base/align/align"? (y or n) Quit^M (gdb) ERROR: test suppressed ... Fix this by turning this and similar test-cases into regular, single executable test-cases. This fixes 100+ FAILs with target board native-gdbserver. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-14 Tom de Vries <tdevries@suse.de> * gdb.base/align.exp: Split into ... * gdb.base/align.exp.in: ... * gdb.base/align-c++.exp: ... * gdb.base/align-c.exp: ... these. * gdb.base/infcall-nested-structs.exp: Split into ... * gdb.base/infcall-nested-structs.exp.in: ... * gdb.base/infcall-nested-structs-c++.exp: ... * gdb.base/infcall-nested-structs-c.exp: ... these. * gdb.base/info-types.exp: Split into ... * gdb.base/info-types.exp.in: ... * gdb.base/info-types-c++.exp: ... * gdb.base/info-types-c.exp: ... these. * gdb.base/max-depth.exp: Split into ... * gdb.base/max-depth.exp.in: ... * gdb.base/max-depth-c++.exp: ... * gdb.base/max-depth-c.exp: ... these. * gdb.cp/infcall-nodebug.exp: Split into ... * gdb.cp/infcall-nodebug.exp.in: ... * gdb.cp/infcall-nodebug-c++-d0.exp: ... * gdb.cp/infcall-nodebug-c++-d1.exp: ... * gdb.cp/infcall-nodebug-c-d0.exp: ... * gdb.cp/infcall-nodebug-c-d1.exp: ... these.
2020-05-14gdb/infrun: handle already-exited threads when attempting to stopTankut Baris Aktemur5-0/+333
In stop_all_threads, GDB sends signals to other threads in an attempt to stop them. While in a typical scenario the expected wait status is TARGET_WAITKIND_STOPPED, it is possible that the thread GDB attempted to stop has already terminated. If so, a waitstatus other than TARGET_WAITKIND_STOPPED would be received. Handle this case appropriately. If a wait status that denotes thread termination is ignored, GDB goes into an infinite loop in stop_all_threads. E.g.: $ gdb ./a.out (gdb) start ... (gdb) add-inferior -exec ./a.out ... (gdb) inferior 2 ... (gdb) start ... (gdb) set schedule-multiple on (gdb) set debug infrun 2 (gdb) continue Continuing. infrun: clear_proceed_status_thread (process 10449) infrun: clear_proceed_status_thread (process 10453) infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT) infrun: proceed: resuming process 10449 infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 10449] at 0x55555555514e infrun: infrun_async(1) infrun: prepare_to_wait infrun: proceed: resuming process 10453 infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 10453] at 0x55555555514e infrun: prepare_to_wait infrun: Found 2 inferiors, starting at #0 infrun: target_wait (-1.0.0, status) = infrun: 10449.10449.0 [process 10449], infrun: status->kind = exited, status = 0 infrun: handle_inferior_event status->kind = exited, status = 0 [Inferior 1 (process 10449) exited normally] infrun: stop_waiting infrun: stop_all_threads infrun: stop_all_threads, pass=0, iterations=0 infrun: process 10453 executing, need stop infrun: target_wait (-1.0.0, status) = infrun: 10453.10453.0 [process 10453], infrun: status->kind = exited, status = 0 infrun: stop_all_threads status->kind = exited, status = 0 process 10453 infrun: process 10453 executing, already stopping infrun: target_wait (-1.0.0, status) = infrun: -1.0.0 [process -1], infrun: status->kind = no-resumed infrun: infrun_async(0) infrun: stop_all_threads status->kind = no-resumed process -1 infrun: process 10453 executing, already stopping infrun: stop_all_threads status->kind = no-resumed process -1 infrun: process 10453 executing, already stopping infrun: stop_all_threads status->kind = no-resumed process -1 infrun: process 10453 executing, already stopping infrun: stop_all_threads status->kind = no-resumed process -1 infrun: process 10453 executing, already stopping infrun: stop_all_threads status->kind = no-resumed process -1 infrun: process 10453 executing, already stopping infrun: stop_all_threads status->kind = no-resumed process -1 infrun: process 10453 executing, already stopping infrun: stop_all_threads status->kind = no-resumed process -1 infrun: process 10453 executing, already stopping infrun: stop_all_threads status->kind = no-resumed process -1 infrun: process 10453 executing, already stopping infrun: stop_all_threads status->kind = no-resumed process -1 infrun: process 10453 executing, already stopping infrun: stop_all_threads status->kind = no-resumed process -1 infrun: process 10453 executing, already stopping ... And this polling goes on forever. This patch prevents the infinite looping behavior. For the same scenario above, we obtain the following behavior: ... (gdb) continue Continuing. infrun: clear_proceed_status_thread (process 31229) infrun: clear_proceed_status_thread (process 31233) infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT) infrun: proceed: resuming process 31229 infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 31229] at 0x55555555514e infrun: infrun_async(1) infrun: prepare_to_wait infrun: proceed: resuming process 31233 infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 31233] at 0x55555555514e infrun: prepare_to_wait infrun: Found 2 inferiors, starting at #0 infrun: target_wait (-1.0.0, status) = infrun: 31229.31229.0 [process 31229], infrun: status->kind = exited, status = 0 infrun: handle_inferior_event status->kind = exited, status = 0 [Inferior 1 (process 31229) exited normally] infrun: stop_waiting infrun: stop_all_threads infrun: stop_all_threads, pass=0, iterations=0 infrun: process 31233 executing, need stop infrun: target_wait (-1.0.0, status) = infrun: 31233.31233.0 [process 31233], infrun: status->kind = exited, status = 0 infrun: stop_all_threads status->kind = exited, status = 0 process 31233 infrun: saving status status->kind = exited, status = 0 for 31233.31233.0 infrun: process 31233 not executing infrun: stop_all_threads, pass=1, iterations=1 infrun: process 31233 not executing infrun: stop_all_threads done (gdb) The exit event from Inferior 1 is received and shown to the user. The exit event from Inferior 2 is not displayed, but kept pending. (gdb) info inferiors Num Description Connection Executable * 1 <null> a.out 2 process 31233 1 (native) a.out (gdb) inferior 2 [Switching to inferior 2 [process 31233] (a.out)] [Switching to thread 2.1 (process 31233)] Couldn't get registers: No such process. (gdb) continue Continuing. infrun: clear_proceed_status_thread (process 31233) infrun: clear_proceed_status_thread: thread process 31233 has pending wait status status->kind = exited, status = 0 (currently_stepping=0). infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT) infrun: proceed: resuming process 31233 infrun: resume: thread process 31233 has pending wait status status->kind = exited, status = 0 (currently_stepping=0). infrun: prepare_to_wait infrun: Using pending wait status status->kind = exited, status = 0 for process 31233. infrun: target_wait (-1.0.0, status) = infrun: 31233.31233.0 [process 31233], infrun: status->kind = exited, status = 0 infrun: handle_inferior_event status->kind = exited, status = 0 [Inferior 2 (process 31233) exited normally] infrun: stop_waiting (gdb) info inferiors Num Description Connection Executable 1 <null> a.out * 2 <null> a.out (gdb) When a process exits and we leave the process exit event pending, we need to make sure that at least one thread is left listed in the inferior's thread list. This is necessary in order to make sure we have a thread that we can later resume, so the process exit event can be collected/reported. When native debugging, the GNU/Linux back end already makes sure that the last LWP isn't deleted. When remote debugging against GNU/Linux GDBserver, the GNU/Linux GDBserver backend also makes sure that the last thread isn't deleted until the process exit event is reported to GDBserver core. However, between the backend reporting the process exit event to GDBserver core, and GDB consuming the event, GDB may update the thread list and find no thread left in the process. The process exit event will be pending somewhere in GDBserver's stop reply queue, or gdb/remote.c's queue, or whathever other event queue inbetween GDBserver and infrun.c's handle_inferior_event. This patch tweaks remote.c's target_update_thread_list implementation to avoid deleting the last thread of an inferior. In the past, this case of inferior-with-no-threads led to a special case at the bottom of handle_no_resumed, where it reads: /* Note however that we may find no resumed thread because the whole process exited meanwhile (thus updating the thread list results in an empty thread list). In this case we know we'll be getting a process exit event shortly. */ for (inferior *inf : all_non_exited_inferiors (ecs->target)) In current master, that code path is still reachable with the gdb.threads/continue-pending-after-query.exp testcase, when tested against GDBserver, with "maint set target-non-stop" forced "on". With this patch, the scenario that loop was concerned about is still properly handled, because the loop above it finds the process's last thread with "executing" set to true, and thus the handle_no_resumed function still returns true. Since GNU/Linux native and remote are the only targets that support non-stop mode, and with this patch, we always make sure the inferior has at least one thread, this patch also removes that "inferior with no threads" special case handling from handle_no_resumed. Since remote.c now has a special case where we treat a thread that has already exited as if it was still alive, we might need to tweak remote.c's target_thread_alive implementation to return true for that thread without querying the remote side (which would say "no, not alive"). After inspecting all the target_thread_alive calls in the codebase, it seems that only the one from prune_threads could result in that thread being accidentally deleted. There's only one call to prune_threads in GDB's common code, so this patch handles this by replacing the prune_threads call with a delete_exited_threads call. This seems like an improvement anyway, because we'll still be doing what the comment suggests we want to do, and, we avoid remote protocol traffic. Regression-tested on X86_64 Linux. gdb/ChangeLog: 2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Tom de Vries <tdevries@suse.de> Pedro Alves <palves@redhat.com> PR threads/25478 * infrun.c (stop_all_threads): Do NOT ignore TARGET_WAITKIND_NO_RESUMED, TARGET_WAITKIND_THREAD_EXITED, TARGET_WAITKIND_EXITED, TARGET_WAITKIND_SIGNALLED wait statuses received. (handle_no_resumed): Remove code handling a live inferior with no threads. * remote.c (has_single_non_exited_thread): New. (remote_target::update_thread_list): Do not delete a thread if is the last thread of the process. * thread.c (thread_select): Call delete_exited_threads instead of prune_threads. gdb/testsuite/ChangeLog: 2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Pedro Alves <palves@redhat.com> * gdb.multi/multi-exit.c: New file. * gdb.multi/multi-exit.exp: New file. * gdb.multi/multi-kill.c: New file. * gdb.multi/multi-kill.exp: New file.
2020-05-14gdb/infrun: enable/disable thread events of all targets in stop_all_threadsTankut Baris Aktemur3-2/+7
In stop_all_threads, the thread events of the current top target are enabled at the beginning of the function and then disabled at the end (at scope exit time). Because there may be multiple targets whose thread lists will be updated and whose threads are stopped, enable/disable thread events for all targets. This update caused a change in the annotations. In particular, a "frames-invalid" annotation is printed one more time due to switching the current inferior. Hence, gdb.base/annota1.exp and gdb.cp/annota2.exp tests are also updated. Regression-tested on X86_64 Linux using the default board file and the native-extended-gdbserver board file. gdb/ChangeLog: 2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * infrun.c (stop_all_threads): Enable/disable thread events of all targets. Move a debug message denoting the end of the function into the SCOPED_EXIT block. gdb/testsuite/ChangeLog: 2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * gdb.base/annota1.exp: Update the expected output. * gdb.cp/annota2.exp: Ditto.
2020-05-12gdb/testsuite: Disable path and duplicate checks when parallel testingAndrew Burgess2-0/+25
This commit disables the recently added checking for paths in test names, and for duplicate test names, when the gdb tests are run in parallel. When running the gdb tests in parallel the extra result count lines produced cause the dg-extract-results scripts to exit with an error. The patches for the dg-extract-results scripts have been posted to the gcc-patches mailing list here: https://gcc.gnu.org/pipermail/gcc-patches/2020-May/545562.html Once they are merged there then these changes can be merged over to binutils-gdb, and this commit can be reverted. gdb/testsuite/ChangeLog: * lib/check-test-names.exp: Disable when testing is being run in parallel.
2020-05-12[gdb/testsuite] Fix incorrect string concat in jit-elf.expTom de Vries2-2/+7
When running test-case gdb.base/jit-elf.exp with target board cc-with-gdb-index, we get: ... spawn -ignore SIGHUP gdb/contrib/cc-with-tweaks.sh -i gcc \ -fno-stack-protector src/gdb/testsuite/gdb.base/jit-elf-main.c \ -fdiagnostics-color=never -DATTACH=1 -DLOAD_ADDRESS=0x7000000 \ -DLOAD_INCREMENT=0x1000000 -g -lm \ -o outputs/gdb.base/jit-elf/jit-elf-main"-attach"^M outputs/gdb.base/jit-elf/.tmp/jit-elf-main-attach: \ No such file or directory.^M output is: outputs/gdb.base/jit-elf/.tmp/jit-elf-main-attach: \ No such file or directory.^M gdb compile failed, outputs/gdb.base/jit-elf/.tmp/jit-elf-main-attach: \ No such file or directory. UNTESTED: gdb.base/jit-elf.exp: failed to compile jit-elf-main"-attach" ... The problem is a string concat in jit-elf.exp: ... ${main_binfile}"-attach" ... which is intended to generate string 'jit-elf-main-attach' but instead generates string 'jit-elf-main"-attach"'. Fix this by using "${main_binfile}-attach" instead. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-12 Tom de Vries <tdevries@suse.de> * gdb.base/jit-elf.exp: Fix string concat.
2020-05-12[gdb/testsuite] Fix tcl error in jit-elf-helpers.expTom de Vries2-8/+17
When running test-case jit-elf.exp with target board cc-with-gdb-index, I run into: ... gdb compile failed, outputs/gdb.base/jit-elf/.tmp/jit-elf-main-attach: \ No such file or directory. ERROR: tcl error sourcing src/gdb/testsuite/gdb.base/jit-elf.exp. ERROR: can't read "main_basename": no such variable while executing "untested "failed to compile ${main_basename}.c"" (procedure "compile_jit_main" line 7) ... The problem is in compile_jit_main in lib/jit-elf-helpers.exp, where we try to emit an untested message using global variable main_basename.c. Fixing this by declaring the variable global results in duplicate test-names, because the same source file is compiled more than once. Instead, fix this by using the result name in the untested message. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-12 Tom de Vries <tdevries@suse.de> * lib/jit-elf-helpers.exp: Don't use undefined variables in untested messages.
2020-05-12[gdb/testsuite] Fix duplicate test-names in gdb.multiTom de Vries2-4/+14
In gdb.multi we have: ... DUPLICATE: gdb.multi/multi-term-settings.exp: \ inf1_how=run: inf2_how=run: info inferiors DUPLICATE: gdb.multi/multi-term-settings.exp: \ inf1_how=run: inf2_how=attach: info inferiors DUPLICATE: gdb.multi/multi-term-settings.exp: \ inf1_how=run: inf2_how=tty: info inferiors DUPLICATE: gdb.multi/multi-term-settings.exp: \ inf1_how=attach: inf2_how=run: info inferiors DUPLICATE: gdb.multi/multi-term-settings.exp: \ inf1_how=attach: inf2_how=attach: attach DUPLICATE: gdb.multi/multi-term-settings.exp: \ inf1_how=attach: inf2_how=attach: info inferiors DUPLICATE: gdb.multi/multi-term-settings.exp: \ inf1_how=attach: inf2_how=tty: info inferiors DUPLICATE: gdb.multi/multi-term-settings.exp: \ inf1_how=tty: inf2_how=run: info inferiors DUPLICATE: gdb.multi/multi-term-settings.exp: \ inf1_how=tty: inf2_how=attach: info inferiors DUPLICATE: gdb.multi/multi-term-settings.exp: \ inf1_how=tty: inf2_how=tty: tty TTY DUPLICATE: gdb.multi/multi-term-settings.exp: \ inf1_how=tty: inf2_how=tty: info inferiors ... Fix these using with_test_prefix. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-12 Tom de Vries <tdevries@suse.de> * gdb.multi/multi-term-settings.exp: Use with_test_prefix.
2020-05-12[gdb/testsuite] Fix duplicate test-names in gdb.adaTom de Vries4-16/+31
In gdb.ada we have these duplicate test-names: ... DUPLICATE: gdb.ada/catch_ex.exp: continuing to program completion DUPLICATE: gdb.ada/mi_catch_ex.exp: breakpoint at main DUPLICATE: gdb.ada/mi_catch_ex.exp: mi runto main DUPLICATE: gdb.ada/mi_catch_ex_hand.exp: breakpoint at main DUPLICATE: gdb.ada/mi_catch_ex_hand.exp: mi runto main ... Fix these using with_test_prefix. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-12 Tom de Vries <tdevries@suse.de> * gdb.ada/catch_ex.exp: Use with_test_prefix. * gdb.ada/mi_catch_ex.exp: Same. * gdb.ada/mi_catch_ex_hand.exp: Same.
2020-05-12[gdb/testsuite] Fix duplicate test-names in gdb.fortranTom de Vries2-7/+19
In gdb.fortran we have: ... DUPLICATE: gdb.fortran/complex.exp: whatis $ DUPLICATE: gdb.fortran/complex.exp: whatis $ DUPLICATE: gdb.fortran/complex.exp: whatis $ DUPLICATE: gdb.fortran/complex.exp: whatis $ ... Fix this by using with_test_prefix. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-12 Tom de Vries <tdevries@suse.de> * gdb.fortran/complex.exp: Use with_test_prefix.
2020-05-12[gdb/testsuite] Fix duplicate test-names in gdb.traceTom de Vries2-3/+7
In gdb.trace we have these duplicates: ... DUPLICATE: gdb.trace/passcount.exp: 4.20a: set all three passcounts to three DUPLICATE: gdb.trace/passcount.exp: 4.6: set passcount to zero DUPLICATE: gdb.trace/passcount.exp: 4.7: set passcount to large number (32767) ... Fix these by fixing the test-names. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-12 Tom de Vries <tdevries@suse.de> * gdb.trace/passcount.exp: Fix test-names.
2020-05-12[gdb/testsuite] Fix duplicate test-names in gdb.pascalTom de Vries2-2/+10
In gdb.pascal we have these duplicates: ... DUPLICATE: gdb.pascal/gdb11492.exp: next DUPLICATE: gdb.pascal/gdb11492.exp: print char_array ... Fix these by using with_test_prefix. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-12 Tom de Vries <tdevries@suse.de> * gdb.pascal/gdb11492.exp: Use with_test_prefix.
2020-05-12[gdb/testsuite] Fix duplicate test-names in gdb.{gdb,opt,xml}Tom de Vries4-7/+17
There are 3 test directories with one duplicate test-name: gdb.gdb, gdb.opt and gdb.xml. The duplicates are: ... DUPLICATE: gdb.gdb/complaints.exp: call complaint_internal ($cstr) DUPLICATE: gdb.opt/inline-locals.exp: info locals above bar 2 \ (PRMS: gdb/25695) DUPLICATE: gdb.xml/tdesc-regs.exp: ptype $extrareg ... Fix as appropriate. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-12 Tom de Vries <tdevries@suse.de> * gdb.gdb/complaints.exp: Use with_test_prefix. * gdb.xml/tdesc-regs.exp: Same. * gdb.opt/inline-locals.exp: Fix test name.
2020-05-12[gdb/testsuite] add jit-elf-util.h and run jit functionMihails Strasuns2-39/+133
Splits ELF related symbols into a separate jit-elf-util.h header and enhances it with a few more. Intention is to make adding new JIT tests possible without repeating most of the common boilerplate. As a test enhancement, jit-elf-main.c now calls the renamed function after registering the jit object and ensures it returns an expected result. gdb/testsuite/ChangeLog: 2020-02-18 Mihails Strasuns <mihails.strasuns@intel.com> * gdb.base/jit-elf-util.h: New header file. * gdb.base/jit-elf-main.c: Use jit-elf-util.h, add a call to the renamed JIT function to verify its result.
2020-05-12[gdb/testsuite] define jit function name via macroMihails Strasuns3-34/+8
Replaces previous approach with patching resulting ELF binary after loading - now that each test iteration works on a separately compiled binary it is not necessary anymore. Tests are still being ran without debug info to preserve original test functionality but this change opens up the possibility to enable debug info if needed too. gdb/testsuite/ChangeLog: 2020-03-27 Mihails Strasuns <mihails.strasuns@intel.com> * lib/jit-elf-helpers.exp: Supply -DFUNCTION_NAME macro definition when compiling jit-elf-solib.co. * gdb.base/jit-elf-main.c: Stop patching jit function name. * gdb.base/jit-elf-solib.c: Use FUNCTION_NAME macro value as a function name.
2020-05-12[gdb/testsuite] use -Ttext-segment for jit-elf testsMihails Strasuns2-15/+46
Removes the need to manually relocate loaded ELF binary by using a fixed constant as both mmap base address and as a requested first segment address supplied to the linker. In future will enable JIT tests with a valid DWARF debug info. Current tests still need to compile without a debug info though, because they do a function name modification. gdb/testsuite/ChangeLog: 2020-02-18 Mihails Strasuns <mihails.strasuns@intel.com> * lib/jit-elf-helpers.exp: Supply -Ttext-segment linker flag and define LOAD_ADDRESS/LOAD_INCREMENT macros for the compiled binaries. * gdb.base/jit-elf-main.c: Use LOAD_ADDRESS/LOAD_INCREMENT to calculate the mmap address.
2020-05-12[gdb/testsuite] add lib/jit-elf-helpers.expMihails Strasuns3-106/+93
New utility library to be used by jit-elf tests responsible for compiling binary artifacts. In the next commit the compilation process will become more complicated because of extra mandatory flag - keeping it in one place will make tests less fragile. gdb/testsuite/ChangeLog: 2020-02-18 Mihails Strasuns <mihails.strasuns@intel.com> * lib/jit-elf-helpers.exp: New file. * gdb.base/jit-elf.exp: Updated to use jit-elf-helpers.exp. * gdb.base/jit-elf-so.exp: Updated to use jit-elf-helpers.exp.
2020-05-12[gdb/testsuite] use args as lib list for jit-elf testsMihails Strasuns via Gdb-patches3-142/+252
Old usage: jit-elf-main lib.so 2 New usage: jit-elf-main lib.so.1 lib.so.2 Refactoring necessary to support running tests over multiple jit binaries rather than mapping the same binary muultiple times. gdb/testsuite/ChangeLog: 2020-02-18 Mihails Strasuns <mihails.strasuns@intel.com> * gdb.base/jit-elf-main.c: Read lib list from argc/argv. * gdb.base/jit-elf.exp: Compile N jit libraries and use the list. * gdb.base/jit-elf-so.exp: Ditto.
2020-05-12[gdb/testsuite] Fix duplicate test-names in gdb.dwarf2Tom de Vries6-22/+38
We currently have these duplicate test-names in gdb.dwarf2: ... $ grep ^DUPLICATE: gdb.sum DUPLICATE: gdb.dwarf2/comp-unit-lang.exp: show language DUPLICATE: gdb.dwarf2/data-loc.exp: get integer valueof "sizeof (int)" DUPLICATE: gdb.dwarf2/data-loc.exp: get integer valueof "sizeof (void *)" DUPLICATE: gdb.dwarf2/data-loc.exp: get integer valueof "sizeof (int)" DUPLICATE: gdb.dwarf2/data-loc.exp: get integer valueof "sizeof (int)" DUPLICATE: gdb.dwarf2/data-loc.exp: ptype foo.array_type DUPLICATE: gdb.dwarf2/varval.exp: get integer valueof "sizeof (int)" DUPLICATE: gdb.dwarf2/varval.exp: get integer valueof "sizeof (void *)" DUPLICATE: gdb.dwarf2/implref-struct.exp: print-object=off: \ set print object off DUPLICATE: gdb.dwarf2/implref-struct.exp: print-object=on: \ set print object on DUPLICATE: gdb.dwarf2/dw2-bad-parameter-type.exp: ptype f ... Fix as appropriate. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-12 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/comp-unit-lang.exp: Use with_test_prefix. * gdb.dwarf2/dw2-bad-parameter-type.exp: Same. * gdb.dwarf2/implref-struct.exp: Same. * gdb.dwarf2/varval.exp: Ensure get_sizeof is called once per type. * gdb.dwarf2/data-loc.exp: Same. Remove duplicate test.
2020-05-11gdb: change duplicate test name in gdb.base/jit-so.expSimon Marchi2-1/+6
When running gdb.base/jit-so.exp, we see duplicate test names: $ grep PASS testsuite/gdb.sum | sort | uniq -c | sort -n ... 2 PASS: gdb.base/jit-so.exp: one_jit_test-1: info function jit_function 2 PASS: gdb.base/jit-so.exp: one_jit_test-2: info function jit_function Give an explicit name to one test to avoid this. gdb/testsuite/ChangeLog: * gdb.base/jit-so.exp (one_jit_test): Change test name.
2020-05-11gdb/testsuite: Detect and warn about duplicate test namesAndrew Burgess2-6/+48
Building on the previous commit, this patch detects when two tests have the same test name and causes Dejagnu to print a new result type '# of duplicate test names' in the result summary. A line starting with 'DUPLICATE: ' is also added to the gdb.sum and gdb.log files. The DUPLICATE markers will be printed the second time a duplicate test name is seen, and every time after that. So you might see: PASS: gdb.base/sometest.exp: foo PASS: gdb.base/sometest.exp: bar PASS: gdb.base/sometest.exp: foo DUPLICATE: gdb.base/sometest.exp: foo PASS: gdb.base/sometest.exp: baz PASS: gdb.base/sometest.exp: foo DUPLICATE: gdb.base/sometest.exp: foo However, the results will report a duplicate count of 1, indicating that just one test name (foo) was duplicated. Currently if the tests are run in parallel mode the new result type is not merged into the combined summary file so users will need to run in non-parallel mode to check this result. Similarly, the 'DUPLICATE: ' markers will not be merged into the final gdb.sum file. A later commit will fix this. gdb/testsuite/ChangeLog: * lib/check-test-names.exp (all_test_names): New module variable. (counts): Add 'duplicates' field. (_check_duplicates): New procedure. (check): Also check for duplicates. (do_log_summary): Print duplicates count. (do_reset_vars): Reset counter for duplicate test names, and discard all know test names.
2020-05-11gdb/testsuite: Detect and warn if paths are used in test namesAndrew Burgess3-0/+148
A new library is introduced that hooks into the core of Dejagnu and detects when a test's name includes either the source or build paths. If any offending test names are detected then Dejagnu will print a new result type, '# of paths in test names'. Users should treat this result type just like other bad results types, and aim not to increase this number. As well as displaying the total number of offending tests as part of the final results, a new marker is included in both the gdb.log and gdb.sum files, this marker starts with 'PATH: ', so an offending test would be expected to appear like this: PASS: gdb.base/sometest.exp: Loaded /path/to/build/testsuite/foo.exe PATH: gdb.base/sometest.exp: Loaded /path/to/build/testsuite/foo.exe This should make it easier to track down offending tests. Currently for a local run on my machine, I don't see any offending test names, but it is possible that different targets, or different configurations, might currently be breaking the no paths rule. In order to get this working I have needed to wrap two core Dejagnu functions, log_summary, and reset_vars. Relying on core functions that are not part of any API is always going to be risky, given the relatively slow rate of Dejagnu change this is probably OK for now, and we can possibly upstream some changes to Dejagnu that would allow this functionality to be supported in a more official way later on. Currently if the tests are run in parallel mode the new result type is not merged into the combined summary file so users will need to run in non-parallel mode to check this result. Similarly, the 'PATH: ' markers will not be merged into the combined summary file. A later commit will fix this. gdb/testsuite/ChangeLog: * lib/gdb.exp: Include check-test-names.exp library. * lib/check-test-names.exp: New file.
2020-05-11[gdb/testsuite] Change kfail into xfail in gdb.ada/packed_tagged.expTom de Vries2-2/+6
Test-case gdb.ada/packed_tagged.exp contains a kfail: ... setup_kfail "gnat compiler bug" *-*-* ... Kfails are used to indicate problems in gdb, xfails are used to indicate problems in the environment. A bug in the gnat compiler is a problem in the environment rather than gdb. Fix this by changing the kfail into an xfail. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-11 Tom de Vries <tdevries@suse.de> * gdb.ada/packed_tagged.exp: Change kfail into xfail.
2020-05-11Fix gdb.ada/attr_ref_and_charlit.exp typoKeith Seitz2-1/+5
... introduced by my last commit: -gdb_test "print s'last" " = 3" + gdb_test "print s'last" " = 3Z gdb/testsuite/ChangeLog 2020-05-11 Keith Seitz <keiths@redhat.com> * gdb.ada/attr_ref_and_charlit.exp: Fix typo.
2020-05-11[gdb/testsuite] Fix gdb.cp/cpexprs-debug-types.exp inclusionTom de Vries4-748/+772
When running tests using RUNTESTFLAGS="cpexprs.exp cpexprs-debug-types.exp", we have: ... Running src/gdb/testsuite/gdb.cp/cpexprs-debug-types.exp ... Running src/gdb/testsuite/gdb.cp/cpexprs.exp ... ... In the first test-case, we have -fdebug-types-section as expected: ... Running src/gdb/testsuite/gdb.cp/cpexprs-debug-types.exp ... g++ -fno-stack-protector -fdiagnostics-color=never \ -fdebug-types-section \ -c -g \ -o outputs/gdb.cp/cpexprs-debug-types/cpexprs-debug-types0.o \ src/gdb/testsuite/gdb.cp/cpexprs.cc ... but in the second test-case, we have also have -fdebug-types-section: ... Running src/gdb/testsuite/gdb.cp/cpexprs.exp ... g++ -fno-stack-protector -fdiagnostics-color=never \ -fdebug-types-section \ -c -g -g \ -o outputs/gdb.cp/cpexprs/cpexprs0.o \ src/gdb/testsuite/gdb.cp/cpexprs.cc ... This is due to using a global variable flags, which is set in cpexprs-debug-types.exp and tested for existence in cpexprs.exp. Fix this by using a more robust inclusion mechanism, that is: - move the bulk of the test-case cpexprs.exp to cpexprs.exp.in, - include it from cpexprs.exp and cpexprs-debug-types.exp, and - set flags in both .exp files gdb/testsuite/ChangeLog: 2020-05-11 Tom de Vries <tdevries@suse.de> * gdb.cp/cpexprs.exp: Move everything except flags setting ... * gdb.cp/cpexprs.exp.in: .. here. * gdb.cp/cpexprs-debug-types.exp: Include cpexprs.exp.in instead of cpexprs.exp.
2020-05-11Clean-up gdb.ada test namesKeith Seitz16-47/+86
This patch fixes all duplicate and tail parentheses test names. These can really hinder automated test analysis such as used by the buildbot. Before: $ cat testsuite/gdb.sum | egrep "^(PASS|FAIL|XPASS|XFAIL|KPASS|KFAIL)" \ | sort | uniq -c | sort -n | grep -v " 1 " 2 PASS: gdb.ada/attr_ref_and_charlit.exp: print s'last 2 PASS: gdb.ada/bp_on_var.exp: set breakpoint pending off 2 PASS: gdb.ada/complete.exp: complete p pck.inne 2 PASS: gdb.ada/fun_overload_menu.exp: multiple matches for f (f (1, null)) 2 PASS: gdb.ada/type_coercion.exp: p q 2 PASS: gdb.ada/unc_arr_ptr_in_var_rec.exp: print My_P_Object.Ptr when no longer null 3 PASS: gdb.ada/fun_overload_menu.exp: 1 After: <empty> For parentheses, I've audited all occurrences of trailing parentheses. Most offenders are of the form: gdb_test "p func (..)" $expected_result I've either added a unique test name or simply removed the whitespace between the function name and the argument list. gdb/testsuite/ChangeLog 2020-05-11 Keith Seitz <keiths@redhat.com> * gdb.ada/arrayparam.exp: Resolve duplicate and tail parentheses test names. * gdb.ada/arrayptr.exp: Likewise. * gdb.ada/assign_arr.exp: Likewise. * gdb.ada/attr_ref_and_charlit.exp: Likewise. * gdb.ada/bp_on_var.exp: Likewise. * gdb.ada/call_pn.exp: Likewise. * gdb.ada/complete.exp: Likewise. * gdb.ada/fun_overload_menu.exp: Likewise. * gdb.ada/funcall_param.exp: Likewise. * gdb.ada/funcall_ref.exp: Likewise. * gdb.ada/packed_array_assign.exp: Likewise. * gdb.ada/same_component_name.exp: Likewise. * gdb.ada/type_coercion.exp: Likewise. * gdb.ada/unc_arr_ptr_in_var_rec.exp: Likewise. * gdb.ada/variant_record_packed_array.exp: Likewise.
2020-05-11[gdb/symtab] Fix incomplete CU list assert in .debug_namesTom de Vries6-107/+229
Consider the following two-file test-case: ... $ cat main.c extern int foo (void); int main (void) { int sum, a, b; sum = a + b + foo (); return sum; } $ cat foo.c int foo (void) { return 3; } ... Compiled like this: ... $ clang-10 -gdwarf-5 -gpubnames -c main.c $ clang-10 -gdwarf-5 -c foo.c $ clang-10 -gdwarf-5 -gpubnames main.o foo.o ... When loading this exec into gdb, we run into this assert: ... $ gdb a.out Reading symbols from a.out... warning: Section .debug_aranges in a.out entry at offset 0 \ debug_info_offset 0 does not exists, ignoring .debug_aranges. src/gdb/dwarf2/read.c:6949: \ internal-error: cutu_reader::cutu_reader(dwarf2_per_cu_data*, \ abbrev_table*, int, bool): \ Assertion `this_cu->length == cu->header.get_length ()' failed. ... The problem is that the determined length of the CU: ... (gdb) p /x this_cu->length $4 = 0x26a ... does not match the actual length: ... (gdb) p /x cu->header.get_length () $5 = 0x59 ... The length of the CU is determined in create_cus_from_debug_names_list, and set based on this list in the .debug_names section: ... Compilation Unit offsets [ CU[0]: 0x000000c7 ] ... and it is assumed that this is a complete list, so the size of the CU is calculated using the end of the .debug_section at 0x331, making it 0x331 - 0xc7 == 0x26a. However, the CU list is not complete: ... $ llvm-dwarfdump -debug-info a.out \ | grep "Compile Unit" \ | sed 's/Compile Unit.*//' 0x00000000: 0x0000002e: 0x000000a5: 0x000000c7: 0x00000120: 0x00000157: 0x0000030f: ... In particular, because the CU for foo.c is there at 0x120 (the rest of the CUs is due to openSUSE having debug info for various linked in objects). Fix the assert by not assuming to know the length of CUs in create_cus_from_debug_names_list (if the .debug_names is not produced by GDB), and setting it to 0, and setting it later to the actual length. Note that this does not fix the .debug_aranges warning, that's PR25969. Build and tested on x86_64-linux, with native and debug-names. gdb/ChangeLog: 2020-05-11 Tom de Vries <tdevries@suse.de> PR symtab/25941 * dwarf2/read.c (create_cus_from_debug_names_list): Initialize CUs with length 0, if not gdb-produced. (cutu_reader::cutu_reader): Set CU length to actual length if 0. gdb/testsuite/ChangeLog: 2020-05-11 Tom de Vries <tdevries@suse.de> PR symtab/25941 * gdb.dwarf2/clang-debug-names.exp.in: New include exp file, factored out of ... * gdb.dwarf2/clang-debug-names.exp: ... here. * gdb.dwarf2/clang-debug-names-2.exp: New file. Include clang-debug-names.exp.in. * gdb.dwarf2/clang-debug-names-2-foo.c: New test. * gdb.dwarf2/clang-debug-names-2.c: New test.
2020-05-11gdb/fortran: Allow Flang MAIN_ in Fortran testingAlok Kumar Sharma40-64/+145
Name of fortran main function for Flang compiler is MAIN_ while for gfortran it is MAIN__ . In test cases MAIN__ is hardcoded for the purpose of inserting breakpoint. New proc is added to detect main function name depending on the compiler used. Fortran specific version of runto_main named fortran_runto_main is added. This commit adds support for Flang main function, there should be no change for gfortran. gdb/testsuite/ChangeLog * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_, (fortran_runto_main): New Proc, fortran version of runto_main. * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_. * gdb.fortran/array-bounds.exp: Likewise. * gdb.fortran/array-slices.exp: Likewise. * gdb.fortran/block-data.exp: Likewise. * gdb.fortran/charset.exp: Likewise. * gdb.fortran/common-block.exp: Likewise. * gdb.fortran/complex.exp: Likewise. * gdb.fortran/derived-type-function.exp: Likewise. * gdb.fortran/derived-type.exp: Likewise. * gdb.fortran/info-modules.exp: Likewise. * gdb.fortran/info-types.exp: Likewise. * gdb.fortran/intrinsics.exp: Likewise. * gdb.fortran/library-module.exp: Likewise. * gdb.fortran/logical.exp: Likewise. * gdb.fortran/max-depth.exp: Likewise. * gdb.fortran/module.exp: Likewise. * gdb.fortran/multi-dim.exp: Likewise. * gdb.fortran/nested-funcs.exp: Likewise. * gdb.fortran/print-formatted.exp: Likewise. * gdb.fortran/print_type.exp: Likewise. * gdb.fortran/printing-types.exp: Likewise. * gdb.fortran/ptr-indentation.exp: Likewise. * gdb.fortran/ptype-on-functions.exp: Likewise. * gdb.fortran/subarray.exp: Likewise. * gdb.fortran/vla-alloc-assoc.exp: Likewise. * gdb.fortran/vla-datatypes.exp: Likewise. * gdb.fortran/vla-history.exp: Likewise. * gdb.fortran/vla-ptr-info.exp: Likewise. * gdb.fortran/vla-ptype-sub.exp: Likewise. * gdb.fortran/vla-ptype.exp: Likewise. * gdb.fortran/vla-sizeof.exp: Likewise. * gdb.fortran/vla-type.exp: Likewise. * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise. * gdb.fortran/vla-value-sub-finish.exp: Likewise. * gdb.fortran/vla-value-sub.exp: Likewise. * gdb.fortran/vla-value.exp: Likewise. * gdb.fortran/whatis_type.exp: Likewise. * gdb.mi/mi-var-child-f.exp: Likewise.
2020-05-09Fix for the complaint observed when symbol reading due to unsupported ↵nitachra2-12/+5
.debug_names form Following complaint is observed with the executable compiled with -gdwarf-5 and -gpubnames flags - "During symbol reading: Unsupported .debug_names form DW_FORM_ref4". This is the form corresponding to DW_IDX_die_offset attribute. This patch fixes this complaint. Tested with clang 10.0.0. Test case used - int main() { int sum,a,b; sum = a + b; return sum; } clang -gdwarf-5 -gpubnames test.c -o test.out gdb -q test.out -ex "set complaints 1" -ex "start" Reading symbols from test.out... During symbol reading: Unsupported .debug_names form DW_FORM_ref4 \ [in module test.out] Temporary breakpoint 1 at 0x400484 Starting program: test.out During symbol reading: Unsupported .debug_names form DW_FORM_ref4 \ [in module test.out] During symbol reading: Unsupported .debug_names form DW_FORM_ref4 \ [in module test.out] During symbol reading: Unsupported .debug_names form DW_FORM_ref4 \ [in module test.out] gdb/dwarf2/ChangeLog: 2020-05-09 Nitika Achra <Nitika.Achra@amd.com> PR symtab/25952 * read.c (dw2_debug_names_iterator::next): Handle DW_FORM_ref* and DW_IDX_die_offset. If there is no compilation unit attribute in the index entry, then there is a single CU. Return the CU at O index of compilation unit vector. gdb/testsuite/ChangeLog: 2020-05-09 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/clang-debug-names.exp: Remove PR25952 kfail.
2020-05-08[gdb/testsuite] Add gdb.dwarf2/clang-debug-names.cTom de Vries3-0/+186
Add test-case with .debug_names section using DW_FORM_ref4. There's currently no support for .debug_names in the dwarf assembler, so we use plain _emit rather than something more structured. Consequently, we cannot use regular declare_labels-generated labels to refer from .debug_names to .debug_info. Instead, we use labels with a predefined name, which we generate using _compute_label, and then define using define_label. This is the test-case for PR25952, so kfail the corresponding test. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-08 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/clang-debug-names.c: New test. * gdb.dwarf2/clang-debug-names.exp: New file.
2020-05-06gdb: handle endbr64 instruction in amd64_analyze_prologueSimon Marchi4-0/+102
v2: - test: build full executable instead of object - test: add and use supports_fcf_protection - test: use gdb_test_multiple's -wrap option - test: don't execute gdb_assert if failed to get breakpoint address Some GCCs now enable -fcf-protection by default. This is the case, for example, with GCC 9.3.0 on Ubuntu 20.04. Enabling it causes the `endbr64` instruction to be inserted at the beginning of all functions and that breaks GDB's prologue analysis. I noticed this because it gives many failures in gdb.base/break.exp. But let's take this dummy program and put a breakpoint on main: int main(void) { return 0; } Without -fcf-protection, the breakpoint is correctly put after the prologue: $ gcc test.c -g3 -O0 -fcf-protection=none $ ./gdb -q -nx --data-directory=data-directory a.out Reading symbols from a.out... (gdb) disassemble main Dump of assembler code for function main: 0x0000000000001129 <+0>: push %rbp 0x000000000000112a <+1>: mov %rsp,%rbp 0x000000000000112d <+4>: mov $0x0,%eax 0x0000000000001132 <+9>: pop %rbp 0x0000000000001133 <+10>: retq End of assembler dump. (gdb) b main Breakpoint 1 at 0x112d: file test.c, line 3. With -fcf-protection, the breakpoint is incorrectly put on the first byte of the function: $ gcc test.c -g3 -O0 -fcf-protection=full $ ./gdb -q -nx --data-directory=data-directory a.out Reading symbols from a.out... (gdb) disassemble main Dump of assembler code for function main: 0x0000000000001129 <+0>: endbr64 0x000000000000112d <+4>: push %rbp 0x000000000000112e <+5>: mov %rsp,%rbp 0x0000000000001131 <+8>: mov $0x0,%eax 0x0000000000001136 <+13>: pop %rbp 0x0000000000001137 <+14>: retq End of assembler dump. (gdb) b main Breakpoint 1 at 0x1129: file test.c, line 2. Stepping in amd64_skip_prologue, we can see that the prologue analysis, for GCC-compiled programs, is done in amd64_analyze_prologue by decoding the instructions and looking for typical patterns. This patch changes the analysis to check for a prologue starting with the `endbr64` instruction, and skip it if it's there. gdb/ChangeLog: * amd64-tdep.c (amd64_analyze_prologue): Check for `endbr64` instruction, skip it if it's there. gdb/testsuite/ChangeLog: * gdb.arch/amd64-prologue-skip-cf-protection.exp: New file. * gdb.arch/amd64-prologue-skip-cf-protection.c: New file.
2020-05-06[gdb/testsuite] Fix gdb.reverse/consecutive-{precsave,reverse}.exp with gcc-8Tom de Vries3-2/+34
When running test-cases gdb.reverse/consecutive-precsave.exp and gdb.reverse/consecutive-reverse.exp with gcc-8, we get: ... FAIL: gdb.reverse/consecutive-precsave.exp: stopped at bp, 2nd instr FAIL: gdb.reverse/consecutive-reverse.exp: stopped at bp, 2nd instr ... These FAILs are duplicates of the FAILs fixed in commit 7c99e7e2b08 "[gdb/testsuite] Fix gdb.base/consecutive.exp with gcc-8". Fix these in the same manner. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-06 Tom de Vries <tdevries@suse.de> * gdb.reverse/consecutive-precsave.exp: Handle if instruction after breakpoint is at a "recommended breakpoint location". * gdb.reverse/consecutive-reverse.exp: Same.
2020-05-06[gdb/testsuite] Fix gdb.base/watchpoint-reuse-slot.exp with gcc-8Tom de Vries2-2/+7
When running test-case gdb.base/watchpoint-reuse-slot.exp with gcc-8 instead of gcc-7, we have: ... (gdb) PASS: $conf: watch *(buf.byte + 0 + 0)@1 stepi^M -0x00000000004004b9 34 for (i = 0; i < 100000; i++);^M +34 for (i = 0; i < 100000; i++);^M -(gdb) PASS: $conf: stepi advanced +(gdb) FAIL: $conf: stepi advanced ... where $conf is "gdb.base/watchpoint-reuse-slot.exp: hw-watch: always-inserted off: watch x watch: : width 1, iter 0: base + 0". This is due to the fact that gcc-8 generates more precise line info, making the instruction at 0x4004b9 a "recommended breakpoint location", such that gdb no longer prints the instruction address. Fix this by getting the instruction address by printing $pc. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-06 Tom de Vries <tdevries@suse.de> * gdb.base/watchpoint-reuse-slot.exp (stepi): Print $pc to get current address.
2020-05-06[gdb/testsuite] Fix cur_addr update in gdb.base/watchpoint-reuse-slot.expTom de Vries2-1/+5
I noticed this code in gdb.base/watchpoint-reuse-slot.exp, proc stepi: ... gdb_test_multiple "stepi" $test { -re "($hex).*[string_to_regexp $srcline]\r\n$gdb_prompt $" { set addr $expect_out(1,string) if {$addr != $cur_addr} { pass $test } else { fail $test } set cur_addr addr } } ... The variable cur_addr is documented as: ... # The address the program is stopped at currently. set cur_addr "" ... but in the gdb_test_multiple clause we assign the string "addr" to cur_addr, while $addr contains the current address. Fix this by assigning $addr instead "addr". Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-06 Tom de Vries <tdevries@suse.de> * gdb.base/watchpoint-reuse-slot.exp: Fix incorrect assignment.
2020-05-06[gdb/testsuite] Fix gdb.base/store.exp with gcc-10Tom de Vries2-16/+41
When running gdb.base/store.exp with gcc-10 instead of gcc-9, we have: ... (gdb) PASS: gdb.base/store.exp: continue to wack_double print l^M -$22 = <optimized out>^M +$22 = -1^M -(gdb) UNSUPPORTED: gdb.base/store.exp: var double l; print old l, expecting -1 -(gdb) PASS: gdb.base/store.exp: var double l; print old l, expecting -1 +print r^M +$23 = <optimized out>^M +(gdb) FAIL: gdb.base/store.exp: var double l; print old r, expecting -2 ... With gcc-9, there's no location info for both l and r, but with gcc-10, there's location info for l, but not r. The test-case only checks for location info availability of l, and then assumes location info for r is also available. Fix this by allowing missing location info for r. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-06 Tom de Vries <tdevries@suse.de> * gdb.base/store.exp (check_set, up_set): Allowing missing location info for r.
2020-05-06[gdb/testsuite] Fix gdb.base/shlib-call.exp with gcc-8Tom de Vries2-3/+13
When running test-case gdb.base/shlib-call.exp with gcc-8 instead of gcc-7, we have: ... (gdb) step^M -main () at /data/gdb_versions/devel/src/gdb/testsuite/gdb.base/shmain.c:42^M -42 g = mainshr1(g);^M -(gdb) PASS: gdb.base/shlib-call.exp: step out of shr2 epilogue to main +main () at /data/gdb_versions/devel/src/gdb/testsuite/gdb.base/shmain.c:41^M +41 g = shr2(g);^M +(gdb) FAIL: gdb.base/shlib-call.exp: step out of shr2 epilogue to main ... This is due to the fact that gcc-8 generates more precise line info, making the instruction after the call to shr2 at 0x4008f1: ... 4008e4: 8b 05 aa 07 20 00 mov 0x2007aa(%rip),%eax # 601094 <g> 4008ea: 89 c7 mov %eax,%edi 4008ec: e8 1f fe ff ff callq 400710 <shr2@plt> 4008f1: 89 05 9d 07 20 00 mov %eax,0x20079d(%rip) # 601094 <g> ... a "recommended breakpoint location": ... [0x00000287] Special opcode 187: advance Address by 13 to 0x4008f1 and \ Line by 0 to 41 ... so when stepping out of shr2, gdb steps back onto line 41, the line containing the call to shr2. Fix this by detecting this situation and adding an extra step to reach line 42. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-06 Tom de Vries <tdevries@suse.de> * gdb.base/shlib-call.exp: Add extra step to reach shmain.c:42, if necessary.
2020-05-06[gdb/testsuite] Fix gdb_unbuffer_output return-typeTom de Vries2-1/+6
When running test-case gdb.base/shlib-call.exp with clang, we get: ... gdb compile failed, In file included from shmain.c:6: unbuffer_output.c:39:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ 1 warning generated. ... Fix this by changing the return-type to void. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-06 Tom de Vries <tdevries@suse.de> * lib/unbuffer_output.c (gdb_unbuffer_output): Change return type to void.
2020-05-06[gdb/testsuite] Fix gdb.base/consecutive.exp with gcc-8Tom de Vries4-13/+56
When running test-case gdb.base/consecutive.exp with gcc-8 instead of gcc-7, we get: ... (gdb) step^M ^M -Breakpoint 3, 0x00000000004004b1 in foo () at consecutive.c:10^M +Breakpoint 3, foo () at consecutive.c:10^M 10 return a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6];^M -(gdb) PASS: gdb.base/consecutive.exp: stopped at bp, 2nd instr +(gdb) FAIL: gdb.base/consecutive.exp: stopped at bp, 2nd instr ... This is due to the fact that gcc-8 generates more precise line info, making the breakpoint address a "recommended breakpoint location", and consequently gdb doesn't print the address prefix anymore. Fix the FAIL by checking in the test-case whether the breakpoint address is at "recommended breakpoint location" or not. gdb/testsuite/ChangeLog: 2020-05-06 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (is_stmt_addresses, hex_in_list): New proc, factored out of ... * gdb.base/async.exp: ... here. * gdb.base/consecutive.exp: Handle if 2nd breakpoint is at a "recommended breakpoint location".