aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2022-02-24gdb: clean up some things in features/MakefileSimon Marchi1-0/+1
- 32bit-segments.xml is not listed in the Makfile, but it's used. This means that it wouldn't get re-generated if we were to change how C files are generated from the XML. It looks like it was simply forgotten, add it. This fixes PR build/28921. (cherry picked from commit 1056aa39196e0af454e6cdff193d7fd4bc638b9c)
2022-01-16Bump GDB version number to 11.2.90.DATE-git.Joel Brobecker4-2/+10
gdb/ChangeLog: * version.in: Set GDB version number to 11.2.90.DATE-git. gdb/testsuite/ChangeLog: * gdb.base/default.exp: Change $_gdb_minor to 3.
2022-01-16Document the GDB 11.2 release in gdb/ChangeLogJoel Brobecker1-0/+4
gdb/ChangeLog: GDB 11.2 released.
2022-01-16Set GDB version number to 11.2.gdb-11.2-releaseJoel Brobecker2-1/+5
gdb/ChangeLog: * version.in: Set GDB version number to 11.2.
2022-01-16Manual copyright year update of various GDB filesJoel Brobecker5-5/+16
This commit updates the copyright year of various files which gdb/copyright.py is not able to handle automatically. gdb/ChangeLog: * gdbarch.sh: Update end year of copyright year range for copyright header of generated files. gdb/doc/ChangeLog: * gdb.texinfo: Change end year of the manual's copyright notice to 2022. * refcard.tex: Ditto.
2022-01-16Automatic Copyright Year update after running gdb/copyright.pyJoel Brobecker5638-5637/+5642
This commit brings all the changes made by running gdb/copyright.py as per GDB's Start of New Year Procedure. For the avoidance of doubt, all changes in this commits were performed by the script.
2022-01-16gdb/copyright.py: Do not update gdbsupport/Makefile.inJoel Brobecker2-0/+5
This file is generated, so we should not modify it (any modification we make is going to be undone at the next re-generation anyway). gdb/ChangeLog: * copyright.py (EXCLUDE_LIST): Add "gdbsupport/Makefile.in". (cherry picked from commit a3f34021316d60ce33d2d52db76b463282519aef)
2022-01-16Update copyright year in version output for gdb, gdbserver and gdbreplayJoel Brobecker2-2/+7
This commit changes the end year of the copyright year range printed by gdb, gdbserver and gdbreplay to be 2022. This reflects the fact that some changes were made on this branch this year. gdb/ChangeLog: * top.c: Update year range in copyright notice. (print_gdb_version): Update copyright year to 2022. gdbserver/ChangeLog: * gdbreplay.cc: Update year range in copyright notice. (gdbreplay_version): Update copyright year to 2022. * server.cc: Update year range in copyright notice. (gdbserver_version): Update copyright year to 2022.
2021-12-23gdb/remote: handle attach when stop packet lacks thread-idAndrew Burgess4-52/+101
Bug PR gdb/28405 reports a regression when using attach with an extended-remote target. In this case the target is not including a thread-id in the stop packet it sends back after the attach. The regression was introduced with this commit: commit 8f66807b98f7634c43149ea62e454ea8f877691d Date: Wed Jan 13 20:26:58 2021 -0500 gdb: better handling of 'S' packets The problem is that when GDB processes the stop packet, it sees that there is no thread-id and so has to "guess" which thread the stop should apply to. In this case the target only has one thread, so really, there's no guessing needed, but GDB still runs through the same process, this shouldn't cause us any problems. However, after the above commit, GDB now expects itself to be more internally consistent, specifically, only a thread that GDB thinks is resumed, can be a candidate for having stopped. It turns out that, when GDB attaches to a process through an extended-remote target, the threads of the process being attached too, are not, initially, marked as resumed. And so, when GDB tries to figure out which thread the stop might apply too, it finds no threads in the processes marked resumed, and so an assert triggers. In extended_remote_target::attach we create a new thread with a call to add_thread_silent, rather than remote_target::remote_add_thread, the reason is that calling the latter will result in a call to 'add_thread' rather than 'add_thread_silent'. However, remote_target::remote_add_thread includes additional actions (i.e. calling remote_thread_info::set_resumed and set_running) which are missing from extended_remote_target::attach. These missing calls are what would serve to mark the new thread as resumed. In this commit I propose that we add an extra parameter to remote_target::remote_add_thread. This new parameter will force the new thread to be added with a call to add_thread_silent. We can now call remote_add_thread from the ::attach method, the extra actions (listed above) will now be performed, and the thread will be left in the correct state. Additionally, in PR gdb/28405, a segfault is reported. This segfault triggers when 'set debug remote 1' is used before trying to reproduce the original assertion failure. The cause of this is in remote_target::select_thread_for_ambiguous_stop_reply, where we do this: remote_debug_printf ("first resumed thread is %s", pid_to_str (first_resumed_thread->ptid).c_str ()); remote_debug_printf ("is this guess ambiguous? = %d", ambiguous); gdb_assert (first_resumed_thread != nullptr); Notice that when debug printing is on we dereference first_resumed_thread before we assert that the pointer is not nullptr. This is the cause of the segfault, and is resolved by moving the assert before the debug printing code. I've extended an existing test, ext-attach.exp, so that the original test is run multiple times; we run in the original mode, as normal, but also, we now run with different packets disabled in gdbserver. In particular, disabling Tthread would trigger the assertion as it was reported in the original bug. I also run the test in all-stop and non-stop modes now for extra coverage, we also run the tests with target-async enabled, and disabled. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28405 This is a cherry pick of commit b622494ee378fd0a490 with a minor edit in gdb.server/ext-attach.exp to disable some tests that fail due to unrelated bugs. Those unrelated bugs have been fixed in the master branch. gdb/ChangeLog: PR gdb/28405 * remote.c (remote_target::remote_add_thread): Add new silent_p argument, use as needed. (remote_target::remote_notice_new_inferior): Pass additional argument to remote_add_thread. (remote_target::remote_notice_new_inferior): Likewise. (extended_remote_target::attach): Call remote_add_thread instead of add_thred_silent directly. (remote_target::select_thread_for_ambiguous_stop_reply): Move assert earlier, before we use the thing we're asserting is not nullptr. gdb/testsuite/ChangeLog: PR gdb/28405 * gdb.server/ext-attach.exp (run_test): New proc containing all of the old code for running the core of the test. This proc is then called multiple times from the global scope.
2021-12-11PR gdb/28480: Improve ambiguous member detectionBruno Larsen5-0/+73
Basic ambiguity detection assumes that when 2 fields with the same name have the same byte offset, it must be an unambiguous request. This is not always correct. Consider the following code: class empty { }; class A { public: [[no_unique_address]] empty e; }; class B { public: int e; }; class C: public A, public B { }; if we tried to use c.e in code, the compiler would warn of an ambiguity, however, since A::e does not demand an unique address, it gets the same address (and thus byte offset) of the members, making A::e and B::e have the same address. however, "print c.e" would fail to report the ambiguity, and would instead print it as an empty class (first path found). The new code solves this by checking for other found_fields that have different m_struct_path.back() (final class that the member was found in), despite having the same byte offset. The testcase gdb.cp/ambiguous.exp was also changed to test for this behavior. gdb/ChangeLog: PR gdb/28480 * valops.c (struct_field_searcher::update_result): Improve ambiguous member detection. gdb/testsuite/ChangeLog: PR gdb/28480 Pushed by Joel Brobecker <brobecker@adacore.com> * gdb.cp/ambiguous.cc: Add code to permit ambiguous member testing. * gdb.cp/ambiguous.exp: Add ambiguous member test. (cherry picked from commit a41ad3474ceacba39e11c7478154c0e553784a01)
2021-11-29Allow DW_ATE_UTF for Rust charactersTom Tromey4-13/+75
The Rust compiler plans to change the encoding of a Rust 'char' type to use DW_ATE_UTF. You can see the discussion here: https://github.com/rust-lang/rust/pull/89887 However, this fails in gdb. I looked into this, and it turns out that the handling of DW_ATE_UTF is currently fairly specific to C++. In particular, the code here assumes the C++ type names, and it creates an integer type. This comes from commit 53e710acd ("GDB thinks char16_t and char32_t are signed in C++"). The message says: Both places need fixing. But since I couldn't tell why dwarf2read.c needs to create a new type, I've made it use the per-arch built-in types instead, so that the types are only created once per arch instead of once per objfile. That seems to work fine. ... which is fine, but it seems to me that it's also correct to make a new character type; and this approach is better because it preserves the type name as well. This does use more memory, but first we shouldn't be too concerned about the memory use of types coming from debuginfo; and second, if we are, we should implement type interning anyway. Changing this code to use a character type revealed a couple of oddities in the C/C++ handling of TYPE_CODE_CHAR. This patch fixes these as well. I filed PR rust/28637 for this issue, so that this patch can be backported to the gdb 11 branch. (cherry picked from commit 1c0e43634cfdd0ad7ef9ac3dd7d208dddeb80f5e)
2021-11-09Fix build on rhES5Tom Tromey3-0/+24
The rhES5 build failed due to an upstream import a while back. The bug here is that, while the 'personality' function exists, ADDR_NO_RANDOMIZE is only defined in <linux/personality.h>, not <sys/personality.h>. However, <linux/personality.h> does not declare the 'personality' function, and <sys/personality.h> and <linux/personality.h> cannot both be included. This patch restores one of the removed configure checks and updates the code to check it. We had this as a local patch at AdaCore, because it seemed like there was no interest upstream. However, now it turns out that this fixes PR build/28555, so I'm sending it now.
2021-11-03[AArch64] Make gdbserver register set selection dynamicLuis Machado2-0/+15
The current register set selection mechanism for AArch64 is static, based on a pre-populated array of register sets. This means that we might potentially probe register sets that are not available. This is OK if the kernel errors out during ptrace, but probing the tag_ctl register, for example, does not result in a ptrace error if the kernel supports the tagged address ABI but not MTE (PR 28355). Making the register set selection dynamic, based on feature checks, solves this and simplifies the code a bit. It allows us to list all of the register sets only once, and pick and choose based on HWCAP/HWCAP2 or other properties. gdb/ChangeLog: 2021-11-03 Luis Machado <luis.machado@linaro.org> PR gdb/28355 * arch/aarch64.h (struct aarch64_features): New struct. gdbserver/ChangeLog: 2021-11-03 Luis Machado <luis.machado@linaro.org> PR gdb/28355 * linux-aarch64-low.cc (is_sve_tdesc): Remove. (aarch64_target::low_arch_setup): Rework to adjust the register sets. (aarch64_regsets): Update to list all register sets. (aarch64_regsets_info, regs_info_aarch64): Replace NULL with nullptr. (aarch64_sve_regsets, aarch64_sve_regsets_info) (regs_info_aarch64_sve): Remove. (aarch64_adjust_register_sets): New. (aarch64_target::get_regs_info): Remove references to removed structs. (initialize_low_arch): Likewise.
2021-10-22[gdb/tui] Fix breakpoint display functionalityTom de Vries4-2/+49
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 gdb/ChangeLog: 2021-10-22 Tom de Vries <tdevries@suse.de> PR tui/28483 * tui/tui-winsource.c (tui_source_window_base::update_breakpoint_info): Fix returns in loop body. gdb/testsuite/ChangeLog: 2021-10-22 Tom de Vries <tdevries@suse.de> PR tui/28483 * gdb.tui/break.exp: New file.
2021-10-04[gdb/build] Add CXX_DIALECT to CXXTom de Vries3-0/+22
Say we use a gcc version that (while supporting c++11) does not support c++11 by default, and needs an -std setting to enable it. If gdb would use the default AX_CXX_COMPILE_STDCXX from autoconf-archive, then we'd have: ... CXX="g++ -std=gnu++11" ... That mechanism however has the following problem (quoting from commit 0bcda685399): ... the top level Makefile passes CXX down to subdirs, and that overrides whatever gdb/Makefile may set CXX to. The result would be that a make invocation from the build/gdb/ directory would use "g++ -std=gnu++11" as expected, while a make invocation at the top level would not. ... Commit 0bcda685399 fixes this by using a custom AX_CXX_COMPILE_STDCXX which does: ... CXX=g++ CXX_DIALECT=-std=gnu++11 ... The problem reported in PR28318 is that using the custom instead of the default AX_CXX_COMPILE_STDCXX makes the configure test for std::thread support fail. We could simply add $CXX_DIALECT to the test for std::thread support, but that would have to be repeated for each added c++ support test. Instead, fix this by doing: ... CXX="g++ -std=gnu++11" CXX_DIALECT=-std=gnu++11 ... This is somewhat awkward, since it results in -std=gnu++11 occuring twice in some situations: ... $ touch src/gdb/dwarf2/read.c $ ( cd build/gdb; make V=1 dwarf2/read.o ) g++-4.8 -std=gnu++11 -x c++ -std=gnu++11 ... ... However, both settings are needed: - the switch in CXX for the std::thread tests (and other tests) - the switch in CXX_DIALECT so it can be appended in Makefiles, to counteract the fact that the top-level Makefile overrides CXX The code added in gdb/ax_cxx_compile_stdcxx.m4 is copied from the default AX_CXX_COMPILE_STDCXX from autoconf-archive. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28318 gdb/ChangeLog: 2021-10-04 Tom de Vries <tdevries@suse.de> PR build/28318 * ax_cxx_compile_stdcxx.m4: Add CXX_DIALECT to CXX. * configure: Regenerate. gdbserver/ChangeLog: 2021-10-04 Tom de Vries <tdevries@suse.de> PR build/28318 * configure: Regenerate. gdbsupport/ChangeLog: 2021-10-04 Tom de Vries <tdevries@suse.de> PR build/28318 * configure: Regenerate.
2021-09-12Bump GDB version number to 11.1.90.DATE-git.Joel Brobecker4-2/+10
gdb/ChangeLog: * version.in: Set GDB version number to 11.1.90.DATE-git. gdb/testsuite/ChangeLog: * gdb.base/default.exp: Change $_gdb_minor to 2.
2021-09-12Document the GDB 11.1 release in gdb/ChangeLogJoel Brobecker1-0/+4
gdb/ChangeLog: GDB 11.1 released.
2021-09-12Set GDB version number to 11.1.gdb-11.1-releaseJoel Brobecker2-1/+5
gdb/ChangeLog: * version.in: Set GDB version number to 11.1.
2021-09-10[gdb/testsuite] Handle unrecognized command line option in gdb_compile_testTom de Vries2-11/+29
When running the gdb testsuite with gnatmake-4.8, I get many fails of the following form: ... gcc: error: unrecognized command line option '-fgnat-encodings=all'^M gnatmake: "gdb.ada/O2_float_param/foo.adb" compilation error^M compiler exited with status 1 compilation failed: gcc ... gdb.ada/O2_float_param/foo.adb gcc: error: unrecognized command line option '-fgnat-encodings=all' gnatmake: "gdb.ada/O2_float_param/foo.adb" compilation error FAIL: gdb.ada/O2_float_param.exp: scenario=all: compilation foo.adb ... Fix this by marking the test unsupported instead, such that we have: ... UNSUPPORTED: gdb.ada/O2_float_param.exp: scenario=all: compilation foo.adb \ (unsupported option '-fgnat-encodings=all') ... Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-09-10 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (gdb_compile_test): Handle unrecognized command line option.
2021-09-09Add ChangeLog entry for previous patchTom Tromey1-0/+15
I forgot to 'git commit' the ChangeLog for the previous patch. 2021-09-08 Tom Tromey <tom@tromey.com> * dwarf2/read.h (dwarf2_per_objfile::resize_symtabs): Remove. * dwarf2/read.c (all_comp_units_iterator, all_comp_units_range): New classes. (dwarf2_per_objfile::symtab_set_p) (dwarf2_per_objfile::get_symtab, dwarf2_per_objfile::set_symtab): Adjust to resizeable vectors. (dwarf2_gdb_index::expand_symtabs_matching) (dwarf2_base_index_functions::map_symbol_filenames) (dwarf2_debug_names_index::expand_symtabs_matching): Use all_comp_units_range. (dwarf2_initialize_objfile, dwarf2_build_psymtabs) (add_type_unit): Don't call resize_symtabs.
2021-09-09[gdb/testsuite] Fix gdb.base/coredump-filter-build-id.exp with older eu-unstripTom de Vries2-1/+6
On openSUSE Leap 42.3 with eu-unstrip 0.158, we run into: ... (gdb) PASS: gdb.base/coredump-filter-build-id.exp: save corefile First line of eu-unstrip: \ 0x400000+0x202000 f4ae8502bd6a14770182382316bc595e9dc6f08b@0x400284 - - [exe] FAIL: gdb.base/coredump-filter-build-id.exp: gcore dumped mapping with build-id ... The test expects an actual file name instead of '[exe]', but that only got introduced with eu-unstrip 0.161. Before it printed '[exe]' or '[pie]'. Fix this by updating the regexp. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-09-09 Tom de Vries <tdevries@suse.de> * gdb.base/coredump-filter-build-id.exp: Handle older eu-unstrip.
2021-09-09[gdb/testsuite] Fix various issues in gdb.mi/mi-sym-info.expTom de Vries2-13/+39
I noticed this failure in gdb.mi/mi-sym-info.exp with gcc-4.8: ... FAIL: gdb.mi/mi-sym-info.exp: -symbol-info-functions --max-results 1 \ (unexpected output) ... due to function f2 instead of f3 being listed. AFAICT, this is caused by a difference in debug info: ... $ readelf -wi outputs/gdb.mi/mi-sym-info/mi-sym-info1.o \ | egrep "DW_AT_name.*: f[1-3]" <72> DW_AT_name : f1 <a1> DW_AT_name : f2 <d0> DW_AT_name : f3 ... vs: ... $ readelf -wi outputs/gdb.mi/mi-sym-info/mi-sym-info1.o \ | egrep "DW_AT_name.*: f[1-3]" <f4> DW_AT_name : f3 <123> DW_AT_name : f2 <152> DW_AT_name : f1 ... and the command documentation does not mention an imposed order, so fix this by allowing f2 as well. Doing this fix, it made sense to do a refactoring of adding f2_re and f3_re variables, in order to write (?:$f2_re|$f3_re), and I applied the same pattern overall. Furthermore, I found a silent FAIL due to calling mi_gdb_proc with 2 args, fix by updating the regexp. Then I ran with clang and found another FAIL, fix by updating the regexp. Tested on x86_64-linux with gcc-4.8.5, gcc-7.5.0, gcc-11.2.1, clang-7.0.1 and clang-12.0.1. gdb/testsuite/ChangeLog: 2021-09-09 Tom de Vries <tdevries@suse.de> * gdb.mi/mi-sym-info.exp: Fix regexps. Add missing message argument to mi_gdb_test. Factor out regexps for functions and variables.
2021-09-08Fix two regressions caused by CU / TU mergingTom Tromey2-38/+85
PR symtab/28160 and PR symtab/27893 concern GDB crashes in the test suite when using the "fission" target board. They are both caused by the patches that merge the list of CUs with the list of TUs (and to a lesser degree by the patches to share DWARF data across objfiles), and the underlying issue is the same: it turns out that reading a DWO can cause new type units to be created. This means that the list of dwarf2_per_cu_data objects depends on precisely which CUs have been expanded. However, because the type units can be created while expanding a CU means that the vector of CUs can expand while it is being iterated over -- a classic mistake. Also, because a TU can be added later, it means the resize_symtabs approach is incorrect. This patch fixes resize_symtabs by removing it, and having set_symtab resize the vector on demand. It fixes the iteration problem by introducing a safe (index-based) iterator and changing the relevant spots to use it. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28160 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27893 (cherry picked from commit d58e54bd277b90d847be09ae4b18bfdbc0dc2066)
2021-09-07fbsd-nat: Don't use '%jd' and '%ju' with printf_filtered.John Baldwin2-22/+28
The handler for 'info proc status' for native processes on FreeBSD uses the 'j' size modifier along with uintmax_t / intmax_t casts to output integer values for types such as off_t that are not aliases of a basic C type such as 'int' or 'long'. printf_filtered does not support the 'j' modifer, so this resulted in runtime errors in practice: (gdb) info proc stat process 8674 Name: ls State: T (stopped) Parent process: 8673 Process group: 8674 Session id: 2779 Unrecognized format specifier 'j' in printf Instead, use plongest and pulongest to generate the output strings of these integer values. gdb/ChangeLog: * fbsd-nat.c (fbsd_nat_target::info_proc): Use plongest and pulongest instead of %j.
2021-09-04[gdb/testsuite] Check avx support in gdb.arch/amd64-disp-step-avx.expTom de Vries5-83/+112
On a machine on Open Build Service I'm running into a SIGILL for test-case gdb.arch/amd64-disp-step-avx.exp: ... Program received signal SIGILL, Illegal instruction.^M test_rip_vex2 () at gdb.arch/amd64-disp-step-avx.S:40^M 40 vmovsd ro_var(%rip),%xmm0^M (gdb) FAIL: gdb.arch/amd64-disp-step-avx.exp: vex2: \ continue to test_rip_vex2_end ... The SIGILL happens when trying to execute the first avx instruction in the executable. I can't directly access the machine, but looking at the log for test-case gdb.arch/i386-avx.exp, it seems that there's no avx support: ... Breakpoint 1, main (argc=1, argv=0x7fffffffd6b8) at gdb.arch/i386-avx.c:68^M 68 if (have_avx ())^M (gdb) print have_avx ()^M $1 = 0^M ... Fix this by: - adding a gdb_caching_proc have_avx, similar to have_mpx, using the have_avx function from gdb.arch/i386-avx.c - using proc have_avx in both gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp and gdb/testsuite/gdb.arch/i386-avx.exp. Tested on my x86_64-linux laptop with avx support, where both test-cases pass. gdb/testsuite/ChangeLog: 2021-09-04 Tom de Vries <tdevries@suse.de> PR testsuite/26950 * gdb/testsuite/gdb.arch/i386-avx.c (main): Remove call to have_avx. (have_avx): Move ... * gdb/testsuite/lib/gdb.exp (have_avx): ... here. New proc. * gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp: Use have_avx. * gdb/testsuite/gdb.arch/i386-avx.exp: Same.
2021-09-03[gdb/testsuite] Add untested case in gdb.gdb/complaints.expTom de Vries2-0/+25
When building gdb with "-Wall -O2 -g -flto=auto", I run into: ... (gdb) call clear_complaints()^M No symbol "clear_complaints" in current context.^M (gdb) FAIL: gdb.gdb/complaints.exp: clear complaints ... The problem is that lto has optimized away clear_complaints, and consequently the selftests cannot run. Fix this by: - using info function to detect presence of clear_complaints - handling the absence of clear_complaints by calling untested ... (gdb) UNTESTED: gdb.gdb/complaints.exp: \ Cannot find clear_complaints, skipping test ... Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-09-03 Tom de Vries <tdevries@suse.de> * gdb.gdb/complaints.exp: Use untested if clear_complaints cannot be found.
2021-09-03[gdb/testsuite] Add untested case in selftest_setupTom de Vries2-7/+14
When building gdb with "-Wall -O2 -g -flto=auto", I run into: ... FAIL: gdb.gdb/python-helper.exp: breakpoint in captured_main \ (got interactive prompt) FAIL: gdb.gdb/python-helper.exp: run until breakpoint at captured_main WARNING: Couldn't test self ... and similar in gdb.gdb/selftest.exp. The first FAIL in more detail: ... (gdb) break captured_main^M Function "captured_main" not defined.^M Make breakpoint pending on future shared library load? (y or [n]) n^M (gdb) FAIL: gdb.gdb/python-helper.exp: breakpoint in captured_main \ (got interactive prompt) ... The problem is that lto has optimized away the captured_main function and consequently the selftests dependent on that cannot run. Fix this by: - using gdb_breakpoint to detect failure to set the breakpoint - handling the failure to set a breakpoint by calling untested - not emitting the warning if we've already got untested such that we have: ... (gdb) UNTESTED: gdb.gdb/python-helper.exp: Cannot set breakpoint at \ captured_main, skipping testcase. ... gdb/testsuite/ChangeLog: 2021-09-03 Tom de Vries <tdevries@suse.de> * lib/selftest-support.exp: Emit untested when not being able to set breakpoint.
2021-09-01[gdb/testsuite] Fix dwo path in fission-*.STom de Vries9-20/+21
[ Using $build for /home/vries/gdb_versions/devel/build to make things a bit more readable. ] When using make check// to run test-case gdb.dwarf2/fission-base.exp: ... ( cd $build/gdb; make check//unix RUNTESTFLAGS="fission-base.exp" ) ... we run into: ... (gdb) file \ $build/gdb/testsuite.unix/outputs/gdb.dwarf2/fission-base/fission-base^M Reading symbols from \ $build/gdb/testsuite.unix/outputs/gdb.dwarf2/fission-base/fission-base...^M warning: Could not find DWO CU \ $build/gdb/testsuite.1/outputs/gdb.dwarf2/fission-base/fission-base.dwo \ (0x807060504030201) referenced by CU at offset 0xc7 [in module \ $build/gdb/testsuite.unix/outputs/gdb.dwarf2/fission-base/fission-base]^M ... The problem is that the executable refers to the dwo file using path name $build/gdb/testsuite.1/outputs/gdb.dwarf2/fission-base/fission-base.dwo, while the actual dwo file is at $build/gdb/testsuite.unix/outputs/gdb.dwarf2/fission-base/fission-base.dwo. This is caused by this trick in fission-base.S: ... #define XSTR(s) STR(s) #define STR(s) #s ... .asciz XSTR(DWO) # DW_AT_GNU_dwo_name ... and: ... $ echo | gcc -E -dD - | grep "define unix" ... I used this trick to avoid doing additional_flags=-DDWO=\"$dwo\", since I was concerned that there could be quoting issues. However, I've found other uses of this pattern, f.i. in gdb/testsuite/gdb.base/corefile-buildid.exp: ... additional_flags=-DSHLIB_NAME=\"$dlopen_lib\"] ... So, fix this by: - using additional_flags=-DDWO=\"$dwo\" and - using plain DWO instead of XSTR(DWO) Likewise in other gdb.dwarf2/fission*.exp test-cases. Tested on x86_64-linux, using make check//unix. gdb/testsuite/ChangeLog: 2021-09-01 Tom de Vries <tdevries@suse.de> PR testsuite/28298 * gdb.dwarf2/fission-base.S: Use DWO instead of XSTR(DWO). * gdb.dwarf2/fission-loclists-pie.S: Same. * gdb.dwarf2/fission-loclists.S: Same. * gdb.dwarf2/fission-reread.S: Same. * gdb.dwarf2/fission-base.exp: Use additional_flags=-DDWO=\"$dwo\". * gdb.dwarf2/fission-loclists-pie.exp: Same. * gdb.dwarf2/fission-loclists.exp: Same. * gdb.dwarf2/fission-reread.exp: Same.
2021-09-01[gdb/testsuite] Fix gdb.fortran/call-no-debug.exp symbol searchTom de Vries2-7/+17
On openSUSE Tumbleweed I ran into: ... (gdb) ptype outstring_func.part^M No symbol "outstring_func" in current context.^M (gdb) FAIL: gdb.fortran/call-no-debug.exp: ptype outstring_func.part ... while on openSUSE Leap 15.2 I have instead: ... (gdb) ptype string_func_^M type = <unknown return type> ()^M (gdb) PASS: gdb.fortran/call-no-debug.exp: ptype string_func_ ... The difference is caused by the result for "info function string_func", which is this for the latter: ... (gdb) info function string_func^M All functions matching regular expression "string_func":^M ^M Non-debugging symbols:^M 0x000000000040089c string_func_^M ... but this for the former: ... (gdb) info function string_func^M All functions matching regular expression "string_func":^M ^M Non-debugging symbols:^M 0x00000000004012bb string_func_^M 0x00007ffff7bac5b0 outstring_func.part^M 0x00007ffff7bb1a00 outstring_func.part^M ... The extra symbols are part of glibc: ... $ nm /lib64/libc.so.6 | grep string_func 00000000000695b0 t outstring_func.part.0 000000000006ea00 t outstring_func.part.0 ... If glibc debug info is installed, we get instead: ... (gdb) info function string_func^M All functions matching regular expression "string_func":^M ^M File /usr/src/debug/glibc-2.33-9.1.x86_64/stdio-common/vfprintf-internal.c:^M 236: static int outstring_func(int, size_t, const unsigned int *, FILE *);^M ^M File vfprintf-internal.c:^M 236: static int outstring_func(int, size_t, const unsigned char *, FILE *);^M ^M Non-debugging symbols:^M 0x00000000004012bb string_func_^M ... and the FAIL doesn't trigger. Fix this by calling "info function string_func" before starting the exec, such that only symbols of the exec are taken into account. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-09-01 Tom de Vries <tdevries@suse.de> * gdb.fortran/call-no-debug.exp: Avoid shared lib symbols for find_mangled_name calls.
2021-08-30[gdb/cli] Don't assert on empty string for core-fileTom de Vries4-1/+17
With current gdb we run into: ... $ gdb -batch '' '' : No such file or directory. pathstuff.cc:132: internal-error: \ gdb::unique_xmalloc_ptr<char> gdb_abspath(const char*): \ Assertion `path != NULL && path[0] != '\0'' failed. ... Fix this by skipping the call to gdb_abspath in core_target_open in the empty-string case, such that we have instead: ... $ gdb -batch '' '' : No such file or directory. : No such file or directory. $ ... Tested on x86_64-linux. gdb/ChangeLog: 2021-08-30 Tom de Vries <tdevries@suse.de> PR cli/28290 * gdb/corelow.c (core_target_open): Skip call to gdb_abspath in the empty-string case. gdb/testsuite/ChangeLog: 2021-08-30 Tom de Vries <tdevries@suse.de> PR cli/28290 * gdb.base/batch-exit-status.exp: Add gdb '' and gdb '' '' tests.
2021-08-23[gdb] Fix 'not in executable format' error messageTom de Vries4-5/+46
With trying to load a non-executable file into gdb, we run into PR26880: ... $ gdb -q -batch test.c "0x7ffc87bfc8d0s": not in executable format: \ file format not recognized ... The problem is caused by using %ps in combination with the error function (note that confusingly, it does work in combination with the warning function). Fix this by using plain "%s" instead. Tested on x86_64-linux. gdb/ChangeLog: 2021-08-23 Tom de Vries <tdevries@suse.de> PR gdb/26880 * gdb/exec.c (exec_file_attach): Use %s instead of %ps in call to error function. gdb/testsuite/ChangeLog: 2021-08-23 Tom de Vries <tdevries@suse.de> PR gdb/26880 * gdb.base/non-executable.exp: New file.
2021-08-12Update documentation to mention PygmentsTom Tromey2-4/+14
Philippe Blain pointed out that the gdb documentation does not mention that Pygments may be used for source highlighting. This patch updates the docs to reflect how highlighting is actually done. (cherry picked from commit 6a33fa0efec5aa87230a84bcab3c097237dd7f90) gdb/doc/ChangeLog 2021-08-12 Tom Tromey <tromey@adacore.com> * gdb.texinfo (Output Styling): Mention Pygments.
2021-08-06[gdb/symtab] Fix zero address complaint for shlibTom de Vries6-8/+247
In PR28004 the following warning / Internal error is reported: ... $ gdb -q -batch \ -iex "set sysroot $(pwd -P)/repro" \ ./repro/gdb \ ./repro/core \ -ex bt ... Program terminated with signal SIGABRT, Aborted. #0 0x00007ff8fe8e5d22 in raise () from repro/usr/lib/libc.so.6 [Current thread is 1 (LWP 1762498)] #1 0x00007ff8fe8cf862 in abort () from repro/usr/lib/libc.so.6 warning: (Internal error: pc 0x7ff8feb2c21d in read in psymtab, \ but not in symtab.) warning: (Internal error: pc 0x7ff8feb2c218 in read in psymtab, \ but not in symtab.) ... #2 0x00007ff8feb2c21e in __gnu_debug::_Error_formatter::_M_error() const \ [clone .cold] (warning: (Internal error: pc 0x7ff8feb2c21d in read in \ psymtab, but not in symtab.) ) from repro/usr/lib/libstdc++.so.6 ... The warning is about the following: - in find_pc_sect_compunit_symtab we try to find the address (0x7ff8feb2c218 / 0x7ff8feb2c21d) in the symtabs. - that fails, so we try again in the partial symtabs. - we find a matching partial symtab - however, the partial symtab has a full symtab, so we should have found a matching symtab in the first step. The addresses are: ... (gdb) info sym 0x7ff8feb2c218 __gnu_debug::_Error_formatter::_M_error() const [clone .cold] in \ section .text of repro/usr/lib/libstdc++.so.6 (gdb) info sym 0x7ff8feb2c21d __gnu_debug::_Error_formatter::_M_error() const [clone .cold] + 5 in \ section .text of repro/usr/lib/libstdc++.so.6 ... which correspond to unrelocated addresses 0x9c218 and 0x9c21d: ... $ nm -C repro/usr/lib/libstdc++.so.6.0.29 | grep 000000000009c218 000000000009c218 t __gnu_debug::_Error_formatter::_M_error() const \ [clone .cold] ... which belong to function __gnu_debug::_Error_formatter::_M_error() in /build/gcc/src/gcc/libstdc++-v3/src/c++11/debug.cc. The partial symtab that is found for the addresses is instead the one for /build/gcc/src/gcc/libstdc++-v3/src/c++98/bitmap_allocator.cc, which is incorrect. This happens as follows. The bitmap_allocator.cc CU has DW_AT_ranges at .debug_rnglist offset 0x4b50: ... 00004b50 0000000000000000 0000000000000056 00004b5a 00000000000a4790 00000000000a479c 00004b64 00000000000a47a0 00000000000a47ac ... When reading the first range 0x0..0x56, it doesn't trigger the "start address of zero" complaint here: ... /* A not-uncommon case of bad debug info. Don't pollute the addrmap with bad data. */ if (range_beginning + baseaddr == 0 && !per_objfile->per_bfd->has_section_at_zero) { complaint (_(".debug_rnglists entry has start address of zero" " [in module %s]"), objfile_name (objfile)); continue; } ... because baseaddr != 0, which seems incorrect given that when loading the shared library individually in gdb (and consequently baseaddr == 0), we do see the complaint. Consequently, we run into this case in dwarf2_get_pc_bounds: ... if (low == 0 && !per_objfile->per_bfd->has_section_at_zero) return PC_BOUNDS_INVALID; ... which then results in this code in process_psymtab_comp_unit_reader being called with cu_bounds_kind == PC_BOUNDS_INVALID, which sets the set_addrmap argument to 1: ... scan_partial_symbols (first_die, &lowpc, &highpc, cu_bounds_kind <= PC_BOUNDS_INVALID, cu); ... and consequently, the CU addrmap gets build using address info from the functions. During that process, addrmap_set_empty is called with a range that includes 0x9c218 and 0x9c21d: ... (gdb) p /x start $7 = 0x9989c (gdb) p /x end_inclusive $8 = 0xb200d ... but it's called for a function at DIE 0x54153 with DW_AT_ranges at 0x40ae: ... 000040ae 00000000000b1ee0 00000000000b200e 000040b9 000000000009989c 00000000000998c4 000040c3 <End of list> ... and neither range includes 0x9c218 and 0x9c21d. This is caused by this code in partial_die_info::read: ... if (dwarf2_ranges_read (ranges_offset, &lowpc, &highpc, cu, nullptr, tag)) has_pc_info = 1; ... which pretends that the function is located at addresses 0x9989c..0xb200d, which is indeed not the case. This patch fixes the first problem encountered: fix the "start address of zero" complaint warning by removing the baseaddr part from the condition. Same for dwarf2_ranges_process. The effect is that: - the complaint is triggered, and - the warning / Internal error is no longer triggered. This does not fix the observed problem in partial_die_info::read, which is filed as PR28200. Tested on x86_64-linux. Co-Authored-By: Simon Marchi <simon.marchi@polymtl.ca> gdb/ChangeLog: 2021-08-06 Simon Marchi <simon.marchi@polymtl.ca> Tom de Vries <tdevries@suse.de> PR symtab/28004 * dwarf2/read.c (dwarf2_rnglists_process, dwarf2_ranges_process): Fix zero address complaint. gdb/testsuite/ChangeLog: 2021-08-06 Simon Marchi <simon.marchi@polymtl.ca> Tom de Vries <tdevries@suse.de> PR symtab/28004 * gdb.dwarf2/dw2-zero-range-shlib.c: New test. * gdb.dwarf2/dw2-zero-range.c: New test. * gdb.dwarf2/dw2-zero-range.exp: New file.
2021-08-02Avoid crash in varobj deletionTom Tromey4-2/+27
PR varobj/28131 points out a crash in the varobj deletion code. It took a while to reproduce this, but essentially what happens is that a top-level varobj deletes its root object, then deletes the "dynamic" object. However, deletion of the dynamic object may cause ~py_varobj_iter to run, which in turn uses gdbpy_enter_varobj: gdbpy_enter_varobj::gdbpy_enter_varobj (const struct varobj *var) : gdbpy_enter (var->root->exp->gdbarch, var->root->exp->language_defn) { } However, because var->root has already been destroyed, this is invalid. I've added a new test case. This doesn't reliably crash, but the problem can easily be seen under valgrind (and, I presume, with ASAN, though I did not try this). Tested on x86-64 Fedora 32. I also propose putting this on the GDB 11 branch, with a suitable ChangeLog entry of course. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28131 (cherry picked from commit 4d0754c5f572b01cf2fe6c8ab292adba83331cbc) gdb/ChangeLog 2021-08-02 Tom Tromey <tromey@adacore.com> PR varobj/28131 * varobj.c (~varobj): Delete 'dynamic' before 'root'. gdb/testsuite/ChangeLog 2021-08-02 Tom Tromey <tromey@adacore.com> PR varobj/28131 * gdb.python/py-mi-var-info-path-expression.exp: Add regression test.
2021-08-02gdb: Make the builtin "boolean" type an unsigned typeShahab Vahedi3-1/+78
When printing the fields of a register that is of a custom struct type, the "unpack_bits_as_long ()" function is used: do_val_print (...) cp_print_value_fields (...) value_field_bitfield (...) unpack_value_bitfield (...) unpack_bits_as_long (...) This function may sign-extend the extracted field while returning it: val >>= lsbcount; if (...) { valmask = (((ULONGEST) 1) << bitsize) - 1; val &= valmask; if (!field_type->is_unsigned ()) if (val & (valmask ^ (valmask >> 1))) val |= ~valmask; } return val; lsbcount: Number of lower bits to get rid of. bitsize: The bit length of the field to be extracted. val: The register value. field_type: The type of field that is being handled. While the logic here is correct, there is a problem when it is handling "field_type"s of "boolean". Those types are NOT marked as "unsigned" and therefore they end up being sign extended. Although this is not a problem for "false" (0), it definitely causes trouble for "true". This patch constructs the builtin boolean type as such that it is marked as an "unsigned" entity. The issue tackled here was first encountered for arc-elf32 target running on an x86_64 machine. The unit-test introduced in this change has passed for all the targets (--enable-targets=all) running on the same x86_64 host. gdb/ChangeLog: PR gdb/28104 * gdbtypes.c (gdbtypes_post_init): Use "arch_boolean_type (..., unsigned=1, ...) to construct "boolean". cp-valprint.c (test_print_flags): New. (_initialize_cp_valprint): Run the "test_print_flags" unit-test.
2021-07-28[gdb/symtab] Fix unhandled dwarf expression opcode with gcc-11 -gdwarf-5Tom de Vries2-1/+20
[ I've confused things by forgetting to add -gdwarf-4 in $subject of commit 0057a7ee0d9 "[gdb/testsuite] Add KFAILs for gdb.ada FAILs with gcc-11". So I'm adding here -gdwarf-5 in $subject, even though -gdwarf-5 is the default for gcc-11. I keep getting confused because of working with a system gcc-11 compiler that was patched to switch the default back to -gdwarf-4. ] When running test-case gdb.ada/arrayptr.exp with gcc-11 (and default -gdwarf-5), I run into: ... (gdb) print pa_ptr.all^M Unhandled dwarf expression opcode 0xff^M (gdb) FAIL: gdb.ada/arrayptr.exp: scenario=all: print pa_ptr.all ... What happens is that pa_ptr: ... <2><1523>: Abbrev Number: 3 (DW_TAG_variable) <1524> DW_AT_name : pa_ptr <1529> DW_AT_type : <0x14fa> ... has type: ... <2><14fa>: Abbrev Number: 2 (DW_TAG_typedef) <14fb> DW_AT_name : foo__packed_array_ptr <1500> DW_AT_type : <0x1504> <2><1504>: Abbrev Number: 4 (DW_TAG_pointer_type) <1505> DW_AT_byte_size : 8 <1505> DW_AT_type : <0x1509> ... which is a pointer to a subrange: ... <2><1509>: Abbrev Number: 12 (DW_TAG_subrange_type) <150a> DW_AT_lower_bound : 0 <150b> DW_AT_upper_bound : 0x3fffffffffffffffff <151b> DW_AT_name : foo__packed_array <151f> DW_AT_type : <0x15cc> <1523> DW_AT_artificial : 1 <1><15cc>: Abbrev Number: 5 (DW_TAG_base_type) <15cd> DW_AT_byte_size : 16 <15ce> DW_AT_encoding : 7 (unsigned) <15cf> DW_AT_name : long_long_long_unsigned <15d3> DW_AT_artificial : 1 ... with upper bound of form DW_FORM_data16. In gdb/dwarf/attribute.h we have: ... /* Return non-zero if ATTR's value falls in the 'constant' class, or zero otherwise. When this function returns true, you can apply the constant_value method to it. ... DW_FORM_data16 is not considered as constant_value cannot handle that. */ bool form_is_constant () const; ... so instead we have attribute::form_is_block (DW_FORM_data16) == true. Then in attr_to_dynamic_prop for the upper bound, we get a PROC_LOCEXPR instead of a PROP_CONST and end up trying to evaluate the constant 0x3fffffffffffffffff as if it were a locexpr, which causes the "Unhandled dwarf expression opcode 0xff". In contrast, with -gdwarf-4 we have: ... <164c> DW_AT_upper_bound : 18 byte block: \ 9e 10 ff ff ff ff ff ff ff ff 3f 0 0 0 0 0 0 0 \ (DW_OP_implicit_value 16 byte block: \ ff ff ff ff ff ff ff ff 3f 0 0 0 0 0 0 0 ) ... Fix the dwarf error by translating the DW_FORM_data16 constant into a PROC_LOCEXPR, effectively by prepending 0x9e 0x10, such that we have same result as with -gdwarf-4: ... (gdb) print pa_ptr.all^M That operation is not available on integers of more than 8 bytes.^M (gdb) KFAIL: gdb.ada/arrayptr.exp: scenario=all: print pa_ptr.all \ (PRMS: gdb/20991) ... Tested on x86_64-linux, with gcc-11 and target board unix/gdb:debug_flags=-gdwarf-5. gdb/ChangeLog: 2021-07-28 Tom de Vries <tdevries@suse.de> * dwarf2/read.c (attr_to_dynamic_prop): Handle DW_FORM_data16.
2021-07-27[gdb/testsuite] Add xfail for PR gcc/101643Tom de Vries2-2/+26
With gcc 8.5.0 I run into: ... (gdb) print bad^M $2 = (0 => 0 <repeats 25 times>)^M (gdb) FAIL: gdb.ada/big_packed_array.exp: scenario=minimal: print bad ... while with gcc 9.3.1 we have instead: ... (gdb) print bad^M $2 = (false <repeats 196 times>)^M (gdb) PASS: gdb.ada/big_packed_array.exp: scenario=minimal: print bad ... This is caused by gcc PR, which I've filed at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101643 "[debug, ada] packed array not described as packed". Fix by marking this as XFAIL. Tested on x86_64-linux. gdb/ChangeLog: 2021-07-27 Tom de Vries <tdevries@suse.de> PR testsuite/26904 * gdb/testsuite/gdb.ada/big_packed_array.exp: Add xfail.
2021-07-27[gdb/testsuite] Add xfail for PR gcc/101633Tom de Vries2-7/+41
With gcc 7.5.0, I run into: ... (gdb) print objects^M $1 = ((tag => object, values => ()), (tag => unused))^M (gdb) FAIL: gdb.ada/array_of_variant.exp: scenario=minimal: print entire array ... while with gcc 8.5.0 we have: ... (gdb) print objects^M $1 = ((tag => object, values => (2, 2, 2, 2, 2)), (tag => unused))^M (gdb) PASS: gdb.ada/array_of_variant.exp: scenario=minimal: print entire array ... This is due to a gcc PR, which I've filed at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101633 "Bug 101633 - [debug] DW_TAG_subrange_type missing DW_AT_upper_bound". Fix by marking this and related FAILs as XFAIL. Tested on x86_64-linux. gdb/ChangeLog: 2021-07-27 Tom de Vries <tdevries@suse.de> PR testsuite/26903 * gdb/testsuite/gdb.ada/array_of_variant.exp: Add xfails.
2021-07-26Update the NetBSD system call table to match NetBSD-current.Frederic Cambus2-1/+21
Generated from sys/sys/syscall.h revision 1.319. We can safely remove the _lwp_gettid syscall, which was never exposed in libc and never made it into a release. gdb/ChangeLog: 2021-07-26 Frederic Cambus <fred@statdns.com> * syscalls/netbsd.xml: Regenerate.
2021-07-26gdb: Fix numerical field extraction for target description "flags"Shahab Vahedi2-2/+43
The "val_print_type_code_flags ()" function is responsible for extraction of fields for "flags" data type. These data types are used when describing a custom register type in a target description XML. The logic used for the extraction though is not sound: unsigned field_len = TYPE_FIELD_BITSIZE (type, field); ULONGEST field_val = val >> (TYPE_FIELD_BITPOS (type, field) - field_len + 1); TYPE_FIELD_BITSIZE: The bit length of the field to be extracted. TYPE_FIELD_BITPOS: The starting position of the field; 0 is LSB. val: The register value. Imagine you have a field that starts at position 1 and its length is 4 bits. According to the third line of the code snippet the shifting right would become "val >> -2", or "val >> 0xfff...fe" to be precise. That will result in a "field_val" of 0. The correct extraction should be: ULONGEST field_val = val >> TYPE_FIELD_BITPOS (type, field); The rest of the algorithm that masks out the higher bits is OK. gdb/ChangeLog: 2021-07-26 Shahab Vahedi <shahab@synopsys.com> Simon Marchi <simon.marchi@efficios.com> PR gdb/28103 * valprint.c (val_print_type_code_flags): Merely shift the VAL to the right to get rid of the lower bits. (test_print_flags): New. (_initialize_valprint): Invoke the "test_print_flags" as a unit-test. Co-Authored-By: Simon Marchi <simon.marchi@efficios.com>
2021-07-26gdb/mi: handle no condition argument case for -break-conditionTankut Baris Aktemur6-10/+50
As reported in PR gdb/28076 [1], passing no condition argument to the -break-condition command (e.g.: "-break-condition 2") should clear the condition for breakpoint 2, just like CLI's "condition 2", but instead an error message is returned: ^error,msg="-break-condition: Missing the <number> and/or <expr> argument" The current implementation of the -break-condition command's argument handling (79aabb7308c "gdb/mi: add a '--force' flag to the '-break-condition' command") was done according to the documentation, where the condition argument seemed mandatory. However, the -break-condition command originally (i.e. before the 79aabb7308c patch) used the CLI's "cond" command, and back then not passing a condition argument was clearing out the condition. So, this is a regression in terms of the behavior. Fix the argument handling of the -break-condition command to allow not having a condition argument, and also update the document to make the behavior clear. Also add test cases to test the scenarios which were previously not covered. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=28076 gdb/ChangeLog: 2021-07-26 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> PR gdb/28076 * mi/mi-cmd-break.c (mi_cmd_break_condition): Handle the case of having no condition argument. gdb/doc/ChangeLog: 2021-07-26 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> PR gdb/28076 * gdb.texinfo (GDB/MI Breakpoint Commands): Mention clearing the condition in the -break-condition command. gdb/testsuite/ChangeLog: 2021-07-26 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> PR gdb/28076 * gdb.mi/mi-break.exp: Add more tests to check clearing the breakpoint condition.
2021-07-22[gdb/testsuite] Fix FAILs due to PR gcc/101575Tom de Vries4-5/+77
When running test-case gdb.ada/formatted_ref.exp with gcc-11 and target board unix/gdb:debug_flags=-gdwarf-4 we run into: ... (gdb) print/x s^M No definition of "s" in current context.^M (gdb) FAIL: gdb.ada/formatted_ref.exp: print/x s ... which is caused by "runto defs.adb:20" taking us to defs__struct1IP: ... (gdb) break defs.adb:20^M Breakpoint 1 at 0x402cfd: defs.adb:20. (2 locations)^M (gdb) run ^M Starting program: formatted_ref ^M ^M Breakpoint 1, defs__struct1IP () at defs.adb:20^M 20 return s.x; -- Set breakpoint marker here.^M (gdb) print s1'access^M ... instead of the expected defs.f1: ... (gdb) break defs.adb:20^M Breakpoint 1 at 0x402d0e: file defs.adb, line 20.^M (gdb) run ^M Starting program: formatted_ref ^M ^M Breakpoint 1, defs.f1 (s=...) at defs.adb:20^M 20 return s.x; -- Set breakpoint marker here.^M ... This is caused by incorrect line info due to gcc PR 101575 - "[gcc-11, -gdwarf-4] Missing .file <n> directive causes invalid line info". Fix this by when landing in defs__struct1IP: - xfailing the runto, and - issuing a continue to land in defs.f1. Likewise in a few other test-cases. Tested on x86_64-linux, with: - system gcc. - gcc-11 and target boards unix/gdb:debug_flags=-gdwarf-4 and unix/gdb:debug_flags=-gdwarf-5. gdb/testsuite/ChangeLog: 2021-07-22 Tom de Vries <tdevries@suse.de> * gdb.ada/formatted_ref.exp: Add xfail for PR gcc/101575. * gdb.ada/iwide.exp: Same. * gdb.ada/pkd_arr_elem.exp: Same.
2021-07-22[gdb/testsuite] Fix gdb.cp/step-and-next-inline.exp with gcc-11Tom de Vries4-13/+92
When running test-case gdb.cp/step-and-next-inline.exp with gcc-11, I run into: ... KPASS: gdb.cp/step-and-next-inline.exp: no_header: next step 1 \ (PRMS symtab/25507) FAIL: gdb.cp/step-and-next-inline.exp: no_header: next step 2 KPASS: gdb.cp/step-and-next-inline.exp: no_header: next step 3 \ (PRMS symtab/25507) ... [ Note that I get the same result with gcc-11 and target board unix/gdb:debug_flags=-gdwarf-4, so this is not a dwarf 4 vs 5 issue. ] With gcc-10, I have this trace: ... 64 get_alias_set (&xx); get_alias_set (t=0x601038 <xx>) at step-and-next-inline.cc:51 51 if (t != NULL 40 if (t->x != i) 52 && TREE_TYPE (t).z != 1 43 return x; 53 && TREE_TYPE (t).z != 2 43 return x; 54 && TREE_TYPE (t).z != 3) 43 return x; main () at step-and-next-inline.cc:65 65 return 0; ... and with gcc-11, I have instead: ... 64 get_alias_set (&xx); get_alias_set (t=0x601038 <xx>) at step-and-next-inline.cc:51 51 if (t != NULL 52 && TREE_TYPE (t).z != 1 43 return x; 53 && TREE_TYPE (t).z != 2 43 return x; 54 && TREE_TYPE (t).z != 3) 43 return x; main () at step-and-next-inline.cc:65 65 return 0; ... and with clang-10, I have instead: ... 64 get_alias_set (&xx); get_alias_set (t=0x601034 <xx>) at step-and-next-inline.cc:51 51 if (t != NULL 52 && TREE_TYPE (t).z != 1 53 && TREE_TYPE (t).z != 2 54 && TREE_TYPE (t).z != 3) 51 if (t != NULL 57 } main () at step-and-next-inline.cc:65 65 return 0; ... The test-case tries to verify that we don't step into inlined function tree_check (lines 40-43) (so, with the clang trace we get that right). The test-case then tries to kfail the problems when using gcc, but this is done in such a way that the testing still gets out of sync after a failure. That is: the "next step 2" check that is supposed to match "TREE_TYPE (t).z != 2" is actually matching "TREE_TYPE (t).z != 1": ... (gdb) next^M 52 && TREE_TYPE (t).z != 1^M (gdb) PASS: gdb.cp/step-and-next-inline.exp: no_header: next step 2 ... Fix this by issuing extra nexts to arrive at the required lines. Tested on x86_64-linux, with gcc-8, gcc-9, gcc-10, gcc-11, clang-8, clang-10 and clang-12. gdb/testsuite/ChangeLog: 2021-07-22 Tom de Vries <tdevries@suse.de> * gdb.cp/step-and-next-inline.cc (tree_check, get_alias_set, main): Tag closing brace with comment. * gdb.cp/step-and-next-inline.h: Update to keep identical with step-and-next-inline.cc. * gdb.cp/step-and-next-inline.exp: Issue extra next when required.
2021-07-21[gdb/testsuite] Fix FAILs due to PR gcc/101452Tom de Vries7-4/+62
When running test-case gdb.base/ptype-offsets.exp with gcc-11 (with -gdwarf-5 default) or gcc-10 with target board unix/gdb:debug_flags=-gdwarf-5 we run into this regression: ... (gdb) ptype/o static_member^M /* offset | size */ type = struct static_member {^M - static static_member Empty;^M /* 0 | 4 */ int abc;^M ^M /* total size (bytes): 4 */^M }^M -(gdb) PASS: gdb.base/ptype-offsets.exp: ptype/o static_member +(gdb) FAIL: gdb.base/ptype-offsets.exp: ptype/o static_member ... This is caused by missing debug info, which I filed as gcc PR101452 - "[debug, dwarf-5] undefined static member removed by -feliminate-unused-debug-symbols". It's not clear yet whether this is a bug or a feature, but work around this in the test-cases by: - defining the static member - adding additional_flags=-fno-eliminate-unused-debug-types. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-07-21 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (gcc_major_version): New proc. * gdb.base/ptype-offsets.cc: Define static member static_member::Empty. * gdb.cp/templates.exp: Define static member using -DGCC_BUG. * gdb.cp/m-static.exp: Add additional_flags=-fno-eliminate-unused-debug-types. * gdb.cp/pr-574.exp: Same. * gdb.cp/pr9167.exp: Same.
2021-07-21[gdb/testsuite] Add KFAILs for gdb.ada FAILs with gcc-11Tom de Vries4-22/+133
With gcc-11 we run into: ... (gdb) print pa_ptr.all^M That operation is not available on integers of more than 8 bytes.^M (gdb) KFAIL: gdb.ada/arrayptr.exp: scenario=all: print pa_ptr.all (PRMS: gdb/20991) ... This is due to PR exp/20991 - "__int128 type support". Mark this and similar FAILs as KFAIL. Also mark this FAIL: .... (gdb) print pa_ptr(3)^M cannot subscript or call something of type `foo__packed_array_ptr'^M (gdb) FAIL: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr(3) ... as a KFAIL for PR ada/28115 - "Support packed array encoded as DW_TAG_subrange_type". Tested on x86_64-linux, with gcc-10 and gcc-11. gdb/testsuite/ChangeLog: 2021-07-21 Tom de Vries <tdevries@suse.de> * gdb.ada/arrayptr.exp: Add KFAILs for PR20991 and PR28115. * gdb.ada/exprs.exp: Add KFAILs for PR20991. * gdb.ada/packed_array_assign.exp: Same.
2021-07-20Fix printing of non-address types when memory tagging is enabledLuis Machado4-31/+68
When the architecture supports memory tagging, we handle pointer/reference types in a special way, so we can validate tags and show mismatches. Unfortunately, the currently implementation errors out when the user prints non-address values: composite types, floats, references, member functions and other things. Vector registers: (gdb) p $v0 Value can't be converted to integer. Non-existent internal variables: (gdb) p $foo Value can't be converted to integer. The same happens for complex types and printing struct/union types. There are a few problems here. The first one is that after print_command_1 evaluates the expression to print, the tag validation code call value_as_address unconditionally, without making sure we have have a suitable type where it makes to sense to call it. That results in value_as_address (if it isn't given a pointer-like type) trying to treat the value as an integer and convert it to an address, which #1 - doesn't make sense (i.e., no sense in validating tags after "print 1"), and throws for non-integer-convertible types. We fix this by making sure we have a pointer or reference type first, and only if so then proceed to check if the address-like value has tags. The second is that we're calling value_as_address even if we have an optimized out or unavailable value, which throws, because the value's contents aren't fully accessible/readable. This error currently escapes out and aborts the print. This case is fixed by checking for optimized out / unavailable explicitly. Third, the tag checking process does not gracefully handle exceptions. If any exception is thrown from the tag validation code, we abort the print. E.g., the target may fail to access tags via a running thread. Or the needed /proc files aren't available. Or some other untold reason. This is a bit too rigid. This commit changes print_command_1 to catch errors, print them, and still continue with the normal expression printing path instead of erroring out and printing nothing useful. With this patch, printing works correctly again: (gdb) p $v0 $1 = {d = {f = {2.0546950501119882e-81, 2.0546950501119882e-81}, u = {3399988123389603631, 3399988123389603631}, s = { 3399988123389603631, 3399988123389603631}}, s = {f = {1.59329203e-10, 1.59329203e-10, 1.59329203e-10, 1.59329203e-10}, u = { 791621423, 791621423, 791621423, 791621423}, s = {791621423, 791621423, 791621423, 791621423}}, h = {bf = {1.592e-10, 1.592e-10, 1.592e-10, 1.592e-10, 1.592e-10, 1.592e-10, 1.592e-10, 1.592e-10}, f = {0.11224, 0.11224, 0.11224, 0.11224, 0.11224, 0.11224, 0.11224, 0.11224}, u = {12079, 12079, 12079, 12079, 12079, 12079, 12079, 12079}, s = {12079, 12079, 12079, 12079, 12079, 12079, 12079, 12079}}, b = {u = {47 <repeats 16 times>}, s = {47 <repeats 16 times>}}, q = {u = { 62718710765820030520700417840365121327}, s = {62718710765820030520700417840365121327}}} (gdb) p $foo $2 = void (gdb) p 2 + 2i $3 = 2 + 2i gdb/ChangeLog 2021-07-20 Luis Machado <luis.machado@linaro.org> Pedro Alves <pedro@palves.net> PR gdb/28110 * gdbarch.sh: Updated documentation for gdbarch_tagged_address_p. * gdbarch.h: Regenerate. * printcmd.c (should_validate_memtags): Reorder comparisons and only validate tags for pointer and reference types. Skip validation of optimized out or unavailable values. (print_command_1): Guard call memory tagging validation code with a try/catch block. Co-Authored-By: Pedro Alves <pedro@palves.net> Change-Id: I82bf00ac88d23553b3f7563c9872dfa6ca1f2207
2021-07-19Avoid expression parsing crash with unknown languageTom Tromey4-2/+18
PR gdb/28093 points out that gdb crashes when language is set to "unknown" and expression parsing is attempted. At first I thought this was a regression due to the expression rewrite, but it turns out that older versions crash as well. This patch avoids the crash by changing the default expression parser to throw an exception. I think this is preferable -- the current behavior of silently doing nothing does not really make sense. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28093 (cherry picked from commit dcd482c1b756d9da2130552a6eb58b852d6efb97) gdb/ChangeLog 2021-07-19 Tom Tromey <tromey@adacore.com> PR gdb/28093 * language.c (auto_or_unknown_language::parser): Call error. gdb/testsuite/ChangeLog 2021-07-19 Tom Tromey <tromey@adacore.com> PR gdb/28093 * gdb.base/langs.exp: Add tests.
2021-07-17Add basic Z80 CPU supportSergey Belyashov12-2/+2982
Supported ISAs: - Z80 (all undocumented instructions) - Z180 - eZ80 (Z80 mode only) Datasheets: Z80: https://www.zilog.com/manage_directlink.php?filepath=docs/z80/um0080&extn=.pdf Z180: https://www.zilog.com/manage_directlink.php?filepath=docs/z180/ps0140&extn=.pdf eZ80: http://www.zilog.com/force_download.php?filepath=YUhSMGNEb3ZMM2QzZHk1NmFXeHZaeTVqYjIwdlpHOWpjeTlWVFRBd056Y3VjR1Jt To debug Z80 programs using GDB you must configure and embed z80-stub.c to your program (SDCC compiler is required). Or you may use some simulator with GDB support. gdb/ChangeLog: * Makefile.in (ALL_TARGET_OBS): Add z80-tdep.c. * NEWS: Mention z80 support. * configure.tgt: Handle z80*. * features/Makefile (XMLTOC): Add z80.xml. * features/z80-cpu.xml: New. * features/z80.c: Generate. * features/z80.xml: New. * z80-tdep.c: New file. * z80-tdep.h: New file. gdb/stubs/ChangeLog: * z80-stub.c: New file. Change-Id: Id0b7a6e210c3f93c6853c5e3031b7bcee47d0db9
2021-07-14[gdb/testsuite] Fix gdb.base/gold-gdb-index.expTom de Vries3-1/+34
When running test-case gdb.base/gold-gdb-index.exp on openSUSE Tumbleweed, I run into: ... FAIL: gdb.base/gold-gdb-index.exp: maint info symtabs ... This is due to a dummy .gdb_index: ... Contents of the .gdb_index section: Version 7 CU table: TU table: Address table: Symbol table: ... The dummy .gdb_index is ignored when loading the symbols, and instead partial symbols are used. Consequently, we get the same result as if we'd removed -Wl,--gdb-index from the compilation. Presumably, gold fails to generate a proper .gdb_index because it lacks DWARF5 support. Anyway, without a proper .gdb_index we can't test the gdb behaviour we're trying to excercise. Fix this by detecting whether we actually used a .gdb_index for symbol loading. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-07-14 Tom de Vries <tdevries@suse.de> * lib/gdb.exp (have_index): New proc. * gdb.base/gold-gdb-index.exp: Use have_index.
2021-07-13Use /bin/sh as shebang in gdb/make-init-cLancelot SIX2-1/+5
While testing the NixOS[1] packaging for gdb-11.0.90.tar.xz, IĀ got the following error: [...] CXX aarch32-tdep.o CXX gdb.o GEN init.c /nix/store/26a78ync552m8j4sbjavhvkmnqir8c9y-bash-4.4-p23/bin/bash: ./make-init-c: /usr/bin/env: bad interpreter: No such file or directory make[2]: *** [Makefile:1866: stamp-init] Error 126 make[2]: *** Waiting for unfinished jobs.... make[2]: Leaving directory '/build/gdb-11.0.90/gdb' make[1]: *** [Makefile:9814: all-gdb] Error 2 make[1]: Leaving directory '/build/gdb-11.0.90' make: *** [Makefile:903: all] Error 2 builder for '/nix/store/xs8my3rrc3l4kdlbpx0azh6q0v0jxphr-gdb-gdb-11.0.90.drv' failed with exit code 2 error: build of '/nix/store/xs8my3rrc3l4kdlbpx0azh6q0v0jxphr-gdb-gdb-11.0.90.drv' failed In the nix build environment, /usr/bin/env is not present, only /bin/sh is. This patch makes sure that gdb/make-init-c uses '/bin/sh' as interpreter as this is the only one available on this platform. I do not think this change will cause regressions on any other configuration. [1] https://nixos.org/ gdb/Changelog * make-init-c: Use /bin/sh as shebang.