aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2021-10-21Fix ARMv8.4 for hw watchpoint and breakpointAndrew Pinski2-0/+3
Just like my previoius patch for ARMv8.1 and v8.2 (49ecef2a7da2ee9df4), this adds ARMv8.4 debug arch as being compatible for hw watchpoint and breakpoints.
2021-10-21Refactor code slightly in nat/aarch64-linux-hw-point.c ↵Andrew Pinski1-6/+18
(aarch64_linux_get_debug_reg_capacity) Since the two locations which check the debug arch are the same code currently, it is a good idea to factor it out to a new function and just use that function from aarch64_linux_get_debug_reg_capacity. This is also the first step to support ARMv8.4 debug arch.
2021-10-21Fixes for gdb.mi/mi-break.expCarl Love1-4/+4
Update the expected pattern for two of the tests. Matching pattern \" doesn't work. Use .* to match the \* pattern.
2021-10-21[gdb/tui] Fix breakpoint display functionalityTom de Vries2-2/+38
In commit 81e6b8eb208 "Make tui-winsource not use breakpoint_chain", a loop body was transformed into a lambda function body: ... - for (bp = breakpoint_chain; - bp != NULL; - bp = bp->next) + iterate_over_breakpoints ([&] (breakpoint *bp) -> bool ... and consequently: - a continue was replaced by a return, and - a final return was added. Then in commit 240edef62f0 "gdb: remove iterate_over_breakpoints function", we transformed back to a loop body: ... - iterate_over_breakpoints ([&] (breakpoint *bp) -> bool + for (breakpoint *bp : all_breakpoints ()) ... but without reverting the changes that introduced the two returns. Consequently, breakpoints no longer show up in the tui source window. Fix this by reverting the changes that introduced the two returns. Build on x86_64-linux, tested with all .exp test-cases that contain tuiterm_env. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28483
2021-10-21Fix test step-and-next-inline.ccCarl Love2-2/+4
The test expect the runto_main to stop at the first line of the function. Depending on the optimization level, gdb may stop in the prolog or after the prolog at the first line. To ensure the test stops at the first line of main, have it explicitly stop at a break point on the first line of the function. On PowerPC, the test passes when compiled with no optimization but fails with all levels of optimization due to gdb stopping in the prolog.
2021-10-21Fix latent Ada bug when accessing field offsetsTom Tromey3-43/+75
The "add accessors for field (and call site) location" patch caused a gdb crash when running the internal AdaCore testsuite. This turned out to be a latent bug in ada-lang.c. The immediate cause of the bug is that find_struct_field unconditionally uses TYPE_FIELD_BITPOS. This causes an assert for a dynamic type. This patch fixes the problem by doing two things. First, it changes find_struct_field to use a dummy value for the field offset in the situation where the offset is not actually needed by the caller. This works because the offset isn't used in any other way -- only as a result. Second, this patch assures that calls to find_struct_field use a resolved type when the offset is needed. For value_tag_from_contents_and_address, this is done by resolving the type explicitly. In ada_value_struct_elt, this is done by passing nullptr for the out parameters when they are not needed (the second call in this function already uses a resolved type). Note that, while we believe the parent field probably can't occur at a variable offset, the patch still updates this code path, just in case. I've updated an existing test case to reproduce the crash. I'm checking this in.
2021-10-20Use std::string in print_one_catch_syscallTom Tromey1-13/+9
This changes print_one_catch_syscall to use std::string, removing a bit of manual memory management.
2021-10-20Use unique_xmalloc_ptr in breakpointTom Tromey6-63/+60
This changes struct breakpoint to use unique_xmalloc_ptr in a couple of spots, removing a bit of manual memory management.
2021-10-20Use unique_xmalloc_ptr in bp_locationTom Tromey2-10/+6
This changes struct bp_location to use a unique_xmalloc_ptr, removing a bit of manual memory management.
2021-10-20Use unique_xmalloc_ptr in watchpointTom Tromey4-25/+18
This changes struct watchpoint to use unique_xmalloc_ptr in a couple of places, removing a bit of manual memory management.
2021-10-20Use unique_xmalloc_ptr in exec_catchpointTom Tromey1-14/+5
This changes struct exec_catchpoint to use a unique_xmalloc_ptr, removing a bit of manual memory management.
2021-10-20Use unique_xmalloc_ptr in solib_catchpointTom Tromey1-12/+7
This changes struct solib_catchpoint to use a unique_xmalloc_ptr, removing a bit of manual memory management.
2021-10-20Make c-exp.y work with Bison 3.8+Christian Biesinger1-2/+3
When using Bison 3.8, we get this error: ../../gdb/c-exp.y:3455:1: error: 'void c_print_token(FILE*, int, YYSTYPE)' defined but not used [-Werror=unused-function] That's because bison 3.8 removed YYPRINT support: https://savannah.gnu.org/forum/forum.php?forum_id=10047 Accordingly, this patch only defines that function for Bison < 3.8. Change-Id: I3cbf2f317630bb72810b00f2d9b2c4b99fa812ad
2021-10-19[gdb/testsuite] Reimplement gdb.gdb/python-interrupts.exp as unittestTom de Vries4-50/+57
The test-case gdb.gdb/python-interrupts.exp: - runs to captured_command_loop - sets a breakpoint at set_active_ext_lang - calls a python command - verifies the command triggers the breakpoint - sends a signal and verifies the result The test-case is fragile, because (f.i. with -flto) it cannot be guaranteed that captured_command_loop and set_active_ext_lang are available for setting breakpoints. Reimplement the test-case as unittest, using: - execute_command_to_string to capture the output - try/catch to catch the "Error while executing Python code" exception - a new hook selftests::hook_set_active_ext_lang to raise the signal Tested on x86_64-linux.
2021-10-19Check index in type::fieldTom Tromey3-2/+3
This changes gdb to check the index that is passed to type::field. This caught one bug in the Ada code when running the test suite (actually I found the bug first, then realized that the check would have helped), so this patch fixes that as well. Regression tested on x86-64 Fedora 34.
2021-10-19Fix Rust lex selftest when using libiconvTom Tromey1-3/+10
The Rust lex selftest fails on our Windows build. I tracked this down to a use of UTF-32 as a parameter to convert_between_encodings. Here, iconv_open succeeds, but the actual conversion of a tab character fails with EILSEQ. I suspect that "UTF-32" is being interpreted as big-endian, as changing the call to use "UTF-32LE" makes it work. This patch implements this fix.
2021-10-19Fix format_pieces selftest on WindowsTom Tromey3-72/+57
The format_pieces selftest currently fails on Windows hosts. The selftest doesn't handle the "%ll" -> "%I64" rewrite that the formatter may perform, but also gdbsupport was missing a configure check for PRINTF_HAS_LONG_LONG. This patch fixes both issues.
2021-10-19Fix bug in dynamic type resolutionTom Tromey3-3/+35
A customer-reported problem led us to a bug in dynamic type resolution. resolve_dynamic_struct will recursively call resolve_dynamic_type_internal, passing it the sub-object for the particular field being resolved. While it offsets the address here, it does not also offset the "valaddr" -- the array of bytes describing the memory. This patch fixes the bug, by offsetting both. A test case is included that can be used to reproduce the bug.
2021-10-19Fix PR gdb/17917 Lookup build-id in remote binariesDaniel Black1-9/+12
GDB doesn't support loading debug files using build-id from remote target filesystems. This is the case when gdbserver attached to a process and a gdb target remote occurs over tcp. With this change we make build-id lookups possible: (gdb) show debug-file-directory The directory where separate debug symbols are searched for is "/usr/local/lib/debug". (gdb) set debug-file-directory /usr/lib/debug (gdb) show sysroot The current system root is "target:". (gdb) target extended-remote :46615 Remote debugging using :46615 warning: Can not parse XML target description; XML support was disabled at compile time Reading /usr/sbin/mariadbd from remote target... warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead. Reading /usr/sbin/mariadbd from remote target... Reading symbols from target:/usr/sbin/mariadbd... Reading /usr/lib/debug/.build-id/6e/0a874dca5a7ff831396ddc0785d939a192efe3.debug from remote target... Reading /usr/lib/debug/.build-id/6e/0a874dca5a7ff831396ddc0785d939a192efe3.debug from remote target... Reading symbols from target:/usr/lib/debug/.build-id/6e/0a874dca5a7ff831396ddc0785d939a192efe3.debug... Reading /lib/x86_64-linux-gnu/libpcre2-8.so.0 from remote target... ... Before this change, the lookups would have been (GNU gdb (GDB) Fedora 10.2-3.fc34): (gdb) target extended-remote :46615 Remote debugging using :46615 Reading /usr/sbin/mariadbd from remote target... warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead. Reading /usr/sbin/mariadbd from remote target... Reading symbols from target:/usr/sbin/mariadbd... Reading /usr/sbin/0a874dca5a7ff831396ddc0785d939a192efe3.debug from remote target... Reading /usr/sbin/.debug/0a874dca5a7ff831396ddc0785d939a192efe3.debug from remote target... Reading /usr/lib/debug//usr/sbin/0a874dca5a7ff831396ddc0785d939a192efe3.debug from remote target... Reading /usr/lib/debug/usr/sbin//0a874dca5a7ff831396ddc0785d939a192efe3.debug from remote target... Reading target:/usr/lib/debug/usr/sbin//0a874dca5a7ff831396ddc0785d939a192efe3.debug from remote target... Missing separate debuginfo for target:/usr/sbin/mariadbd Try: dnf --enablerepo='*debug*' install /usr/lib/debug/.build-id/6e/0a874dca5a7ff831396ddc0785d939a192efe3.debug (No debugging symbols found in target:/usr/sbin/mariadbd) Observe it didn't look for /usr/lib/debug/.build-id/6e/0a874dca5a7ff831396ddc0785d939a192efe3.debug on the remote target (where it is) and expected them to be installed locally. As a minor optimization, this also changes the build-id lookup such that if sysroot is empty, no second lookup of the same location is performed. Change-Id: I5181696d271c325a25a0805a8defb8ab7f9b3f55 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17917
2021-10-18CTF: incorrect underlying type setting for enumeration typesWeimin Pan6-36/+42
A bug was filed against the incorrect underlying type setting for an enumeration type, which was caused by a copy and paste error. This patch fixes the problem by setting it by calling objfile_int_type, which was originally dwarf2_per_objfile::int_type, with ctf_type_size bits. Also add error checking on ctf_func_type_info call.
2021-10-14Powerpc: Add support for openat and fstatat syscallsCarl Love1-2/+11
[gdb] update ppc-linux-tdep.c Add argument to ppc_canonicalize_syscall for the wordsize. Add syscall entries for the openat and fstatat system calls.
2021-10-14[gdb/testsuite] Add .debug_loc support in dwarf assemblerTom de Vries3-0/+257
Add .debug_loc support in the dwarf assembler, and use it in new test-case gdb.dwarf2/loc-sec-offset.exp (which is based on gdb.dwarf2/loclists-sec-offset.exp). Tested on x86_64-linux.
2021-10-13[gdb/exp] Improve <error reading variable> messageTom de Vries3-1/+75
When printing a variable x in a subroutine foo: ... subroutine foo (x) integer(4) :: x (*) x(3) = 1 end subroutine foo ... where x is an array with unknown bounds, we get: ... $ gdb -q -batch outputs/gdb.fortran/array-no-bounds/array-no-bounds \ -ex "break foo" \ -ex run \ -ex "print x" Breakpoint 1 at 0x4005cf: file array-no-bounds.f90, line 18. Breakpoint 1, foo (x=...) at array-no-bounds.f90:18 18 x(3) = 1 $1 = <error reading variable> ... Improve the error message by printing the details of the error, such that we have instead: ... $1 = <error reading variable: failed to get range bounds> ... This is a change in gdb/valprint.c, and grepping through the sources reveals that this is a common pattern. Tested on x86_64-linux.
2021-10-13PPC fix for stfiwx instruction (and additional stores with primary opcode of 31)Carl Love1-4/+4
[gdb] Fix address being recorded in rs6000-tdep.c, ppc_process_record_op31. The GDB record function was recording the variable addr that was passed in rather than the calculated effective address (ea) by the ppc_process_record_op31 function.
2021-10-13gdb: improve error reporting from the disassemblerAndrew Burgess2-6/+15
If the libopcodes disassembler returns a negative value then this indicates that the disassembly failed for some reason. In disas.c, in the function gdb_disassembler::print_insn we can see how this is handled; when we get a negative value back, we call the memory_error function, which throws an exception. The problem here is that the address used in the memory_error call is gdb_disassembler::m_err_memaddr, which is set in gdb_disassembler::dis_asm_memory_error, which is called from within the libopcodes disassembler through the disassembler_info::memory_error_func callback. However, for this to work correctly, every time the libopcodes disassembler returns a negative value, the libopcodes disassembler must have first called the memory_error_func callback. My first plan was to make m_err_memaddr a gdb::optional, and assert that it always had a value prior to calling memory_error, however, a quick look in opcodes/*-dis.c shows that there _are_ cases where a negative value is returned without first calling the memory_error_func callback, for example in arc-dis.c and cris-dis.c. Now, I think that a good argument can be made that these disassemblers must therefore be broken, except for the case where we can't read memory, we should always be able to disassemble the memory contents to _something_, even if it's just '.word 0x....'. However, I certainly don't plan to go and fix all of the disassemblers. What I do propose to do then, is make m_err_memaddr a gdb::optional, but now, instead of always calling memory_error, I add a new path which just calls error complaining about an unknown error. This new path is only used if m_err_memaddr doesn't have a value (indicating that the memory_error_func callback was not called). To test this I just augmented one of the disassemblers to always return -1, before this patch I see this: Dump of assembler code for function main: 0x000101aa <+0>: Cannot access memory at address 0x0 And after this commit I now see: Dump of assembler code for function main: 0x000101aa <+0>: unknown disassembler error (error = -1) This doesn't really help much, but that's because there's no way to report non memory errors out of the disasembler, because, it was not expected that the disassembler would ever report non memory errors.
2021-10-13[gdb/testsuite] Fix gdb.fortran/call-no-debug.exp with native-gdbserverTom de Vries1-1/+3
When running test-case gdb.fortran/call-no-debug.exp with target board native-gdbserver, I run into: ... (gdb) PASS: gdb.fortran/call-no-debug.exp: print string_func_ (&'abcdefg', 3) call (integer) string_func_ (&'abcdefg', 3)^M $2 = 0^M (gdb) FAIL: gdb.fortran/call-no-debug.exp: call (integer) string_func_ (&'abcdefg', 3) ... The problem is that gdb_test is used to match inferior output. Fix this by using gdb_test_stdio. Tested on x86_64-linux.
2021-10-13[gdb/testsuite] Require use_gdb_stub == 0 where appropriateTom de Vries6-17/+35
When running with target board native-gdbserver, we run into a number of FAILs due to use of the start command (and similar), which is not supported when use_gdb_stub == 1. Fix this by: - requiring use_gdb_stub == 0 for the entire test-case, or - guarding some tests in the test-case with use_gdb_stub == 0. Tested on x86_64-linux.
2021-10-13[gdb/testsuite] Fix test name in gdb.python/python.expTom de Vries1-4/+11
When running test-case gdb.python/python.exp, we have: ... PASS: gdb.python/python.exp: starti via gdb.execute, not from tty PASS: gdb.python/python.exp: starti via interactive input ... The two tests are instances of the same test, with different values for starti command argument from_tty, so it's strange that the test names are so different. This is due to using a gdb_test nested in a gdb_test_multiple, with the inner one using a different test name than the outer one. [ That could still make sense if both produced passes, but that's not the case here. ] Fix this by using $gdb_test_name, such that we have: ... PASS: gdb.python/python.exp: starti via gdb.execute, not from tty PASS: gdb.python/python.exp: starti via gdb.execute, from tty ... Also make this more readable by using variables. Tested on x86_64-linux.
2021-10-13[gdb/testsuite] Fix gdb.base/batch-exit-status.exp with native-gdbserverTom de Vries1-1/+1
When running test-case gdb.base/batch-exit-status.exp with target board native-gdbserver, I 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 auto-connect-native-target off" \ -iex "set sysroot" -batch ""^M : No such file or directory.^M PASS: gdb.base/batch-exit-status.exp: 1x: \ No such file or directory: [lindex $result 2] == 0 FAIL: gdb.base/batch-exit-status.exp: 1x: \ No such file or directory: [lindex $result 3] == $expect_status ... As in commit a02a90c114c "[gdb/testsuite] Set sysroot earlier in local-board.exp", the problem is the use of -ex for "set auto-connect-native-target off", which makes that the last command to be executed, and consequently determines the return status. Fix this by using -iex instead. Tested on x86_64-linux.
2021-10-13[gdb/testsuite] Remove quit in gdb.arch/i386-mpx.expTom de Vries1-2/+0
When running test-case gdb.arch/i386-mpx.exp with target board native-gdbserver, I run into: ... (gdb) PASS: gdb.arch/i386-mpx.exp: verify size for bnd0 Remote debugging from host ::1, port 42328^M quit^M A debugging session is active.^M ^M Inferior 1 [process 19679] will be killed.^M ^M Quit anyway? (y or n) monitor exit^M Please answer y or n.^M A debugging session is active.^M ^M Inferior 1 [process 19679] will be killed.^M ^M Quit anyway? (y or n) WARNING: Timed out waiting for EOF in server after monitor exit ... The problem is that the test-case sends a quit at the end (without verifying the result of this in any way): ... send_gdb "quit\n" ... Fix this by removing the quit. Tested on x86_64-linux.
2021-10-11[ARM] Add support for M-profile MVE extensionSrinath Parvathaneni9-4/+206
This patch adds support for the M-profile MVE extension, which includes the following: - New M-profile XML feature m-profile-mve - MVE vector predication status and control register (VPR) - p0 pseudo register (contained in the VPR) - q0 ~ q7 pseudo vector registers - New feature bits - Documentation update Pseudo register p0 is the least significant bits of vpr and can be accessed as $p0 or displayed through $vpr. For more information about the register layout, please refer to [1]. The q0 ~ q7 registers map back to the d0 ~ d15 registers, two d registers per q register. The register dump looks like this: (gdb) info reg all r0 0x0 0 r1 0x0 0 r2 0x0 0 r3 0x0 0 r4 0x0 0 r5 0x0 0 r6 0x0 0 r7 0x0 0 r8 0x0 0 r9 0x0 0 r10 0x0 0 r11 0x0 0 r12 0x0 0 sp 0x0 0x0 <__Vectors> lr 0xffffffff -1 pc 0xd0c 0xd0c <Reset_Handler> xpsr 0x1000000 16777216 d0 0 (raw 0x0000000000000000) d1 0 (raw 0x0000000000000000) d2 0 (raw 0x0000000000000000) d3 0 (raw 0x0000000000000000) d4 0 (raw 0x0000000000000000) d5 0 (raw 0x0000000000000000) d6 0 (raw 0x0000000000000000) d7 0 (raw 0x0000000000000000) d8 0 (raw 0x0000000000000000) d9 0 (raw 0x0000000000000000) d10 0 (raw 0x0000000000000000) d11 0 (raw 0x0000000000000000) d12 0 (raw 0x0000000000000000) d13 0 (raw 0x0000000000000000) d14 0 (raw 0x0000000000000000) d15 0 (raw 0x0000000000000000) fpscr 0x0 0 vpr 0x0 [ P0=0 MASK01=0 MASK23=0 ] s0 0 (raw 0x00000000) s1 0 (raw 0x00000000) s2 0 (raw 0x00000000) s3 0 (raw 0x00000000) s4 0 (raw 0x00000000) s5 0 (raw 0x00000000) s6 0 (raw 0x00000000) s7 0 (raw 0x00000000) s8 0 (raw 0x00000000) s9 0 (raw 0x00000000) s10 0 (raw 0x00000000) s11 0 (raw 0x00000000) s12 0 (raw 0x00000000) s13 0 (raw 0x00000000) s14 0 (raw 0x00000000) s15 0 (raw 0x00000000) s16 0 (raw 0x00000000) s17 0 (raw 0x00000000) s18 0 (raw 0x00000000) s19 0 (raw 0x00000000) s20 0 (raw 0x00000000) s21 0 (raw 0x00000000) s22 0 (raw 0x00000000) s23 0 (raw 0x00000000) s24 0 (raw 0x00000000) s25 0 (raw 0x00000000) s26 0 (raw 0x00000000) s27 0 (raw 0x00000000) s28 0 (raw 0x00000000) s29 0 (raw 0x00000000) s30 0 (raw 0x00000000) s31 0 (raw 0x00000000) q0 {u8 = {0x0 <repeats 16 times>}, u16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, u32 = {0x0, 0x0, 0x0, 0x0}, u64 = {0x0, 0x0}, f32 = {0x0, 0x0, 0x0, 0x0}, f64 = {0x0, 0x0}} q1 {u8 = {0x0 <repeats 16 times>}, u16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, u32 = {0x0, 0x0, 0x0, 0x0}, u64 = {0x0, 0x0}, f32 = {0x0, 0x0, 0x0, 0x0}, f64 = {0x0, 0x0}} q2 {u8 = {0x0 <repeats 16 times>}, u16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, u32 = {0x0, 0x0, 0x0, 0x0}, u64 = {0x0, 0x0}, f32 = {0x0, 0x0, 0x0, 0x0}, f64 = {0x0, 0x0}} q3 {u8 = {0x0 <repeats 16 times>}, u16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, u32 = {0x0, 0x0, 0x0, 0x0}, u64 = {0x0, 0x0}, f32 = {0x0, 0x0, 0x0, 0x0}, f64 = {0x0, 0x0}} q4 {u8 = {0x0 <repeats 16 times>}, u16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, u32 = {0x0, 0x0, 0x0, 0x0}, u64 = {0x0, 0x0}, f32 = {0x0, 0x0, 0x0, 0x0}, f64 = {0x0, 0x0}} q5 {u8 = {0x0 <repeats 16 times>}, u16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, u32 = {0x0, 0x0, 0x0, 0x0}, u64 = {0x0, 0x0}, f32 = {0x0, 0x0, 0x0, 0x0}, f64 = {0x0, 0x0}} q6 {u8 = {0x0 <repeats 16 times>}, u16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, u32 = {0x0, 0x0, 0x0, 0x0}, u64 = {0x0, 0x0}, f32 = {0x0, 0x0, 0x0, 0x0}, f64 = {0x0, 0x0}} q7 {u8 = {0x0 <repeats 16 times>}, u16 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, u32 = {0x0, 0x0, 0x0, 0x0}, u64 = {0x0, 0x0}, f32 = {0x0, 0x0, 0x0, 0x0}, f64 = {0x0, 0x0}} p0 0x0 0 Built and regtested with a simulator. [1] https://developer.arm.com/documentation/ddi0553/bn Co-Authored-By: Luis Machado <luis.machado@linaro.org>
2021-10-11[ARM] Refactor pseudo register numberingLuis Machado2-45/+115
The pseudo register handling for ARM uses some hardcoded constants to determine types and names. In preparation to the upcoming MVE support patch (that will add another pseudo register), this patch refactors and reorganizes things in order to simplify handling of future pseudo registers. We keep track of the first pseudo register number in a group and the number of pseudo registers in that group. Right now we only have the S and Q pseudo registers.
2021-10-11[ARM] Small refactoring of arm gdbarch initializationLuis Machado1-11/+11
This is in preparation to MVE support, where we will define another pseudo register. We need to define the pseudo register numbers *after* accounting for all the registers in the XML description, so move the call to tdesc_use_registers up. If we don't do it, GDB's register count won't consider registers contained in the XML but ignored by GDB, throwing the register numbering off.
2021-10-11[ARM] Refactor some constantsLuis Machado1-4/+10
In preparation for the MVE extension patch, this one refactors some of the register-related constants we have for ARM. Basically I'm separating counting constants from numbering constants. For example, ARM_A1_REGNUM is a numbering constant, whereas ARM_NUM_ARG_REGS is a counting constant.
2021-10-11[gdb/testsuite] Fix FAIL in gdb.mi/mi-var-child-f.expTom de Vries7-0/+41
When running test-case gdb.mi/mi-var-child-f.exp on openSUSE Tumbleweed (with glibc 2.34) I run into: ... (gdb) ^M PASS: gdb.mi/mi-var-child-f.exp: mi runto prog_array Expecting: ^(-var-create array \* array[^M ]+)?(\^done,name="array",numchild="[0-9]+",value=".*",type=.*,has_more="0"[^M ]+[(]gdb[)] ^M [ ]*) -var-create array * array^M &"Attempt to use a type name as an expression.\n"^M ^error,msg="-var-create: unable to create variable object"^M (gdb) ^M FAIL: gdb.mi/mi-var-child-f.exp: create local variable array (unexpected output) ... The problem is that the name array is used both: - as the name for a local variable - as the name of a type in glibc, in file malloc/dynarray-skeleton.c, as included by nss/nss_files/files-hosts.c. Fix this by ignoring the shared lib symbols. Likewise in a couple of other fortran tests. Tested on x86_64-linux.
2021-10-11[gdb/testsuite] Fix double debug info in gdb.dwarf2/dw2-ref-missing-frame.expTom de Vries1-3/+5
A mistake slipped in in commit a5ea23036d8 "[gdb/testsuite] Use function_range in gdb.dwarf2/dw2-ref-missing-frame.exp". Before the commit the main file was compiled with debug info, and the two others not: ... if {[prepare_for_testing_full "failed to prepare" \ [list $testfile {} $srcfile {} $srcfuncfile {} \ $srcmainfile debug]]} { ... After the commit, all were compiled with debug info, and consequently, there are two versions of debug info for $srcfuncfile. This shows up as a FAIL when running the test-case with target boards readnow and cc-with-debug-names. Fix this by using prepare_for_testing_full, as before. Tested on x86_64-linux. Fixes: a5ea23036d8 ("[gdb/testsuite] Use function_range in gdb.dwarf2/dw2-ref-missing-frame.exp")
2021-10-11[gdb/testsuite] Use require for ensure_gdb_indexTom de Vries6-15/+9
Replace: ... if { [ensure_gdb_index $binfile] == -1 } { return -1 } ... with: ... require {ensure_gdb_index $binfile} != -1 ... and consequently, add a missing UNTESTED message. Tested on x86_64-linux, both with native and target board readnow.
2021-10-11[gdb/testsuite] Handle readnow in ensure_gdb_indexTom de Vries1-0/+9
When running test-case gdb.base/with-mf.exp with target board readnow, I run into: ... FAIL: gdb.base/with-mf.exp: check if index present ... This is since commit 6010fb0c49e "[gdb/testsuite] Fix full buffer in gdb.rust/dwindex.exp". Before that commit, the proc ensure_gdb_index would treat the line: ... .gdb_index: faked for "readnow"^M ... as proof that an index is already present (which is incorrect). Now, instead it generates aforementioned FAIL and continues to generate an index. Fix this by explicitly handling the readnow case in proc ensure_gdb_index, such that we bail out instead. Tested on x86_64-linux.
2021-10-11[gdb/testsuite] Fix gdb.dwarf2/gdb-add-index-symlink.expTom de Vries1-0/+13
The test-case gdb.dwarf2/gdb-add-index-symlink.exp interpretes a failure to add an index as a failure to add an index for a symlink: ... if { [ensure_gdb_index $symlink] == -1 } { fail "Unable to call gdb-add-index with a symlink to a symfile" return -1 } ... However, it's possible that the gdb-add-index also fails with a regular file. Add a check for that situation. Tested on x86_64-linux.
2021-10-11[gdb/testsuite] Add proc require in lib/gdb.expTom de Vries5-20/+38
Add a new proc require in lib/gdb.exp, and use it to shorten: ... if { [gdb_skip_xml_test] } { # Valgrind gdbserver requires gdb with xml support. untested "missing xml support" return 0 } ... into: ... require gdb_skip_xml_test 0 ... Tested on x86_64-linux, both with and without a trigger patch that forces gdb_skip_xml_test to return 1.
2021-10-09[gdb] Make execute_command_to_string return string on throwTom de Vries7-20/+50
The pattern for using execute_command_to_string is: ... std::string output; output = execute_fn_to_string (fn, term_out); ... This results in a problem when using it in a try/catch: ... try { output = execute_fn_to_string (fn, term_out) } catch (const gdb_exception &e) { /* Use output. */ } ... If an expection was thrown during execute_fn_to_string, then the output remains unassigned, while it could be worthwhile to known what output was generated by gdb before the expection was thrown. Fix this by returning the string using a parameter instead: ... execute_fn_to_string (output, fn, term_out) ... Also add a variant without string parameter, to support places where the function is used while ignoring the result: ... execute_fn_to_string (fn, term_out) ... Tested on x86_64-linux.
2021-10-09[gdb/testsuite] Add check-readmoreTom de Vries5-21/+166
Consider the gdb output: ... 27 return SYSCALL_CANCEL (nanosleep, requested_time, remaining);^M (gdb) ^M Thread 2 "run-attach-whil" stopped.^M ... When trying to match the gdb prompt using gdb_test which uses '$gdb_prompt $', it may pass or fail. This sort of thing needs to be fixed (see commit b0e2f96b56b), but there's currently no way to reliably find this type of FAILs. We have check-read1, but that one actually make the test pass reliably. We need something like the opposite of check-read1: something that makes expect read a bit slower, or more exhaustively. Add a new test target check-readmore that implements this. There are two methods of implementing this in read1.c: - the first method waits a bit before doing a read - the second method does a read and then decides whether to return or to wait a bit and do another read, and so on. The second method is potentially faster, has less risc of timeout and could potentially detect more problems. The first method has a simpler implementation. The second method is enabled by default. The default waiting period is 10 miliseconds. The first method can be enabled using: ... $ export READMORE_METHOD=1 ... and the waiting period can be specified in miliseconds using: ... $ export READMORE_SLEEP=9 ... Also a log file can be specified using: ... $ export READMORE_LOG=$(pwd -P)/LOG ... Tested on x86_64-linux. Testing with check-readmore showed these regressions: ... FAIL: gdb.base/bp-cmds-continue-ctrl-c.exp: run: stop with control-c (continue) FAIL: gdb.base/bp-cmds-continue-ctrl-c.exp: attach: stop with control-c (continue) ... I have not been able to find a problem in the test-case, and I think it's the nature of both the test-case and readmore that makes it run longer. Make these pass by increasing the alarm timeout from 60 to 120 seconds. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27957
2021-10-09[gdb/testsuite] Fix fortran module tests with stressed cpuTom de Vries3-0/+17
When running these test-cases: - gdb.fortran/info-modules.exp - gdb.fortran/module.exp - gdb.mi/mi-fortran-modules.exp in conjunction with: ... $ stress -c $(($(cat /proc/cpuinfo | grep -c "^processor") + 1)) ... I run into timeouts. Fix this by using: - "set auto-solib-add off" to avoid symbols of shared libs (which doesn't work for libc, now that libpthread_name_p has been updated to match libc) - "nosharedlibrary" to avoid symbols of libc Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28133
2021-10-09[gdb/testsuite] Fix gdb.base/info-types-c++.exp with stressed cpuTom de Vries1-0/+1
When running test-case gdb.base/info-types-c++.exp in conjunction with: ... $ stress -c $(($(cat /proc/cpuinfo | grep -c "^processor") + 1)) ... we get: ... FAIL: gdb.base/info-types-c++.exp: info types (timeout) ... Fix this by setting auto-solib-add to off. Tested on x86_64-linux.
2021-10-08[gdb/testsuite] Fix gdb.base/info_sources_2.exp with check-read1Tom de Vries1-4/+12
When running test-case gdb.base/info_sources_2.exp with check-read1, I run into: ... FAIL: gdb.base/info_sources_2.exp: args: : info sources (timeout) ... Fix this by consuming a "$src1, $src2, ..., $srcn: line bit by bit rather than as one whole line. Also add the missing handling of "Objfile has no debug information". Tested on x86_64-linux.
2021-10-08[gdb/testsuite] Fix gdb.mi/gdb2549.exp with check-read1Tom de Vries1-25/+21
When running test-case gdb.mi/gdb2549.exp with check-read1, I run into: ... FAIL: gdb.mi/gdb2549.exp: register values x (timeout) ... Fix this by applying the same fix as for "register values t" in commit 478e490a4df "[gdb/testsuite] Fix gdb.mi/gdb2549.exp with check-read1". Tested on x86_64-linux.
2021-10-08[gdb/testsuite] Fix gdb.base/bt-on-error-and-warning.exp with check-read1Tom de Vries1-2/+2
When running test-case gdb.base/bt-on-error-and-warning.exp with check-read1, I run into: ... (gdb) maint internal-error foobar^M src/gdb/maint.c:82: internal-error: foobar^M A problem internal to GDB has been detectedFAIL: \ gdb.base/bt-on-error-and-warning.exp: problem=internal-error, mode=on: \ scan for backtrace (GDB internal error) Resyncing due to internal error. ,^M ... The corresponding gdb_test_multiple in the test-case contains: ... -early -re "^A problem internal to GDB has been detected,\r\n" { incr header_lines exp_continue } ... but instead this one triggers in gdb_test_multiple: ... -re ".*A problem internal to GDB has been detected" { fail "$message (GDB internal error)" gdb_internal_error_resync set result -1 } ... Fix this by likewise shortening the regexp to before the comma. Tested on x86_64-linux.
2021-10-08[gdb/testsuite] Add nopie in two test-casesTom de Vries2-1/+4
When running test-case gdb.dwarf2/dw2-restrict.exp on openSUSE Leap 15.2 with gcc-PIE installed (switching compiler default to -fPIE/-pie), I get: ... gdb compile failed, ld: outputs/gdb.dwarf2/dw2-restrict/dw2-restrict0.o: \ warning: relocation in read-only section `.text' ld: warning: creating DT_TEXTREL in a PIE UNTESTED: gdb.dwarf2/dw2-restrict.exp: failed to prepare ... This is due to using a hardcoded .S file that was generated with -fno-PIE. Fix this by adding the missing nopie. Likewise in gdb.arch/amd64-tailcall-noret.exp. Tested on x86_64-linux.
2021-10-07[gdb/testsuite] Fix gdb.threads/check-libthread-db.exp with glibc 2.34Tom de Vries1-1/+3
When running test-case gdb.threads/check-libthread-db.exp on openSUSE Tumbleweed (with glibc 2.34) I get: ... (gdb) continue^M Continuing.^M [Thread debugging using libthread_db enabled]^M Using host libthread_db library "/lib64/libthread_db.so.1".^M Stopped due to shared library event:^M Inferior loaded /lib64/libm.so.6^M /lib64/libc.so.6^M (gdb) FAIL: gdb.threads/check-libthread-db.exp: user-initiated check: continue ... The check expect the inferior to load libpthread, but since glibc 2.34 libpthread has been integrated into glibc, and consequently it's no longer a dependency: ... $ ldd outputs/gdb.threads/check-libthread-db/check-libthread-db linux-vdso.so.1 (0x00007ffe4cae4000) libm.so.6 => /lib64/libm.so.6 (0x00007f167c77c000) libc.so.6 => /lib64/libc.so.6 (0x00007f167c572000) /lib64/ld-linux-x86-64.so.2 (0x00007f167c86e000) ... Fix this by updating the regexp to expect libpthread or libc. Tested on x86_64-linux.
2021-10-07[gdb/testsuite] Fix gdb.guile/scm-type.exp with gcc 4.8Tom de Vries1-1/+1
With gcc 7.5.0, I get: ... (gdb) guile (print (type-range (field-type (type-field (value-type \ (value-dereference f)) "items"))))^M = (0 0)^M (gdb) PASS: gdb.guile/scm-type.exp: lang_cpp: test_range: \ on flexible array member: $cmd ... but with gcc 4.8.5, I get instead: ... (gdb) guile (print (type-range (field-type (type-field (value-type \ (value-dereference f)) "items"))))^M = (0 -1)^M (gdb) FAIL: gdb.guile/scm-type.exp: lang_cpp: test_range: \ on flexible array member: $cmd ... There's a difference in debug info. With gcc 4.8.5, we have: ... <2><224>: Abbrev Number: 15 (DW_TAG_member) <225> DW_AT_name : items <22b> DW_AT_type : <0x231> <1><231>: Abbrev Number: 4 (DW_TAG_array_type) <232> DW_AT_type : <0x105> <2><23a>: Abbrev Number: 16 (DW_TAG_subrange_type) <23b> DW_AT_type : <0x11a> <23f> DW_AT_upper_bound : 0xffffffffffffffff ... and with gcc 7.5.0, we have instead: ... <2><89f>: Abbrev Number: 12 (DW_TAG_member) <8a0> DW_AT_name : items <8a6> DW_AT_type : <0x8ac> <1><8ac>: Abbrev Number: 17 (DW_TAG_array_type) <8ad> DW_AT_type : <0x29d> <2><8b5>: Abbrev Number: 41 (DW_TAG_subrange_type) <2><8b6>: Abbrev Number: 0 ... As mentioned in commit 858c8f2c1b9 "gdb/testsuite: adjust gdb.python/flexible-array-member.exp expected pattern": ... Ideally, GDB would present a consistent and documented value for an array member declared with size 0, regardless of how the debug info looks like. ... As in gdb.python/flexible-array-member.exp, change the test to accept the two values. Tested on x86_64-linux.