aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
AgeCommit message (Collapse)AuthorFilesLines
2021-09-20[gdb/testsuite] Fix gdb.ada/big_packed_array.exp xfail for -m32Tom de Vries1-0/+10
With test-case gdb.ada/big_packed_array.exp and target board unix/-m32 I run into: ... (gdb) print bad^M $2 = (0 => 0 <repeats 24 times>, 160)^M (gdb) FAIL: gdb.ada/big_packed_array.exp: scenario=minimal: print bad ... The problem is that while the variable is an array of 196 bits (== 24.5 bytes), the debug information describes it as 25 unsigned char. This is PR gcc/101643, and the test-case contains an xfail for this, which catches only: ... (gdb) print bad^M $2 = (0 => 0 <repeats 25 times>)^M ... Fix this by updating the xfail pattern. Tested on x86_64-linux.
2021-09-18CTF: multi-CU and archive supportWeimin Pan16-8/+281
Now gdb is capable of debugging executable, which consists of multiple compilation units (CUs) with the CTF debug info. An executable could potentially have one or more archives, which, in CTF context, contain conflicting types. all changes were made in ctfread.c in which elfctf_build_psymtabs was modified to handle archives, via the ctf archive iterator and its callback build_ctf_archive_member and scan_partial_symbols was modified to scan archives, which are treated as subfiles, to build the psymtabs. Also changes were made to handle CTF's data object section and function info section which now share the same format of their contents - an array of type IDs. New functions ctf_psymtab_add_stt_entries, which is called by ctf_psymtab_add_stt_obj and ctf_psymtab_add_stt_func, and add_stt_entries, which is called by add_stt_obj and add_stt_func when setting up psymtabs and full symtab, respectively.
2021-09-18[gdb/testsuite] Fix gdb.server/server-kill.exp with -m32Tom de Vries1-4/+6
When running test-case gdb.server/server-kill.exp with target board unix/-m32, I run into: ... 0xf7fd6b20 in _start () from /lib/ld-linux.so.2^M (gdb) Executing on target: kill -9 13082 (timeout = 300) builtin_spawn -ignore SIGHUP kill -9 13082^M bt^M (gdb) FAIL: gdb.server/server-kill.exp: kill_pid_of=server: test_unwind_syms: bt ... The test-case expects the backtrace command to trigger remote communication, which then should result in a "Remote connection closed" or similar. However, no remote communication is triggered, because we hit the "Check that this frame is unwindable" case in get_prev_frame_always_1. We don't hit this problem in the kill_pid_of=inferior case, because there we run to main before doing the backtrace. Fix this by doing the same in the kill_pid_of=server case. Tested on x86_64-linux.
2021-09-18[gdb/ada] Handle artificial local symbolsTom de Vries1-0/+7
With current master and gcc 7.5.0/8.5.0, we have this timeout: ... (gdb) print s^M Multiple matches for s^M [0] cancel^M [1] s at src/gdb/testsuite/gdb.ada/interface/foo.adb:20^M [2] s at src/gdb/testsuite/gdb.ada/interface/foo.adb:?^M > FAIL: gdb.ada/interface.exp: print s (timeout) ... [ The FAIL doesn't reproduce with gcc 9.3.1. This difference in behaviour bisects to gcc commit d70ba0c10de. The FAIL with earlier gcc bisects to gdb commit ba8694b650b. ] The FAIL is caused by gcc generating this debug info describing a named artificial variable: ... <2><1204>: Abbrev Number: 31 (DW_TAG_variable) <1205> DW_AT_name : s.14 <1209> DW_AT_type : <0x1213> <120d> DW_AT_artificial : 1 <120d> DW_AT_location : 5 byte block: 91 e0 7d 23 18 \ (DW_OP_fbreg: -288; DW_OP_plus_uconst: 24) ... An easy way to fix this would be to simply not put named artificial variables into the symbol table. However, that causes regressions for Ada. It relies on being able to get the value from such variables, using a named reference. Fix this instead by marking the symbol as artificial, and: - ignoring such symbols in ada_resolve_variable, which fixes the FAIL - ignoring such ada symbols in do_print_variable_and_value, which prevents them from showing up in "info locals" Note that a fix for the latter was submitted here ( https://sourceware.org/pipermail/gdb-patches/2008-January/054994.html ), and this patch borrows from it. Tested on x86_64-linux. Co-Authored-By: Joel Brobecker <brobecker@adacore.com> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28180
2021-09-16[gdb/testsuite] Fix interrupted sleep in multi-threaded test-casesTom de Vries3-3/+14
When running test-case gdb.threads/continue-pending-status.exp with native, I have: ... (gdb) continue^M Continuing.^M PASS: gdb.threads/continue-pending-status.exp: attempt 0: continue for ctrl-c ^C^M Thread 1 "continue-pendin" received signal SIGINT, Interrupt.^M [Switching to Thread 0x7ffff7fc4740 (LWP 1276)]^M 0x00007ffff758e4c0 in __GI___nanosleep () at nanosleep.c:27^M 27 return SYSCALL_CANCEL (nanosleep, requested_time, remaining);^M (gdb) PASS: gdb.threads/continue-pending-status.exp: attempt 0: caught interrupt ... but with target board unix/-m32, I run into: ... (gdb) continue^M Continuing.^M PASS: gdb.threads/continue-pending-status.exp: attempt 0: continue for ctrl-c [Thread 0xf74aeb40 (LWP 31957) exited]^M [Thread 0xf7cafb40 (LWP 31956) exited]^M [Inferior 1 (process 31952) exited normally]^M (gdb) Quit^M ... The problem is that the sleep (300) call at the end of main is interrupted, which causes the inferior to exit before the ctrl-c can be send. This problem is described at "Interrupted System Calls" in the docs, and the suggested solution (using a sleep loop) indeed fixes the problem. Fix this instead using the more prevalent: ... alarm (300); ... while (1) sleep (1); ... which is roughly equivalent because the sleep is called at the end of main, but slightly better because it guards against hangs from the start rather than from the end of main. Likewise in gdb.base/watch_thread_num.exp. Likewise in gdb.btrace/enable-running.exp, but use the sleep loop there, because the sleep is not called at the end of main. Tested on x86_64-linux.
2021-09-15[gdb/testsuite] Use function_range in gdb.dwarf2/dw2-abs-hi-pc.expTom de Vries5-18/+41
When I run test-case gdb.dwarf2/dw2-abs-hi-pc.exp with gcc, we have: ... (gdb) break hello^M Breakpoint 1 at 0x4004c0: file dw2-abs-hi-pc-hello.c, line 24.^M (gdb) PASS: gdb.dwarf2/dw2-abs-hi-pc.exp: break hello ... but with clang, I run into: ... (gdb) break hello^M Breakpoint 1 at 0x4004e4^M (gdb) FAIL: gdb.dwarf2/dw2-abs-hi-pc.exp: break hello ... The problem is that the CU and function both have an empty address range: ... <0><d2>: Abbrev Number: 1 (DW_TAG_compile_unit) <108> DW_AT_name : dw2-abs-hi-pc-hello.c <123> DW_AT_low_pc : 0x4004e0 <127> DW_AT_high_pc : 0x4004e0 <1><12f>: Abbrev Number: 2 (DW_TAG_subprogram) <131> DW_AT_name : hello <13a> DW_AT_low_pc : 0x4004e0 <13e> DW_AT_high_pc : 0x4004e0 ... The address ranges are set like this in dw2-abs-hi-pc-hello-dbg.S: ... .4byte .hello_start /* DW_AT_low_pc */ .4byte .hello_end /* DW_AT_high_pc */ ... where the labels refer to dw2-abs-hi-pc-hello.c: ... extern int v; asm (".hello_start: .globl .hello_start\n"); void hello (void) { asm (".hello0: .globl .hello0\n"); v++; asm (".hello1: .globl .hello1\n"); } asm (".hello_end: .globl .hello_end\n"); ... Using asm labels in global scope is a known source of problems, as explained in the comment of proc function_range in gdb/testsuite/lib/dwarf.exp. Fix this by using function_range instead. Tested on x86_64-linux with gcc and clang-7 and clang-12.
2021-09-14[gdb/testsuite] Fix gdb_load_no_complaints with gnu-debuglinkTom de Vries1-2/+2
When running test-case gdb.dwarf2/dw2-ranges-psym-warning.exp with target board gnu-debuglink I run into: ... (gdb) file dw2-ranges-psym-warning^M Reading symbols from dw2-ranges-psym-warning...^M Reading symbols from .debug/dw2-ranges-psym-warning.debug...^M (gdb) FAIL: gdb.dwarf2/dw2-ranges-psym-warning.exp: No complaints ... Fix this by updating the regexp in gdb_load_no_complaints. Tested on x86_64-linux.
2021-09-14[gdb/symtab] Fix function range handling in psymtabsTom de Vries3-0/+213
Consider the test-case from this patch. We run into: ... (gdb) PASS: gdb.dwarf2/dw2-ranges-psym-warning.exp: continue bt^M warning: (Internal error: pc 0x4004b6 in read in psymtab, but not in symtab.)^M ^M warning: (Internal error: pc 0x4004b6 in read in psymtab, but not in symtab.)^M ^M warning: (Internal error: pc 0x4004b6 in read in psymtab, but not in symtab.)^M ^M warning: (Internal error: pc 0x4004b6 in read in psymtab, but not in symtab.)^M ^M warning: (Internal error: pc 0x4004b6 in read in psymtab, but not in symtab.)^M ^M warning: (Internal error: pc 0x4004b6 in read in psymtab, but not in symtab.)^M ^M read in psymtab, but not in symtab.)^M ^M )^M (gdb) FAIL: gdb.dwarf2/dw2-ranges-psym-warning.exp: bt ... This happens as follows. The function foo: ... <1><31>: Abbrev Number: 4 (DW_TAG_subprogram) <33> DW_AT_name : foo <37> DW_AT_ranges : 0x0 ... has these ranges: ... 00000000 00000000004004c1 00000000004004d2 00000000 00000000004004ae 00000000004004af 00000000 <End of list> ... which have a hole at at [0x4004af,0x4004c1). However, the address map of the partial symtabs incorrectly maps addresses in the hole (such as 0x4004b6 in the backtrace) to the foo CU. The address map of the full symbol table of the foo CU however does not contain the addresses in the hole, which is what the warning / internal error complains about. Fix this by making sure that ranges of functions are read correctly. The patch adds a bit to struct partial_die_info, in this hole (shown for x86_64-linux): ... /* 11: 7 | 4 */ unsigned int canonical_name : 1; /* XXX 4-byte hole */ /* 16 | 8 */ const char *raw_name; ... So there's no increase in size for 64-bit, but AFAIU there will be an increase for 32-bit. Tested on x86_64-linux. gdb/ChangeLog: 2021-08-10 Tom de Vries <tdevries@suse.de> PR symtab/28200 * dwarf2/read.c (struct partial_die_info): Add has_range_info and range_offset field. (add_partial_subprogram): Handle pdi->has_range_info. (partial_die_info::read): Set pdi->has_range_info. gdb/testsuite/ChangeLog: 2021-08-10 Tom de Vries <tdevries@suse.de> PR symtab/28200 * gdb.dwarf2/dw2-ranges-psym-warning-main.c: New test. * gdb.dwarf2/dw2-ranges-psym-warning.c: New test. * gdb.dwarf2/dw2-ranges-psym-warning.exp: New file.
2021-09-14[gdb/testsuite] Generate .debug_aranges in ↵Tom de Vries1-1/+6
gdb.dwarf2/locexpr-data-member-location.exp When running test-case gdb.dwarf2/locexpr-data-member-location.exp with target board cc-with-debug-names, all tests pass but we run into PR28261: ... (gdb) run ^M Starting program: locexpr-data-member-location ^M warning: Section .debug_names in locexpr-data-member-location-lib.so has \ abbreviation_table of size 1 vs. written as 37, ignoring .debug_names.^M ... Using a patch that fixes PR28261, the warning is gone, but we run into: ... FAIL: gdb.dwarf2/locexpr-data-member-location.exp: step into foo ... This is due a missing .debug_aranges contribution for the CU declared in gdb.dwarf2/locexpr-data-member-location.exp. Fix this by adding the missing .debug_aranges contribution. Tested on x86_64-linux.
2021-09-13[gdb/testsuite] Check for valid test nameTom de Vries1-0/+9
When running gdb.base/batch-exit-status.exp I noticed that the test name contains a newline: ... PASS: gdb.base/batch-exit-status.exp: : No such file or directory\.^M : No such file or directory\.: [lindex $result 2] == 0 ... Check for this in ::CheckTestNames::check, such that we have a warning: ... PASS: gdb.base/batch-exit-status.exp: : No such file or directory\.^M : No such file or directory\.: [lindex $result 2] == 0 WARNING: Newline in test name ... Tested on x86_64-linux.
2021-09-13[gdb/tdep] Fix exec check in gdb_print_insn_armTom de Vries1-7/+0
With a gdb build with --enable-targets=all we run into a KFAIL: ... KFAIL: gdb.gdb/unittest.exp: executable loaded: maintenance selftest, \ failed none (PRMS: gdb/27891) ... due to: ... Running selftest print_one_insn.^M Self test failed: arch armv8.1-m.main: self-test failed at \ disasm-selftests.c:165^M ... The test fails because we expect disassembling of one arm insn to consume 4 bytes and produce (using verbose = true in disasm-selftests.c): ... arm mov r0, #0 ... but instead the disassembler uses thumb mode and only consumes 2 bytes and produces: ... arm movs r0, r0 ... The failure does not show up in the "no executable loaded" variant because this code in gdb_print_insn_arm isn't triggered: ... if (current_program_space->exec_bfd () != NULL) info->flags |= USER_SPECIFIED_MACHINE_TYPE; ... and consequently we do this in print_insn: ... if ((info->flags & USER_SPECIFIED_MACHINE_TYPE) == 0) info->mach = bfd_mach_arm_unknown; ... and don't set force_thumb to true in select_arm_features. The code in gdb_print_insn_arm makes the assumption that the disassembly architecture matches the exec architecture, which in this case is incorrect, because the exec architecture is x86_64, and the disassembly architecture is armv8.1-m.main. Fix that by explicitly checking it: ... if (current_program_space->exec_bfd () != NULL && (current_program_space->exec_bfd ()->arch_info == gdbarch_bfd_arch_info (gdbarch))) ... This fixes the print_one_insn failure, so remove the KFAIL. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27891
2021-09-13[gdb/testsuite] Fix gdb.gdb/selftest.expTom de Vries1-1/+1
With a gdb build with CFLAGS "-O2 -g -flto=auto", I run into: ... #7 gdb_main (args=0x7fffffffd220) at src/gdb/main.c:1368^M #8 main (argc=<optimized out>, argv=<optimized out>) at src/gdb/gdb.c:32^M (gdb) FAIL: gdb.gdb/selftest.exp: backtrace through signal handler ... which means that this regexp in proc test_with_self fails: ... -re "#0.*(read|poll).*in main \\(.*\\) at .*gdb\\.c.*$gdb_prompt $" { ... The problem is that gdb_main has been inlined into main, and consequently the backtrace uses: ... #x <fn> ... ... instead of ... #x <address> in <fn> ... ... Fix this by updating the regexp to not require "in" before " main". Tested on x86_64-linux.
2021-09-13[gdb/testsuite] Fix test name in gdb.base/batch-exit-status.expTom de Vries1-6/+20
When running gdb.base/batch-exit-status.exp I noticed that the test name contains a newline: ... PASS: gdb.base/batch-exit-status.exp: : No such file or directory\.^M : No such file or directory\.: [lindex $result 2] == 0 ... The mistake is that I passed an output regexp argument to a parameter interpreted as testname prefix. Fix this by passing a testname prefix instead. Add support for checking output, to be able to handle the output regexp argument. Tested on x86_64-linux.
2021-09-12[gdb/testsuite] Set sysroot earlier in local-board.expTom de Vries1-1/+1
When running test-case gdb.base/batch-exit-status.exp for native, it passes. But with target board cc-with-debug-names, we run into (added missing double quotes for clarity): ... builtin_spawn $build/gdb/testsuite/../../gdb/gdb -nw -nx \ -data-directory $build/gdb/testsuite/../data-directory \ -iex "set height 0" -iex "set width 0" -ex "set sysroot" -batch ""^M : No such file or directory.^M PASS: gdb.base/batch-exit-status.exp: \ : No such file or directory\.: [lindex $result 2] == 0 FAIL: gdb.base/batch-exit-status.exp: \ : No such file or directory\.: [lindex $result 3] == $expect_status ... The difference between the passing and failing case is that with native we have (leaving out set height/width for brevity): ... $ gdb -batch ""; echo $? : No such file or directory. 1 ... and with target board cc-with-debug-names: ... $ gdb -ex "set sysroot" -batch ""; echo $? : No such file or directory. 0 ... The difference is expected. GDB returns the exit status of the last executed command. In the former case that's 'file ""', which fails. In the latter case, that's 'set sysroot', which succeeds. Fix this by setting sysroot using -iex instead of -ex in local-board.exp, such that we have the expected: ... $ gdb -iex "set sysroot" -batch ""; echo $? : No such file or directory. 1 ... Tested on x86_64-linux.
2021-09-10[gdb/testsuite] Reimplement gdb.gdb/python-selftest.exp as unittestTom de Vries1-30/+0
The test-case gdb.gdb/python-selftest.exp: - patches the gdb_python_initialized variable in gdb to 0 - checks that the output of a python command is "Python not initialized" Reimplement gdb.gdb/python-selftest.exp as unittest, using: - execute_command_to_string to capture the output - try/catch to catch the "Python not initialized" exception. Tested on x86_64-linux.
2021-09-10[gdb/testsuite] Fix DUPLICATE in gdb.base/global-var-nested-by-dso.expTom de Vries1-2/+2
Fix DUPLICATE in gdb.base/global-var-nested-by-dso.exp by naming commands more uniquely.
2021-09-10[gdb/testsuite] Fix DUPLICATE in gdb.base/skip-solib.expTom de Vries1-55/+49
Fix DUPLICATE in gdb.base/skip-solib.exp by using with_test_prefix. Also fix indentation style and long lines, remove outdated question/answer bits, and use multi_line.
2021-09-10[gdb/testsuite] Fix handling of nr_args < 3 in mi_gdb_testTom de Vries6-12/+43
The documentation of mi_gdb_test states that the command, pattern and message arguments are mandatory: ... # mi_gdb_test COMMAND PATTERN MESSAGE [IPATTERN] -- send a command to gdb; # test the result. ... However, this is not checked, and when mi_gdb_test is called with less than 3 arguments, it passes or fails silently. Fix this by using the following semantics: - if there are 1 or 2 arguments, use the command as the message. - if there is 1 argument, use ".*" as the pattern. - if there are no or too much arguments, error out. Fix a PATH issue in gdb.mi/mi-logging.exp, introduced by using the command as message. Fix a few other trivial-looking FAILs. There are 11 less trivial-looking FAILs left in gdb.mi in test-cases: - mi-nsmoribund.exp - mi-breakpoint-changed.exp - mi-break.exp. Tested on x86_64-linux.
2021-09-10[gdb/testsuite] Add string_list_to_regexpTom de Vries2-0/+78
A regexp pattern with escapes like this is hard to read: ... set re "~\"\[$\]$decimal = 1\\\\n\"\r\n\\^done" ... We can make it more readable by spacing out parts (which allows us to also use the curly braces where that's convenient): ... set re [list "~" {"} {[$]} $decimal " = 1" "\\\\" "n" {"} "\r\n" "\\^" "done"] set re [join $re ""] ... or by using string_to_regexp: ... set re [list \ [string_to_regexp {~"$}] \ $decimal \ [string_to_regexp " = 1\\n\"\r\n^done"]] set re [join $re ""] ... Note: we have to avoid applying string_to_list to decimal, which is already a regexp. Add a proc string_list_to_regexp to make it easy to do both: ... set re [list \ [string_list_to_regexp ~ {"} $] \ $decimal \ [string_list_to_regexp " = 1" \\ n {"} \r\n ^ done]] ... Also add a test-case gdb.testsuite/string_to_regexp.exp.
2021-09-10[gdb/testsuite] Handle unrecognized command line option in gdb_compile_testTom de Vries1-11/+24
When running the gdb testsuite with gnatmake-4.8, I get many fails of the following form: ... gcc: error: unrecognized command line option '-fgnat-encodings=all'^M gnatmake: "gdb.ada/O2_float_param/foo.adb" compilation error^M compiler exited with status 1 compilation failed: gcc ... gdb.ada/O2_float_param/foo.adb gcc: error: unrecognized command line option '-fgnat-encodings=all' gnatmake: "gdb.ada/O2_float_param/foo.adb" compilation error FAIL: gdb.ada/O2_float_param.exp: scenario=all: compilation foo.adb ... Fix this by marking the test unsupported instead, such that we have: ... UNSUPPORTED: gdb.ada/O2_float_param.exp: scenario=all: compilation foo.adb \ (unsupported option '-fgnat-encodings=all') ... Tested on x86_64-linux.
2021-09-09[gdb/testsuite] Fix gdb.base/coredump-filter-build-id.exp with older eu-unstripTom de Vries1-1/+2
On openSUSE Leap 42.3 with eu-unstrip 0.158, we run into: ... (gdb) PASS: gdb.base/coredump-filter-build-id.exp: save corefile First line of eu-unstrip: \ 0x400000+0x202000 f4ae8502bd6a14770182382316bc595e9dc6f08b@0x400284 - - [exe] FAIL: gdb.base/coredump-filter-build-id.exp: gcore dumped mapping with build-id ... The test expects an actual file name instead of '[exe]', but that only got introduced with eu-unstrip 0.161. Before it printed '[exe]' or '[pie]'. Fix this by updating the regexp. Tested on x86_64-linux.
2021-09-09[gdb/testsuite] Fix various issues in gdb.mi/mi-sym-info.expTom de Vries1-13/+34
I noticed this failure in gdb.mi/mi-sym-info.exp with gcc-4.8: ... FAIL: gdb.mi/mi-sym-info.exp: -symbol-info-functions --max-results 1 \ (unexpected output) ... due to function f2 instead of f3 being listed. AFAICT, this is caused by a difference in debug info: ... $ readelf -wi outputs/gdb.mi/mi-sym-info/mi-sym-info1.o \ | egrep "DW_AT_name.*: f[1-3]" <72> DW_AT_name : f1 <a1> DW_AT_name : f2 <d0> DW_AT_name : f3 ... vs: ... $ readelf -wi outputs/gdb.mi/mi-sym-info/mi-sym-info1.o \ | egrep "DW_AT_name.*: f[1-3]" <f4> DW_AT_name : f3 <123> DW_AT_name : f2 <152> DW_AT_name : f1 ... and the command documentation does not mention an imposed order, so fix this by allowing f2 as well. Doing this fix, it made sense to do a refactoring of adding f2_re and f3_re variables, in order to write (?:$f2_re|$f3_re), and I applied the same pattern overall. Furthermore, I found a silent FAIL due to calling mi_gdb_proc with 2 args, fix by updating the regexp. Then I ran with clang and found another FAIL, fix by updating the regexp. Tested on x86_64-linux with gcc-4.8.5, gcc-7.5.0, gcc-11.2.1, clang-7.0.1 and clang-12.0.1.
2021-09-09[gdb/testsuite] Reimplement gdb.gdb/complaints.exp as unittestTom de Vries1-137/+0
When building gdb with "-Wall -O2 -g -flto=auto", I run into: ... (gdb) call clear_complaints()^M No symbol "clear_complaints" in current context.^M (gdb) FAIL: gdb.gdb/complaints.exp: clear complaints ... The problem is that lto has optimized away the clear_complaints function and consequently the selftest doesn't work. Fix this by reimplementing the selftest as a unit test. Factor out two new functions: - void execute_fn_to_ui_file (struct ui_file *file, std::function<void(void)> fn); - std::string execute_fn_to_string (std::function<void(void)> fn, bool term_out); and use the latter to capture the complaints output. Tested on x86_64-linux.
2021-09-07gdb/python: new function to add values into GDB's historyAndrew Burgess1-0/+26
The guile API has (history-append! <value>) to add values into GDB's history list. There is currently no equivalent in the Python API. This commit adds gdb.add_history(<value>) to the Python API, this function takes <value> a gdb.Value (or anything that can be passed to the constructor of gdb.Value), and adds the value it represents to GDB's history list. The index of the newly added value is returned.
2021-09-07[gdb/testsuite] Handle internal-error in gdb_unloadTom de Vries1-0/+5
When reverting commit 5a20fadc841 and using gdb_unload instead of runto "bar" to trigger the internal-error in test-case gdb.dwarf2/locexpr-data-member-location.exp, we run into: ... ERROR: couldn't unload file in $gdb (timeout). ... and the test-case takes about 1 minute. Fix this by handling internal-error in gdb_unload, such that we have: ... ERROR: Couldn't unload file in $gdb (GDB internal error). ERROR: Could not resync from internal error (eof) ... within 2 seconds. Tested on x86_64-linux.
2021-09-07[gdb/testsuite] Handle internal-error in gdb_run_cmdTom de Vries1-0/+3
When reverting commit 5a20fadc841 the test-case gdb.dwarf2/locexpr-data-member-location.exp fails like this: ... FAIL: gdb.dwarf2/locexpr-data-member-location.exp: running to bar in runto \ (GDB internal error) ERROR: Could not resync from internal error (eof) ... and takes 1 minute to run. The long running time is caused by running into a timeout in gdb_run_cmd, at this point: ... (gdb) run ^M The program being debugged has been started already.^M Start it from the beginning? (y or n) y^M /home/vries/gdb_versions/devel/src/gdb/gdbtypes.c:5583: internal-error: \ Unexpected type field location kind: 4^M A problem internal to GDB has been detected,^M further debugging may prove unreliable.^M Quit this debugging session? (y or n) ... Fix this by detecting the internal-error in gdb_run_cmd. We don't handle it in gdb_run_cmd, but stash the gdb output back into the buffer using -notransfer, and let the caller proc runto deal with it. After the fix, the test-case just takes 2 seconds. Tested on x86_64-linux.
2021-09-06gdb: rename gdb/testsuite/gdb.arch/riscv64-unwind-prologue-with-ld-lw.cLancelot SIX2-1/+1
A previous commit added the gdb.arch/riscv64-unwind-prologue-with-ld-lw.exp testcase, but one of its associated file was named after a previous version of the test. This commit fixes this and makes sure that all the files linked to this testcase share the same prefix in the name. Tested on riscv64 GNU/Linux.
2021-09-06[gdb/testsuite] Handle eof in gdb_internal_error_resyncTom de Vries1-0/+4
Before commit 5a20fadc841 the test-case gdb.dwarf2/locexpr-data-member-location.exp fails like this: ... FAIL: gdb.dwarf2/locexpr-data-member-location.exp: running to bar in runto \ (GDB internal error) ERROR: : spawn id exp9 not open while executing "expect { -i exp9 -timeout 10 -re "Quit this debugging session\\? \\(y or n\\) $" { send_gdb "n\n" answer incr count } -re "Create ..." ("uplevel" body line 1) invoked from within "uplevel $body" NONE : spawn id exp9 not open ERROR: Could not resync from internal error (timeout) ... Fix the: ... ERROR: : spawn id exp9 not open ... by handling eof in gdb_internal_error_resync, such that we have instead: ... FAIL: gdb.dwarf2/locexpr-data-member-location.exp: running to bar in runto \ (GDB internal error) ERROR: Could not resync from internal error (eof) ... Tested on x86_64-linux.
2021-09-04[gdb/testsuite] Check avx support in gdb.arch/amd64-disp-step-avx.expTom de Vries4-83/+103
On a machine on Open Build Service I'm running into a SIGILL for test-case gdb.arch/amd64-disp-step-avx.exp: ... Program received signal SIGILL, Illegal instruction.^M test_rip_vex2 () at gdb.arch/amd64-disp-step-avx.S:40^M 40 vmovsd ro_var(%rip),%xmm0^M (gdb) FAIL: gdb.arch/amd64-disp-step-avx.exp: vex2: \ continue to test_rip_vex2_end ... The SIGILL happens when trying to execute the first avx instruction in the executable. I can't directly access the machine, but looking at the log for test-case gdb.arch/i386-avx.exp, it seems that there's no avx support: ... Breakpoint 1, main (argc=1, argv=0x7fffffffd6b8) at gdb.arch/i386-avx.c:68^M 68 if (have_avx ())^M (gdb) print have_avx ()^M $1 = 0^M ... Fix this by: - adding a gdb_caching_proc have_avx, similar to have_mpx, using the have_avx function from gdb.arch/i386-avx.c - using proc have_avx in both gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp and gdb/testsuite/gdb.arch/i386-avx.exp. Tested on my x86_64-linux laptop with avx support, where both test-cases pass. gdb/testsuite/ChangeLog: 2021-09-04 Tom de Vries <tdevries@suse.de> PR testsuite/26950 * gdb/testsuite/gdb.arch/i386-avx.c (main): Remove call to have_avx. (have_avx): Move ... * gdb/testsuite/lib/gdb.exp (have_avx): ... here. New proc. * gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp: Use have_avx. * gdb/testsuite/gdb.arch/i386-avx.exp: Same.
2021-09-03Test case reproducing PR28030 bugKevin Buettner4-0/+454
The original reproducer for PR28030 required use of a specific compiler version - gcc-c++-11.1.1-3.fc34 is mentioned in the PR, though it seems probable that other gcc versions might also be able to reproduce the bug as well. This commit introduces a test case which, using the DWARF assembler, provides a reproducer which is independent of the compiler version. (Well, it'll work with whatever compilers the DWARF assembler works with.) To the best of my knowledge, it's also the first test case which uses the DWARF assembler to provide debug info for a shared object. That being the case, I provided more than the usual commentary which should allow this case to be used as a template when a combo shared library / DWARF assembler test case is required in the future. I provide some details regarding the bug in a comment near the beginning of locexpr-dml.exp. This problem was difficult to reproduce; I found myself constantly referring to the backtrace while trying to figure out what (else) I might be missing while trying to create a reproducer. Below is a partial backtrace which I include for posterity. #0 internal_error ( file=0xc50110 "/ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/gdbtypes.c", line=5575, fmt=0xc520c0 "Unexpected type field location kind: %d") at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdbsupport/errors.cc:51 #1 0x00000000006ef0c5 in copy_type_recursive (objfile=0x1635930, type=0x274c260, copied_types=0x30bb290) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/gdbtypes.c:5575 #2 0x00000000006ef382 in copy_type_recursive (objfile=0x1635930, type=0x274ca10, copied_types=0x30bb290) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/gdbtypes.c:5602 #3 0x0000000000a7409a in preserve_one_value (value=0x24269f0, objfile=0x1635930, copied_types=0x30bb290) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/value.c:2529 #4 0x000000000072012a in gdbscm_preserve_values ( extlang=0xc55720 <extension_language_guile>, objfile=0x1635930, copied_types=0x30bb290) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/guile/scm-value.c:94 #5 0x00000000006a3f82 in preserve_ext_lang_values (objfile=0x1635930, copied_types=0x30bb290) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/extension.c:568 #6 0x0000000000a7428d in preserve_values (objfile=0x1635930) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/value.c:2579 #7 0x000000000082d514 in objfile::~objfile (this=0x1635930, __in_chrg=<optimized out>) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/objfiles.c:549 #8 0x0000000000831cc8 in std::_Sp_counted_ptr<objfile*, (__gnu_cxx::_Lock_policy)2>::_M_dispose (this=0x1654580) at /usr/include/c++/11/bits/shared_ptr_base.h:348 #9 0x00000000004e6617 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x1654580) at /usr/include/c++/11/bits/shared_ptr_base.h:168 #10 0x00000000004e1d2f in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=0x190bb88, __in_chrg=<optimized out>) at /usr/include/c++/11/bits/shared_ptr_base.h:705 #11 0x000000000082feee in std::__shared_ptr<objfile, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr (this=0x190bb80, __in_chrg=<optimized out>) at /usr/include/c++/11/bits/shared_ptr_base.h:1154 #12 0x000000000082ff0a in std::shared_ptr<objfile>::~shared_ptr ( this=0x190bb80, __in_chrg=<optimized out>) at /usr/include/c++/11/bits/shared_ptr.h:122 #13 0x000000000085ed7e in __gnu_cxx::new_allocator<std::_List_node<std::shared_ptr<objfile> > >::destroy<std::shared_ptr<objfile> > (this=0x114bc00, __p=0x190bb80) at /usr/include/c++/11/ext/new_allocator.h:168 #14 0x000000000085e88d in std::allocator_traits<std::allocator<std::_List_node<std::shared_ptr<objfile> > > >::destroy<std::shared_ptr<objfile> > (__a=..., __p=0x190bb80) at /usr/include/c++/11/bits/alloc_traits.h:531 #15 0x000000000085e50c in std::__cxx11::list<std::shared_ptr<objfile>, std::allocator<std::shared_ptr<objfile> > >::_M_erase (this=0x114bc00, __position= std::shared_ptr<objfile> (expired, weak count 1) = {get() = 0x1635930}) at /usr/include/c++/11/bits/stl_list.h:1925 #16 0x000000000085df0e in std::__cxx11::list<std::shared_ptr<objfile>, std::allocator<std::shared_ptr<objfile> > >::erase (this=0x114bc00, __position= std::shared_ptr<objfile> (expired, weak count 1) = {get() = 0x1635930}) at /usr/include/c++/11/bits/list.tcc:158 #17 0x000000000085c748 in program_space::remove_objfile (this=0x114bbc0, objfile=0x1635930) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/progspace.c:210 #18 0x000000000082d3ae in objfile::unlink (this=0x1635930) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/objfiles.c:487 #19 0x000000000082e68c in objfile_purge_solibs () at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/objfiles.c:875 #20 0x000000000092dd37 in no_shared_libraries (ignored=0x0, from_tty=1) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/solib.c:1236 #21 0x00000000009a37fe in target_pre_inferior (from_tty=1) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/target.c:2496 #22 0x00000000007454d6 in run_command_1 (args=0x0, from_tty=1, run_how=RUN_NORMAL) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/infcmd.c:437 I'll note a few points regarding this backtrace: Frame #1 is where the internal error occurs. It's caused by an unhandled case for FIELD_LOC_KIND_DWARF_BLOCK. The fix for this bug adds support for this case. Frame #22 - it's a partial backtrace - shows that GDB is attempting to (re)run the program. You can see the exact command sequence that was used for reproducing this problem in the PR (at https://sourceware.org/bugzilla/show_bug.cgi?id=28030), but in a nutshell, after starting the program and advancing to the appropriate source line, GDB was asked to step into libstdc++; a "finish" command was issued, returning a value. The fact that a value was returned is very important. GDB was then used to step back into libstdc++. A breakpoint was set on a source line in the library after which a "run" command was issued. Frame #19 shows a call to objfile_purge_solibs. It's aptly named. Frame #7 is a call to the destructor for one of the objfile solibs; it turned out to be the one for libstdc++. Frames #6 thru #3 show various value preservation frames. If you look at preserve_values() in gdb/value.c, the value history is preserved first, followed by internal variables, followed by values for the extension languages (python and guile).
2021-09-03[gdb/testsuite] Add untested case in gdb.gdb/complaints.expTom de Vries1-0/+20
When building gdb with "-Wall -O2 -g -flto=auto", I run into: ... (gdb) call clear_complaints()^M No symbol "clear_complaints" in current context.^M (gdb) FAIL: gdb.gdb/complaints.exp: clear complaints ... The problem is that lto has optimized away clear_complaints, and consequently the selftests cannot run. Fix this by: - using info function to detect presence of clear_complaints - handling the absence of clear_complaints by calling untested ... (gdb) UNTESTED: gdb.gdb/complaints.exp: \ Cannot find clear_complaints, skipping test ... Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-09-03 Tom de Vries <tdevries@suse.de> * gdb.gdb/complaints.exp: Use untested if clear_complaints cannot be found.
2021-09-03gdb: Enable finish command and inferior calls for _Float16 on amd64 and i386.Felix Willgerodt2-0/+101
Values of type _Float16 and _Float16 _Complex can now be used on CPUs with AVX512-FP16 support. Return values of those types are located in XMM0. Compiler support for gcc and clang is in progress, see e.g.: https://gcc.gnu.org/pipermail/gcc-patches/2021-July/574117.html gdb/ChangeLog: 2021-07-21 Felix Willgerodt <Felix.Willgerodt@intel.com> * amd64-tdep.c (amd64_classify): Classify _Float16 and _Float16 _Complex as AMD64_SSE. * i386-tdep.c (i386_extract_return_value): Read _Float16 and _Float16 _Complex from xmm0. gdb/testsuite/ChangeLog: 2021-07-21 Felix Willgerodt <Felix.Willgerodt@intel.com> * gdb.arch/x86-avx512fp16-abi.c: New file. * gdb.arch/x86-avx512fp16-abi.exp: New file.
2021-09-03Add half support for AVX512 register view.Felix Willgerodt3-0/+283
This adds support for the half datatype, FP16, to the AVX512 register printing. gdb/ChangeLog: 2020-07-21 Felix Willgerodt <Felix.Willgerodt@intel.com> * i386-tdep.c (i386_zmm_type) <v32_half>: New field. (i386_ymm_type) <v16_half>: New field. (i386_gdbarch_init): Add set_gdbarch_half_format. * features/i386/64bit-avx512.xml: Add half type. * features/i386/64bit-avx512.c: Regenerated. * features/i386/64bit-sse.xml: Add half type. * features/i386/64bit-sse.c: Regenerated. gdb/testsuite/ChangeLog: 2021-07-21 Felix Willgerodt <Felix.Willgerodt@intel.com> * gdb.arch/x86-avx512fp16.c: New file. * gdb.arch/x86-avx512fp16.exp: New file. * lib/gdb.exp (skip_avx512fp16_tests): New function.
2021-09-03gdb, i386: Enable AVX512-bfloat16 for i386 targets.Felix Willgerodt1-6/+6
Values of type bfloat16 can also be used on 32-bit targets, which was missed in the original enablement. This also adjusts the testcase to pass with "unix/-m32", where only the lower 8 AVX registers are available. gdb/ChangeLog: 2021-07-21 Felix Willgerodt <Felix.Willgerodt@intel.com> * features/i386/32bit-sse.xml: Add bfloat16 type. * features/i386/32bit-sse.c: Regenerated. gdb/testsuite/ChangeLog: 2021-07-21 Felix Willgerodt <Felix.Willgerodt@intel.com> * gdb.arch/x86-avx512bf16.exp: Only use x/z/ymm 0-7.
2021-09-03[gdb/testsuite] Add untested case in selftest_setupTom de Vries1-7/+9
When building gdb with "-Wall -O2 -g -flto=auto", I run into: ... FAIL: gdb.gdb/python-helper.exp: breakpoint in captured_main \ (got interactive prompt) FAIL: gdb.gdb/python-helper.exp: run until breakpoint at captured_main WARNING: Couldn't test self ... and similar in gdb.gdb/selftest.exp. The first FAIL in more detail: ... (gdb) break captured_main^M Function "captured_main" not defined.^M Make breakpoint pending on future shared library load? (y or [n]) n^M (gdb) FAIL: gdb.gdb/python-helper.exp: breakpoint in captured_main \ (got interactive prompt) ... The problem is that lto has optimized away the captured_main function and consequently the selftests dependent on that cannot run. Fix this by: - using gdb_breakpoint to detect failure to set the breakpoint - handling the failure to set a breakpoint by calling untested - not emitting the warning if we've already got untested such that we have: ... (gdb) UNTESTED: gdb.gdb/python-helper.exp: Cannot set breakpoint at \ captured_main, skipping testcase. ... gdb/testsuite/ChangeLog: 2021-09-02 Tom de Vries <tdevries@suse.de> * lib/selftest-support.exp: Emit untested when not being able to set breakpoint.
2021-09-01[gdb/testsuite] Fix dwo path in fission-*.STom de Vries8-20/+9
[ Using $build for /home/vries/gdb_versions/devel/build to make things a bit more readable. ] When using make check// to run test-case gdb.dwarf2/fission-base.exp: ... ( cd $build/gdb; make check//unix RUNTESTFLAGS="fission-base.exp" ) ... we run into: ... (gdb) file \ $build/gdb/testsuite.unix/outputs/gdb.dwarf2/fission-base/fission-base^M Reading symbols from \ $build/gdb/testsuite.unix/outputs/gdb.dwarf2/fission-base/fission-base...^M warning: Could not find DWO CU \ $build/gdb/testsuite.1/outputs/gdb.dwarf2/fission-base/fission-base.dwo \ (0x807060504030201) referenced by CU at offset 0xc7 [in module \ $build/gdb/testsuite.unix/outputs/gdb.dwarf2/fission-base/fission-base]^M ... The problem is that the executable refers to the dwo file using path name $build/gdb/testsuite.1/outputs/gdb.dwarf2/fission-base/fission-base.dwo, while the actual dwo file is at $build/gdb/testsuite.unix/outputs/gdb.dwarf2/fission-base/fission-base.dwo. This is caused by this trick in fission-base.S: ... #define XSTR(s) STR(s) #define STR(s) #s ... .asciz XSTR(DWO) # DW_AT_GNU_dwo_name ... and: ... $ echo | gcc -E -dD - | grep "define unix" ... I used this trick to avoid doing additional_flags=-DDWO=\"$dwo\", since I was concerned that there could be quoting issues. However, I've found other uses of this pattern, f.i. in gdb/testsuite/gdb.base/corefile-buildid.exp: ... additional_flags=-DSHLIB_NAME=\"$dlopen_lib\"] ... So, fix this by: - using additional_flags=-DDWO=\"$dwo\" and - using plain DWO instead of XSTR(DWO) Likewise in other gdb.dwarf2/fission*.exp test-cases. Tested on x86_64-linux, using make check//unix. gdb/testsuite/ChangeLog: 2021-09-01 Tom de Vries <tdevries@suse.de> PR testsuite/28298 * gdb.dwarf2/fission-base.S: Use DWO instead of XSTR(DWO). * gdb.dwarf2/fission-loclists-pie.S: Same. * gdb.dwarf2/fission-loclists.S: Same. * gdb.dwarf2/fission-reread.S: Same. * gdb.dwarf2/fission-base.exp: Use additional_flags=-DDWO=\"$dwo\". * gdb.dwarf2/fission-loclists-pie.exp: Same. * gdb.dwarf2/fission-loclists.exp: Same. * gdb.dwarf2/fission-reread.exp: Same.
2021-09-01[gdb/testsuite] Fix gdb.fortran/call-no-debug.exp symbol searchTom de Vries1-7/+12
On openSUSE Tumbleweed I ran into: ... (gdb) ptype outstring_func.part^M No symbol "outstring_func" in current context.^M (gdb) FAIL: gdb.fortran/call-no-debug.exp: ptype outstring_func.part ... while on openSUSE Leap 15.2 I have instead: ... (gdb) ptype string_func_^M type = <unknown return type> ()^M (gdb) PASS: gdb.fortran/call-no-debug.exp: ptype string_func_ ... The difference is caused by the result for "info function string_func", which is this for the latter: ... (gdb) info function string_func^M All functions matching regular expression "string_func":^M ^M Non-debugging symbols:^M 0x000000000040089c string_func_^M ... but this for the former: ... (gdb) info function string_func^M All functions matching regular expression "string_func":^M ^M Non-debugging symbols:^M 0x00000000004012bb string_func_^M 0x00007ffff7bac5b0 outstring_func.part^M 0x00007ffff7bb1a00 outstring_func.part^M ... The extra symbols are part of glibc: ... $ nm /lib64/libc.so.6 | grep string_func 00000000000695b0 t outstring_func.part.0 000000000006ea00 t outstring_func.part.0 ... If glibc debug info is installed, we get instead: ... (gdb) info function string_func^M All functions matching regular expression "string_func":^M ^M File /usr/src/debug/glibc-2.33-9.1.x86_64/stdio-common/vfprintf-internal.c:^M 236: static int outstring_func(int, size_t, const unsigned int *, FILE *);^M ^M File vfprintf-internal.c:^M 236: static int outstring_func(int, size_t, const unsigned char *, FILE *);^M ^M Non-debugging symbols:^M 0x00000000004012bb string_func_^M ... and the FAIL doesn't trigger. Fix this by calling "info function string_func" before starting the exec, such that only symbols of the exec are taken into account. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-09-01 Tom de Vries <tdevries@suse.de> * gdb.fortran/call-no-debug.exp: Avoid shared lib symbols for find_mangled_name calls.
2021-08-30[gdb/cli] Don't assert on empty string for core-fileTom de Vries1-0/+4
With current gdb we run into: ... $ gdb -batch '' '' : No such file or directory. pathstuff.cc:132: internal-error: \ gdb::unique_xmalloc_ptr<char> gdb_abspath(const char*): \ Assertion `path != NULL && path[0] != '\0'' failed. ... Fix this by skipping the call to gdb_abspath in core_target_open in the empty-string case, such that we have instead: ... $ gdb -batch '' '' : No such file or directory. : No such file or directory. $ ... Tested on x86_64-linux. gdb/ChangeLog: 2021-08-30 Tom de Vries <tdevries@suse.de> PR cli/28290 * gdb/corelow.c (core_target_open): Skip call to gdb_abspath in the empty-string case. gdb/testsuite/ChangeLog: 2021-08-30 Tom de Vries <tdevries@suse.de> PR cli/28290 * gdb.base/batch-exit-status.exp: Add gdb '' and gdb '' '' tests.
2021-08-30[gdb/testsuite] Improve argument syntax of proc arangeTom de Vries7-56/+150
The current syntax of proc arange is: ... proc arange { arange_start arange_length {comment ""} {seg_sel ""} } { ... and a typical call looks like: ... arange $start $len ... This style is somewhat annoying because if you want to specify the last parameter, you need to give the default values of all the other optional ones before as well: ... arange $start $len "" $seg_sel ... Update the syntax to: ... proc arange { options arange_start arange_length } { parse_options { { comment "" } { seg_sel "" } } ... such that a typical call looks like: ... arange {} $start $len ... and a call using seg_sel looks like: ... arange { seg_sel $seg_sel } $start $len ... Also update proc aranges, which already has an options argument, to use the new proc parse_options. Tested on x86_64-linux. Co-Authored-By: Simon Marchi <simon.marchi@polymtl.ca>
2021-08-27[gdb/testsuite] Generate .debug_aranges in gdb.dlang/watch-loc.expTom de Vries2-41/+8
Before commit 5ef670d81fd "[gdb/testsuite] Add dummy start and end CUs in dwarf assembly" we had in exec outputs/gdb.dlang/watch-loc/watch-loc a D compilation unit at offset 0xc7: ... Compilation Unit @ offset 0xc7: Length: 0x4c (32-bit) Version: 4 Abbrev Offset: 0x64 Pointer Size: 8 <0><d2>: Abbrev Number: 2 (DW_TAG_compile_unit) <d3> DW_AT_language : 19 (D) ... with a corresponding .debug_aranges entry: ... Offset into .debug_info: 0xc7 Pointer Size: 4 Segment Size: 0 Address Length 004004a7 0000000b 00000000 00000000 ... After that commit we have a dummy CU at offset 0xc7 and the D compilation unit at offset 0xd2: ... Compilation Unit @ offset 0xc7: Length: 0x7 (32-bit) Version: 4 Abbrev Offset: 0x64 Pointer Size: 8 Compilation Unit @ offset 0xd2: Length: 0x4c (32-bit) Version: 4 Abbrev Offset: 0x65 Pointer Size: 8 <0><dd>: Abbrev Number: 2 (DW_TAG_compile_unit) <de> DW_AT_language : 19 (D) ... while the .debug_aranges entry still points to 0xc7. The problem is that the test-case uses a hack (quoting from commit 75f06e9dc59): ... [ Note: this is a non-trivial test-case. The file watch-loc-dw.S contains a .debug_info section, but not an .debug_aranges section or any actual code. The file watch-loc.c contains code and a .debug_aranges section, but no other debug section. So, the intent for the .debug_aranges section in watch-loc.c is to refer to a compilation unit in the .debug_info section in watch-loc-dw.S. ] ... and adding the dummy CU caused that hack to stop working. Fix this by moving the generation of .debug_aranges from watch-loc.c to watch-loc.exp, such that we have: ... Offset into .debug_info: 0xd2 Pointer Size: 4 Segment Size: 0 Address Length 004004a7 0000000b 00000000 00000000 ... Tested on x86_64-linux.
2021-08-27[gdb/testsuite] Generate .debug_aranges entry for dummy CUTom de Vries1-1/+5
A best practise for DWARF [1] is to generate .debug_aranges entries for CUs even if they have no address range. Generate .debug_arange entries for the dummy CUs added by the DWARF assembler. Tested on x86_64-linux. [1] http://wiki.dwarfstd.org/index.php?title=Best_Practices
2021-08-27[gdb/testsuite] Add .debug_aranges in more test-casesTom de Vries3-3/+22
A couple of test-cases fail when run with target board cc-with-debug-names due to missing .debug_aranges entries for the CUs added by the dwarf assembler. Add a .debug_aranges entry for those CUs. Tested on x86_64-linux.
2021-08-27[gdb/testsuite] Support .debug_aranges in dwarf assemblyTom de Vries1-0/+153
Add a proc aranges such that we can generate .debug_aranges sections in dwarf assembly using: ... cu { label cu_label } { ... } aranges {} cu_label { arange $addr $len [<comment>] [$segment_selector] } ... Tested on x86_64-linux.
2021-08-27[gdb/testsuite] Add label option to proc cuTom de Vries1-0/+11
We can use current dwarf assembly infrastructure to declare a label that marks the start of the CU header: ... declare_labels header_start_cu_a _section ".debug_info" header_start_cu_a : cu {} { } _section ".debug_info" header_start_cu_b : cu {} { } ... on the condition that we switch to the .debug_info section before, which makes this style of use fragile. Another way to achieve the same is to use the label as generated by the cu proc itself: ... variable _cu_label cu {} { } set header_start_cu_a $_cu_label cu {} { } set header_start_cu_b $_cu_label ... but again that seems fragile given that adding a new CU inbetween will silently result in the wrong value for the label. Add a label option to proc cu such that we can simply do: ... cu { label header_start_cu_a } { } cu { label header_start_cu_b } { } ... Tested on x86_64-linux.
2021-08-23Fix a latent bug in dw2-ranges-overlap.expTom Tromey2-6/+13
dw2-ranges-overlap.exp creates a program where a psymtab has two address ranges, and a function without debug info whose address is between these two ranges. Then it sets a breakpoint on this function and runs to it, expecting that the language should remain "auto; c" when stopped. However, this test case also has a "main" function described (briefly) in the DWARF, and this function is given language C++. Also, a breakpoint stop sets the current language to the language that was used when setting the breakpoint. My new DWARF scanner decides that this "main" is the main program and sets the current language to C++ at startup, causing this test to fail. This patch fixes the test in a simple way, by introducing a new function that takes the place of "main" in the DWARF. I think this still exercises the original problem, but also avoids problems with my branch. It seemed safe to me to submit this separately.
2021-08-23[gdb] Fix 'not in executable format' error messageTom de Vries1-0/+32
With trying to load a non-executable file into gdb, we run into PR26880: ... $ gdb -q -batch test.c "0x7ffc87bfc8d0s": not in executable format: \ file format not recognized ... The problem is caused by using %ps in combination with the error function (note that confusingly, it does work in combination with the warning function). Fix this by using plain "%s" instead. Tested on x86_64-linux. gdb/ChangeLog: 2021-08-22 Tom de Vries <tdevries@suse.de> PR gdb/26880 * gdb/exec.c (exec_file_attach): Use %s instead of %ps in call to error function. gdb/testsuite/ChangeLog: 2021-08-22 Tom de Vries <tdevries@suse.de> PR gdb/26880 * gdb.base/non-executable.exp: New file.
2021-08-23[gdb/testsuite] Use compiler-generated instead of gas-generated stabsTom de Vries1-12/+3
The test-case gdb.dwarf2/dw2-ranges.exp is the only one in the gdb testsuite that uses gas-generated stabs. While the use seems natural alongside the use of gas-generated dwarf in the same test-case, there are a few known issues, filed on the gdb side as: - PR symtab/12497 - "stabs: PIE relocation does not work" - PR symtab/28221 - "[readnow, stabs] FAIL: gdb.dwarf2/dw2-ranges.exp: \ info line func" and on the gas side as: - PR gas/28233 - "[gas, --gstabs] Generate stabs more similar to gcc" The test-case contains a KFAIL for PR12497, but it's outdated and fails to trigger. The intention of the test-case is to test gas-generated dwarf, and using gcc-generated stabs instead of gas-generated stabs works fine. Supporting compiler-generated stabs is already a corner-case for gdb, and there's no current commitment/incentive to support/workaround gas-generated stabs, which can be considered a corner-case of a corner-case. Work around these problem by using compiler-generated stabs in the test-case. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-08-22 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/dw2-ranges.exp: Use compiler-generated stabs.
2021-08-23[gdb/testsuite] Add dummy start and end CUs in dwarf assemblyTom de Vries1-1/+16
Say one compiles a hello.c: ... $ gcc -g hello.c ... On openSUSE Leap 15.2 and Tumbleweed, the CU for hello.c is typically not the first in .debug_info, nor the last, due to presence of debug information in objects for sources like: - ../sysdeps/x86_64/start.S - init.c - ../sysdeps/x86_64/crti.S - elf-init.c - ../sysdeps/x86_64/crtn.S. On other systems, say ubuntu 18.04.5, the CU for hello.c is typically the first and the last in .debug_info. This difference has caused me to find some errors in the dwarf assembly using openSUSE, that didn't show up on other platforms. Force the same situation on other platforms by adding a dummy start and end CU. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-08-22 Tom de Vries <tdevries@suse.de> PR testsuite/28235 * lib/dwarf.exp (Dwarf::dummy_cu): New proc. (Dwarf::assemble): Add dummy start and end CU.
2021-08-23[gdb/testsuite] Fix dw2-ranges-psym.exp with -readnowTom de Vries1-1/+5
When running test-case gdb.dwarf2/dw2-ranges-psym.exp with target board -readnow, I run into: ... (gdb) file dw2-ranges-psym^M Reading symbols from dw2-ranges-psym...^M Expanding full symbols from dw2-ranges-psym...^M (gdb) set complaints 0^M (gdb) FAIL: gdb.dwarf2/dw2-ranges-psym.exp: No complaints ... The problem is that the regexp expects a gdb prompt immediately after the "Reading symbols" line. Fix this by updating the regexp. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-08-22 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (gdb_load_no_complaints): Update regexp to allow "Expanding full symbols" Line.
2021-08-16Notify observer of breakpoint auto-disablingPatrick Monnerat2-0/+64
As breakpoint_modified observer is currently notified upon breakpoint stop before handling auto-disabling when enable count is reached, the observer is never notified of the disabling. The problem affects: - The MI interpreter enabled= value when reporting =breakpoint-modified - A Python event handler for breakpoint_modified using the "enabled" member of its parameter - insight: breakpoint GUI window is not properly updated upon auto-disable This patch moves the observer notification after the auto-disabling code and implements corresponding tests for the MI and Python cases. Fixes https://sourceware.org/bugzilla/show_bug.cgi?id=23336 Change-Id: I0c50df4789334071e5390cb46b3ca0d4a7f83c61