aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
AgeCommit message (Collapse)AuthorFilesLines
2020-10-12Eliminate mi_run_to_main, introduce mi_clean_restartusers/palves/runto_mainPedro Alves59-400/+184
Since we now have mi_runto_main which is like runto_main, eliminate mi_run_to_main, in favor of a new MI clean_restart counterpart -- mi_clean_restart -- and mi_runto_main. This makes MI testcases look a bit more like CLI testcases. gdb/testsuite/ChangeLog: * lib/mi-support.exp (mi_clean_restart): New. (mi_run_to_main): Delete. All callers adjust to use mi_clean_restart / mi_runto_main. Change-Id: I34920bab4fea1f23fb752928c2969c1f6ad714b6
2020-10-12gdb/testsuite/: Use "-qualified" in explicit "break main", etc.Pedro Alves45-83/+83
Similar to the previous patch, but this time add "-q" to tests that do "break main", "list main", etc. explicitly. gdb/testsuite/ChangeLog: * config/monitor.exp: Use "list -q". * gdb.arch/gdb1558.exp: Use "break -q". * gdb.arch/i386-permbkpt.exp: Use "break -q". * gdb.arch/i386-prologue-skip-cf-protection.exp: Use "break -q". * gdb.base/break.exp: Use "break -q", "list -q" and "tbreak -q". * gdb.base/commands.exp: Use "break -q". * gdb.base/condbreak.exp: Use "break -q". * gdb.base/ctf-ptype.exp: Use "list -q". * gdb.base/define.exp: Use "break -q". * gdb.base/del.exp: Use "break -q". * gdb.base/fullname.exp: Use "break -q". * gdb.base/hbreak-in-shr-unsupported.exp: Use "hbreak -q". * gdb.base/hbreak-unmapped.exp: Use "hbreak -q". * gdb.base/hbreak2.exp: Use "hbreak -q" and "list -q". * gdb.base/hw-sw-break-same-address.exp: Use "break -q" and "hbreak -q". * gdb.base/included.exp: Use "list -q". * gdb.base/label.exp: Use "break -q". * gdb.base/lineinc.exp: Use "break -q". * gdb.base/list.exp: Use "list -q". * gdb.base/macscp.exp: Use "list -q". * gdb.base/pending.exp: Use "break -q". * gdb.base/prologue-include.exp: Use "break -q". * gdb.base/ptype.exp: Use "list -q". * gdb.base/sepdebug.exp: Use "break -q", "list -q" and "tbreak -q". * gdb.base/server-del-break.exp: Use "break -q". * gdb.base/style.exp: Use "break -q". * gdb.base/symbol-without-target_section.exp: Use "list -q". * gdb.base/watchpoint-reuse-slot.exp: Use "hbreak -q". * gdb.cp/exception.exp: Use "tbreak -q". * gdb.dwarf2/dw2-error.exp: Use "break -q". * gdb.dwarf2/fission-mix.exp: Use "break -q". * gdb.dwarf2/fission-reread.exp: Use "break -q". * gdb.dwarf2/pr13961.exp: Use "break -q". * gdb.linespec/explicit.exp: Use "list -q". * gdb.linespec/linespec.exp: Use "break -q". * gdb.mi/mi-simplerun.exp: Use "--qualified". * gdb.python/py-mi-objfile-gdb.py: Use "list -q". * gdb.server/bkpt-other-inferior.exp: Use "break -q". * gdb.server/connect-without-multi-process.exp: Use "break -q". * gdb.trace/change-loc.exp: Use "break -q". * gdb.trace/pending.exp: Use "break -q". * gdb.tui/basic.exp: Use "list -q". * gdb.tui/list-before.exp: Use "list -q". * gdb.tui/list.exp: Use "list -q". * lib/gdb.exp (gdb_has_argv0): Use "break -q". Change-Id: Iab9408e90ed71cbb111cd737d2d81b5ba8adb108
2020-10-12gdb/testsuite/: Use -qualified in runto_main / mi_runto_mainPedro Alves4-6/+10
In some runtimes, there may be a "main" function in some class or namespace. The breakpoint created by runto_main may therefore have unexpected locations on some other functions than the actual main. These breakpoint locations can unexpectedly get hit during tests and lead to failures. I saw this while playing with AMD's ROCm toolchain -- I wrote a board file to run the testsuite against device kernels. There, the runtime calls a "main" function before the device kernel code is reached: Thread 4 "bit_extract" hit Breakpoint 1, 0x00007ffeea140960 in lld::elf::LinkerDriver::main(llvm::ArrayRef<char const*>) () from /opt/rocm/lib/libamd_comgr.so.1 (gdb) bt #0 0x00007ffeea140960 in lld::elf::LinkerDriver::main(llvm::ArrayRef<char const*>) () from /opt/rocm/lib/libamd_comgr.so.1 #1 0x00007ffeea2257a5 in lld::elf::link(llvm::ArrayRef<char const*>, bool, llvm::raw_ostream&, llvm::raw_ostream&) () from /opt/rocm/lib/libamd_comgr.so.1 #2 0x00007ffeea1bc374 in COMGR::linkWithLLD(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&) () from /opt/rocm/lib/libamd_comgr.so.1 #3 0x00007ffeea1bfb09 in COMGR::InProcessDriver::execute(llvm::ArrayRef<char const*>) () from /opt/rocm/lib/libamd_comgr.so.1 #4 0x00007ffeea1c4da9 in COMGR::AMDGPUCompiler::linkToExecutable() () from /opt/rocm/lib/libamd_comgr.so.1 #5 0x00007ffeea1fde20 in dispatchCompilerAction(amd_comgr_action_kind_s, COMGR::DataAction*, COMGR::DataSet*, COMGR::DataSet*, llvm::raw_ostream&) () from /opt/rocm/lib/libamd_comgr.so.1 #6 0x00007ffeea203a87 in amd_comgr_do_action () from /opt/rocm/lib/libamd_comgr.so.1 ... To avoid that, pass "qualified" to runto, in runto_main, so that gdb_breakpoint ends up creating a breakpoint with -qualified. This avoids creating breakpoints locations for other unrelated "main" functions. Note: I first tried making runto itself use "-qualified", but that caused regressions in the gdb.ada/ tests, which use runto without specifying the whole fully-qualified function name (i.e., without the package). So I end up restricting the -qualified to runto_main/mi_runto_main. The gdb.base/ui-redirect.exp change is necessary because that testcase is looking at what "save breakpoint" generates. gdb/testsuite/ChangeLog: * gdb.base/ui-redirect.exp: Expect "break -qualified main" in saved breakpoints file. * gdb.guile/scm-breakpoint.exp: Expect "-qualified main" when inspecting breakpoint list. * lib/gdb.exp (runto_main): Add "qualified" to options. * lib/mi-support.exp (mi_runto_helper): Add 'qualified' parameter, and handle it. (mi_runto_main): Pass 1 as qualified argument. Change-Id: I51468359ab0a518f05f7c0394c97f7e33b45fe69
2020-10-12Introduce mi_runto_mainPedro Alves11-18/+24
This adds an mi_runto_main routine, very much like the runto_main CLI counterpart. Note there's already a mi_run_to_main (extra underscore in "run_to"), but unlike its intro comment says, that does more than the CLI's runto_main -- it also starts GDB. I would like to eliminate that other one by introducing a mi_clean_restart function instead. That is done later in the series. gdb/testsuite/ChangeLog: * lib/mi-support.exp (mi_runto_main): New proc. (mi_run_to_main): Use it. * gdb.mi/mi-catch-cpp-exceptions.exp: Likewise. * gdb.mi/mi-var-cmd.exp: Likewise. * gdb.mi/mi-var-invalidate.exp: Likewise. * mi-var-list-children-invalid-grandchild.exp: Likewise. * gdb.mi/mi2-amd64-entry-value.exp: Likewise. * gdb.mi/new-ui-mi-sync.exp: Likewise. * gdb.mi/user-selected-context-sync.exp: Likewise. * gdb.opt/inline-cmds.exp: Likewise. * gdb.python/py-framefilter-mi.exp: Likewise. * gdb.python/py-mi.exp: Likewise. Change-Id: I2e49ca7b0b61cea57c1202e5dfa32417e6a4403d
2020-10-12'runto main' -> 'runto_main' throughoutPedro Alves56-63/+63
This commit does 's/runto main/runto_main/g' throughout. gdb/testsuite/ChangeLog: * gdb.ada/fun_in_declare.exp: Use "runto_main" instead of "runto main". * gdb.ada/small_reg_param.exp: Likewise. * gdb.arch/powerpc-d128-regs.exp: Likewise. * gdb.base/annota1.exp: Likewise. * gdb.base/anon.exp: Likewise. * gdb.base/breakpoint-in-ro-region.exp: Likewise. * gdb.base/dprintf-non-stop.exp: Likewise. * gdb.base/dprintf.exp: Likewise. * gdb.base/gdb11530.exp: Likewise. * gdb.base/gdb11531.exp: Likewise. * gdb.base/gnu_vector.exp: Likewise. * gdb.base/interrupt-noterm.exp: Likewise. * gdb.base/memattr.exp: Likewise. * gdb.base/step-over-syscall.exp: Likewise. * gdb.base/watch-cond-infcall.exp: Likewise. * gdb.base/watch-read.exp: Likewise. * gdb.base/watch-vfork.exp: Likewise. * gdb.base/watch_thread_num.exp: Likewise. * gdb.base/watchpoint-stops-at-right-insn.exp: Likewise. * gdb.guile/scm-frame-inline.exp: Likewise. * gdb.linespec/explicit.exp: Likewise. * gdb.opt/inline-break.exp: Likewise. * gdb.python/py-frame-inline.exp: Likewise. * gdb.reverse/break-precsave.exp: Likewise. * gdb.reverse/break-reverse.exp: Likewise. * gdb.reverse/consecutive-precsave.exp: Likewise. * gdb.reverse/consecutive-reverse.exp: Likewise. * gdb.reverse/finish-precsave.exp: Likewise. * gdb.reverse/finish-reverse.exp: Likewise. * gdb.reverse/fstatat-reverse.exp: Likewise. * gdb.reverse/getresuid-reverse.exp: Likewise. * gdb.reverse/i386-precsave.exp: Likewise. * gdb.reverse/i386-reverse.exp: Likewise. * gdb.reverse/i386-sse-reverse.exp: Likewise. * gdb.reverse/i387-env-reverse.exp: Likewise. * gdb.reverse/i387-stack-reverse.exp: Likewise. * gdb.reverse/insn-reverse.exp: Likewise. * gdb.reverse/machinestate-precsave.exp: Likewise. * gdb.reverse/machinestate.exp: Likewise. * gdb.reverse/pipe-reverse.exp: Likewise. * gdb.reverse/readv-reverse.exp: Likewise. * gdb.reverse/recvmsg-reverse.exp: Likewise. * gdb.reverse/rerun-prec.exp: Likewise. * gdb.reverse/s390-mvcle.exp: Likewise. * gdb.reverse/solib-precsave.exp: Likewise. * gdb.reverse/solib-reverse.exp: Likewise. * gdb.reverse/step-precsave.exp: Likewise. * gdb.reverse/step-reverse.exp: Likewise. * gdb.reverse/time-reverse.exp: Likewise. * gdb.reverse/until-precsave.exp: Likewise. * gdb.reverse/until-reverse.exp: Likewise. * gdb.reverse/waitpid-reverse.exp: Likewise. * gdb.reverse/watch-precsave.exp: Likewise. * gdb.reverse/watch-reverse.exp: Likewise. * gdb.threads/kill.exp: Likewise. * gdb.threads/tid-reuse.exp: Likewise. Change-Id: I70f457253836019880b4d7fb981936afa56724c2
2020-10-11gdb: detect main function even when there's no matching msymbolAndrew Burgess2-2/+6
Currently, GDB will only stop the backtrace at the main function if there is a minimal symbol with the matching name. In Fortran programs compiled with gfortran this is not the case. The main function is present in the DWARF, and as marked as DW_AT_main_subprogram, but there's no minimal symbol. This commit extends `inside_main_func` to check the full symbols if no matching minimal symbol is found. There's an updated test case that covers this change. gdb/ChangeLog: * frame.c (inside_main_func): Check full symbols as well as minimal symbols. gdb/testsuite/ChangeLog: * gdb.fortran/mixed-lang-stack.exp (run_tests): Update expected output of backtrace.
2020-10-09Fix bit offset regressionTom Tromey3-5/+14
The type-safe attribute patch introduced a regression that can occur when the DW_AT_bit_offset value is negative. This can happen with some Ada programs. This patch fixes the problem. It also fixes a minor oddity in the existing scalar storage test -- this test was intended to assign a smaller number of bits to the field. 2020-10-09 Tom Tromey <tromey@adacore.com> * dwarf2/read.c (dwarf2_add_field): Handle signed offsets. gdb/testsuite/ChangeLog 2020-10-09 Tom Tromey <tromey@adacore.com> * gdb.ada/scalar_storage/storage.adb (Another_Range): New type. (Rec): Add field. Fix range. * gdb.ada/scalar_storage.exp: Update.
2020-10-09Handle void results as unformatted printsHannes Domani2-0/+10
When printing void results without any format letter, they are output as expected: (gdb) p $abcd $1 = void (gdb) p (void)10 $2 = void But if any format letter (besides s) is used, it always outputs zero: (gdb) p/x $abcd $3 = 0x0 (gdb) p/x (void)10 $4 = 0x0 So this adds void results to the types handled like unformatted prints. gdb/ChangeLog: 2020-10-09 Hannes Domani <ssbssa@yahoo.de> PR exp/26714 * printcmd.c (print_formatted): Handle void results as unformatted prints. gdb/testsuite/ChangeLog: 2020-10-09 Hannes Domani <ssbssa@yahoo.de> PR exp/26714 * gdb.base/printcmds.exp: Add tests for void results.
2020-10-09Notify observers that directories have changed when using "directory" CLI ↵Jan Vrany2-0/+16
command gdb/ChangeLog * source.c (directory_command): Notify observers that "directories" parameter has changed. gdb/testsuite/ChangeLog * gdb.mi/mi-cmd-param-changed.exp: Check that notification is is emmited for both 'set directories' and 'directory' commands.
2020-10-08Style more output of "disassemble" commandTom Tromey2-1/+8
I noticed a couple of spots where the "disassemble" could style its output, but currently does not. This patch adds styling to the function name at the start of the disassembly, and any addresses printed there. gdb/ChangeLog 2020-10-08 Tom Tromey <tom@tromey.com> * cli/cli-cmds.c (print_disassembly): Style function name and addresses. Add _() wrappers. gdb/testsuite/ChangeLog 2020-10-08 Tom Tromey <tom@tromey.com> * gdb.base/style.exp: Check that "main"'s name is styled.
2020-10-07Rename some tests in find.expTom Tromey2-6/+10
This renames some tests in find.exp, to avoid duplicate test names. gdb/testsuite/ChangeLog 2020-10-07 Tom Tromey <tromey@adacore.com> * gdb.base/find.exp: Rename some tests.
2020-10-06Fix gdb.base/list.exp with ClangGary Benson3-2/+7
Two subtests of gdb.base/list.exp failed when built with Clang because the unused function "unused" was optimized out. This commit adds __attribute__ ((used)) to both definitions. gdb/testsuite/ChangeLog: * gdb.base/list0.c (unused): Add __attribute__ ((used)). * gdb.base/list1.c (unused): Likewise.
2020-10-06Fix gdb.base/list-ambiguous.exp with ClangGary Benson3-2/+8
The ambiguous variable parts of gdb.base/list-ambiguous.exp failed when built with Clang because the variable in question was unused and was optimized out. This commit adds __attribute__ ((used)) to both definitions. gdb/testsuite/ChangeLog: * gdb.base/list-ambiguous0.c (ambiguous_var): Add __attribute__ ((used)). * gdb.base/list-ambiguous1.c (ambiguous_var): Likewise.
2020-10-06gdb/testsuite: allow gdb.base/overlays.exp to compile for m32rAndrew Burgess4-38/+58
The gdb.base/overlays.exp test is only currently supported on m32r baremetal targets, however, when I configure a toolchain for m32r-elf the test does not compile. This commit updates the linker script, fixes some TCL errors in the exp file, and adds some missing includes to the source file so that the test does compile. With this test, when run against an m32r-elf toolchain the test mostly passes, but there are a couple of failures, these are GDB issues and will be addressed in a later commit. gdb/testsuite/ChangeLog: * gdb.base/m32r.ld: Remove SEARCH_DIR line. Add MEMORY regions, make use of regions throughout. * gdb.base/overlays.exp: Enclose string with variableds in "..", not {...}. * gdb.base/ovlymgr.c: Add 'string.h' and 'stdlib.h' includes.
2020-10-05Fix function argument and return value locationsHannes Domani3-1/+23
Fixes these testsuite fails on Windows: FAIL: gdb.base/callfuncs.exp: p t_float_complex_values(fc1, fc2) FAIL: gdb.base/callfuncs.exp: p t_float_complex_many_args(fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4) FAIL: gdb.base/callfuncs.exp: noproto: p t_float_complex_values(fc1, fc2) FAIL: gdb.base/callfuncs.exp: noproto: p t_float_complex_many_args(fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4) FAIL: gdb.base/call-sc.exp: p/c fun(); call call-sc-tld FAIL: gdb.base/call-sc.exp: advance to fun for return; return call-sc-tld FAIL: gdb.base/call-sc.exp: zed L for return; return call-sc-tld FAIL: gdb.base/call-sc.exp: return foo; return call-sc-tld FAIL: gdb.base/call-sc.exp: return foo; synchronize pc to main() for 'call-sc-tld' FAIL: gdb.base/call-sc.exp: return foo; synchronize pc to main() for 'call-sc-tld' FAIL: gdb.base/call-sc.exp: advance to fun for finish; return call-sc-tld FAIL: gdb.base/call-sc.exp: zed L for finish; return call-sc-tld FAIL: gdb.base/call-sc.exp: finish foo; return call-sc-tld (the program is no longer running) FAIL: gdb.base/call-sc.exp: value foo finished; return call-sc-tld For function arguments (callfuncs.exp), only TYPE_CODE_COMPLEX was missing in the types passed via integer registers. For return values, there were a lot more issues: - TYPE_CODE_DECFLOAT is NOT returned via XMM0. - long double is NOT returned via XMM0. - but __int128 IS returned via XMM0. - the comments for TYPE_CODE_FLT state that __m128, __m128i and __m128d are returned by XMM0, and this is correct, but it doesn't actually check for them, because they are TYPE_CODE_ARRAY with TYPE_VECTOR So I had to add TYPE_CODE_DECFLOAT to the arguments passed via XMM register, but I had to remove it from the values returned via XMM0 register. gdb/ChangeLog: 2020-10-05 Hannes Domani <ssbssa@yahoo.de> * amd64-windows-tdep.c (amd64_windows_passed_by_integer_register): Add TYPE_CODE_COMPLEX. (amd64_windows_return_value): Fix types returned via XMM0. gdb/testsuite/ChangeLog: 2020-10-05 Hannes Domani <ssbssa@yahoo.de> * gdb.base/call-sc.c: Fix return struct on stack test case. * gdb.base/call-sc.exp: Likewise.
2020-10-02Fix spelling mistake in gdb/testsuite/README.Gary Benson2-1/+5
This commit corrects the spelling mistake detailed below. gdb/testsuite/ChangeLog: * README: Fix "paralell".
2020-09-30Fix gdb.dwarf2/dw2-double-set-die-type.exp with ClangGary Benson2-4/+10
gdb.dwarf2/dw2-double-set-die-type.exp failed to build with Clang, because of the following issues: - One .uleb128 directive was specified with an uppercase U, causing Clang to fail with the message: error: unknown directive This commit converts that directive to all-lowercase. - The label ".Labbrev1_begin" was referenced but not defined, causing Clang to fail with the message: <unknown>:0: error: Undefined temporary symbol This commit adds the label in the appropriate place. - The label ".Ldebug_line0" was referenced but not defined, causing Clang to fail with the message: <unknown>:0: error: Undefined temporary symbol This commit removes the reference. gdb/testsuite/ChangeLog: * gdb.dwarf2/dw2-double-set-die-type.S (.Ldie_3e0): Convert directive to lowercase. (.Labbrev1_begin): Add missing label. (abbrev code 0x1): Remove DW_AT_stmt_list. (.Ldie_b): Likewise.
2020-09-27Remove test duplicate from gdb.tuiTom Tromey2-4/+10
I noticed a duplicated test in gdb.tui. This patch removes it by wrapping a test in with_test_prefix. gdb/testsuite/ChangeLog 2020-09-27 Tom Tromey <tom@tromey.com> * gdb.tui/new-layout.exp: Use with_test_prefix.
2020-09-26gdb: Fix from_tty argument to gdb.execute in Python.Gareth Rees2-0/+19
Prior to commit 56bcdbea2b, the from_tty keyword argument to the Python function gdb.execute controlled whether the command took input from the terminal. When from_tty=True, "starti" and similar commands prompted the user: (gdb) python gdb.execute("starti", from_tty=True) The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /bin/true Program stopped. When from_tty=False, these commands did not prompt the user, and "yes" was assumed: (gdb) python gdb.execute("starti", from_tty=False) Program stopped. However, after commit 56bcdbea2b, the from_tty keyword argument no longer had this effect. For example, as of commit 7ade7fba75: (gdb) python gdb.execute("starti", from_tty=True) The program being debugged has been started already. Start it from the beginning? (y or n) [answered Y; input not from terminal] Starting program: /bin/true Program stopped. Note the "[answered Y; input not from terminal]" in the output even though from_tty=True was requested. Looking at commit 56bcdbea2b, it seems that the behaviour of the from_tty argument was changed accidentally. The commit message said: Let gdb.execute handle multi-line commands This changes the Python API so that gdb.execute can now handle multi-line commands, like "commands" or "define". and there was no mention of changing the effect of the from_tty argument. It looks as though the code for setting the instream to nullptr was accidentally moved from execute_user_command() to execute_control_commands() along with the other scoped restores. Accordingly, the simplest way to fix this is to partially reverse commit 56bcdbea2b by moving the code for setting the instream to nullptr back to execute_user_command() where it was to begin with. Additionally, add a test case to reduce the risk of similar breakage in future. gdb/ChangeLog: PR python/26586 * cli/cli-script.c (execute_control_commands): don't set instream to nullptr here as this breaks the from_tty argument to gdb.execute in Python. (execute_user_command): set instream to nullptr here instead. gdb/testsuite/ChangeLog: PR python/26586 * gdb.python/python.exp: add test cases for the from_tty argument to gdb.execute.
2020-09-25Fix gdb.base/infcall-nested-structs-c++.exp with ClangGary Benson2-0/+13
gdb.base/infcall-nested-structs-c++.exp failed to build using Clang with many variations on the following error: gdb compile failed, /gdbtest/src/gdb/testsuite/gdb.base/infcall-nested-structs.c:207:46: warning: self-comparison always evaluates to true [-Wtautological-compare] This commit builds this testcase with -Wno-tautological-compare when using Clang, to avoid this failure. gdb/testsuite/ChangeLog: * gdb.base/infcall-nested-structs.exp.tcl: Add additional_flags=-Wno-tautological-compare for C++ tests when compiling using Clang.
2020-09-25Fix compilation of .c files as C++ when using ClangGary Benson2-2/+8
In commit 221db974e653659edb280787af1b3efdd1615083, this patch: 2020-06-24 Pedro Alves <palves@redhat.com> * lib/gdb.exp (gdb_compile): Pass "-x c++" explicitly when compiling C++ programs. attempted to fix problems with testcases that compile .c files with the C++ compiler. They pass the "c++" option to gdb_compile, resulting in the following error when using Clang: gdb compile failed, clang-10: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated] This fix did not work for gdb.base/infcall-nested-structs-c++.exp, however: the "-x c++" appeared in the compiler's commandline after the .c file, so the option was not enabled for that file. The previous files fixed all used build_executable_from_specs, which compiles and links in separate steps, using gdb_compile: the compile step passes $type=object to gdb_compile, while the link step passes $type=executable. gdb.base/infcall-nested-structs-c++.exp uses gdb_compile directly instead, and it passes $type=executable to compile and link all in one step. Pedro found that DejaGnu's default_target_compile adds the sources at the end when $type=object, but at the beginning when $type=executable: # This is obscure: we put SOURCES at the end when building an # object, because otherwise, in some situations, libtool will # become confused about the name of the actual source file. if {$type == "object"} { set opts "$add_flags $sources" } else { set opts "$sources $add_flags" } This commit moves the "-x c++" earlier in the compiler's commandline. Unfortunately this then broke the testcase that required the original fix, gdb.compile/compile-cplus.exp: the "-x c++" was being parsed for the linker pass, causing the compiler to attempt to parse the .o files as C++. This commit makes passing "-x c++" conditional on the source being a .c file. gdb/testsuite/ChangeLog: * lib/gdb.exp (gdb_compile): Pass "-x c++" earlier, and only for .c files.
2020-09-24Don't let TUI focus on locatorTom Tromey2-0/+6
PR tui/26638 notes that the C-x o binding can put the focus on the locator window. However, this is not useful and did not happen historically. This patch changes the TUI to skip this window when switching focus. gdb/ChangeLog 2020-09-24 Tom Tromey <tromey@adacore.com> PR tui/26638: * tui/tui-stack.h (struct tui_locator_window) <can_focus>: New method. * tui/tui-data.h (struct tui_win_info) <can_focus>: New method. * tui/tui-data.c (tui_next_win): Exclude non-focusable windows. (tui_prev_win): Rewrite. gdb/testsuite/ChangeLog 2020-09-24 Tom Tromey <tromey@adacore.com> PR tui/26638: * gdb.tui/list.exp: Check output of "focus next".
2020-09-23Handle bit offset and bit size in base typesTom Tromey3-0/+254
PR symtab/25470 points out that the Zig programming language allows integers of various bit sizes (including zero), not just sizes that are a multiple of 8. This is supported in DWARF by applying both a byte size and a DW_AT_bit_size. This patch adds support for this feature to integer and boolean types. Other base types are not handled -- for floating-point types, this didn't seem to make sense, and for character types I didn't see much need. (These can be added later if desired.) I've also added support for DW_AT_data_bit_offset at the same time. I don't know whether the Zig compiler requires this, but it was described in the same section in the DWARF standard and was easy to add. A new test case is supplied, using the DWARF assembler. gdb/ChangeLog 2020-09-23 Tom Tromey <tom@tromey.com> PR symtab/25470: * value.c (unpack_long, pack_long, pack_unsigned_long): Handle bit offset and bit size. * printcmd.c (print_scalar_formatted): Handle zero-length integer. (print_scalar_formatted): Use bit_size_differs_p. * gdbtypes.h (enum type_specific_kind) <TYPE_SPECIFIC_INT>: New constant. (union type_specific): <int_stuff>: New member. (struct type) <bit_size_differs_p, bit_size, bit_offset>: New methods. * gdbtypes.c (init_integer_type, init_boolean_type): Initialize TYPE_SPECIFIC_FIELD. (recursive_dump_type, copy_type_recursive): Update. * dwarf2/read.c (read_base_type): Handle DW_AT_bit_size and DW_AT_data_bit_offset. gdb/testsuite/ChangeLog 2020-09-23 Tom Tromey <tom@tromey.com> * gdb.dwarf2/intbits.exp: New file. * gdb.dwarf2/intbits.c: New file.
2020-09-20Fix mi_gdb_exit with secondary MI channelsPedro Alves2-0/+17
Tests that use a secondary MI channel (i.e., either tests that call mi_gdb_start with separate-mi-tty, or all tests when FORCE_SEPARATE_MI_TTY=1 is specified on the make check command line), don't close GDB correctly. E.g., if you run gdb.mi/mi-exec-run.exp in a loop: while true; do make check TESTS="gdb.mi/mi-exec-run.exp"; done you can see more than one gdb running at the same time: $ ps -ef | grep -v grep | grep "gdb/gdb" pedro 40507 1 7 15:47 ? 00:00:00 /home/pedro/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/pedro/gdb/build/gdb/testsuite/../data-directory pedro 40562 1 0 15:47 ? 00:00:00 /home/pedro/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/pedro/gdb/build/gdb/testsuite/../data-directory pedro 40727 1 0 15:47 ? 00:00:00 /home/pedro/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/pedro/gdb/build/gdb/testsuite/../data-directory pedro 40786 1 0 15:47 ? 00:00:00 /home/pedro/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/pedro/gdb/build/gdb/testsuite/../data-directory This commit fixes it. gdb/testsuite/ChangeLog: * lib/mi-support.exp (mi_uncatched_gdb_exit) Switch to the main spawn_id before calling remote_close. Close secondary MI channel.
2020-09-20Robustify gdb.base/testenv.exp:find_envPedro Alves2-0/+11
If printing 'envp[$i]' in find_env fails, the testcase goes into an infinite loop: Running /home/pedro/rocm/gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/testenv.exp ... FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[0] ? envp[0] : "" FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[1] ? envp[1] : "" FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[2] ? envp[2] : "" FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[3] ? envp[3] : "" ... FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[2519] ? envp[2519] : "" FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[2520] ? envp[2520] : "" FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[2521] ? envp[2521] : "" .. FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[5128] ? envp[5128] : "" FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[5129] ? envp[5129] : "" FAIL: gdb.base/testenv.exp: test_inherit_env_var: test1: printf "var1: %s\n", envp[5130] ? envp[5130] : "" ... Fix that by bailing out of the loop on failure. gdb/testsuite/ChangeLog: * gdb.base/testenv.exp (find_env): Bail out if printing 'envp[$i]' fails.
2020-09-19gdb/fortran: Change whitespace when printing arraysAndrew Burgess6-14/+22
This commit makes the whitespace usage when printing Fortran arrays more consistent, and more inline with how we print C arrays. Currently a 2 dimensional Fotran array is printed like this, I find the marked whitespace unpleasant: (( 1, 2, 3) ( 4, 5, 6) ) ^ ^ ^ After this commit the same array is printed like this: ((1, 2, 3) (4, 5, 6)) Which seems more inline with how we print C arrays, in the case of C arrays we don't add extra whitespace before the first element. gdb/ChangeLog: * f-valprint.c (f77_print_array_1): Adjust printing of whitespace for arrays. gdb/testsuite/ChangeLog: * gdb.fortran/array-slices.exp: Update expected results. * gdb.fortran/class-allocatable-array.exp: Likewise. * gdb.fortran/multi-dim.exp: Likewise. * gdb.fortran/vla-type.exp: Likewise. * gdb.mi/mi-vla-fortran.exp: Likewise.
2020-09-18gdb: Update i386_analyze_prologue to skip endbr32Victor Collod3-3/+12
With -m32 -fcf-protection, GCC generates an `endbr32` instruction at the function entry: [hjl@gnu-cfl-2 gdb]$ cat /tmp/x.c int main(void) { return 0; } [hjl@gnu-cfl-2 gdb]$ gcc -g -fcf-protection /tmp/x.c -m32 (gdb) b main Breakpoint 1 at 0x8049176: file /tmp/x.c, line 3. (gdb) r Breakpoint 1, main () at /tmp/x.c:3 3 { (gdb) disass Dump of assembler code for function main: => 0x08049176 <+0>: endbr32 0x0804917a <+4>: push %ebp 0x0804917b <+5>: mov %esp,%ebp 0x0804917d <+7>: mov $0x0,%eax 0x08049182 <+12>: pop %ebp 0x08049183 <+13>: ret End of assembler dump. (gdb) Update i386_analyze_prologue to skip `endbr32`: (gdb) b main Breakpoint 1 at 0x804917d: file /tmp/x.c, line 4. (gdb) r Breakpoint 1, main () at /tmp/x.c:4 4 return 0; (gdb) disass Dump of assembler code for function main: 0x08049176 <+0>: endbr32 0x0804917a <+4>: push %ebp 0x0804917b <+5>: mov %esp,%ebp => 0x0804917d <+7>: mov $0x0,%eax 0x08049182 <+12>: pop %ebp 0x08049183 <+13>: ret End of assembler dump. (gdb) Tested with $ make check RUNTESTFLAGS="--target_board='unix{-m32,}' i386-prologue-skip-cf-protection.exp" on Fedora 32/x86-64. 2020-0X-YY Victor Collod <vcollod@nvidia.com> gdb/ChangeLog: PR gdb/26635 * i386-tdep.c (i386_skip_endbr): Add a helper function to skip endbr. (i386_analyze_prologue): Call i386_skip_endbr. gdb/testsuite/ChangeLog: PR gdb/26635 * gdb.arch/amd64-prologue-skip-cf-protection.exp: Make the test compatible with i386, and move it to... * gdb.arch/i386-prologue-skip-cf-protection.exp: ... here. * gdb.arch/amd64-prologue-skip-cf-protection.c: Move to... * gdb.arch/i386-prologue-skip-cf-protection.c: ... here.
2020-09-18Fix "thread find" with multiple inferiors/targets (PR gdb/26631)Pedro Alves2-0/+111
"thread find" with multiple inferiors got broken with the multi-target work: Thread 1 "gdb" hit Breakpoint 1, internal_error (...) at ../../src/gdbsupport/errors.cc:51 51 { (top-gdb) bt #0 internal_error (file=0xffffd4d0 <error: Cannot access memory at address 0xffffd4d0>, line=0, fmt=0x555556330320 "en_US.UTF-8") at ../../src/gdbsupport/errors.cc:51 #1 0x0000555555bca4c7 in target_thread_name (info=0x555556801290) at ../../src/gdb/target.c:2035 #2 0x0000555555beb07a in thread_find_command (arg=0x7fffffffe08e "1", from_tty=0) at ../../src/gdb/thread.c:1959 #3 0x000055555572ec49 in do_const_cfunc (c=0x555556786bc0, args=0x7fffffffe08e "1", from_tty=0) at ../../src/gdb/cli/cli-decode.c:95 #4 0x0000555555732abd in cmd_func (cmd=0x555556786bc0, args=0x7fffffffe08e "1", from_tty=0) at ../../src/gdb/cli/cli-decode.c:2181 #5 0x0000555555bf1245 in execute_command (p=0x7fffffffe08e "1", from_tty=0) at ../../src/gdb/top.c:664 #6 0x00005555559cad10 in catch_command_errors (command=0x555555bf0c31 <execute_command(char const*, int)>, arg=0x7fffffffe082 "thread find 1", from_tty=0) at ../../src/gdb/main.c:457 #7 0x00005555559cc33d in captured_main_1 (context=0x7fffffffdb60) at ../../src/gdb/main.c:1218 #8 0x00005555559cc571 in captured_main (data=0x7fffffffdb60) at ../../src/gdb/main.c:1243 #9 0x00005555559cc5e8 in gdb_main (args=0x7fffffffdb60) at ../../src/gdb/main.c:1268 #10 0x0000555555623816 in main (argc=17, argv=0x7fffffffdc78) at ../../src/gdb/gdb.c:32 The problem is that we're not switching to the inferior/target before calling target methods, which trips on an assertion put in place exactly to catch this sort of problem. gdb/testsuite/ChangeLog: PR gdb/26631 * gdb.multi/multi-target-thread-find.exp: New file. gdb/ChangeLog: PR gdb/26631 * thread.c (thread_find_command): Switch inferior before calling target methods.
2020-09-18Split gdb.multi/multi-target.exp into separate testcasesPedro Alves8-546/+670
gdb.multi/multi-target.exp sets up a debug environment with multiple gdbservers, multiple native processes, and multiple cores, which has proved useful for exercising a number of multi-target scenarios. But, as we add more tests to gdb.base/multi-target.exp, it is growing a bit too large (making a bit cumbersome to debug) and too slow to run (if you have glibc debug info). This commit thus splits the multi-target.exp into several testcases, one per use case. The common setup code is moved to a new multi-target.exp.tcl file that is included by all the resulting multi-target testcases. gdb/testsuite/ChangeLog: * gdb.multi/multi-target-continue.exp: New file, factored out from multi-target.exp. * gdb.multi/multi-target-info-inferiors.exp: New file, factored out from multi-target.exp. * gdb.multi/multi-target-interrupt.exp: New file, factored out from multi-target.exp. * gdb.multi/multi-target-no-resumed.exp: New file, factored out from multi-target.exp. * gdb.multi/multi-target-ping-pong-next.exp: New file, factored out from multi-target.exp. * gdb.multi/multi-target.exp.tcl: New file, factored out from multi-target.exp. * gdb.multi/multi-target.exp: Delete.
2020-09-18gdb/testsuite: Add missing expected resultsAndrew Burgess2-1/+8
The tests in this script are driven from two lists of expected results, one of the lists is missing some data so DejaGNU ends up passing the empty string to gdb_test, which means the test always passes. This commit adds the missing expected results into the script. The tests still pass so there's no change in the results, but we are now actually checking GDB's behaviour. gdb/testsuite/ChangeLog: * gdb.fortran/array-slices.exp: Add missing message data.
2020-09-18gdb.cp/call-c.exp C++ifyPedro Alves2-0/+7
Make the testcase work when built with a C++ compiler. gdb/testsuite/ChangeLog: * gdb.cp/call-c-1.c (foo) [__cplusplus]: Add extern "C".
2020-09-18gdb.python/py-frame-inline.exp and C++Pedro Alves2-1/+6
Make the testcase work when built with a C++ compiler. gdb/testsuite/ChangeLog: * gdb.python/py-frame-inline.exp: Adjust to optionally expect a full prototype.
2020-09-18gdb.python/py-as-string.exp C++ifyPedro Alves2-1/+5
Make the testcase buildable with a C++ compiler. gdb/testsuite/ChangeLog: * gdb.python/py-as-string.c: Add cast.
2020-09-18gdb.base/sizeof.exp C++ifyPedro Alves2-1/+5
Fixes: src/gdb/testsuite/gdb.base/sizeof.c:54:9: error: cannot initialize a variable of type 'char *' with an lvalue of type 'void *' ... when the testcase is built with a C++ compiler. gdb/testsuite/ChangeLog: * gdb.base/sizeof.c (fill): Add cast.
2020-09-18gdb.base/share-env-with-gdbserver.exp C++ifyPedro Alves2-1/+5
gdb/testsuite/ChangeLog: * gdb.base/share-env-with-gdbserver.c (main): Add cast.
2020-09-18gdb.base/{prologue,symbol-alias}.exp C++ifyPedro Alves5-2/+23
Make these testcases work when compiled as C++ programs. These testcases use the alias attribute, which requires passing in the target function's mangled name in C++. To avoid having to figure out how the functions are mangled, explicitly specify a linkage name. This is preferred over 'extern "C"' because that doesn't work with static functions. gdb/testsuite/ChangeLog: * gdb.base/prologue.c [__cplusplus] (marker): Explicitly specify linkage name. * gdb.base/prologue.exp: Use print /d. * gdb.base/symbol-alias.exp: Handle C++ output. * gdb.base/symbol-alias2.c: Handle C++ output. [__cplusplus] (func): Explicitly specify linkage name.
2020-09-18gdb.python/py-nested-maps.exp C++ifyPedro Alves2-22/+31
This adjusts gdb.python/py-nested-maps.c to make it buildable as C++ program. key_t is renamed because of: src/gdb/testsuite/gdb.python/py-nested-maps.c:23:8: error: definition of type 'key_t' conflicts with typedef of the same name struct key_t ^ /usr/include/x86_64-linux-gnu/sys/types.h:121:17: note: 'key_t' declared here typedef __key_t key_t; ^ gdb/testsuite/ChangeLog: * gdb.python/py-nested-maps.c (struct key_t): Rename to... (struct my_key_t): ... this. Adjust all references. (struct value_t): Rename to ... (struct my_value_t): ... this. Adjust all references. (create_map, add_map_element, create_map_map) (add_map_map_element): Add casts.
2020-09-18gdb.python/{py-framefilter-mi,py-framefilter}.c C++ifyPedro Alves3-6/+11
This adjusts: gdb.python/{py-framefilter-mi,py-framefilter}.c to make them buildable as C++ programs. gdb/testsuite/ChangeLog: * gdb.python/py-framefilter-mi.c (funca): Add casts. * gdb.python/py-framefilter.c.c (funca, func2): Add casts.
2020-09-18gdb.mi/var-cmd.c C++ifyPedro Alves2-1/+5
This adjusts gdb.mi/var-cmd.c to make it buildable as a C++ program. gdb/testsuite/ChangeLog: * gdb.mi/var-cmd.c (do_anonymous_type_tests): Add cast.
2020-09-18gdb.base/{exprs,ptype,ptype1,setvar,whatis}.c C++ifyPedro Alves6-11/+20
This adjusts: gdb.base/{exprs,ptype,ptype1,setvar,whatis}.c, to make them buildable as C++ programs. gdb/testsuite/ChangeLog: * gdb.base/exprs.c: Replace 'this' with 'self' throughout. * gdb.base/ptype.c: : Replace 'this' with 'self' throughout. (charfoo, intfoo): Define full prototype. * gdb.base/ptype1.c (charfoo): Define full prototype. * gdb.base/setvar.c: Replace 'this' with 'self' throughout. * gdb.base/whatis.c: Replace 'this' with 'self' throughout.
2020-09-18gdb.base/charset.{c,exp} C++ifyPedro Alves3-7/+19
Adjust gdb.base/charset.{c,exp} so that the testcase works when compiled as a C++ program. wchar_t is built-in in C++, so don't make a phony typedef. The "print /d" is so that we also get "1" instead of "true" in C++ mode. gdb/testsuite/ChangeLog: * gdb.base/charset.c [__cplusplus] (wchar_t, char16_t, char32_t): Don't define. (utf_32_string): Compile for both C and C++. * gdb.base/charset.exp: Use "print /d".
2020-09-18gdb.base/watchpoint.{c,exp}Pedro Alves3-4/+11
Adjust gdb.base/watchpoint.c so that it can be built as a C++ program. Fixes: gdb compile failed, src/gdb/testsuite/gdb.base/watchpoint.c:33:16: error: initializer-string for array of chars is too long [-fpermissive] 33 | char buf[30] = "testtesttesttesttesttesttestte"; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/gdb/testsuite/gdb.base/watchpoint.c:62:14: error: expected unqualified-id before 'nullptr' 62 | struct foo5 *nullptr; | ^~~~~~~ gdb/testsuite/ChangeLog: * gdb.base/watchpoint.c (buf): Make it 31 bytes. (nullptr): Rename to ... (null_ptr): ... this. * gdb.base/watchpoint.exp: Adjust to rename.
2020-09-18gdb.base/printcmds.c C++-ifyPedro Alves2-3/+8
Adjust gdb.base/printcmds.c to make it buildable as a C++ program. gdb/testsuite/ChangeLog: * gdb.base/printcmds.c (three, flag_enum_without_zero) (three_not_flag): Add casts.
2020-09-18gdb.base/examine-backward.exp C++ify and ClangPedro Alves3-4/+19
Adjust gdb.base/examine-backward.exp to let the testcase build and run as a C++ program, built with either G++ or Clang++. The change to use unsigned char instead of plain char is to avoid narrowing warnings: gdb compile failed, src/gdb/testsuite/gdb.base/examine-backward.c:55:1: error: narrowing conversion of '227' from 'int' to 'char' [-Wnarrowing] 55 | }; | ^ gdb/testsuite/ChangeLog: * gdb.base/examine-backward.c (Barrier, TestStrings): Now unsigned char array. (main): Add references to Barrier, TestStrings, TestStringsH and TestStringsW. * gdb.base/examine-backward.exp: Issue "set print asm-demangle on" and expect a full prototype in C++.
2020-09-18gdb.base/nested-addr.{c,exp} C++ifyPedro Alves3-2/+7
Adjust gdb.base/nested-addr.exp to let the testcase build and run as a C++ program. "print /d" is used so we get "= 1" instead of "= true" in C++ mode. gdb/testsuite/ChangeLog: * gdb.base/nested-addr.c (main): Add cast. * gdb.base/nested-addr.exp: Use "print /d".
2020-09-18gdb.base/break.exp C++ifyPedro Alves2-22/+33
Some adjustments to make gdb.base/break.exp work when compiled as a C++ program. Passes cleanly with Clang++, but not with G++. The latter puts a breakpoint at an unexpected line in one case. It seems like a bug that gcc and g++ behave differently here. gdb/testsuite/ChangeLog: * gdb.base/break.exp (func): New. Use it throughout when expecting a function name.
2020-09-18gdb.base/display.exp C++ifyPedro Alves2-0/+7
This makes the testcase work when compiled with C++ compiler. gdb/testsuite/ChangeLog: * gdb.base/display.exp: Issue "set print asm-demangle on".
2020-09-17gdb.base/find.exp C++ifyPedro Alves3-1/+11
This makes the testcase work when compiled with C++ compiler. We need #include <string.h> for memset. gdb/testsuite/ChangeLog: * gdb.base/find.c: Include <string.h>. (init_bufs): Add cast. * gdb.base/find.exp: Issue "set print asm-demangle on".
2020-09-16Match demangled name in "skip"Tom Tromey3-0/+67
PR gdb/26598 notes that, before commit bcfe6157ca28 ("Use the linkage name if it exists"), the "skip" command would match the demangled name of a symbol, but now only matches the linkage name. This patch fixes this regression. I looked at all calls to function_name_is_marked_for_skip, and only one used the linkage name. 2020-09-16 Tom Tromey <tromey@adacore.com> PR gdb/26598: * infrun.c (fill_in_stop_func): Use find_pc_partial_function_sym. gdb/testsuite/ChangeLog 2020-09-16 Tom Tromey <tromey@adacore.com> PR gdb/26598: * gdb.base/skipcxx.exp: New file. * gdb.base/skipcxx.cc: New file.
2020-09-16[gdb/testsuite] Fix gdb.dlang/watch-loc.exp on ppc64Tom de Vries3-3/+33
On ppc64, we run into: ... /tmp/ccKXURmw.s: Assembler messages:^M /tmp/ccKXURmw.s:99: Error: can't resolve \ `_Dmain_end' {.text section} - `_Dmain' {.opd section}^M compiler exited with status 1 ... The unresolvable entity comes from the .debug_aranges section hardcoded in watch-loc.c: ... " .4byte _Dmain \n" // Address " .4byte _Dmain_end - _Dmain \n" // Length ... where _Dmain is the function label for function _Dmain, and _Dmain_end is a label after function _Dmain: ... int _Dmain (void) { asm ("_Dmain_label: .globl _Dmain_label"); return 0; } asm ("_Dmain_end: .globl _Dmain_end"); ... The problem is that the two labels are not in the same section, because _Dmain ends up in the .opd section, which "contains the official procedure descriptors. A pointer to a function shall reference a procedure descriptor in this section." Fix this by using function_range instead to get the length. Also, fix the address part to not use _Dmain, but instead use the function start as returned by function_range. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-09-16 Tom de Vries <tdevries@suse.de> PR testsuite/26617 * gdb.dlang/watch-loc.c: Only add .debug_aranges if WITH_DEBUG_SECTIONS is defined. (xstr, str): New macro. (.debug_aranges): Use DMAIN_START_0/1/2 and DMAIN_LENGTH to get start and size of _Dmain. * gdb.dlang/watch-loc.exp: Pass DMAIN_START_0/1/2 and DMAIN_LENGTH using additional_flags.