aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
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*-*-*.
2020-05-27cp-completion-aliases.exp: Use test_gdb_complete_{unique,multiple}Pedro Alves2-23/+18
gdb.linespec/cp-completion-aliases.exp is calling test_gdb_complete_{tab,cmd}_unique and test_gdb_complete_{tab,cmd}_multiple separately for each use case. I.e., testing once for TAB completion and once for the "complete" command. There's no need to do that explicitly and separately, we have wrapper procedures to do that for us. gdb/testsuite/ChangeLog: 2020-05-27 Pedro Alves <palves@redhat.com> * gdb.linespec/cp-completion-aliases.exp: Remove readline_is_used check. Use test_gdb_complete_unique instead of test_gdb_complete_tab_unique + test_gdb_complete_cmd_unique. Use test_gdb_complete_multiple instead of test_gdb_complete_tab_multiple + test_gdb_complete_cmd_multiple.
2020-05-27Use add_partial_symbol in load_partial_diesTom Tromey2-10/+7
An earlier patch added the add_partial_symbol helper function to dwarf2/read.c. However, a couple of calls to add_psymbol_to_list were left in place. It turns out that these calls slow down partial symbol reading, because they still go via the path that tries to needlessly demangle already-demangled names. This patch improves the performance of partial symbol reading by changing this code to use add_partial_symbol instead. The run previous to this had times of (see the first patch in the series for an explanation): gdb 1.64 libxul 1.99 Ada 2.47 This patch improves the times to: gdb 1.47 libxul 1.89 Ada 2.39 gdb/ChangeLog 2020-05-27 Tom Tromey <tromey@adacore.com> * dwarf2/read.c (load_partial_dies): Use add_partial_symbol.
2020-05-27Inline abbrev lookupTom Tromey3-18/+28
Profiling showed that calls to abbrev_table::lookup_abbrev were "too visible". As these are just forwarding calls to the hash table, this patch inlines the lookup. Also, htab_find_with_hash is used, avoiding another call. The run previous to this had times of (see the first patch in the series for an explanation): gdb 1.69 libxul 2.02 Ada 2.52 This patch improves the times to: gdb 1.64 libxul 1.99 Ada 2.47 gdb/ChangeLog 2020-05-27 Tom Tromey <tromey@adacore.com> * dwarf2/abbrev.h (struct abbrev_table) <lookup_abbrev>: Inline. Use htab_find_with_hash. <add_abbrev>: Remove "abbrev_number" parameter. * dwarf2/abbrev.c (abbrev_table::add_abbrev): Remove "abbrev_number" parameter. Use htab_find_slot_with_hash. (hash_abbrev): Add comment. (abbrev_table::lookup_abbrev): Move to header file. (abbrev_table::read): Update.
2020-05-27Lazily compute partial DIE nameTom Tromey2-33/+74
Currently the name of a partial DIE is computed eagerly. However, the name is not always needed. This patch changes partial DIEs to compute their name lazily, improving performance by avoiding unnecessary name computations. The run previous to this had times of (see the first patch in the series for an explanation): gdb 1.88 libxul 2.11 Ada 2.60 This patch improves the times to: gdb 1.69 libxul 2.02 Ada 2.52 gdb/ChangeLog 2020-05-27 Tom Tromey <tromey@adacore.com> * dwarf2/read.c (struct partial_die_info) <name>: Declare new method. <canonical_name>: New member. <raw_name>: Rename from "name". (partial_die_info): Initialize canonical_name. (scan_partial_symbols): Check raw_name. (partial_die_parent_scope, partial_die_full_name) (add_partial_symbol, add_partial_subprogram) (add_partial_enumeration, load_partial_dies): Use "name" method. (partial_die_info::name): New method. (partial_die_info::read, guess_partial_die_structure_name) (partial_die_info::fixup): Update.
2020-05-27Attribute method inliningTom Tromey3-29/+34
This inlines a couple of methods on struct attribute, improving the performance of DWARF partial symbol reading. These methods were discovered as hot spots using callgrind. For this patch, and for all the patches in this series, I tested gdb's performance on three programs: 1. gdb itself -- I built gdb and copied it to /tmp, ensuring that the same version was used in all tests. 2. The system libxul.so, the main library of Firefox. I installed the separate debuginfo and ensured that gdb read it. 3. A large-ish Ada program that I happen to have. I ran gdb 10 times like: /bin/time -f %e \ ./gdb/gdb --data-directory ./gdb/data-directory -nx \ -iex 'set debug-file-directory /usr/lib/debug' \ -batch $X ... where $X was the test executable. Then I computed the mean time. This was all done with a standard (-g -O2) build of gdb. The baseline times were gdb 1.90 libxul 2.12 Ada 2.61 This patch brings the numbers down to gdb 1.88 libxul 2.11 Ada 2.60 Not a huge change, but still visible in the results. gdb/ChangeLog 2020-05-27 Tom Tromey <tromey@adacore.com> * dwarf2/attribute.h (struct attribute) <form_is_ref>: Inline. <get_ref_die_offset>: Inline. <get_ref_die_offset_complaint>: New method. * dwarf2/attribute.c (attribute::form_is_ref): Move to header. (attribute::get_ref_die_offset_complaint): Rename from get_ref_die_offset. Just issue complaint.
2020-05-27Move exit_status_set_internal_vars out of GLOBAL_CURDIRHannes Domani2-1/+5
Fixes these testsuite fails on Windows: FAIL: gdb.base/shell.exp: shell success exitcode FAIL: gdb.base/shell.exp: shell fail exitcode The convenience variables $_shell_exitcode and $_shell_exitsignal don't depend on the GLOBAL_CURDIR define. gdb/ChangeLog: 2020-05-27 Hannes Domani <ssbssa@yahoo.de> * cli/cli-cmds.c (shell_escape): Move exit_status_set_internal_vars.
2020-05-27Use errno value of first openp failureHannes Domani2-0/+7
Fixes this testsuite fail on Windows: FAIL: gdb.base/bad-file.exp: directory If both tries to open the file fail (without and with ".exe"), use the errno value of the first try. gdb/ChangeLog: 2020-05-27 Hannes Domani <ssbssa@yahoo.de> * exec.c (exec_file_attach): Use errno value of first openp failure.
2020-05-27Don't close process handle provided by WaitForDebugEventHannes Domani2-4/+21
Only the process handle returned by OpenProcess or CreateProcess needs to be closed, the one provided by WaitForDebugEvent is closed automatically. gdbserver/ChangeLog: 2020-05-27 Hannes Domani <ssbssa@yahoo.de> * win32-low.cc (do_initial_child_stuff): Set open_process_used. (win32_clear_inferiors): Use open_process_used. (get_child_debug_event): Likewise.
2020-05-27Don't close thread handles provided by WaitForDebugEventHannes Domani2-1/+5
I sometimes encountered a weird breakpoint failure when using start: (gdb) start Temporary breakpoint 2 at 0x40162d: file gdb-25911.c, line 4. Starting program: C:\src\tests\gdb-25911.exe Warning: Cannot insert breakpoint 2. Cannot access memory at address 0x401628 After trying a lot of combinations, I found a way to reproduce it: (gdb) file gdb-25987.exe Reading symbols from gdb-25987.exe... (gdb) start Temporary breakpoint 1 at 0x401638: file gdb-25987.cpp, line 13. Starting program: C:\src\tests\gdb-25987.exe Temporary breakpoint 1, main () at gdb-25987.cpp:13 13 int main() { (gdb) c Continuing. Program received signal SIGSEGV, Segmentation fault. MyClass::call (this=0x3d20d0) at gdb-25987.cpp:8 8 *(char*)(nullptr) = 1; (gdb) kill Kill the program being debugged? (y or n) y [Inferior 1 (process 1140) killed] (gdb) file gdb-25911.exe Load new symbol table from "gdb-25911.exe"? (y or n) y Reading symbols from gdb-25911.exe... (gdb) start Temporary breakpoint 2 at 0x40162d: file gdb-25911.c, line 4. Starting program: C:\src\tests\gdb-25911.exe Warning: Cannot insert breakpoint 2. Cannot access memory at address 0x401628 Command aborted. The actual failure was that ReadProcessMemory used a process handle that was no longer valid. And the underlying reason was that the windows_thread_info destructor closes a thread handle that was provided earlier by WaitForDebugEvent. But since this is not allowed (and it was actually already closed at this point, and the handle value reused), this closed another still-needed handle. gdb/ChangeLog: 2020-05-27 Hannes Domani <ssbssa@yahoo.de> * nat/windows-nat.c (windows_thread_info::~windows_thread_info): Don't close thread handle.
2020-05-27 [PATCH] allow empty string as argument to -MapNick Clifton5-2/+76
* lexsup.c (parse_args): If the map filename is defined but empty create a name based upon the output file name. If the name is defined but refers to a directory create a file inside the directory based on the output file name. * ld.texi: Document the new feature. * testsuite/ld-script/map-address.exp: Add test of new feature. * NEWS: Mention the new feature.
2020-05-27Share DWARF partial symtabsTom Tromey4-15/+115
This changes the DWARF reader to share partial symtabs (or indices if they are available) across objfiles. This has a few parts. * If multiple objfiles backed by the same BFD can share partial symtabs (see below), a single dwarf2_per_bfd is created. It is stored in the per-bfd `dwarf2_per_bfd_bfd_data_key` registry. Multiple dwarf2_per_objfile objects will point to the same instance. The lifetime of these dwarf2_per_bfd objects is naturally handled. When all the objfiles using the BFD are destroyed, the BFD's refount drops to 0, which triggers the removal of the corresponding dwarf2_per_bfd object from the registry and its destruction. * If multiple objfiles backed by the same BFD can't share partial symtabs (see below), one dwarf2_per_bfd object is created for each objfile. Each dwarf2_per_objfile will point to their own instance of dwarf2_per_bfd. These instances of dwarf2_per_bfd are kept in a per-objfile registry, meaning that when the objfile gets destroyed, the dwarf2_per_bfd instance gets destroyed as well. * objfile::partial_symtabs is changed to be a shared_ptr again. This lets us stash a second reference in dwarf2_per_bfd; if the DWARF data is being shared, we can simply copy this value to the new objfile. * Two dwarf2_per_objfile objects backed by the same BFD may share a dwarf2_per_bfd instance if: * No other symbol reader has found symbols, and * No BFD section rqeuires relocation gdb/ChangeLog: YYYY-MM-DD Tom Tromey <tom@tromey.com> YYYY-MM-DD Simon Marchi <simon.marchi@efficios.com> * objfiles.h (struct objfile) <partial_symtabs>: Now a shared_ptr. * dwarf2/read.h (struct dwarf2_per_objfile) <partial_symtabs>: New member. * dwarf2/read.c (dwarf2_per_bfd_bfd_data_key, dwarf2_per_bfd_objfile_data_key>: New globals. (dwarf2_has_info): Use shared dwarf2_per_bfd if possible. (dwarf2_get_section_info): Use get_dwarf2_per_objfile. (dwarf2_initialize_objfile): Consider cases where per_bfd can be shared. (dwarf2_build_psymtabs): Set objfile::partial_symtabs and short-circuit when sharing. (dwarf2_build_psymtabs): Set dwarf2_per_objfile::partial_symtabs. (dwarf2_psymtab::expand_psymtab): Use free_cached_comp_units. Change-Id: I868c64448589102ab8cbb8f06c31a8de50a14004
2020-05-27Move line_header_hash to dwarf2_per_objfileSimon Marchi3-9/+16
The `line_header_hash` field of `struct dwarf2_per_bfd` contains some `struct line_header` objects. A `struct line_header` objects contains some `file_entry` objects. A `file_entry` object contains a pointer to the `symtab` object created from it. The `line_header_hash` is therefore ultimately objfile-dependent and can't be shared as-is between objfiles. Move it from `dwarf2_per_bfd` to `dwarf2_per_objfile`. gdb/ChangeLog: * dwarf2/read.h (struct dwarf2_per_bfd) <line_header_hash>: Move to... (struct dwarf2_per_objfile) <line_header_hash>: ... here. * dwarf2/read.c (handle_DW_AT_stmt_list): Update. Change-Id: I8d2ee04df4f4847c2db99061fc976c35af98ac71
2020-05-27Make mapped_debug_names independent of objfileSimon Marchi2-74/+126
mapped_debug_names currently has a dwarf2_per_objfile field. Since we want it to become objfile-independent, this field must be removed. This patch removes it, and then arranges for all methods that needed it to accept a dwarf2_per_objfile parameter. This trickles down at various places, like the dw2_debug_names_iterator type. Ultimately, the objfile only seems to be needed because we might need to read a string from the string section. For that, we might need to read in the section, and if it's a relocatable section, the objfile is needed in order to do the relocation. This pattern happens often (that we to pass an objfile only because a section might be read). I think it's a bit ugly, but I don't have a good alternative right now. gdb/ChangeLog: * dwarf2/read.c (struct mapped_index_base) <symbol_name_at, build_name_components, find_name_components_bounds>: Add per_objfile parameter. (struct mapped_index) <symbol_name_at>: Likewise. (struct mapped_debug_names): Remove constructor. <dwarf2_per_objfile>: Remove field. <namei_to_name, symbol_name_at>: Add per_objfile parameter. (mapped_index_base::find_name_components_bounds, mapped_index_base::build_name_components, dw2_expand_symtabs_matching_symbol): Likewise. (class mock_mapped_index) <symbol_name_at>: Likewise. (check_match): Likewise. (check_find_bounds_finds): Likewise. (test_mapped_index_find_name_component_bounds): Update. (CHECK_MATCH): Update. (dw2_expand_symtabs_matching): Update. (class dw2_debug_names_iterator) <dw2_debug_names_iterator>: Add per_objfile parameter. <find_vec_in_debug_names>: Likewise. <m_per_objfile>: New field. (mapped_debug_names::namei_to_name): Add dwarf2_per_objfile parameter. (dw2_debug_names_iterator::find_vec_in_debug_names): Likewise. (dw2_debug_names_iterator::next): Update. (dw2_debug_names_lookup_symbol): Update. (dw2_debug_names_expand_symtabs_for_function): Update. (dw2_debug_names_map_matching_symbols): Update. (dw2_debug_names_expand_symtabs_matching): Update. (dwarf2_read_debug_names): Update. Change-Id: I00ee0d939390d353442675c7d400a261307c57a1
2020-05-27Replace dwarf2_per_cu_data::cu backlink with per-objfile mapSimon Marchi3-201/+247
The dwarf2_per_cu_data type is going to become objfile-independent, while the dwarf2_cu type will stay object-dependent. This patch removes the backlink from dwarf2_per_cu_data to dwarf2_cu, in favor of the dwarf2_per_objfile::m_dwarf2_cus map. It maps dwarf2_per_cu_data objects to the corresponding dwarf2_cu objects for this objfile. If a CU has been read in in the context of this objfile, then an entry will be present in the map. The dwarf2_cu objects that are read in are currently kept in a linked list rooted in the dwarf2_per_bfd. Except that the dwarf2_cu objects are not simply linked together, they are interleaved with their corresponding dwarf2_per_cu_data objects. So if we have CUs A and B read in, the dwarf2_per_bfd::read_in_chain will point to a chain like this (DPCD == dwarf2_per_cu_data, DC == dwarf2_cu): DPCD A -> DC A -> DPCD B -> DC B Obviously, this can't stay as is, since a same CU can be read in for an objfile but not read in for another objfile sharing the same BFD, and the dwarf2_per_cu_data::cu link is removed. This is all replaced by the dwarf2_per_objfile::m_dwarf2_cus map. gdb/ChangeLog: * dwarf2/read.h (struct dwarf2_cu): Forward-declare. (struct dwarf2_per_bfd) <free_cached_comp_units>: Remove, move to dwarf2_per_objfile. <read_in_chain>: Remove. (struct dwarf2_per_objfile) <get_cu, set_cu, remove_cu, remove_all_cus, age_comp_units>: New methods. <m_dwarf2_cus>: New member. (struct dwarf2_per_cu_data) <cu>: Remove. * dwarf2/read.c (struct dwarf2_cu) <read_in_chain>: Remove. (age_cached_comp_units, free_one_cached_comp_unit): Remove, moved to methods of dwarf2_per_objfile. (dwarf2_clear_marks): Remove. (dwarf2_queue_item::~dwarf2_queue_item): Update. (dwarf2_per_bfd::~dwarf2_per_bfd): Don't free dwarf2_cus. (dwarf2_per_bfd::free_cached_comp_units): Remove. (dwarf2_per_objfile::remove_all_cus): New. (class free_cached_comp_units) <~free_cached_comp_units>: Update. (load_cu): Update. (dw2_do_instantiate_symtab): Adjust. (fill_in_sig_entry_from_dwo_entry): Adjust. (cutu_reader::init_tu_and_read_dwo_dies): Update. (cutu_reader::cutu_reader): Likewise. (cutu_reader::keep): Use dwarf2_per_objfile::set_cu. (cutu_reader::cutu_reader): Use dwarf2_per_objfile::get_cu. (process_psymtab_comp_unit): Use dwarf2_per_objfile::remove_cu and dwarf2_per_objfile::age_comp_units. (load_partial_comp_unit): Update. (maybe_queue_comp_unit): Use dwarf2_per_objfile::get_cu. (process_queue): Likewise. (find_partial_die): Use dwarf2_per_objfile::get_cu instead of cu backlink. (dwarf2_read_addr_index): Likewise. (follow_die_offset): Likewise. (dwarf2_fetch_die_loc_sect_off): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (dwarf2_fetch_die_type_sect_off): Likewise. (follow_die_sig_1): Likewise. (load_full_type_unit): Likewise. (read_signatured_type): Likewise. (dwarf2_cu::dwarf2_cu): Don't set cu field. (dwarf2_cu::~dwarf2_cu): Remove. (dwarf2_per_objfile::get_cu): New. (dwarf2_per_objfile::set_cu): New. (age_cached_comp_units): Rename to... (dwarf2_per_objfile::age_comp_units): ... this. Adjust to std::unordered_map. (free_one_cached_comp_unit): Rename to... (dwarf2_per_objfile::remove_cu): ... this. Adjust to std::unordered_map. (dwarf2_per_objfile::~dwarf2_per_objfile): New. (dwarf2_mark_helper): Use dwarf2_per_objfile::get_cu, expect a dwarf2_per_objfile in data. (dwarf2_mark): Pass dwarf2_per_objfile in data to htab_traverse. (dwarf2_clear_marks): Remove. Change-Id: Ia33ac71c79b2de4710569008e22a6563a1505cde
2020-05-27Pass existing_cu object to cutu_readerSimon Marchi2-25/+48
It is possible, seemingly for a special case described in find_partial_die, for cutu_reader to re-use an existing dwarf2_cu instead of creating a new one. This happens when running this test, for example: make check TESTS="gdb.dwarf2/fission-reread.exp" Right now the, `use_existing_cu` flag tells cutu_reader to use the dwarf2_cu object at dwarf2_per_cu_data::cu. However, we'll remove that field, so we need to find another solution. This situation arises when some caller up the stack has already created the dwarf2_cu to read a dwarf2_per_cu_data, but needs to re-read it with some other parameters. Therefore, it's possible to just have that caller pass down the dwarf2_cu object to use as a `existing_cu` parameter. If `existing_cu` is NULL, it tells cutu_reader that it needs to instantiate a new one. gdb/ChangeLog: * dwarf2/read.c (class cutu_reader) <cutu_reader>: Replace `int use_existing_cu` parameter with `dwarf2_cu *existing_cu`. (init_tu_and_read_dwo_dies): Likewise. (cutu_reader::init_tu_and_read_dwo_dies): Likewise. (cutu_reader::cutu_reader): Likewise. (load_partial_comp_unit): Likewise. (process_psymtab_comp_unit): Update. (build_type_psymtabs_1): Update. (process_skeletonless_type_unit): Update. (load_full_comp_unit): Update. (find_partial_die): Update. (dwarf2_read_addr_index): Update. (read_signatured_type): Update. Change-Id: Id03e3bc3de3cf99d9e4b4080ad83b029c93bf434
2020-05-27Add comp_unit_head to dwarf2_per_cu_dataSimon Marchi3-34/+48
The per_cu_header_read_in function allows obtaining a filled comp_unit_head object for a given dwarf2_per_cu_data object. If a dwarf2_cu object exists for this dwarf2_per_cu_data, then it just returns a pointer to the comp_unit_head from that dwarf2_cu. Otherwise, it reads the header into a temporary buffer provided by the caller, and returns a pointer to that. Since the dwarf2_per_cu_data::cu link is going to be removed (dwarf2_per_cu_data will become objfile-independent while dwarf2_cu stays objfile-dependent), we cannot rely anymore on returning the header from the dwarf2_cu object. The not too complex solution implemented by this patch is to keep a copy of the header in the dwarf2_per_cu_data object, independent from the copy in dwarf2_cu. The new copy is only used in the addr_size, offset_size and ref_addr_size methods of dwarf2_per_cu_data. There's nothing intrinsic to the comp_unit_head object that prevents it to be shared between two dwarf2_cu objects (belonging to different objfiles) representing the same CU. In other words, I think we could eventually get rid of the copy in dwarf2_cu to only keep the one in dwarf2_per_cu_data. It is not trivial, however, so I have decided not to do it for the moment. gdb/ChangeLog: * dwarf2/read.h (struct dwarf2_per_cu_data) <m_header, m_header_read_in>: New fields. <get_header>: New method. * dwarf2/read.c (per_cu_header_read_in): Remove. (dwarf2_per_cu_data::get_header): New. (dwarf2_per_cu_data::addr_size): Update. (dwarf2_per_cu_data::offset_size): Update. (dwarf2_per_cu_data::ref_addr_size): Update. Change-Id: Id7541fca7562843eba110ece21c4df38d45fca23
2020-05-27Make load_cu return the loaded dwarf2_cuSimon Marchi2-32/+43
In a subsequent patch, the dwarf2_per_cu_data::cu link will be removed. dwarf2_cu objects will instead need to be looked up from a per-objfile map, using the dwarf2_per_cu_data object as the key. To make it easier for some callers, this patch makes load_cu return the dwarf2_cu it creates. If the caller needs to use the created dwarf2_cu, it will have it available right away, rather than having to do a map lookup. At the same time, this allows changing queue_and_load_all_dwo_tus to take a dwarf2_cu instead of a dwarf2_per_cu_data. gdb/ChangeLog: * dwarf2/read.c (load_cu): Return dwarf2_cu. (dw2_do_instantiate_symtab): Update. (queue_and_load_all_dwo_tus): Change parameter from dwarf2_per_cu_data to dwarf2_cu. (dwarf2_fetch_die_loc_sect_off): Update. (dwarf2_fetch_constant_bytes): Update. (dwarf2_fetch_die_type_sect_off): Update. Change-Id: I8a04c5d1b8cc661b8203f97999258ba8e04e1765
2020-05-27Pass dwarf2_cu to process_full_{comp,type}_unitSimon Marchi2-22/+22
These two functions work on a dwarf2_cu. It is currently obtained from the per_cu->cu link, which we want to remove. Make them accept the dwarf2_cu directly as a parameter. This moves the per_cu->cu references one level up, but that one will be removed too in a subsequent patch. gdb/ChangeLog: * dwarf2/read.c (process_full_comp_unit, process_full_type_unit): Remove per_cu, per_objfile paramters. Add dwarf2_cu parameter. (process_queue): Update. Change-Id: I1027d36986073ac991e198e06f9d51341dc19c6e
2020-05-27Pass dwarf2_per_bfd instead of dwarf2_per_objfile to some index-related ↵Simon Marchi2-47/+55
functions All these functions actually only need to receive a dwarf2_per_bfd, pass that instead of dwarf2_per_objfile. gdb/ChangeLog: * dwarf2/read.c (create_cu_from_index_list): Replace dwarf2_per_objfile parameter with dwarf2_per_bfd. (create_cus_from_index_list): Likewise. (create_cus_from_index): Likewise. (create_signatured_type_table_from_index): Likewise. (create_cus_from_debug_names_list): Likewise. (create_cus_from_debug_names): Likewise. (dwarf2_read_gdb_index): Update. (dwarf2_read_debug_names): Update. Change-Id: I8cd7dc04bf815723a48745e7e9b283663dccc1ac
2020-05-27Move signatured_type::type to unshareable objectTom Tromey3-10/+47
signatured_type has a link to the "struct type". However, types are inherently objfile-specific, so once sharing is implemented, this will be incorrect. This patch moves the type to a new map in the DWARF unshareable object. gdb/ChangeLog: YYYY-MM-DD Tom Tromey <tom@tromey.com> YYYY-MM-DD Simon Marchi <simon.marchi@efficios.com> * dwarf2/read.h (struct dwarf2_per_objfile) <get_type_for_signatured_type, set_type_for_signatured_type>: New methods. <m_type_map>: New member. (struct signatured_type) <type>: Remove. * dwarf2/read.c (dwarf2_per_objfile::get_type_for_signatured_type, dwarf2_per_objfile::set_type_for_signatured_type): New. (get_signatured_type): Use new methods. Change-Id: I765ae3c43fae1064f51ced352167a57638609f02
2020-05-27Split type_unit_groupTom Tromey3-26/+83
type_unit_group has links to the compunit_symtab and other symtabs. However, once this object is shared across objfiles, this will no longer be ok. This patch introduces a new type_unit_group_unshareable and arranges to store a map from type unit groups to type_unit_group_unshareable objects in dwarf2_per_objfile. gdb/ChangeLog: YYYY-MM-DD Tom Tromey <tom@tromey.com> YYYY-MM-DD Simon Marchi <simon.marchi@efficios.com> * dwarf2/read.h (struct type_unit_group_unshareable): New. (struct dwarf2_per_objfile) <type_units>: New member. <get_type_unit_group_unshareable>: New method. * dwarf2/read.c (struct type_unit_group) <compunit_symtab, num_symtabs, symtabs>: Remove; move to type_unit_group_unshareable. (dwarf2_per_objfile::get_type_unit_group_unshareable): New. (process_full_type_unit, dwarf2_cu::setup_type_unit_groups) (dwarf2_cu::setup_type_unit_groups): Use type_unit_group_unshareable. Change-Id: I1fec2fab59e0ec40fee3614fc821172a469c0e41