aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
AgeCommit message (Collapse)AuthorFilesLines
2020-07-25gdb/fortran: resolve dynamic types when readjusting after an indirectionAndrew Burgess5-0/+186
After dereferencing a pointer (in value_ind) or following a reference (in coerce_ref) we call readjust_indirect_value_type to "fixup" the type of the resulting value object. This fixup handles cases relating to the type of the resulting object being different (a sub-class) of the original pointers target type. If we encounter a pointer to a dynamic type then after dereferencing a pointer (in value_ind) the type of the object created will have had its dynamic type resolved. However, in readjust_indirect_value_type, we use the target type of the original pointer to "fixup" the type of the resulting value. In this case, the target type will be a dynamic type, so the resulting value object, once again has a dynamic type. This then triggers an assertion later within GDB. The solution I propose here is that we call resolve_dynamic_type on the pointer's target type (within readjust_indirect_value_type) so that the resulting value is not converted back to a dynamic type. The test case is based on the original test in the bug report. gdb/ChangeLog: PR fortran/23051 PR fortran/26139 * valops.c (value_ind): Pass address to readjust_indirect_value_type. * value.c (readjust_indirect_value_type): Make parameter non-const, and add extra address parameter. Resolve original type before using it. * value.h (readjust_indirect_value_type): Update function signature and comment. gdb/testsuite/ChangeLog: PR fortran/23051 PR fortran/26139 * gdb.fortran/class-allocatable-array.exp: New file. * gdb.fortran/class-allocatable-array.f90: New file. * gdb.fortran/pointer-to-pointer.exp: New file. * gdb.fortran/pointer-to-pointer.f90: New file.
2020-07-25[gdb/symtab] Ignore zero line table entriesTom de Vries3-0/+208
The DWARF standard states for the line register in the line number information state machine the following: ... An unsigned integer indicating a source line number. Lines are numbered beginning at 1. The compiler may emit the value 0 in cases where an instruction cannot be attributed to any source line. ... So, it's possible to have a zero line number in the DWARF line table. This is currently not handled by GDB. The zero value is read in as any other line number, but internally the zero value has a special meaning: end-of-sequence, so the line table entry ends up having a different interpretation than intended in some situations. I've created a test-case where various aspects are tested, which has these 4 interesting tests. 1. Next-step through a zero-line instruction, is_stmt == 1 gdb.dwarf2/dw2-line-number-zero.exp: bar1, 2nd next 2. Next-step through a zero-line instruction, is_stmt == 0 gdb.dwarf2/dw2-line-number-zero.exp: bar2, 2nd next 3. Show source location at zero-line instruction, is_stmt == 1 gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar1_label_3 4. Show source location at zero-line instruction, is_stmt == 0 gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar2_label_3 And we have the following results: 8.3.1, 9.2: ... FAIL: gdb.dwarf2/dw2-line-number-zero.exp: bar1, 2nd next PASS: gdb.dwarf2/dw2-line-number-zero.exp: bar2, 2nd next PASS: gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar1_label_3 FAIL: gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar2_label_3 ... commit 8c95582da8 "gdb: Add support for tracking the DWARF line table is-stmt field": ... PASS: gdb.dwarf2/dw2-line-number-zero.exp: bar1, 2nd next PASS: gdb.dwarf2/dw2-line-number-zero.exp: bar2, 2nd next FAIL: gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar1_label_3 FAIL: gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar2_label_3 ... commit d8cc8af6a1 "[gdb/symtab] Fix line-table end-of-sequence sorting", master: FAIL: gdb.dwarf2/dw2-line-number-zero.exp: bar1, 2nd next FAIL: gdb.dwarf2/dw2-line-number-zero.exp: bar2, 2nd next PASS: gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar1_label_3 PASS: gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar2_label_3 ... The regression in test 2 at commit d8cc8af6a1 was filed as PR symtab/26243, where clang emits zero line numbers. The way to fix all tests is to make sure line number zero internally doesn't clash with special meaning values, and by handling it appropriately everywhere. That however looks too intrusive for the GDB 10 release. Instead, we decide to ensure defined behaviour for line number zero by ignoring it. This gives us back the test results from before commit d8cc8af6a1, fixing PR26243. We mark the FAILs for tests 3 and 4 as KFAILs. Test 4 was already failing for the 9.2 release, and we consider the regression of test 3 from gdb 9.2 to gdb 10 the cost for having defined behaviour. Build and reg-tested on x86_64-linux. gdb/ChangeLog: 2020-07-25 Tom de Vries <tdevries@suse.de> PR symtab/26243 * dwarf2/read.c (lnp_state_machine::record_line): Ignore zero line entries. gdb/testsuite/ChangeLog: 2020-07-25 Tom de Vries <tdevries@suse.de> PR symtab/26243 * gdb.dwarf2/dw2-line-number-zero.c: New test. * gdb.dwarf2/dw2-line-number-zero.exp: New file.
2020-07-24[gdb/testsuite] Require gnatmake-8 for gdb.ada/mi_prot.expTom de Vries2-0/+8
With gcc-7, I run into: ... gcc -c -I./ -gnata -Isrc/gdb/testsuite/gdb.ada/mi_prot -g -lm -I- \ src/gdb/testsuite/gdb.ada/mi_prot/prot.adb^M prot.adb:21:04: info: "Obj_Type" is frozen here, aspects evaluated at this \ point^M prot.adb:23:09: visibility of aspect for "Obj_Type" changes after freeze \ point^M gnatmake: "src/gdb/testsuite/gdb.ada/mi_prot/prot.adb" compilation error^M compiler exited with status 1 ... FAIL: gdb.ada/mi_prot.exp: compilation prot.adb ... Fix this by requiring gnatmake-8 for this test-case. Tested on x86_64-linux, with gnatmake-7, gnatmake-8 and gnatmake-11. gdb/testsuite/ChangeLog: 2020-07-24 Tom de Vries <tdevries@suse.de> PR testsuite/26293 * gdb.ada/mi_prot.exp: Require gnatmake-8.
2020-07-23Don't touch frame_info objects if frame cache was reinitializedPedro Alves2-24/+98
This fixes yet another bug exposed by ASAN + multi-target.exp Running an Asan-enabled GDB against gdb.multi/multi-target.exp exposed yet another latent GDB bug. See here for the full log: https://sourceware.org/pipermail/gdb-patches/2020-July/170761.html As Simon described, the problem is: - We create a new frame_info object in restore_selected_frame (by calling find_relative_frame) - The frame is allocated on the frame_cache_obstack - In frame_unwind_try_unwinder, we try to find an unwinder for that frame - While trying unwinders, memory read fails because the remote target closes, because of "monitor exit" - That calls reinit_frame_cache (as shown above), which resets frame_cache_obstack - When handling the exception in frame_unwind_try_unwinder, we try to set some things on the frame_info object (like *this_cache, which in fact tries to write into frame_info::prologue_cache), but the frame_info object is no more, it went away with the obstack. Fix this by maintaining a frame cache generation counter. Then in exception handling code paths, don't touch frame objects if the generation is not the same as it was on entry. This commit generalizes the gdb.server/server-kill.exp testcase and reuses it to test the scenario in question. The new tests fail without the GDB fix. gdb/ChangeLog: * frame-unwind.c (frame_unwind_try_unwinder): On exception, don't touch THIS_CACHE/THIS_FRAME if the frame cache was cleared meanwhile. * frame.c (frame_cache_generation, get_frame_cache_generation): New. (reinit_frame_cache): Increment FRAME_CACHE_GENERATION. (get_prev_frame_if_no_cycle): On exception, don't touch PREV_FRAME/THIS_FRAME if the frame cache was cleared meanwhile. * frame.h (get_frame_cache_generation): Declare. gdb/testsuite/ChangeLog: * gdb.server/server-kill.exp (prepare): New, factored out from the top level. (kill_server): New. (test_tstatus, test_unwind_nosyms, test_unwind_syms): New. (top level) : Call test_tstatus, test_unwind_nosyms, test_unwind_syms.
2020-07-23gdb/disassembly: Update to handle non-statement addressesAndrew Burgess2-0/+210
After the introduction of support for non-statement addresses in the line table, the output for 'disassemble /m' can be broken in some cases. With the /m format disassembly GDB associates a set of addresses with each line, these addresses are then sorted and printed for each line. When the non-statement support was added GDB was incorrectly told to ignore non-statement instructions, and not add these to the result table. This means that these instructions are completely missing from the output. This commit removes the code that caused non-statement lines to be ignored. A result of this change is that GDB will now potentially include new line numbers in the 'disassemble /m' output, lines that previously were only in the line table as non-statement lines will now appear in the disassembly output. This feels like an improvement though. gdb/ChangeLog: * disasm.c (do_mixed_source_and_assembly_deprecated): Don't exclude non-statement entries. gdb/testsuite/ChangeLog: * gdb.dwarf2/dw2-disasm-over-non-stmt.exp: New file.
2020-07-22Fix more bugs in gdb testglue wrapper handlingSandra Loosemore2-12/+22
In commit 24ac169ac5a918cd82b7485935f0c40a094c625e, this patch: 2020-02-21 Shahab Vahedi <shahab@synopsys.com> * lib/gdb.exp (gdb_wrapper_init): Reset "gdb_wrapper_initialized" to 0 if "wrapper_file" does not exist. attempted to fix problems finding the gdb test wrapper gdb_tg.o in some tests that cd to some non-default directory by rebuilding also the test wrapper in that directory. This had the side-effect of leaving these .o files in various places in the GDB source directory tree. Furthermore, while the tests that cd to some non-default directory cannot run on remote host, the code that was added to probe for the presence of the wrapper file was also specific to host == build. This patch reverts the problematic parts of that commit and replaces it with forcing use of an absolute (rather than relative) pathname to the .o file for linking when host == build. While debugging this patch, I also observed that use of the construct "[info exists gdb_wrapper_file]" was not reliable for detecting when that variable had been initialized by gdb_wrapper_init. I rewrote that so that the variable is always initialized and has a value of an empty string when no wrapper file is needed. 2020-07-22 Sandra Loosemore <sandra@codesourcery.com> gdb/testsuite/ * lib/gdb.exp (gdb_wrapper_file, gdb_wrapper_flags): Initialize to empty string at top level. (gdb_wrapper_init): Revert check for file existence on build. Build the wrapper in its default place, not a build-specific location. When host == build, make the pathname absolute. (gdb_compile): Delete leftover declaration of gdb_wrapper_initialized. Check gdb_wrapper_file being an empty string instead of uninitialized.
2020-07-22New core file tests with mappings over existing program memoryKevin Buettner3-0/+340
This test case was inspired by Pedro's demonstration of a problem with my v2 patches. It can be found here: https://sourceware.org/pipermail/gdb-patches/2020-May/168826.html In a nutshell, my earlier patches could not handle the case in which a read-only mapping created with mmap() was created at an address used by other file-backed read-only memory in use by the process. This problem has been fixed (for Linux, anyway) by the commit "Use NT_FILE note section for reading core target memory". When I run this test without any of my recent corefile patches, I see these failures: FAIL: gdb.base/corefile2.exp: kernel core: print/x mbuf_ro[0]@4 FAIL: gdb.base/corefile2.exp: kernel core: print/x mbuf_ro[pagesize-4]@4 FAIL: gdb.base/corefile2.exp: kernel core: print/x mbuf_ro[-3]@6 FAIL: gdb.base/corefile2.exp: kernel core: print/x mbuf_rw[pagesize-3]@6 FAIL: gdb.base/corefile2.exp: kernel core: print/x mbuf_ro[pagesize-3]@6 FAIL: gdb.base/corefile2.exp: maint print core-file-backed-mappings FAIL: gdb.base/corefile2.exp: gcore core: print/x mbuf_ro[-3]@6 The ones involving mbuf_ro will almost certainly fail when run on non-Linux systems; I've used setup_xfail on those tests to prevent them from outright FAILing when not run on Linux. For a time, I had considered skipping these tests altogether when not run on Linux, but I changed my mind due to this failure... FAIL: gdb.base/corefile2.exp: print/x mbuf_rw[pagesize-3]@6 I think it *should* pass without my recent corefile patches. The fact that it doesn't is likely due to a bug in GDB. The following interaction with GDB demonstrates the problem: (gdb) print/x mbuf_rw[pagesize-3]@6 $1 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0} (gdb) print/x mbuf_rw[pagesize]@3 $2 = {0x6b, 0x6b, 0x6b} The last three values in display of $1 should be the same as those shown by $2. Like this... (gdb) print/x mbuf_rw[pagesize-3]@6 $1 = {0x0, 0x0, 0x0, 0x6b, 0x6b, 0x6b} (gdb) print/x mbuf_rw[pagesize]@3 $2 = {0x6b, 0x6b, 0x6b} That latter output was obtained with the use of all of my current corefile patches. I see no failures on Linux when running this test with my current set of corefile patches. I tested 3 architectures: x86_64, s390x, and aarch64. I also tested on FreeBSD 12.1-RELEASE. I see the following results both with and without the current set of core file patches: # of expected passes 26 # of expected failures 8 Of particular interest is that I did *not* see the problematic mbuf_rw failure noted earlier (both with and without the core file patches). I still don't have an explanation for why this failure occurred on Linux. Prior to running the tests, I had hypothesized that I'd see this failure on FreeBSD too, but testing shows that this is not the case. Also of importance is that we see no FAILs with this test on FreeBSD which indicates that I XFAILed the correct tests. This version runs the interesting tests twice, once with a kernel created core file and another time with a gcore created core file. It also does a very minimal test of the new command "maint print core-file-backed-mappings". gdb/testsuite/ChangeLog: * gdb.base/corefile2.exp: New file. * gdb.base/coremaker2.exp: New file.
2020-07-22Adjust coredump-filter.exp to account for NT_FILE note handlingKevin Buettner2-1/+24
This commit makes adjustments to coredump-filter.exp to account for the fact that NT_FILE file-backed mappings are now available when a core file is loaded. Thus, a test which was expected to PASS when a memory region was determined to be unavailable (due to no file-backed mappings being available) will now FAIL due to those mappings being available from having loaded the NT_FILE note. I had originally marked the test as XFAIL, but Mihails Strasuns suggested a much better approach: 1) First test that it still works if file is accessible in the filesystem. 2) Temporarily move / rename the file and test that disassembly doesn't work anymore. That's what this commit implements. gdb/testsuite/ChangeLog: * gdb.base/coredump-filter.exp: Add second non-Private-Shared-Anon-File test. (test_disasm): Rename binfile for test which is expected to fail.
2020-07-22Add test for accessing read-only mmapped data in a core fileKevin Buettner3-3/+36
This test passes when run using a GDB with my corefile patches. When run against a GDB without my patches, I see the following failures, the first of which is due to the test added by this commit: FAIL: gdb.base/corefile.exp: accessing read-only mmapped data in core file (mapping address not found in core file) FAIL: gdb.base/corefile.exp: accessing anonymous, unwritten-to mmap data gdb/testsuite/ChangeLog: * gdb.base/corefile.exp: Add test "accessing read-only mmapped data in core file". * gdb.base/coremaker.c (buf2ro): New global. (mmapdata): Add a read-only mmap mapping.
2020-07-22Test ability to access unwritten-to mmap data in core fileKevin Buettner3-1/+29
gdb/testsuite/ChangeLog: PR corefiles/25631 * gdb.base/corefile.exp (accessing anonymous, unwritten-to mmap data): New test. * gdb.base/coremaker.c (buf3): New global. (mmapdata): Add mmap call which uses MAP_ANONYMOUS and MAP_PRIVATE flags.
2020-07-22Adjust corefile.exp test to show regression after bfd hack removalKevin Buettner2-0/+10
In his review of my BZ 25631 patch series, Pedro was unable to reproduce the regression which should occur after patch #1, "Remove hack for GDB which sets the section size to 0", is applied. Pedro was using an ld version older than 2.30. Version 2.30 introduced the linker option -z separate-code. Here's what the man page has to say about it: Create separate code "PT_LOAD" segment header in the object. This specifies a memory segment that should contain only instructions and must be in wholly disjoint pages from any other data. In ld version 2.31, use of separate-code became the default for Linux/x86. So, really, 2.31 or later is required in order to see the regression that occurs in recent Linux distributions when only the bfd hack removal patch is applied. For the test case in question, use of the separate-code linker option means that the global variable "coremaker_ro" ends up in a separate load segment (though potentially with other read-only data). The upshot of this is that when only patch #1 is applied, GDB won't be able to correctly access coremaker_ro. The reason for this is due to the fact that this section will now have a non-zero size, but will not have contents from the core file to find this data. So GDB will ask BFD for the contents and BFD will respond with zeroes for anything from those sections. GDB should instead be looking in the executable for this data. Failing that, it can then ask BFD for a reasonable value. This is what a later patch in this series does. When using ld versions earlier than 2.31 (or 2.30 w/ the -z separate-code option explicitly provided to the linker), there is the possibility that coremaker_ro ends up being placed near other data which is recorded in the core file. That means that the correct value will end up in the core file, simply because it resides on a page that the kernel chooses to put in the core file. This is why Pedro wasn't able to reproduce the regression that should occur after fixing the BFD hack. This patch places a big chunk of memory, two pages worth on x86, in front of "coremaker_ro" to attempt to force it onto another page without requiring use of that new-fangled linker switch. Speaking of which, I considered changing the test to use -z separate-code, but this won't work because it didn't exist prior to version 2.30. The linker would probably complain of an unrecognized switch. Also, it likely won't be available in other linkers not based on current binutils. I.e. it probably won't work in FreeBSD, NetBSD, etc. To make this more concrete, this is what *should* happen when attempting to access coremaker_ro when only patch #1 is applied: Core was generated by `/mesquite2/sourceware-git/f28-coresegs/bld/gdb/testsuite/outputs/gdb.base/coref'. Program terminated with signal SIGABRT, Aborted. #0 0x00007f68205deefb in raise () from /lib64/libc.so.6 (gdb) p coremaker_ro $1 = 0 Note that this result is wrong; 201 should have been printed instead. But that's the point of the rest of the patch series. However, without this commit, or when using an old Linux distro with a pre-2.31 ld, this is what you might see instead: Core was generated by `/mesquite2/sourceware-git/f28-coresegs/bld/gdb/testsuite/outputs/gdb.base/coref'. Program terminated with signal SIGABRT, Aborted. #0 0x00007f63dd658efb in raise () from /lib64/libc.so.6 (gdb) p coremaker_ro $1 = 201 I.e. it prints the right answer, which sort of makes it seem like the rest of the series isn't required. Now, back to the patch itself... what should be the size of the memory chunk placed before coremaker_ro? It needs to be at least as big as the page size (PAGE_SIZE) from the kernel. For x86 and several other architectures this value is 4096. I used MAPSIZE which is defined to be 8192 in coremaker.c. So it's twice as big as what's currently needed for most Linux architectures. The constant PAGE_SIZE is available from <sys/user.h>, but this isn't portable either. In the end, it seemed simpler to just pick a value and hope that it's big enough. (Running a separate program which finds the page size via sysconf(_SC_PAGESIZE) and then passes it to the compilation via a -D switch seemed like overkill for a case which is rendered moot by recent linker versions.) Further information can be found here: https://sourceware.org/pipermail/gdb-patches/2020-May/168168.html https://sourceware.org/pipermail/gdb-patches/2020-May/168170.html Thanks to H.J. Lu for telling me about the '-z separate-code' linker switch. gdb/testsuite/ChangeLog: * gdb.base/coremaker.c (filler_ro): New global constant.
2020-07-22Fix crash in -stack-list-argumentsTom Tromey5-0/+141
-stack-list-arguments will crash when stopped in an Ada procedure that has an argument with a certain name ("_objectO" -- which can only be generated by the compiler). The bug occurs because lookup_symbol will fail in this case. This patch changes -stack-list-arguments to mirror what is done with arguments elsewhere. (As an aside, I don't understand why this lookup is even needed, but I assume it is some stabs thing?) In the longer term I think it would be good to share this code between MI and the CLI. However, due to the upcoming release, I preferred a more local fix. gdb/ChangeLog 2020-07-22 Tom Tromey <tromey@adacore.com> * mi/mi-cmd-stack.c (list_args_or_locals): Use lookup_symbol_search_name. gdb/testsuite/ChangeLog 2020-07-22 Tom Tromey <tromey@adacore.com> * gdb.ada/mi_prot.exp: New file. * gdb.ada/mi_prot/pkg.adb: New file. * gdb.ada/mi_prot/pkg.ads: New file. * gdb.ada/mi_prot/prot.adb: New file.
2020-07-22gdb/jit: enable tracking multiple JITer objfilesTankut Baris Aktemur2-1/+47
GDB's JIT handler stores an objfile (and data associated with it) per program space to keep track of JIT breakpoint information. This assumes that there is at most one JITer objfile in the program space. However, there may be multiple. If so, only the first JITer's hook breakpoints would be realized and the JIT events from the other JITers would be missed. This patch removes that assumption, allowing an arbitrary number of objfiles within a program space to be JITers. - The "unique" program_space -> JITer objfile pointer in jit_program_space_data is removed. In fact, jit_program_space_data becomes empty, so it is removed entirely. - jit_breakpoint_deleted is modified, it now has to assume that any objfile in a program space is a potential JITer. It now iterates on all objfiles, checking if they are indeed JITers, and if they are, whether the deleted breakpoint belongs to them. - jit_breakpoint_re_set_internal also has to assume that any objfile in a program space is a potential JITer. It creates (or updates) one jiter_objfile_data structure for each JITer it finds. - Same for jit_inferior_init. It now iterates all objfiles to read the initial JIT object list. gdb/ChangeLog: 2020-07-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Simon Marchi <simon.marchi@polymtl.ca> * jit.c (struct jit_program_space_data): Remove. (jit_program_space_key): Remove. (jiter_objfile_data::~jiter_objfile_data): Remove program space stuff. (get_jit_program_space_data): Remove. (jit_breakpoint_deleted): Iterate on all of the program space's objfiles. (jit_inferior_init): Likewise. (jit_breakpoint_re_set_internal): Likewise. Also change return type to void. (jit_breakpoint_re_set): Pass current_program_space to jit_breakpoint_re_set_internal. gdb/testsuite/ChangeLog: 2020-07-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * gdb.base/jit-reader-simple.exp: Add a scenario for a binary that loads two JITers.
2020-07-21gdb/python: Reuse gdb.RegisterGroup objects where possibleAndrew Burgess2-0/+23
Only create one gdb.RegisterGroup Python object for each of GDB's reggroup objects. I could have added a field into the reggroup object to hold the Python object pointer for each reggroup, however, as reggroups are never deleted within GDB, and are global (not per-architecture) a simpler solution seemed to be just to hold a single global map from reggroup pointer to a Python object representing the reggroup. Then we can reuse the objects out of this map. After this commit it is possible for a user to tell that two gdb.RegisterGroup objects are now identical when previously they were unique, however, as both these objects are read-only I don't think this should be a problem. There should be no other user visible changes after this commit. gdb/ChangeLog: * python/py-registers.c : Add 'unordered_map' include. (gdbpy_new_reggroup): Renamed to... (gdbpy_get_reggroup): ...this. Update to only create register group descriptors when needed. (gdbpy_reggroup_iter_next): Update. gdb/testsuite/ChangeLog: * gdb.python/py-arch-reg-groups.exp: Additional tests.
2020-07-21gdb/python: Reuse gdb.RegisterDescriptor objects where possibleAndrew Burgess2-0/+23
Instead of having the gdb.RegisterDescriptorIterator creating new gdb.RegisterDescriptor objects for each regnum, instead cache gdb.RegisterDescriptor objects on the gdbarch object and reuse these. This means that for every gdbarch/regnum pair there is a single unique gdb.RegisterDescriptor, this feels like a neater implementation than the existing one. It is possible for a user to see (in Python code) that the descriptors are now identical, but as the descriptors are read-only this should make no real difference. There should be no other user visible changes. gdb/ChangeLog: * python/py-registers.c (gdbpy_register_object_data): New static global. (gdbpy_register_object_data_init): New function. (gdbpy_new_register_descriptor): Renamed to... (gdbpy_get_register_descriptor): ...this, and update to reuse existing register descriptors where possible. (gdbpy_register_descriptor_iter_next): Update. (gdbpy_initialize_registers): Register new gdbarch data. gdb/testsuite/ChangeLog: * gdb.python/py-arch-reg-names.exp: Additional tests.
2020-07-21[gdb/testsuite] Fix gdb.reverse/solib-{precsave,reverse}.exp with gcc-8Tom de Vries3-6/+60
With gcc-8, we have the following FAILs, which are not there for gcc-7: ... FAIL: gdb.reverse/solib-precsave.exp: reverse-step into solib function one FAIL: gdb.reverse/solib-precsave.exp: reverse-step within solib function one FAIL: gdb.reverse/solib-precsave.exp: reverse-step back to main one FAIL: gdb.reverse/solib-precsave.exp: reverse-step into solib function two FAIL: gdb.reverse/solib-precsave.exp: reverse-step within solib function two FAIL: gdb.reverse/solib-precsave.exp: reverse-step back to main two FAIL: gdb.reverse/solib-precsave.exp: run until end part two FAIL: gdb.reverse/solib-precsave.exp: reverse-next over solib function one FAIL: gdb.reverse/solib-reverse.exp: reverse-step into solib function one FAIL: gdb.reverse/solib-reverse.exp: reverse-step within solib function one FAIL: gdb.reverse/solib-reverse.exp: reverse-step back to main one FAIL: gdb.reverse/solib-reverse.exp: reverse-step into solib function two FAIL: gdb.reverse/solib-reverse.exp: reverse-step within solib function two FAIL: gdb.reverse/solib-reverse.exp: reverse-step back to main two FAIL: gdb.reverse/solib-reverse.exp: run until end part two FAIL: gdb.reverse/solib-reverse.exp: reverse-next over solib function one ... Looking at the first FAIL for gdb.reverse/solib-precsave.exp, we have: ... (gdb) PASS: reverse-next first shr1 reverse-next^M 40 b[0] = 6; b[1] = 9; /* generic statement, end part two */^M (gdb) PASS: reverse-next generic reverse-step^M -shr2 (x=17) at gdb.reverse/shr2.c:23^M -23 }^M -(gdb) PASS: reverse-step into solib function one +38 b[1] = shr2(17); /* middle part two */^M +(gdb) FAIL: reverse-step into solib function one ... There's a difference in line number info for line 38, where for gcc-7 we have: ... Line number Starting address View Stmt 38 0x4005c6 x ... and for gcc-8: ... 38 0x4005c1 x 38 0x4005cb x ... which explains why we don't step directly into "solib function one". Fix this by recognizing the extra "recommended breakpoint location" and issuing an additional reverse-next/step. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-07-21 Tom de Vries <tdevries@suse.de> * gdb.reverse/solib-precsave.exp: Handle additional "recommended breakpoint locations". * gdb.reverse/solib-reverse.exp: Same.
2020-07-21[gdb/testsuite] Fix step-reverse.c with gcc-10Tom de Vries2-1/+5
The file gdb.reverse/step-reverse.c is used in test-cases: - gdb.reverse/step-reverse.exp - gdb.reverse/next-reverse-bkpt-over-sr.exp - gdb.reverse/step-precsave.exp With gcc-7, there are only PASSes (apart from one KFAIL), but with gcc-10, we have the following FAILs: ... FAIL: gdb.reverse/step-reverse.exp: reverse stepi from a function call \ (start statement) FAIL: gdb.reverse/step-reverse.exp: simple reverse stepi FAIL: gdb.reverse/step-reverse.exp: reverse step out of called fn FAIL: gdb.reverse/step-reverse.exp: reverse next over call FAIL: gdb.reverse/step-reverse.exp: reverse step test 1 FAIL: gdb.reverse/step-reverse.exp: reverse next test 1 FAIL: gdb.reverse/step-reverse.exp: reverse step test 2 FAIL: gdb.reverse/step-reverse.exp: reverse next test 2 FAIL: gdb.reverse/step-precsave.exp: reverse stepi from a function call \ (start statement) FAIL: gdb.reverse/step-precsave.exp: simple reverse stepi FAIL: gdb.reverse/step-precsave.exp: reverse step out of called fn FAIL: gdb.reverse/step-precsave.exp: reverse next over call FAIL: gdb.reverse/step-precsave.exp: reverse step test 1 FAIL: gdb.reverse/step-precsave.exp: reverse next test 1 FAIL: gdb.reverse/step-precsave.exp: reverse step test 2 FAIL: gdb.reverse/step-precsave.exp: reverse next test 2 ... Looking at the first step-precsave.exp FAIL, we have: ... (gdb) stepi^M 26 myglob++; return 0; /* ARRIVED IN CALLEE */^M (gdb) PASS: gdb.reverse/step-precsave.exp: reverse stepi thru function return stepi^M 0x000000000040055f 26 myglob++; return 0; /* ARRIVED IN CALLEE */^M (gdb) FAIL: gdb.reverse/step-precsave.exp: reverse stepi from a function call \ (start statement) ... There's a difference in line info for callee: ... 25 int callee() { /* ENTER CALLEE */ 26 myglob++; return 0; /* ARRIVED IN CALLEE */ 27 } /* RETURN FROM CALLEE */ ... between gcc-7: ... Line number Starting address View Stmt 25 0x400557 x 26 0x40055b x 27 0x40056f x ... and gcc-10: ... 25 0x400552 x 26 0x400556 x 26 0x400565 x 27 0x40056a x ... The two "recommend breakpoint location" entries at line 26 are for the two statements ("myglob++" and "return 0"), but the test-case expects to hit line 26 only once. Fix this by rewriting the two statements into a single statement: ... - myglob++; return 0; /* ARRIVED IN CALLEE */ + return myglob++; /* ARRIVED IN CALLEE */ ... Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-07-21 Tom de Vries <tdevries@suse.de> * gdb.reverse/step-reverse.c (callee): Merge statements.
2020-07-21[gdb/testsuite] Fix gdb.fortran/info-modules.exp with gcc-8Tom de Vries2-2/+7
When using test-case gdb.fortran/info-modules.exp with gcc 8.4.0, I run into: ... FAIL: gdb.fortran/info-modules.exp: info module variables: check for entry \ 'info-types.f90', '35', 'Type m1t1 mod1::__def_init_mod1_M1t1;' FAIL: gdb.fortran/info-modules.exp: info module variables: check for entry \ 'info-types.f90', '35', 'Type __vtype_mod1_M1t1 mod1::__vtab_mod1_M1t1;' ... This is caused by this change in gdb output: ... (gdb) info module variables ... File gdb.fortran/info-types.f90: -35: Type m1t1 mod1::__def_init_mod1_M1t1; + Type m1t1 mod1::__def_init_mod1_M1t1; -35: Type __vtype_mod1_M1t1 mod1::__vtab_mod1_M1t1; + Type __vtype_mod1_M1t1 mod1::__vtab_mod1_M1t1; 21: real(kind=4) mod1::mod1_var_1; 22: integer(kind=4) mod1::mod1_var_2; ... caused by a change in debug info. Fix this by allowing those entries without line number. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-07-21 Tom de Vries <tdevries@suse.de> * gdb.fortran/info-modules.exp (info module variables): Allow missing line numbers for some variables.
2020-07-21[gdb/testsuite] Make inline-locals.c deterministicTom de Vries3-1/+16
When running testcase gdb.opt/inline-locals.exp on openSUSE Tumbleweed, I get: ... (gdb) info locals^M array = {0 <repeats 48 times>, 15775231, 0, 194, 0, -11497, 32767, 4199061, \ 0, 0, 0, 0, 0, 4198992, 0, 4198432, 0}^M (gdb) FAIL: gdb.opt/inline-locals.exp: info locals above bar 2 ... Fix this by: - completely initializing array before printing any value - updating the pattern to match "array = {0 <repeats 64 times>}" Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-07-21 Tom de Vries <tdevries@suse.de> * gdb.opt/inline-locals.c (init_array): New func. (func1): Use init_array. * gdb.opt/inline-locals.exp: Update pattern.
2020-07-21[gdb/testsuite] Don't leak env vars in gdb.debuginfod/fetch_src_and_symbols.expTom de Vries2-89/+125
Test-case gdb.debuginfod/fetch_src_and_symbols.exp leaks env vars DEBUGINFOD_URLS, DEBUGINFOD_TIMEOUT and DEBUGINFOD_CACHE_PATH, causing timeouts in subsequent tests. Fix this by using save_vars. Also, fix PATH and DUPLICATE errors. Finally, cleanup whitespace. gdb/testsuite/ChangeLog: 2020-07-21 Tom de Vries <tdevries@suse.de> * gdb.debuginfod/fetch_src_and_symbols.exp: Use save_vars for env vars. Fix PATH and DUPLICATE errors. Cleanup whitespace.
2020-07-20guile: Add support for Guile 3.0.Ludovic Courtès3-4/+10
gdb/ChangeLog 2020-06-28 Ludovic Courtès <ludo@gnu.org> * guile/scm-math.c (vlscm_integer_fits_p): Use 'uintmax_t' and 'intmax_t' instead of 'scm_t_uintmax' and 'scm_t_intmax', which are deprecated in Guile 3.0. * configure.ac (try_guile_versions): Add "guile-3.0". * configure (try_guile_versions): Regenerate. * NEWS: Update entry. gdb/testsuite/ChangeLog 2020-06-28 Ludovic Courtès <ludo@gnu.org> * gdb.guile/source2.scm: Add #f first argument to 'format'. * gdb.guile/types-module.exp: Remove "ERROR:" from regexps since Guile 3.0 no longer prints that. gdb/doc/ChangeLog 2020-06-28 Ludovic Courtès <ludo@gnu.org> * doc/guile.texi (Guile Introduction): Mention Guile 3.0. Change-Id: Iff116c2e40f334e4e0ca4e759a097bfd23634679
2020-07-20guile: Add support for Guile 2.2.Ludovic Courtès2-1/+6
This primarily updates code that uses the I/O port API of Guile. gdb/ChangeLog 2020-06-28 Ludovic Courtès <ludo@gnu.org> Doug Evans <dje@google.com> PR gdb/21104 * guile/scm-ports.c (USING_GUILE_BEFORE_2_2): New macro. (ioscm_memory_port)[read_buf_size, write_buf_size]: Wrap in #if USING_GUILE_BEFORE_2_2. (stdio_port_desc, memory_port_desc) [!USING_GUILE_BEFORE_2_2]: Change type to 'scm_t_port_type *'. (natural_buffer_size) [!USING_GUILE_BEFORE_2_2]: New variable. (ioscm_open_port) [USING_GUILE_BEFORE_2_2]: Add 'stream' parameter and honor it. Update callers. (ioscm_open_port) [!USING_GUILE_BEFORE_2_2]: New function. (ioscm_read_from_port, ioscm_write) [!USING_GUILE_BEFORE_2_2]: New functions. (ioscm_fill_input, ioscm_input_waiting, ioscm_flush): Wrap in #if USING_GUILE_BEFORE_2_2. (ioscm_init_gdb_stdio_port) [!USING_GUILE_BEFORE_2_2]: Use 'ioscm_read_from_port'. Call 'scm_set_port_read_wait_fd'. (ioscm_init_stdio_buffers) [!USING_GUILE_BEFORE_2_2]: New function. (gdbscm_stdio_port_p) [!USING_GUILE_BEFORE_2_2]: Use 'SCM_PORTP' and 'SCM_PORT_TYPE'. (gdbscm_memory_port_end_input, gdbscm_memory_port_seek) (ioscm_reinit_memory_port): Wrap in #if USING_GUILE_BEFORE_2_2. (gdbscm_memory_port_read, gdbscm_memory_port_write) (gdbscm_memory_port_seek, gdbscm_memory_port_close) [!USING_GUILE_BEFORE_2_2]: New functions. (gdbscm_memory_port_print): Remove use of 'SCM_PTOB_NAME'. (ioscm_init_memory_port_type) [!USING_GUILE_BEFORE_2_2]: Use 'gdbscm_memory_port_read'. Wrap 'scm_set_port_end_input', 'scm_set_port_flush', and 'scm_set_port_free' calls in #if USING_GUILE_BEFORE_2_2. (gdbscm_get_natural_buffer_sizes) [!USING_GUILE_BEFORE_2_2]: New function. (ioscm_init_memory_port): Remove. (ioscm_init_memory_port_stream): New function (ioscm_init_memory_port_buffers) [USING_GUILE_BEFORE_2_2]: New function. (gdbscm_memory_port_read_buffer_size) [!USING_GUILE_BEFORE_2_2]: Return scm_from_uint (0). (gdbscm_set_memory_port_read_buffer_size_x) [!USING_GUILE_BEFORE_2_2]: Call 'scm_setvbuf'. (gdbscm_memory_port_write_buffer_size) [!USING_GUILE_BEFORE_2_2]: Return scm_from_uint (0). (gdbscm_set_memory_port_write_buffer_size_x) [!USING_GUILE_BEFORE_2_2]: Call 'scm_setvbuf'. * configure.ac (try_guile_versions): Add "guile-2.2". * configure: Regenerate. * NEWS: Add entry. gdb/testsuite/ChangeLog 2020-06-28 Ludovic Courtès <ludo@gnu.org> * gdb.guile/scm-error.exp ("source $remote_guile_file_1"): Relax error regexp to match on Guile 2.2. gdb/doc/ChangeLog 2020-06-28 Ludovic Courtès <ludo@gnu.org> * guile.texi (Memory Ports in Guile): Mark 'memory-port-read-buffer-size', 'set-memory-port-read-buffer-size!', 'memory-port-write-buffer-size', 'set-memory-port-read-buffer-size!' as deprecated. * doc/guile.texi (Guile Introduction): Clarify which Guile versions are supported. Change-Id: Ib119b10a2787446e0ae482a5e1b36d809c44bb31
2020-07-20Skip tests requiring "alignof (void)" when compiling using clangGary Benson2-1/+17
As an extension, GCC allows void pointer arithmetic, with sizeof(void) and alignof(void) both 1. GDB supports this extension, but clang does not, and fails to compile the generated output of gdb.cp/align.exp with the following error: gdb compile failed, /gdbtest/build/gdb/testsuite/outputs/gdb.cp/align/align.cc:28:23: error: invalid application of 'alignof' to an incomplete type 'void' unsigned a_void = alignof (void); ^ ~~~~~~ 1 error generated. This commit adds preprocessor conditionals to the generated output, to omit the unsupported code when using clang, and supplies the expected value so the test can complete. gdb/testsuite/ChangeLog: * gdb.cp/align.exp: Fix "alignof (void)" tests when compiling with clang.
2020-07-20[gdb/testsuite] Stabilize execution order in omp-par-scope.cTom de Vries2-0/+55
In openmp test-case gdb.threads/omp-par-scope.exp we xfail and kfail dependent on omp_get_thread_num (). Since execution order of the threads can vary from execution to execution, this can cause changes in test results. F.i., we can see this difference between two test runs: ... -KFAIL: single_scope: first thread: print i3 (PRMS: gdb/22214) +PASS: single_scope: first thread: print i3 -PASS: single_scope: second thread: print i3 +KFAIL: single_scope: second thread: print i3 (PRMS: gdb/22214) ... In both cases, the KFAIL is for omp_get_thread_num () == 1, but in one case that corresponds to the first thread executing that bit of code, and in the other case to the second thread. Get rid of this difference by stabilizing execution order. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-07-20 Tom de Vries <tdevries@suse.de> * gdb.threads/omp-par-scope.c (lock, lock2): New variable. (omp_set_lock_in_order): New function. (single_scope, multi_scope, nested_func, nested_parallel): Use omp_set_lock_in_order and omp_unset_lock. (main): Init and destroy lock and lock2.
2020-07-20[gdb/testsuite] Fix valgrind-infcall-2.exp without libc debug infoTom de Vries2-1/+5
When running test-case gdb.base/valgrind-infcall-2.exp on a system without libc debug info installed, I run into: ... (gdb) p printf ("bla")^M 'printf' has unknown return type; cast the call to its declared return type^M (gdb) FAIL: gdb.base/valgrind-infcall-2.exp: do printf ... Fix this by casting the result of the printf call to int. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-07-20 Tom de Vries <tdevries@suse.de> * gdb.base/valgrind-infcall-2.exp: Handle printf unknown return type.
2020-07-20[gdb/testsuite] Bail out after gdb_start error in ↵Tom de Vries2-1/+10
gdb.threads/attach-slow-waitpid.exp When building gdb using CFLAGS/CXXFLAGS+=-fsanitizer=address and LDFLAGS+=-lasan, and running test-case gdb.threads/attach-slow-waitpid.exp, we get: ... spawn gdb -nw -nx -data-directory data-directory^M ==16079==ASan runtime does not come first in initial library list; \ you should either link runtime to your application or manually preload \ it with LD_PRELOAD.^M ERROR: (eof) GDB never initialized. ERROR: : spawn id exp10 not open while executing "expect { -i exp10 -timeout 120 -re "Kill the program being debugged. .y or n. $" { send_gdb "y\n" answer verbose "\t\tKilling previous pro..." ("uplevel" body line 1) invoked from within "uplevel $body" NONE : spawn id exp10 not open WARNING: remote_expect statement without a default case ERROR: : spawn id exp10 not open while executing "expect { -i exp10 -timeout 120 -re "Reading symbols from.*LZMA support was disabled.*$gdb_prompt $" { verbose "\t\tLoaded $arg into $GDB; .gnu_..." ("uplevel" body line 1) invoked from within "uplevel $body" NONE : spawn id exp10 not open ERROR: Couldn't load attach-slow-waitpid into GDB (eof). ERROR: Couldn't send attach 16070 to GDB. UNRESOLVED: gdb.threads/attach-slow-waitpid.exp: attach to target ... Bail out at the first ERROR, such that we have instead: ... ERROR: (eof) GDB never initialized. UNTESTED: gdb.threads/attach-slow-waitpid.exp: \ Couldn't start GDB with preloaded lib ... Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-07-20 Tom de Vries <tdevries@suse.de> * gdb.threads/attach-slow-waitpid.exp: Bail out if gdb_start fails.
2020-07-17[gdb/testsuite] Add gdb.base/valgrind-infcall-2.expTom de Vries4-13/+131
In commit ee3c5f8968 "Fix GDB crash when registers cannot be modified", we fix a GDB crash: ... $ valgrind /usr/bin/sleep 10000 ==31595== Memcheck, a memory error detector ==31595== Command: /usr/bin/sleep 10000 ==31595== $ gdb /usr/bin/sleep (gdb) target remote | vgdb --pid=31595 Remote debugging using | vgdb --pid=31595 ... $hex in __GI___nanosleep () at nanosleep.c:27 27 return SYSCALL_CANCEL (nanosleep, requested_time, remaining); (gdb) p printf ("bla") terminate called after throwing an instance of 'gdb_exception_error' Aborted (core dumped) ... This patch adds a test-case for it. Unfortunately, I was not able to trigger the error condition using a regular vgdb_start, so I've added a parameter active_at_startup, and when set to 0 this causes valgrind to be started without --vgdb-error=0. Tested on x86_64-linux. Tested with the commit mentioned above reverted, resulting in: ... (gdb) p printf ("bla")^M terminate called after throwing an instance of 'gdb_exception_error'^M ERROR: GDB process no longer exists GDB process exited with wait status 6152 exp10 0 0 CHILDKILLED SIGABRT SIGABRT UNRESOLVED: gdb.base/valgrind-infcall-2.exp: do printf ... gdb/testsuite/ChangeLog: 2020-07-17 Tom de Vries <tdevries@suse.de> * gdb.base/valgrind-infcall-2.c: New test. * gdb.base/valgrind-infcall-2.exp: New file. * lib/valgrind.exp (vgdb_start): Add and handle active_at_startup.
2020-07-17[gdb/testsuite] Use MACRO_AT_{func,range}Tom de Vries23-198/+64
Use dwarf assembly procs MACRO_AT_func and MACRO_AT_range in test-cases where that's appropriate. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-07-17 Tom de Vries <tdevries@suse.de> * gdb.dlang/circular.c (found): Use found_label as label name. * gdb.dwarf2/arr-subrange.c (main): Use main_label as label name. * gdb.dwarf2/comp-unit-lang.c (func): Use func_label as label name. * gdb.dlang/circular.exp: Use MACRO_AT_func and MACRO_AT_range. * gdb.dwarf2/ada-linkage-name.exp: Same. * gdb.dwarf2/arr-subrange.exp: Same. * gdb.dwarf2/atomic-type.exp: Same. * gdb.dwarf2/comp-unit-lang.exp: Same. * gdb.dwarf2/cpp-linkage-name.exp: Same. * gdb.dwarf2/dw2-bad-mips-linkage-name.exp: Same. * gdb.dwarf2/dw2-lexical-block-bare.exp: Same. * gdb.dwarf2/dw2-regno-invalid.exp: Same. * gdb.dwarf2/implptr-64bit.exp: Same. * gdb.dwarf2/imported-unit-abstract-const-value.exp: Same. * gdb.dwarf2/imported-unit-runto-main.exp: Same. * gdb.dwarf2/imported-unit.exp: Same. * gdb.dwarf2/main-subprogram.exp: Same. * gdb.dwarf2/missing-type-name.exp: Same. * gdb.dwarf2/nonvar-access.exp: Same. * gdb.dwarf2/struct-with-sig.exp: Same. * gdb.dwarf2/typedef-void-finish.exp: Same. * gdb.dwarf2/void-type.exp: Same.
2020-07-17[gdb/testsuite] Drop src arg of MACRO_AT_{func,range}Tom de Vries17-45/+47
The dwarf assembly procs MACRO_AT_func and MACRO_AT_range have a src parameter, which is set to $srcdir/$subdir/$srcfile in every single call. Drop the src parameter and hardcode usage of $srcdir/$subdir/$srcfile in the procs. Build and reg-tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-07-17 Tom de Vries <tdevries@suse.de> * lib/dwarf.exp (Dwarf::MACRO_AT_func, Dwarf::MACRO_AT_range): Drop src parameter. * gdb.dlang/watch-loc.exp: Update MACRO_AT_{func,range} calls. * gdb.dwarf2/bitfield-parent-optimized-out.exp: Same. * gdb.dwarf2/dw2-ifort-parameter.exp: Same. * gdb.dwarf2/dw2-opt-structptr.exp: Same. * gdb.dwarf2/dwz.exp: Same. * gdb.dwarf2/implptr-optimized-out.exp: Same. * gdb.dwarf2/implref-array.exp: Same. * gdb.dwarf2/implref-const.exp: Same. * gdb.dwarf2/implref-global.exp: Same. * gdb.dwarf2/implref-struct.exp: Same. * gdb.dwarf2/info-locals-optimized-out.exp: Same. * gdb.dwarf2/opaque-type-lookup.exp: Same. * gdb.dwarf2/var-access.exp: Same. * gdb.dwarf2/varval.exp: Same. * gdb.trace/entry-values.exp: Same.
2020-07-17[gdb/testsuite] Remove Dwarf::externTom de Vries12-28/+14
The file lib/dwarf.exp contains: ... # Declare a global label. This is typically used to refer to # labels defined in other files, for example a function defined in # a .c file. proc extern {args} { foreach name $args { _op .global $name } } ... The assembler directive to refer to labels defined in other files is not .global, but .extern, and that one is ignored by gas. Since we require gas for all dwarf assembly test-cases, remove the proc and all it's uses. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-07-17 Tom de Vries <tdevries@suse.de> * lib/dwarf.exp (Dwarf::extern): Remove. * gdb.compile/compile-ops.exp: Remove use of Dwarf::extern. * gdb.dlang/circular.exp: Same. * gdb.dwarf2/comp-unit-lang.exp: Same. * gdb.dwarf2/dw2-ifort-parameter.exp: Same. * gdb.dwarf2/dw2-symtab-includes.exp: Same. * gdb.dwarf2/dwz.exp: Same. * gdb.dwarf2/imported-unit-abstract-const-value.exp: Same. * gdb.dwarf2/imported-unit-runto-main.exp: Same. * gdb.dwarf2/imported-unit.exp: Same. * gdb.dwarf2/opaque-type-lookup.exp: Same.
2020-07-16Fix POSIX-isms in gdb.base/shell.expSandra Loosemore2-10/+21
Some recent tests added to gdb.base/shell.exp have been failing on Windows host due to assumptions that the shell is a POSIX variant. On Windows, GDB uses CMD.EXE via the system() call to run shell commands instead. There seems to be no obvious CMD.EXE equivalent for "kill -2 $$" to signal the shell process, so this patch skips those tests on Windows host. The second problem addressed here is that CMD.EXE only recognizes double quotes, not single quotes; that change can be made unconditionally since POSIX shells recognize double quotes as well. 2020-07-16 Sandra Loosemore <sandra@codesourcery.com> gdb/testsuite/ * gdb.base/shell.exp: Skip pipe tests dependent on sh on Windows host. Use double quotes instead of single quotes.
2020-07-16gdb: fix issues with handling DWARF v5 rnglists & .dwo files.Caroline Tice3-0/+142
While experimenting with GDB on DWARF 5 with split debug (dwo files), I discovered that GDB was not reading the rnglist index properly (it needed to be reprocessed in the same way the loclist index does), and that there was no code for reading rnglists out of dwo files at all. Also, the rnglist address reading function (dwarf2_rnglists_process) was adding the base address to all rnglist entries, when it's only supposed to add it to the DW_RLE_offset_pair entries (http://dwarfstd.org/doc/DWARF5.pdf, p. 53), and was not handling several entry types. - Added 'reprocessing' for reading rnglist index (as is done for loclist index). - Added code for reading rnglists out of .dwo files. - Added several missing rnglist forms to dwarf2_rnglists_process. - Fixed bug that was alwayas adding base address for rnglists (only one form needs that). - Updated dwarf2_rnglists_process to read rnglist out of dwo file when appropriate. - Added new functions cu_debug_rnglist_section & read_rnglist_index. - Added new testcase, dw5-rnglist-test.{cc,exp} Special note about the new testcase: In order for the test case to test anything meaningful, it must be compiled with clang, not GCC. The way to do this is as follows: $ make check RUNTESTFLAGS="CC_FOR_TARGET=/path/to/clang CXX_FOR_TARGET=/path/to/clang++ dw5-rnglist-test.exp" This following version of clang was used for this testing: clang version 9.0.1-11 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin Change-Id: I3053c5ddc345720b8ed81e23a88fe537ab38748d
2020-07-16[gdb/testsuite] Add pseudo line number program instruction: lineTom de Vries8-99/+100
There's an idiom in dwarf assembly test-cases: ... set line1 [gdb_get_line_number "line 1"] set line2 [gdb_get_line_number "line 2"] set line3 [gdb_get_line_number "line 3"] ... {DW_LNS_advance_line [expr $line1 - 1]} ... {DW_LNS_advance_line [expr $line2 - $line1]} ... {DW_LNS_advance_line [expr $line3 - $line2]} ... Add a pseudo line number program instruction "line", such that we can simply write: ... {line $line1} ... {line $line2} ... {line $line3} ... Build and reg-tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-07-16 Tom de Vries <tdevries@suse.de> * lib/dwarf.exp (program): Initialize _line. (DW_LNE_end_sequence): Reinitialize _line. (DW_LNS_advance_line): Update _line. (line): New proc. * gdb.dwarf2/dw2-inline-many-frames.exp: Use line. * gdb.dwarf2/dw2-inline-small-func.exp: Same. * gdb.dwarf2/dw2-inline-stepping.exp: Same. * gdb.dwarf2/dw2-is-stmt-2.exp: Same. * gdb.dwarf2/dw2-is-stmt.exp: Same. * gdb.dwarf2/dw2-ranges-func.exp: Same.
2020-07-15gdb/testsuite: Update test pattern in ptype-on-functions.expAndrew Burgess2-1/+6
It was pointed out that the recently added test gdb.fortran/ptype-on-functions.exp fails on older versions of gfortran. This is because the ABI for passing string lengths changed from a 4-byte to 8-byte value (on some targets). This change is documented here: https://gcc.gnu.org/gcc-8/changes.html. Character variables longer than HUGE(0) elements are now possible on 64-bit targets. Note that this changes the procedure call ABI for all procedures with character arguments on 64-bit targets, as the type of the hidden character length argument has changed. The hidden character length argument is now of type INTEGER(C_SIZE_T). This commit just relaxes the pattern to accept any size of integer for the string length argument. gdb/testsuite/ChangeLog: * gdb.fortran/ptype-on-functions.exp: Make the result pattern more generic.
2020-07-15[gdb/testsuite] Handle callq -> call disassembly changeTom de Vries2-2/+5
We're currently running into: ... FAIL: gdb.trace/entry-values.exp: disassemble bar ... Since commit 36938cabf0 "x86: avoid attaching suffixes to unambiguous insns", "callq" is disassembled as "call", and the test-case expects "callq". Fix this by expecting "call" instead. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-07-15 Tom de Vries <tdevries@suse.de> * gdb.trace/entry-values.exp: Expect "call" instead of "callq" if is_amd64_regs_target.
2020-07-15gdb/fortran: Handle dynamic string types when printing typesAndrew Burgess3-0/+34
After commit: commit 8c2e4e0689ea244d0ed979171a3d09c9176b8175 Date: Sun Jul 12 22:58:51 2020 -0400 gdb: add accessors to struct dynamic_prop An existing bug was exposed in the Fortran type printing code. When GDB is asked to print the type of a function that takes a dynamic string argument GDB will try to read the upper bound of the string. The read of the upper bound is written as: if (type->bounds ()->high.kind () == PROP_UNDEFINED) // Treat the upper bound as unknown. else // Treat the upper bound as known and constant. However, this is not good enough. When printing a function type the dynamic argument types will not have been resolved. As a result the dynamic property is not PROP_UNDEFINED, but nor is it constant. By rewriting this code to specifically check for the PROP_CONST case, and treating all other cases as the upper bound being unknown we avoid incorrectly treating the dynamic property as being constant. gdb/ChangeLog: * f-typeprint.c (f_type_print_base): Allow for dynamic types not being resolved. gdb/testsuite/ChangeLog: * gdb.fortran/ptype-on-functions.exp: Add more tests. * gdb.fortran/ptype-on-functions.f90: Likewise.
2020-07-14gdb/testsuite/lib/dwarf.exp: fix addr_size parameter commentsSimon Marchi2-3/+8
The comments modified in this patch claim that the addr_size parameters can take the value 32 or 64 (suggesting the value is in bits). In fact, the expected value is in bytes, either 4 or 8. The actual value in the DWARF info is in bytes. And we can see that the default values used (if addr_size == "default") are: if {$_cu_addr_size == "default"} { if {[is_64_target]} { set _cu_addr_size 8 } else { set _cu_addr_size 4 } } gdb/testsuite/ChangeLog: * lib/dwarf.exp (Dwarf::cu, Dwarf::tu, Dwarf::lines): Change valid values in documentation for addr_size to 4 and 8. Change-Id: I4a02dca2bb7992198864e545ef099f020f54ff2f
2020-07-14gdb: Improve formatting of 'show endian' messagesAndrew Burgess2-19/+19
This commit changes the output of 'show endian'. Here is a session before this commit: (gdb) show endian The target endianness is set automatically (currently little endian) (gdb) set endian big The target is assumed to be big endian (gdb) show endian The target is assumed to be big endian (gdb) After this commit the session now looks like this: (gdb) show endian The target endianness is set automatically (currently little endian). (gdb) set endian big The target is set to big endian. (gdb) show endian The target is set to big endian. (gdb) The changes are: 1. Each line ends with '.', and 2. After setting the endianness GDB is now a little more assertive; 'target is set to' not 'target is assumed to be', the user did just tell us after all!
2020-07-14gdb: Improve formatting of 'show architecture' messagesAndrew Burgess10-17/+29
This commit changes the output of 'show architecture'. Here is a session before this commit: (gdb) show architecture The target architecture is set automatically (currently i386) (gdb) set architecture mips The target architecture is assumed to be mips (gdb) show architecture The target architecture is assumed to be mips (gdb) After this commit the session now looks like this: (gdb) show architecture The target architecture is set to "auto" (currently "i386"). (gdb) set architecture mips The target architecture is set to "mips". (gdb) show architecture The target architecture is set to "mips". (gdb) The changes are: 1. The value is now enclosed in quotes, 2. Each line ends with '.', and 3. After setting the architecture GDB is now a little more assertive; 'architecture is set to' not 'is assumed to be', the user did just tell us after all! gdb/ChangeLog: * arch-utils.c (show_architecture): Update formatting of messages. gdb/testsuite/ChangeLog: * gdb.arch/amd64-osabi.exp: Update. * gdb.arch/arm-disassembler-options.exp: Update. * gdb.arch/powerpc-disassembler-options.exp: Update. * gdb.arch/ppc64-symtab-cordic.exp: Update. * gdb.arch/s390-disassembler-options.exp: Update. * gdb.base/all-architectures.exp.tcl: Update. * gdb.base/attach-pie-noexec.exp: Update. * gdb.base/catch-syscall.exp: Update. * gdb.xml/tdesc-arch.exp: Update.
2020-07-14[gdb/testsuite] Fix clone-new-thread-event.c with glibc 2.30Tom de Vries2-2/+8
Starting glibc 2.30, unistd.h declares gettid (for _GNU_SOURCE). This clashes with a static gettid in test source clone-new-thread-event.c: ... gdb compile failed, gdb.threads/clone-new-thread-event.c:46:1: error: \ static declaration of 'gettid' follows non-static declaration 46 | gettid (void) | ^~~~~~ In file included from /usr/include/unistd.h:1170, from gdb.threads/clone-new-thread-event.c:27: /usr/include/bits/unistd_ext.h:34:16: note: previous declaration of 'gettid' \ was here 34 | extern __pid_t gettid (void) __THROW; | ^~~~~~ ... Fix this by renaming the static gettid to local_gettid. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-07-14 Tom de Vries <tdevries@suse.de> * gdb.threads/clone-new-thread-event.c (gettid): Rename to ... (local_gettid): ... this. (fn): Update.
2020-07-13Skip directory tests in gdb.base/info_sources.exp on remote hostSandra Loosemore2-3/+12
When testing on a remote host, source files from build are copied to an arbitrary location on host. Tests that try to pattern-match host pathnames against directory prefixes on build don't generally work. 2020-07-13 Sandra Loosemore <sandra@codesourcery.com> gdb/testsuite/ * gdb.base/info_sources.exp: Skip directory match tests on remote hosts.
2020-07-13Fix gdb.base/savedregs.exp with clangGary Benson2-1/+6
gdb.base/savedregs.exp fails to run with clang, because of: gdb compile failed, /gdbtest/src/gdb/testsuite/gdb.base/savedregs.c:36:37: warning: operator '<<' has lower precedence than '+'; '+' will be evaluated first [-Wshift-op-parentheses] return callee (a1 << a2 * a3 / a4 + a6 & a6 % a7 - a8) + done; ~~ ~~~~~~~~~~~~~^~~~ /gdbtest/build/gdb/testsuite/gdb.base/savedregs.c:36:37: note: place parentheses around the '+' expression to silence this warning return callee (a1 << a2 * a3 / a4 + a6 & a6 % a7 - a8) + done; ^ ( ) 1 warning generated. This commit fixes it by adding the suggested parentheses. gdb/testsuite/ChangeLog: * gdb.base/savedregs.exp (caller): Use parentheses to make expected expression evaluation ordering explicit.
2020-07-13Fix gdb.arch/i386-sse.exp with clangGary Benson2-1/+5
gdb.arch/i386-sse.exp fails to run with clang, because of: gdb compile failed, /gdbtest/src/gdb/testsuite/gdb.arch/i386-sse.c:56:40: warning: passing 'int *' to parameter of type 'unsigned int *' converts between pointers to integer types with different sign [-Wpointer-sign] if (!x86_cpuid (1, NULL, NULL, NULL, &edx)) ^~~~ /gdbtest/src/gdb/testsuite/../nat/x86-cpuid.h:35:41: note: passing argument to parameter '__edx' here unsigned int *__ecx, unsigned int *__edx) ^ 1 warning generated. Fix it by declaring edx unsigned. gdb/testsuite/ChangeLog: * gdb.arch/i386-sse.c (have_sse) <edx>: Make unsigned.
2020-07-13Use volatile pointers when attempting to trigger SIGSEGVsGary Benson6-5/+14
Clang fails to compile a number of files with the following warning: indirection of non-volatile null pointer will be deleted, not trap [-Wnull-dereference]. This commit qualifies the relevant pointers with 'volatile'. gdb/testsuite/ChangeLog: * gdb.base/bigcore.c (main): Use a volatile pointer when attempting to trigger a SIGSEGV. * gdb.base/gcore-relro-pie.c (break_here): Likewise. * gdb.base/gcore-tls-pie.c (break_here): Likewise. * gdb.base/savedregs.c (thrower): Likewise. * gdb.mi/mi-syn-frame.c (bar): Likewise.
2020-07-13Skip VLA structure field tests when compiling with clangGary Benson5-77/+180
Clang fails to compile gdb.base/vla-datatypes.c with the following error: fields must have a constant size: 'variable length array in structure' extension will never be supported. This commit factors the affected tests out into a new testcase, vla-struct-fields.{exp,c}, which is skipped when the testcase is compiled using clang, gdb/testsuite/ChangeLog: * gdb.base/vla-datatypes.c (vla_factory): Factor out sections defining and using VLA structure fields into... * gdb.base/vla-struct-fields.c: New file. * gdb.base/vla-datatypes.exp: Factor out VLA structure field tests into... * gdb.base/vla-struct-fields.exp: New file.
2020-07-13[gdb/testsuite] Handle missing gold linker in gdb.base/morestack.expTom de Vries5-2/+29
When running test-case gdb.base/morestack.exp without the gold linker installed, we run into: ... Running src/gdb/testsuite/gdb.base/morestack.exp ... gdb compile failed, collect2: fatal error: cannot find 'ld' compilation terminated. FAIL: gdb.base/morestack.exp: continue === gdb Summary === nr of expected passes 1 nr of unexpected failures 1 nr of untested testcases 1 ... The test-case needs the gold linker to run correctly (as explained in commit b8d38ee425 "testsuite: Fix false FAIL for gdb.base/morestack.exp"), but only prefers it, and doesn't require it. Fix this by requiring the gold linker in the test-case. Furthermore, silence the compilation error by introducing a caching proc have_fuse_ld_gold and using it in this and other test-cases that use -fuse-ld=gold. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-07-13 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (have_fuse_ld_gold): New caching proc. * gdb.base/gcore-tls-pie.exp: Use have_fuse_ld_gold. * gdb.base/gold-gdb-index.exp: Same. * gdb.base/morestack.exp: Same.
2020-07-11rust: Fix rust modules testDaniel Xu2-1/+8
I noticed that the modules test was failing. Some choice use of `nm` revealed `TWENTY_THREE` was not in the final binary. Fix by taking a pointer to the global, forcing the linker to keep the symbol in. gdb/testsuite/ChangeLog 2020-07-11 Daniel Xu <dxu@dxuuu.xyz> PR rust/26121 * gdb.rust/modules.rs: Prevent linker from discarding test symbol. Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
2020-07-10Testcase for previous handle_no_resumed fixesPedro Alves3-1/+87
This adds a testcase that covers the scenarios described in the previous two commits. gdb/testsuite/ChangeLog: PR gdb/26199 * gdb.multi/multi-target.c (exit_thread): New. (thread_start): Break loop if EXIT_THREAD. * gdb.multi/multi-target.exp (test_no_unwaited_for): New proc. (top level) Call test_no_resumed.
2020-07-08Use read_memory in ada_exception_message_1Tom Tromey3-2/+7
Testing using the internal AdaCore test suite showed a regression from the target string reading changes. In particular, now ada_exception_message_1 can get the wrong answer in some cases. In particular, when an Ada exception catchpoint is hit, sometimes the exception name will be incorrect. The case I was seeing changed from the correct: Catchpoint 2, CONSTRAINT_ERROR (catch C_E) at [...] to: Catchpoint 2, CONSTRAINT_ERROR (catch C_EE) at [...] I was not able to reproduce this failure with the Fedora gnat. Perhaps it is related to some local change to gnat; I do not know. Meanwhile, because ada_exception_message_1 knows the length of the string to read, we can use read_memory here. This fixes the bug. I've updated the test suite to at least exercise this code path. However, as mentioned above, the new test does not actually provoke the failure. gdb/ChangeLog 2020-07-08 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_exception_message_1): Use read_memory. gdb/testsuite/ChangeLog 2020-07-08 Tom Tromey <tromey@adacore.com> * gdb.ada/catch_ex/foo.adb: Pass string to raise. * gdb.ada/catch_ex.exp: Examine catchpoint text.
2020-07-06gdb: Python unwinders, inline frames, and tail-call framesAndrew Burgess4-0/+166
This started with me running into the bug described in python/22748, in summary, if the frame sniffing code accessed any registers within an inline frame then GDB would crash with this error: gdb/frame.c:579: internal-error: frame_id get_frame_id(frame_info*): Assertion `fi->level == 0' failed. The problem is that, when in the Python unwinder I write this: pending_frame.read_register ("register-name") This is translated internally into a call to `value_of_register', which in turn becomes a call to `value_of_register_lazy'. Usually this isn't a problem, `value_of_register_lazy' requires the next frame (more inner) to have a valid frame_id, which will be the case (if we're sniffing frame #1, then frame #0 will have had its frame-id figured out). Unfortunately if frame #0 is inline within frame #1, then the frame-id for frame #0 can't be computed until we have the frame-id for #1. As a result we can't create a lazy register for frame #1 when frame #0 is inline. Initially I proposed a solution inline with that proposed in bugzilla, changing value_of_register to avoid creating a lazy register value. However, when this was discussed on the mailing list I got this reply: https://sourceware.org/pipermail/gdb-patches/2020-June/169633.html Which led me to look at these two patches: [1] https://sourceware.org/pipermail/gdb-patches/2020-April/167612.html [2] https://sourceware.org/pipermail/gdb-patches/2020-April/167930.html When I considered patches [1] and [2] I saw that all of the issues being addressed here were related, and that there was a single solution that could address all of these issues. First I wrote the new test gdb.opt/inline-frame-tailcall.exp, which shows that [1] and [2] regress the inline tail-call unwinder, the reason for this is that these two patches replace a call to gdbarch_unwind_pc with a call to get_frame_register, however, this is not correct. The previous call to gdbarch_unwind_pc takes THIS_FRAME and returns the $pc value in the previous frame. In contrast get_frame_register takes THIS_FRAME and returns the value of the $pc in THIS_FRAME; these calls are not equivalent. The reason these patches appear (or do) fix the regressions listed in [1] is that the tail call sniffer depends on identifying the address of a caller and a callee, GDB then looks for a tail-call sequence that takes us from the caller address to the callee, if such a series is found then tail-call frames are added. The bug that was being hit, and which was address in patch [1] is that in order to find the address of the caller, GDB ended up creating a lazy register value for an inline frame with to frame-id. The solution in patch [1] is to instead take the address of the callee and treat this as the address of the caller. Getting the address of the callee works, but we then end up looking for a tail-call series from the callee to the callee, which obviously doesn't return any sane results, so we don't insert any tail call frames. The original patch [1] did cause some breakage, so patch [2] undid patch [1] in all cases except those where we had an inline frame with no frame-id. It just so happens that there were no tests that fitted this description _and_ which required tail-call frames to be successfully spotted, as a result patch [2] appeared to work. The new test inline-frame-tailcall.exp, exposes the flaw in patch [2]. This commit undoes patch [1] and [2], and replaces them with a new solution, which is also different to the solution proposed in the python/22748 bug report. In this solution I propose that we introduce some special case logic to value_of_register_lazy. To understand what this logic is we must first look at how inline frames unwind registers, this is very simple, they do this: static struct value * inline_frame_prev_register (struct frame_info *this_frame, void **this_cache, int regnum) { return get_frame_register_value (this_frame, regnum); } And remember: struct value * get_frame_register_value (struct frame_info *frame, int regnum) { return frame_unwind_register_value (frame->next, regnum); } So in all cases, unwinding a register in an inline frame just asks the next frame to unwind the register, this makes sense, as an inline frame doesn't really exist, when we unwind a register in an inline frame, we're really just asking the next frame for the value of the register in the previous, non-inline frame. So, if we assume that we only get into the missing frame-id situation when we try to unwind a register from an inline frame during the frame sniffing process, then we can change value_of_register_lazy to not create lazy register values for an inline frame. Imagine this stack setup, where #1 is inline within #2. #3 -> #2 -> #1 -> #0 \______/ inline Now when trying to figure out the frame-id for #1, we need to compute the frame-id for #2. If the frame sniffer for #2 causes a lazy register read in #2, either due to a Python Unwinder, or for the tail-call sniffer, then we call value_of_register_lazy passing in frame #2. In value_of_register_lazy, we grab the next frame, which is #1, and we used to then ask for the frame-id of #1, which was not computed, and this was our bug. Now, I propose we spot that #1 is an inline frame, and so lookup the next frame of #1, which is #0. As #0 is not inline it will have a valid frame-id, and so we create a lazy register value using #0 as the next-frame-id. This will give us the exact same result we had previously (thanks to the code we inspected above). Encoding into value_of_register_lazy the knowledge that reading an inline frame register will always just forward to the next frame feels.... not ideal, but this seems like the cleanest solution to this recursive frame-id computation/sniffing issue that appears to crop up. The following two commits are fully reverted with this commit, these correspond to patches [1] and [2] respectively: commit 5939967b355ba6a940887d19847b7893a4506067 Date: Tue Apr 14 17:26:22 2020 -0300 Fix inline frame unwinding breakage commit 991a3e2e9944a4b3a27bd989ac03c18285bd545d Date: Sat Apr 25 00:32:44 2020 -0300 Fix remaining inline/tailcall unwinding breakage for x86_64 gdb/ChangeLog: PR python/22748 * dwarf2/frame-tailcall.c (dwarf2_tailcall_sniffer_first): Remove special handling for inline frames. * findvar.c (value_of_register_lazy): Skip inline frames when creating lazy register values. * frame.c (frame_id_computed_p): Delete definition. * frame.h (frame_id_computed_p): Delete declaration. gdb/testsuite/ChangeLog: PR python/22748 * gdb.opt/inline-frame-tailcall.c: New file. * gdb.opt/inline-frame-tailcall.exp: New file. * gdb.python/py-unwind-inline.c: New file. * gdb.python/py-unwind-inline.exp: New file. * gdb.python/py-unwind-inline.py: New file.