aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2020-06-02gas: Fix checking for backwards .org with negative offsetAlex Coplan8-2/+27
This patch fixes internal errors in (at least) arm and aarch64 GAS when assembling code that attempts a negative .org. The bug appears to be a regression introduced in binutils-2.29 by commit 9875b36538d. * write.c (relax_segment): Fix handling of negative offset when relaxing an rs_org frag. * testsuite/gas/aarch64/org-neg.d: New test. * testsuite/gas/aarch64/org-neg.l: Error output for test. * testsuite/gas/aarch64/org-neg.s: Input for test. * testsuite/gas/arm/org-neg.d: New test. * testsuite/gas/arm/org-neg.l: Error output for test. * testsuite/gas/arm/org-neg.s: Input for test.
2020-06-01alpha-vms: ETIR checksAlan Modra2-13/+29
Better validity checks, and remove a fuzzer vulnerability of sorts that targeted the store-immediate-repeat command with a zero length but very large repeat counts to chew cpu. * vms-alpha.c (_bfd_vms_slurp_etir): Check bound for the current command against cmd_length, not the end of record. For ETIR__C_STO_IMMR check size against cmd_length, mask repeat count to 32-bits and break out on zero size. Add ETIR__C_STC_LP_PSB cmd_length test.
2020-06-01Regen opcodes/bpf-desc.cAlan Modra2-12/+8
The last regen used an old version of cgen. * bpf-desc.c: Regenerate.
2020-06-01gdb: Preserve is-stmt lines when switch between filesAndrew Burgess10-3/+734
After the is-stmt support commit: commit 8c95582da858ac981f689a6f599acacb8c5c490f Date: Mon Dec 30 21:04:51 2019 +0000 gdb: Add support for tracking the DWARF line table is-stmt field A regression was observed where a breakpoint could no longer be placed in some cases. Consider a line table like this: File 1: test.c File 2: test.h | Addr | File | Line | Stmt | |------|------|------|------| | 1 | 1 | 16 | Y | | 2 | 1 | 17 | Y | | 3 | 2 | 21 | Y | | 4 | 2 | 22 | Y | | 4 | 1 | 18 | N | | 5 | 2 | 23 | N | | 6 | 1 | 24 | Y | | 7 | 1 | END | Y | |------|------|------|------| Before the is-stmt patch GDB would ignore any non-stmt lines, so GDB built two line table structures: File 1 File 2 ------ ------ | Addr | Line | | Addr | Line | |------|------| |------|------| | 1 | 16 | | 3 | 21 | | 2 | 17 | | 4 | 22 | | 3 | END | | 6 | END | | 6 | 24 | |------|------| | 7 | END | |------|------| After the is-stmt patch GDB now records non-stmt lines, so the generated line table structures look like this: File 1 File 2 ------ ------ | Addr | Line | Stmt | | Addr | Line | Stmt | |------|------|------| |------|------|------| | 1 | 16 | Y | | 3 | 21 | Y | | 2 | 17 | Y | | 4 | 22 | Y | | 3 | END | Y | | 4 | END | Y | | 4 | 18 | N | | 5 | 23 | N | | 5 | END | Y | | 6 | END | Y | | 6 | 24 | Y | |------|------|------| | 7 | END | Y | |------|------|------| The problem is that in 'File 2', end END marker at address 4 causes the previous line table entry to be discarded, so we actually end up with this: File 2 ------ | Addr | Line | Stmt | |------|------|------| | 3 | 21 | Y | | 4 | END | Y | | 5 | 23 | N | | 6 | END | Y | |------|------|------| When a user tries to place a breakpoint in file 2 at line 22, this is no longer possible. The solution I propose here is that we ignore line table entries that would trigger a change of file if: 1. The new line being added is at the same address as the previous line, and 2. We have previously seen an is-stmt line at the current address. The result of this is that GDB switches file, and knows that some line entry (or entries) are going to be discarded, prefer to keep is-stmt lines and discard non-stmt lines. After this commit the lines tables are now: File 1 File 2 ------ ------ | Addr | Line | Stmt | | Addr | Line | Stmt | |------|------|------| |------|------|------| | 1 | 16 | Y | | 3 | 21 | Y | | 2 | 17 | Y | | 4 | 22 | Y | | 3 | END | Y | | 5 | 23 | N | | 5 | END | Y | | 6 | END | Y | | 6 | 24 | Y | |------|------|------| | 7 | END | Y | |------|------|------| We've lost the non-stmt entry for file 1, line 18, but retained the is-stmt entry for file 2, line 22. The user can now place a breakpoint at that location. One problem that came from this commit was the test gdb.cp/step-and-next-inline.exp, which broke in several places. After looking at this test again I think that in some cases this test was only ever passing by pure luck. The debug GCC is producing for this test is pretty broken. I raised this GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94474 for this and disabled one entire half of the test. There are still some cases in here that do pass, and if/when GCC is fixed it would be great to enable this test again. gdb/ChangeLog: * dwarf2/read.c (class lnp_state_machine) <m_last_address>: New member variable. <m_stmt_at_address>: New member variable. (lnp_state_machine::record_line): Don't record some lines, update tracking of is_stmt at the same address. (lnp_state_machine::lnp_state_machine): Initialise new member variables. gdb/testsuite/ChangeLog: * gdb.cp/step-and-next-inline.exp (do_test): Skip all tests in the use_header case. * gdb.dwarf2/dw2-inline-header-1.exp: New file. * gdb.dwarf2/dw2-inline-header-2.exp: New file. * gdb.dwarf2/dw2-inline-header-3.exp: New file. * gdb.dwarf2/dw2-inline-header-lbls.c: New file. * gdb.dwarf2/dw2-inline-header.c: New file. * gdb.dwarf2/dw2-inline-header.h: New file.
2020-06-01hurd: Add shared mig declarationsSamuel Thibault4-7/+43
We are using -Werror=missing-declarations, and the _S.h files generated by mig do not currently include a declaration for the server routine. gnu-nat.c used to have its own external declarations, but better just share them between gnu-nat.c and the _S.c files. Fixes exc_request_S.c:177:24: error: no previous declaration for ‘exc_server’ [-Werror=missing-declarations] 177 | mig_external boolean_t exc_server gdb/ChangeLog: * config/i386/i386gnu.mn [%_S.o %_U.o] (COMPILE.post): Add "-include gnu-nat-mig.h". * gnu-nat-mig.h: New file. * gnu-nat.c: Include "gnu-nat-mig.h". (exc_server, msg_reply_server, notify_server, process_reply_server): Remove declarations.
2020-06-01Automatic date update in version.inGDB Administrator1-1/+1
2020-05-31gnu-nat: Move local functions inside gnu_nat_target classSamuel Thibault3-88/+115
This allows to have the process_stratum_target object at hand for future use in the gdb API, and only use gnu_target from external calls. gdb/Changelog: * gnu-nat.h (inf_validate_procs, inf_suspend, inf_set_traced, steal_exc_port, proc_get_state, inf_clear_wait, inf_cleanup, inf_startup, inf_update_suspends, inf_set_pid, inf_steal_exc_ports, inf_validate_procinfo, inf_validate_task_sc, inf_restore_exc_ports, inf_set_threads_resume_sc, inf_set_threads_resume_sc_for_signal_thread, inf_resume, inf_set_step_thread, inf_detach, inf_attach, inf_signal, inf_continue, make_proc, proc_abort, _proc_free, proc_update_sc, proc_get_exception_port, proc_set_exception_port, _proc_get_exc_port, proc_steal_exc_port, proc_restore_exc_port, proc_trace): Move functions to gnu_nat_target class. * gnu-nat.c: Likewise. (inf_update_procs, S_proc_wait_reply, set_task_pause_cmd, set_task_exc_port_cmd, set_signals_cmd, set_thread_pause_cmd, set_thread_exc_port_cmd): Call inf_validate_procs through gnu_target object. (gnu_nat_target::create_inferior, gnu_nat_target::detach): Pass `this' instead of `gnu_target'.
2020-05-31Automatic date update in version.inGDB Administrator1-1/+1
2020-05-30hurd: unwinding support over signal trampolinesSamuel Thibault2-0/+144
This allows to get full backtrace from signal handlers, otherwise the backtrace stops at the trampoline that calls the handler. This needs special knowledge how the trampoline records register context for the sigreturn call after signal handling. gdb/ChangeLog: * i386-gnu-tdep.c: Include "gdbcore.h" (gnu_sigtramp_code, i386_gnu_sc_reg_offset): New arrays. (GNU_SIGTRAMP_LEN, GNU_SIGTRAMP_TAIL, I386_GNU_SIGCONTEXT_THREAD_STATE_OFFSET): New macros (i386_gnu_sigtramp_start, i386_gnu_sigtramp_p, i386_gnu_sigcontext_addr): New functions (i386gnu_init_abi): Register i386_gnu_sigtramp_p, i386_gnu_sigcontext_addr, and i386_gnu_sc_reg_offset in the gdbarch tdep.
2020-05-30hurd: fix pushing target on inferior creationSamuel Thibault2-2/+9
This fixes creating inferiors, which was broken since 5b6d1e4fa ('Multi-target support') gdb/ChangeLog: * gnu-nat.c (gnu_nat_target::create_inferior): Move push_target call before fork_inferior call. Avoid calling it if target_is_pushed returns true.
2020-05-30hurd: add gnu_target pointer to fix thread API callsSamuel Thibault4-6/+26
Fixes ../../gdb/gnu-nat.c:1110:28: error: cannot convert ‘ptid_t’ to ‘process_stratum_target*’ 1110 | thread_change_ptid (inferior_ptid, ptid); and others related to 5b6d1e4fa ("Multi-target support") gdb/ChangeLog: * gnu-nat.h (gnu_target): New variable declaration. * i386-gnu-nat.c (_initialize_i386gnu_nat): Initialize gnu_target. * gnu-nat.c (gnu_target): New variable. (inf_validate_procs): Pass gnu_target to thread_change_ptid, add_thread_silent, and add_thread calls. (gnu_nat_target::create_inferior): Pass gnu_target to add_thread_silent, thread_change_ptid call. (gnu_nat_target::detach): Pass gnu_target to detach_inferior call.
2020-05-30hurd: remove unused variablesSamuel Thibault2-2/+6
Fixes ../../gdb/gnu-nat.c:2554:7: error: unused variable ‘res’ [-Werror=unused-variable] 2554 | int res; ../../gdb/gnu-nat.c:2644:20: error: unused variable ‘old_address’ [-Werror=unused-variable] 2644 | vm_address_t old_address = region_address; gdb/ChangeLog: * gnu-nat.c (gnu_xfer_auxv): Remove unused `res' variable. (gnu_nat_target::find_memory_regions): Remove unused `old_address' variable.
2020-05-30hurd: add missing includeSamuel Thibault2-0/+5
Fixes ../../gdb/gnu-nat.c:2522:14: error: ‘target_gdbarch’ was not declared in this scope; did you mean ‘target_detach’? 2522 | paddress (target_gdbarch (), memaddr), pulongest (len), gdb/Changelog: * gnu-nat.c: Include "gdbarch.h".
2020-05-30hurd: make function cast strongerSamuel Thibault2-1/+7
Fixes process_reply_S.c:104:23: error: function called through a non-compatible type [-Werror] 104 | OutP->RetCode = (*(kern_return_t (*)(mach_port_t, kern_return_t)) S_proc_setmsgport_reply) (In0P->Head.msgh_request_port, In0P- As the existing comment says, it is in general not safe to drop some parameters like this, but this is the error handling case, where the called function does not actually read them, and mig is currently planned to be used on i386 and x86_64 only, where this is not a problem. As the existing comment says, fixing it properly would be far from trivial: we can't just pass 0 for them, as they might not be scalar. gdb/ChangeLog: * reply_mig_hack.awk (Error return): Cast function through void *, to bypass compiler function call check.
2020-05-30hurd: add missing awk script dependencySamuel Thibault2-1/+6
To make sure the *_reply_S.[ch] files get regenerated whenever we change the awk script. gdb/ChangeLog: * config/i386/i386gnu.mn (%_reply_S.c): Add dependency on $(srcdir)/reply_mig_hack.awk.
2020-05-30hurd: fix gnu_debug_flag typeSamuel Thibault2-1/+5
Fixes ../../gdb/gnu-nat.c:96:6: error: conflicting declaration ‘bool gnu_debug_flag’ 96 | bool gnu_debug_flag = false; ../../gdb/gnu-nat.c: In function ‘void _initialize_gnu_nat()’: ../../gdb/gnu-nat.c:3511:7: error: cannot gdb/ChangeLog: * gnu-nat.h (gnu_debug_flag): Set type to bool.
2020-05-30gdb: change bug URL to httpsJonny Grant3-2/+6
gdb/ChangeLog: * configure.ac (ACX_BUGURL): change bug URL to https. Signed-off-by: Jonny Grant <jg@jguk.org> Change-Id: If8d939e50c830e3e452c3e8f7a7aee06d9c96645
2020-05-30replace_typedefs: handle templates in namespacesPedro Alves5-4/+305
GDB currently crashes with infinite recursion, if you set a breakpoint on a function inside a namespace that includes a template on its fully qualified name, and, the template's name is also used as typedef in the global scope that expands to a name that includes the template name in its qualified name. For example, from the testcase added by this commit: namespace NS1 { namespace NS2 { template<typename T> struct Templ1 { T x; Templ1 (object_p) {} }} // namespace NS1::NS2 using Templ1 = NS1::NS2::Templ1<unsigned>; Setting a breakpoint like so: (gdb) break NS1::NS2::Templ1<int>::Templ1(NS1::NS2::object*) Results in infinite recursion, with this cycle (started by cp_canonicalize_string_full) repeating until the stack is exhausted: ... #1709 0x000000000055533c in inspect_type (info=0x38ff720, ret_comp=0xd83be10, finder=0x0, data=0x0) at /home/pedro/gdb/mygit/src/gdb/cp-support.c:267 #1710 0x0000000000555a6f in replace_typedefs (info=0x38ff720, ret_comp=0xd83be10, finder=0x0, data=0x0) at /home/pedro/gdb/mygit/src/gdb/cp-support.c:475 #1711 0x0000000000555a36 in replace_typedefs (info=0x38ff720, ret_comp=0xd83be70, finder=0x0, data=0x0) at /home/pedro/gdb/mygit/src/gdb/cp-support.c:470 #1712 0x0000000000555800 in replace_typedefs_qualified_name (info=0x38ff720, ret_comp=0xd839470, finder=0x0, data=0x0) at /home/pedro/gdb/mygit/src/gdb/cp-support.c:389 #1713 0x0000000000555a8c in replace_typedefs (info=0x38ff720, ret_comp=0xd839470, finder=0x0, data=0x0) at /home/pedro/gdb/mygit/src/gdb/cp-support.c:479 ... The demangle component tree for that symbol name looks like this: d_dump tree for NS1::NS2::Templ1<int>::Templ1(NS1::NS2::object*): typed name qualified name name 'NS1' qualified name name 'NS2' qualified name template <<<<<<<<<< name 'Templ1' template argument list builtin type int name 'Templ1' function type argument list pointer qualified name name 'NS1' qualified name name 'NS2' name 'object' The recursion starts at replace_typedefs_qualified_name, which doesn't handle the "template" node, and thus doesn't realize that the template name actually has the fully qualified name NS1::NS2::Templ1. replace_typedefs_qualified_name calls into replace_typedefs on the template node, and that ends up in inspect_type looking up for a symbol named "Templ1", which finds the global namespace typedef, which itself expands to NS1::NS2::Templ1. GDB then tries replacing typedefs in that newly expanded name, which ends up again in replace_typedefs_qualified_name, trying to expand a fully qualified name with "NS::NS2::Templ1<unsigned>" in its name, which results in recursion whenever the template node is reached. Fix this by teaching replace_typedefs_qualified_name how to handle template nodes. It needs handling in two places: the first spot handles the symbol above; the second spot handles a symbol like this, from the new test: (gdb) b NS1::NS2::grab_it(NS1::NS2::Templ1<int>*) d_dump tree for NS1::NS2::grab_it(NS1::NS2::Templ1<int>*): typed name qualified name name 'NS1' qualified name name 'NS2' name 'grab_it' function type argument list pointer qualified name name 'NS1' qualified name name 'NS2' template <<<<<<<< name 'Templ1' template argument list builtin type int What's different in this case is that the template node appears on the right child node of a qualified name, instead of on the left child. The testcase includes a test that checks whether template aliases are correctly replaced by GDB too. That fails with GCC due to GCC PR 95437, which makes GDB not know about a typedef for "NS1::NS2::AliasTempl<int>". GCC emits a typedef named "NS1::NS2::AliasTempl" instead, with no template parameter info. The test passes with Clang (5.0.2 at least). See more details here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95437 gdb/ChangeLog: 2020-05-30 Pedro Alves <palves@redhat.com> * cp-support.c (replace_typedefs_template): New. (replace_typedefs_qualified_name): Handle DEMANGLE_COMPONENT_TEMPLATE. gdb/testsuite/ChangeLog: 2020-05-30 Pedro Alves <palves@redhat.com> * gdb.linespec/cp-replace-typedefs-ns-template.cc: New. * gdb.linespec/cp-replace-typedefs-ns-template.exp: New.
2020-05-30Automatic date update in version.inGDB Administrator1-1/+1
2020-05-29gdb: rename dwarf2_per_objfile variables/fields to per_objfileSimon Marchi13-793/+719
While doing the psymtab-sharing patchset, I avoided renaming variables unnecessarily to avoid adding noise to patches, but I'd like to do it now. Basically, we have these dwarf2 per-something structures: - dwarf2_per_objfile - dwarf2_per_bfd - dwarf2_per_cu_data I named the instances of dwarf2_per_bfd `per_bfd` and most of instances of dwarf2_per_cu_data are called `per_cu`. Most pre-existing instances of dwarf2_per_objfile are named `dwarf2_per_objfile`. For consistency with the other type, I'd like to rename them to just `per_objfile`. The `dwarf2_` prefix is superfluous, since it's already clear we are in dwarf2 code. It also helps reducing the line wrapping by saving 7 precious columns. gdb/ChangeLog: * dwarf2/comp-unit.c, dwarf2/comp-unit.h, dwarf2/index-cache.c, dwarf2/index-cache.h, dwarf2/index-write.c, dwarf2/index-write.h, dwarf2/line-header.c, dwarf2/line-header.h, dwarf2/macro.c, dwarf2/macro.h, dwarf2/read.c, dwarf2/read.h: Rename struct dwarf2_per_objfile variables and fields from `dwarf2_per_objfile` to just `per_objfile` throughout. Change-Id: I3c45cdcc561265e90df82cbd36b4b4ef2fa73aef
2020-05-29Fix build errors in with clang in gdb.compile/compile-cplus.cGary Benson2-2/+20
Clang fails to compile the file, with the following error: fatal error: 'iostream' file not found This prevents the following testcase from executing: gdb.compile/compile-cplus.exp The testcase sets additional_flags when building with GCC, which this commit causes to also be set when building with clang. This makes the testcase fail to build with a different error: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated] so this commit adds -Wno-deprecated in two places to sidestep this. Note that, while allowing the testcase to build, this commit reveals failures when the testsuite is built using clang. gdb/testsuite/ChangeLog: * gdb.compile/compile-cplus.exp (additional_flags): Also set when building with clang. (additional_flags, srcfilesoptions): Pass -Wno-deprecated when building with clang.
2020-05-29Fix file-not-found error with clang in gdb.arch/i386-{avx,sse}.cGary Benson3-2/+8
Clang fails to compile two testcases with the following error: fatal error: 'nat/x86-cpuid.h' file not found This prevents the following testcases from executing: gdb.arch/i386-avx.exp gdb.arch/i386-sse.exp Both testcases set additional_flags when building with GCC. This commit causes the additional_flags to also be used when building with clang. Note that, while fixing the build, this commit reveals several new failures when using clang to build the testsuite. gdb/testsuite/ChangeLog: * gdb.arch/i386-avx.exp (additional_flags): Also set when building with clang. * gdb.arch/i386-sse.exp (additional_flags): Likewise.
2020-05-29Build two gdb.cp testcases with -Wno-unused-comparisonGary Benson3-2/+10
Clang fails to compile two testcases with the following error: warning: equality comparison result unused [-Wunused-comparison] This prevents the following testcases from executing: gdb.cp/koenig.exp gdb.cp/operator.exp This commit builds those testcases with -Wno-unused-comparison, to avoid the failure. Note that this commit reveals a new failure, "FAIL: gdb.cp/koenig.exp: p foo (p_union)" when the testsuite is compiled using clang. gdb/testsuite/ChangeLog: * gdb.cp/koenig.exp (prepare_for_testing): Add additional_flags=-Wno-unused-comparison. * gdb.cp/operator.exp (prepare_for_testing): Likewise.
2020-05-28binutils: Add myself as Xtensa maintainerMax Filippov2-0/+5
2020-05-28 Max Filippov <jcmvbkbc@gmail.com> binutils/ * MAINTAINERS (Xtensa): Add myself as maintainer.
2020-05-29Automatic date update in version.inGDB Administrator1-1/+1
2020-05-28bfd: fix handling of R_BPF_INSN_{32,64} relocations.David Faust2-1/+31
2020-05-28 David Faust <david.faust@oracle.com> * elf64-bpf.c (bpf_elf_relocate_section): Fix handling of R_BPF_INSN_{32,64} relocations.
2020-05-28cpu,opcodes: add instruction semantics to bpf.cpu and minor fixesJose E. Marchesi8-295/+515
This patch adds semantic RTL descriptions to the eBPF instructions defined in cpu/bpf.cpu. It also contains a couple of minor improvements. Tested in bpf-unknown-none targets. No regressions. cpu/ChangeLog: 2020-05-28 Jose E. Marchesi <jose.marchesi@oracle.com> David Faust <david.faust@oracle.com> * bpf.cpu (define-alu-insn-un): Add definitions of semantics. (define-alu-insn-mov): Likewise. (daib): Likewise. (define-alu-instructions): Likewise. (define-endian-insn): Likewise. (define-lddw): Likewise. (dlabs): Likewise. (dlind): Likewise. (dxli): Likewise. (dxsi): Likewise. (dsti): Likewise. (define-ldstx-insns): Likewise. (define-st-insns): Likewise. (define-cond-jump-insn): Likewise. (dcji): Likewise. (define-condjump-insns): Likewise. (define-call-insn): Likewise. (ja): Likewise. ("exit"): Likewise. (define-atomic-insns): Likewise. (sem-exchange-and-add): New macro. * bpf.cpu ("brkpt"): New instruction. (bpfbf): Set word-bitsize to 32 and insn-endian big. (h-gpr): Prefer r0 to `a' and r6 to `ctx'. (h-pc): Expand definition. * bpf.opc (bpf_print_insn): Set endian_code to BIG. opcodes/ChangeLog: 2020-05-28 Jose E. Marchesi <jose.marchesi@oracle.com> David Faust <david.faust@oracle.com> * bpf-desc.c: Regenerate. * bpf-opc.h: Likewise. * bpf-opc.c: Likewise. * bpf-dis.c: Likewise.
2020-05-28gdb: add comment in dwarf_evaluate_loc_desc::push_dwarf_reg_entry_valueSimon Marchi2-0/+11
Add a comment to clarify why we temporarily override some of the context's fields, and especially the per_objfile field. A longer explanation can be found in this previous commit 44486dcf19b ("gdb: use caller objfile in dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value") gdb/ChangeLog: * dwarf2/loc.c (class dwarf_evaluate_loc_desc) <push_dwarf_reg_entry_value>: Add comment. Change-Id: I60c6e1062799f729b30a9db78bcb6448783324b4
2020-05-28Fix Python3.9 related runtime problemsKevin Buettner2-26/+40
Python3.9b1 is now available on Rawhide. GDB w/ Python 3.9 support can be built using the configure switch -with-python=/usr/bin/python3.9. Attempting to run gdb/Python3.9 segfaults on startup: #0 0x00007ffff7b0582c in PyEval_ReleaseLock () from /lib64/libpython3.9.so.1.0 #1 0x000000000069ccbf in do_start_initialization () at worktree-test1/gdb/python/python.c:1789 #2 _initialize_python () at worktree-test1/gdb/python/python.c:1877 #3 0x00000000007afb0a in initialize_all_files () at init.c:237 ... Consulting the the documentation... https://docs.python.org/3/c-api/init.html ...we find that PyEval_ReleaseLock() has been deprecated since version 3.2. It recommends using PyEval_SaveThread or PyEval_ReleaseThread() instead. In do_start_initialization, in gdb/python/python.c, we can replace the calls to PyThreadState_Swap() and PyEval_ReleaseLock() with a single call to PyEval_SaveThread. (Thanks to Keith Seitz for working this out.) With that in place, GDB gets a little bit further. It still dies on startup, but the backtrace is different: #0 0x00007ffff7b04306 in PyOS_InterruptOccurred () from /lib64/libpython3.9.so.1.0 #1 0x0000000000576e86 in check_quit_flag () at worktree-test1/gdb/extension.c:776 #2 0x0000000000576f8a in set_active_ext_lang (now_active=now_active@entry=0x983c00 <extension_language_python>) at worktree-test1/gdb/extension.c:705 #3 0x000000000069d399 in gdbpy_enter::gdbpy_enter (this=0x7fffffffd2d0, gdbarch=0x0, language=0x0) at worktree-test1/gdb/python/python.c:211 #4 0x0000000000686e00 in python_new_inferior (inf=0xddeb10) at worktree-test1/gdb/python/py-inferior.c:251 #5 0x00000000005d9fb9 in std::function<void (inferior*)>::operator()(inferior*) const (__args#0=<optimized out>, this=0xccad20) at /usr/include/c++/10/bits/std_function.h:617 #6 gdb::observers::observable<inferior*>::notify (args#0=0xddeb10, this=<optimized out>) at worktree-test1/gdb/../gdbsupport/observable.h:106 #7 add_inferior_silent (pid=0) at worktree-test1/gdb/inferior.c:113 #8 0x00000000005dbcb8 in initialize_inferiors () at worktree-test1/gdb/inferior.c:947 ... We checked with some Python Developers and were told that we should acquire the GIL prior to calling any Python C API function. We definitely don't have the GIL for calls of PyOS_InterruptOccurred(). I moved class_gdbpy_gil earlier in the file and use it in gdbpy_check_quit_flag() to acquire (and automatically release) the GIL. With those changes in place, I was able to run to a GDB prompt. But, when trying to quit, it segfaulted again due to due to some other problems with gdbpy_check_quit_flag(): Thread 1 "gdb" received signal SIGSEGV, Segmentation fault. 0x00007ffff7bbab0c in new_threadstate () from /lib64/libpython3.9.so.1.0 (top-gdb) bt 8 #0 0x00007ffff7bbab0c in new_threadstate () from /lib64/libpython3.9.so.1.0 #1 0x00007ffff7afa5ea in PyGILState_Ensure.cold () from /lib64/libpython3.9.so.1.0 #2 0x000000000069b58c in gdbpy_gil::gdbpy_gil (this=<synthetic pointer>) at worktree-test1/gdb/python/python.c:278 #3 gdbpy_check_quit_flag (extlang=<optimized out>) at worktree-test1/gdb/python/python.c:278 #4 0x0000000000576e96 in check_quit_flag () at worktree-test1/gdb/extension.c:776 #5 0x000000000057700c in restore_active_ext_lang (previous=0xe9c050) at worktree-test1/gdb/extension.c:729 #6 0x000000000088913a in do_my_cleanups ( pmy_chain=0xc31870 <final_cleanup_chain>, old_chain=0xae5720 <sentinel_cleanup>) at worktree-test1/gdbsupport/cleanups.cc:131 #7 do_final_cleanups () at worktree-test1/gdbsupport/cleanups.cc:143 In this case, we're trying to call a Python C API function after Py_Finalize() has been called from finalize_python(). I made finalize_python set gdb_python_initialized to false and then cause check_quit_flag() to return early when it's false. With these changes in place, GDB seems to be working again with Python3.9b1. I think it likely that there are other problems lurking. I wouldn't be surprised to find that there are other calls into Python where we don't first make sure that we have the GIL. Further changes may well be needed. I see no regressions testing on Rawhide using a GDB built with the default Python version (3.8.3) versus one built using Python 3.9b1. I've also tested on Fedora 28, 29, 30, 31, and 32 (all x86_64) using the default (though updated) system installed versions of Python on those OSes. This means that I've tested against Python versions 2.7.15, 2.7.17, 2.7.18, 3.7.7, 3.8.2, and 3.8.3. In each case GDB still builds without problem and shows no regressions after applying this patch. gdb/ChangeLog: 2020-MM-DD Kevin Buettner <kevinb@redhat.com> Keith Seitz <keiths@redhat.com> * python/python.c (do_start_initialization): For Python 3.9 and later, call PyEval_SaveThread instead of PyEval_ReleaseLock. (class gdbpy_gil): Move to earlier in file. (finalize_python): Set gdb_python_initialized. (gdbpy_check_quit_flag): Acquire GIL via gdbpy_gil. Return early when not initialized.
2020-05-28Fix all unexpected failures in gas testsuite for pdp11-aout.Stephen Casner8-3/+141
These failures were caused by the PDP11's mix of little-endian octets in shorts but shorts in big endian order for long or quad so regexps did not match. Also tests used addresses as values in .long which required BRD_RELOC_32 that was not implemented. * gas/config/tc-pdp11.c (md_number_to_chars): Implement .quad * gas/testsuite/gas/all/gas.exp: Select alternate test scripts for pdp11, skip octa test completely. * gas/testsuite/gas/all/eqv-dot-pdp11.s: Identical to eqv-dot.s * gas/testsuite/gas/all/eqv-dot-pdp11.d: Match different octet order. * gas/testsuite/gas/all/cond-pdp11.l: Match different octet order. * bfd/pdp11.c: Implement BRD_RELOC_32 to relocate the low 16 bits of addreses in .long (used in testsuites) and .stab values.
2020-05-28Fix "enumeration values not handled in switch" error in testsuiteGary Benson2-0/+7
When running the testsuite with clang, gdb.base/sigaltstack.c fails to compile with the following error: warning: enumeration values 'LEAF' and 'NR_LEVELS' not handled in switch [-Wswitch] This prevents the gdb.base/sigaltstack.exp from executing. This commit fixes. gdb/testsuite/ChangeLog: * gdb.base/sigaltstack.c (catcher): Add default case to switch statement.
2020-05-28Have the linker fail if any attempt to link in an executable is made.Nick Clifton2-2/+14
PR 26047 * ldelf.c (ldelf_after_open): Fail if attempting to link one executable into another. Ensure that the test is made for all forms of linking.
2020-05-28Stop the linker from accepting executable ELF files as inputs to other links.Nick Clifton2-0/+13
PR 26047 * ldelf.c (ldelf_after_open): Fail if attempting to link one executable into another.
2020-05-28gdb: use caller objfile in dwarf_evaluate_loc_desc::push_dwarf_reg_entry_valueSimon Marchi2-3/+9
In commit 89b07335fe ("Add dwarf2_per_objfile to dwarf_expr_context and dwarf2_frame_cache") I replaced the offset property of dwarf_expr_context by a per_objfile property (since we can get the text offset from the objfile). The previous code in dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value (dwarf_evaluate_loc_desc derives from dwarf_expr_context) did temporarily override the offset property while evaluating a DWARF sub-expression. I speculated that this sub-expression always came from the same objfile as the outer expression, so I didn't see the need to temporarily override the per_objfile property in the new code. A later commit: 9f47c70716 ("Remove dwarf2_per_cu_data::objfile ()") added the following assertion to verify this: gdb_assert (this->per_objfile == caller_per_objfile); It turns out that this is not true. Call sites can refer to function in another objfile, and therefore the caller's objfile can be different from the callee's objfile. This can happen when the call site DIE in the DWARF represents a function call done through a function pointer. The DIE can't describe statically which function is being called, since it's variable and not known at compile time. Instead, it provides an expression that evaluates to the address of the function being called. In this case, the called function can very well be in a separate objfile. Fix this by overriding the per_objfile property while evaluating the sub-expression. This was exposed by the gdb.base/catch-load.exp test failing on openSUSE Tumbleweed with the glibc debug info installed. It was also reported to fail on Fedora. When I investigated the problem, the particular call site on which we did hit the assert was coming from this DIE, in /usr/lib/debug/lib64/libc-2.31.so-2.31-5.1.x86_64.debug on openSUSE Tumbleweed: 0x0091aa10: DW_TAG_GNU_call_site DW_AT_low_pc [DW_FORM_addr] (0x00000000001398e0) DW_AT_GNU_call_site_target [DW_FORM_exprloc] (DW_OP_fbreg -272, DW_OP_deref) DW_AT_sibling [DW_FORM_ref4] (0x0091aa2b) And for you curious out there, this call site is found in this function: 0x0091a91d: DW_TAG_subprogram DW_AT_external [DW_FORM_flag_present] (true) DW_AT_name [DW_FORM_strp] ("_dl_catch_exception") DW_AT_decl_file [DW_FORM_data1] ("/usr/src/debug/glibc-2.31-5.1.x86_64/elf/dl-error-skeleton.c") ... Which is a function that indeed uses a function pointer. gdb/ChangeLog: * dwarf2/loc.c (class dwarf_evaluate_loc_desc) <push_dwarf_reg_entry_value>: Remove assert. Override per_objfile with caller_per_objfile. Change-Id: Ib227d767ce525c10607ab6621a373aaae982c67a
2020-05-28Pass -Wno-deprecated-register for gdb.cp that use "register"Gary Benson4-3/+13
Clang fails to compile three testcases with the following error: warning: 'register' storage class specifier is deprecated and incompatible with C++17 [-Wdeprecated-register] This prevents the following testcases from executing: gdb.cp/classes.exp gdb.cp/inherit.exp gdb.cp/misc.exp This commit builds those testcases with -Wno-deprecated-register, to avoid the failure. Note that this commit reveals five "wrong access specifier for typedef" failures in gdb.cp/classes.exp when compiling the testsuite with clang. gdb/testsuite/ChangeLog: * gdb.cp/classes.exp (prepare_for_testing): Add additional_flags=-Wno-deprecated-register. * gdb.cp/inherit.exp (prepare_for_testing): Likewise. * gdb.cp/misc.exp: Likewise.
2020-05-28[gdb/symtab] Make gold index workaround more preciseTom de Vries2-8/+19
There's a PR gold/15646 - "gold-generated .gdb_index has duplicated symbols that gdb-generated index doesn't", that causes gold to generate duplicate symbols in the index. F.i., a namespace N1 declared in a header file can be listed for two CUs that include the header file: ... [759] N1: 2 [global type] 3 [global type] ... This causes a gdb performance problem: f.i. when attempting to set a breakpoint on a non-existing function N1::misspelled, the symtab for both CUs will be expanded. Gdb contains a workaround for this, added in commit 8943b87476 "Work around gold/15646", that skips duplicate global symbols in the index. However, the workaround does not check for the symbol kind ("type" in the example above). Make the workaround more precise by limiting it to symbol kind "type". Tested on x86_64-linux, with target boards cc-with-gdb-index and gold-gdb-index. gdb/ChangeLog: 2020-05-28 Tom de Vries <tdevries@suse.de> * dwarf2/read.c (dw2_symtab_iter_next, dw2_expand_marked_cus): Limit PR gold/15646 workaround to symbol kind "type".
2020-05-28[PATCH] gas: Fix comment on definition of frag_grow()Nick Clifton2-3/+7
* frags.c (frag_grow): Fix comment.
2020-05-28Fix "'operator new' should not return NULL" errors in testsuiteGary Benson2-2/+10
When running the testsuite with clang, gdb.linespec/cpls-ops.cc fails to compile with the following errors: warning: 'operator new' should not return a null pointer unless it is declared 'throw()' or 'noexcept' [-Wnew-returns-null] warning: 'operator new[]' should not return a null pointer unless it is declared 'throw()' or 'noexcept' [-Wnew-returns-null] This prevents the gdb.linespec/cpls-ops.exp testcase from executing. This commit fixes. gdb/testsuite/ChangeLog: * gdb.linespec/cpls-ops.cc (dummy): New static global. (test_op_new::operator new): Add return statement. (test_op_new_array::operator new[]): Likewise.
2020-05-28ubsan: nios2: undefined shiftAlan Modra2-11/+10
* nios2-dis.c (nios2_print_insn_arg): Avoid shift left of negative values.
2020-05-28PR26044, Some targets can't be compiled with GCC 10 (tilepro)Alan Modra2-3/+7
Since this value is used in fields of type tilepro_pipeline (as NO_PIPELINE, see tc-tilepro.c) it is appropriate to put it in the tilepro_pipelen enum. This avoids a warning about converting from one enum type to another. PR 26044 * opcode/tilepro.h (TILEPRO_NUM_PIPELINE_ENCODINGS): Move to tilepro_pipeline enum.
2020-05-28asan: ns32k: use of uninitialized valueAlan Modra2-7/+8
* ns32k-dis.c (print_insn_arg): Handle d value of 'f' for immediates. (print_insn_ns32k): Revert last change.
2020-05-28ld: Mention --enable-textrel-check=yes is default for Linux/x86 targetsH.J. Lu2-3/+5
* NEWS: Mention --enable-textrel-check=yes is default for Linux/x86 targets.
2020-05-28ld: Enable --warn-textrel by default for Linux/x86 targetsH.J. Lu2-1/+9
* configure.tgt (ac_default_ld_textrel_check): Set to if unset for Linux/x86 targets.
2020-05-28ld: Add --enable-textrel-check=[no|yes|warning|error]H.J. Lu7-3/+98
Add a configure option, --enable-textrel-check=[no|yes|warning|error], to decide what ELF linker should do by default with DT_TEXTREL in an executable or shared library. PR ld/20824 * NEWS: Mention --enable-textrel-check=[no|yes|warning|error]. * configure.ac: Add --enable-textrel-check=[no|yes|warning|error]. (DEFAULT_LD_TEXTREL_CHECK): New AC_DEFINE_UNQUOTED. (DEFAULT_LD_TEXTREL_CHECK_WARNING): Likewise. * ldmain.c (main): Initialize link_info.textrel_check to DEFAULT_LD_TEXTREL_CHECK. * lexsup.c (ld_options): Check DEFAULT_LD_TEXTREL_CHECK_WARNING. * config.in: Regenerated. * configure: Likewise.
2020-05-28Fix a potential use of an uninitialised value in the ns32k disassembler.Nick Clifton2-1/+9
* ns32k-dis.c (print_insn_ns32k): Change the arg_bufs array to static.
2020-05-28Linker: Remove support for -Map= with an empty argument.Nick Clifton4-18/+29
* lexsup.c (parse_args): Generate an error if a name is not provided to the -Map option. (ld_options): Mention that the -Map option supports a directory name as an argument. * NEWS: Remove mention of support for an empty string as an argument to -Map. * ld.texi: Likewise.
2020-05-27Fix PR gas/26001 (pdp11-*-*)Stephen Casner5-1/+41
PR gas/26001 * gas/config/tc-pdp11.c (parse_reg): Distinguish register names from symbols that begin with a register name. * gas/testsuite/gas/pdp11/pdp11.exp: Add test of such symbols. * gas/testsuite/gas/pdp11/pr26001.s: Likewise. * gas/testsuite/gas/pdp11/pr26001.d: Likewise.
2020-05-28Automatic date update in version.inGDB Administrator1-1/+1
2020-05-27RISC-V: Fix missing initialization of riscv_csr_extra structsSimon Cook2-0/+6
The next pointer of struct riscv_csr_extra was not always initilized to NULL or a valid pointer, causing the assembler to attempt to read through an uninitialized pointer on startup. gas/ChangeLog: * config/tc-riscv.c (riscv_init_csr_hash): NULL initilize next pointer when creating struct riscv_csr_extra.
2020-05-27PR ld/22909 amendment; don't xfail ld-elf/pr19539.d for cris*-*-*.Hans-Peter Nilsson2-1/+6
Noticed by my autotester covering cris-axis-linux-gnu: ... Running <x>/src/ld/testsuite/ld-elf/elf.exp ... XPASS: ld-elf/pr19539 ... This was apparently as intended, so I'm just adjusting the xfail. PR ld/22909 * testsuite/ld-elf/pr19539.d: Don't xfail for cris*-*-*.