aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-03-02libctf: minor error-handling fixesNick Alcock3-8/+32
A transient bug in the preceding change (fixed before commit) exposed a new failure, of ld/testsuite/ld-ctf/diag-parname.d. This attempts to ensure that if we link a dict with child type IDs but no attached parent, we get a suitable ECTF_NOPARENT error. This was happening before this commit, but only by chance, because ctf_variable_iter and ctf_variable_next check to see if the dict they're passed is a child dict without an associated parent. We forgot error-checking on the ctf_variable_next call, and as a result this was concealed -- and looking for the problem exposed a new bug. If any of the lookups beneath ctf_dedup_hash_type fail, the CTF link does *not* fail, but acts quite bizarrely, skipping the type but emitting an error to the CTF error/warning log -- so the linker will report an error, emit a partial CTF dict missing some types, and exit with exitcode 0 as if nothing went wrong. Since ctf_dedup_hash_type is never expected to fail in normal operation, this is surely wrong: failures at emission time do not emit partial CTF dicts, so failures at hashing time should not either. So propagate the error back up. Also fix a couple of smaller bugs where we fail to properly free things and/or propagate error codes on various rare link-time errors and out-of-memory conditions. libctf/ChangeLog 2021-03-02 Nick Alcock <nick.alcock@oracle.com> * ctf-dedup.c (ctf_dedup): Pass on errors from ctf_dedup_hash_type. Call ctf_dedup_fini properly on other errors. (ctf_dedup_emit_type): Set the errno on dynhash insertion failure. * ctf-link.c (ctf_link_deduplicating_per_cu): Close outputs beyond output 0 when asserting because >1 output is found. (ctf_link_deduplicating): Likewise, when asserting because the shared output is not the same as the passed-in fp.
2021-03-02libctf: add a deduplicator-specific type mapping tableNick Alcock5-328/+344
When CTF linking is done, the linker has to track the association between types in the inputs and types in the outputs. The deduplicator does this via the cd_output_emission_hashes, which maps from hashes of types (valid in both the input and output) to the IDs of types in the specific dict in which the cd_emission_hashes is held. However, the nondeduplicating linker and ctf_add_type used a different mechanism, a dedicated hashtab stored in the ctf_link_type_mapping, populated via ctf_add_type_mapping and queried via the ctf_type_mapping function. To allow the same functions to be used for variable and symbol population in both the deduplicating and nondeduplicating linker, the deduplicator carefully transferred all its input->output mappings into this hashtab before returning. This is *expensive*. The number of entries in this hashtab scales as the number of input types, and unlike the hashing machinery the type mapping machinery (the only other thing which scales that way) has not been much optimized. Now the nondeduplicating linker is gone, we can throw this out, move the existing type mapping machinery to ctf-create.c and dedicate it to ctf_add_type alone, and add a new function ctf_dedup_type_mapping which uses the deduplicator's built-in knowledge of type mappings directly, without requiring an expensive repopulation phase. This speeds up a test link of nouveau.ko (a good worst-case candidate with a lot of types in each of a lot of input files) from 9.11s to 7.15s in my testing, a speedup of over 20%. libctf/ChangeLog 2021-03-02 Nick Alcock <nick.alcock@oracle.com> * ctf-impl.h (ctf_dict_t) <ctf_link_type_mapping>: No longer used by the nondeduplicating linker. (ctf_add_type_mapping): Removed, now static. (ctf_type_mapping): Likewise. (ctf_dedup_type_mapping): New. (ctf_dedup_t) <cd_input_nums>: New. * ctf-dedup.c (ctf_dedup_init): Populate it. (ctf_dedup_fini): Free it again. Emphasise that this has to be the last thing called. (ctf_dedup): Populate it. (ctf_dedup_populate_type_mapping): Removed. (ctf_dedup_populate_type_mappings): Likewise. (ctf_dedup_emit): No longer call it. No longer call ctf_dedup_fini either. (ctf_dedup_type_mapping): New. * ctf-link.c (ctf_unnamed_cuname): New. (ctf_create_per_cu): Arguments must be non-null now. (ctf_in_member_cb_arg): Removed. (ctf_link): No longer populate it. No longer discard the mapping table. (ctf_link_deduplicating_one_symtypetab): Use ctf_dedup_type_mapping, not ctf_type_mapping. Use ctf_unnamed_cuname. (ctf_link_one_variable): Likewise. Pass in args individually: no longer a ctf_variable_iter callback. (empty_link_type_mapping): Removed. (ctf_link_deduplicating_variables): Use ctf_variable_next, not ctf_variable_iter. No longer pack arguments to ctf_link_one_variable into a struct. (ctf_link_deduplicating_per_cu): Call ctf_dedup_fini once all link phases are done. (ctf_link_deduplicating): Likewise. (ctf_link_intern_extern_string): Improve comment. (ctf_add_type_mapping): Migrate... (ctf_type_mapping): ... these functions... * ctf-create.c (ctf_add_type_mapping): ... here... (ctf_type_mapping): ... and make static, for the sole use of ctf_add_type.
2021-03-02libctf: remove reference to "unconflicted link mode".Nick Alcock2-3/+8
There is no such thing, and the comment makes no sense, and doesn't match what the code is doing. We always want to put variables in the same dicts as the types they relate to if at all possible. libctf/ChangeLog 2021-03-02 Nick Alcock <nick.alcock@oracle.com> * ctf-link.c (ctf_link_one_variable): Remove reference to "unconflicted link mode".
2021-03-02libctf, include: remove the nondeduplicating CTF linkerNick Alcock4-231/+46
The nondeduplicating CTF linker was kept around when the deduplicating one was added so that people had something to fall back to in case the deduplicating linker turned out to be buggy. It's now much more stable than the nondeduplicating linker, in addition to much faster, using much less memory and producing much better output. In addition, while libctf has a linker flag to invoke the nondeduplicating linker, ld does not expose it: the only way to turn it on within ld is an intentionally- undocumented environment variable. So we can remove it without any ABI or user-visibility concerns (the only thing we leave around is the CTF_LINK_NONDEDUP flag, which can easily be interpreted as "deduplicate less", though right now it does nothing). This lets us remove a lot of complexity associated with tracking filenames and CU names separately (something the deduplcating linker never bothered with, since the cunames are always reliable and ld never hands us useful filenames anyway) The biggest lacuna left behind is the ctf_type_mapping machinery, which slows down deduplicating links quite a lot. We can't just ditch it because ctf_add_type uses it: removing the slowdown from the deduplicating linker is a job for another commit. include/ChangeLog 2021-03-02 Nick Alcock <nick.alcock@oracle.com> * ctf-api.h (CTF_LINK_SHARE_DUPLICATED): Note that this might merely change how much deduplication is done. libctf/ChangeLog 2021-03-02 Nick Alcock <nick.alcock@oracle.com> * ctf-link.c (ctf_create_per_cu): Drop FILENAME now that it is always identical to CUNAME. (ctf_link_deduplicating_one_symtypetab): Adjust. (ctf_link_one_type): Remove. (ctf_link_one_input_archive_member): Likewise. (ctf_link_close_one_input_archive): Likewise. (ctf_link_one_input_archive): Likewise. (ctf_link): No longer call it. Drop CTF_LINK_NONDEDUP path. Improve header comment a bit (dicts, not files). Adjust ctf_create_per_cu call. (ctf_link_deduplicating_variables): Simplify. (ctf_link_in_member_cb_arg_t) <cu_name>: Remove. <in_input_cu_file>: Likewise. <in_fp_parent>: Likewise. <done_parent>: Likewise. (ctf_link_one_variable): Turn uses of in_file_name to in_cuname.
2021-03-02libctf: fix ChangeLog dateNick Alcock1-1/+1
I pushed this change without fixing up the date by mistake.
2021-03-02libctf: reimplement many _iter iterators in terms of _nextNick Alcock3-124/+69
Ever since the generator-style _next iterators were introduced, there have been separate implementations of the functional-style _iter iterators that do the same thing as _next. This is annoying and adds more dependencies on the internal guts of the file format. Rip them all out and replace them with the corresponding _next iterators. Only ctf_archive_raw_iter and ctf_label_iter survive, the former because there is no access to the raw binary data of archives via any _next iterator, and the latter because ctf_label_next hasn't been implemented (because labels are currently not used for anything). Tested by reverting the change (already applied) that reimplemented ctf_member_iter in terms of ctf_member_next, then verifying that the _iter and _next iterators produced the same results for every iterable entity within a large type archive. libctf/ChangeLog 2021-03-02 Nick Alcock <nick.alcock@oracle.com> * ctf-types.c (ctf_member_iter): Move 'rc' to an inner scope. (ctf_enum_iter): Reimplement in terms of ctf_enum_next. (ctf_type_iter): Reimplement in terms of ctf_type_next. (ctf_type_iter_all): Likewise. (ctf_variable_iter): Reimplement in terms of ctf_variable_next. * ctf-archive.c (ctf_archive_iter_internal): Remove. (ctf_archive_iter): Reimplement in terms of ctf_archive_next.
2021-03-02libctf: ctf_archive_next should set the parent name consistentlyNick Alcock2-0/+7
The top level of CTF containers is a "CTF archive", which contains a collection of named members (each a CTF dictionary). In the serialized file format, this is optional and skipped if the archive would have only one member, as when no ambiguous types are present: so it is commonplace to have a simple ctf_dict_t written out, with no archive container wrapped around it. But, unlike ctf_archive_iter, ctf_archive_next didn't quite handle this case right. It should set the name of this fake "member" to _CTF_SECTION, i.e. ".ctf", but it was failing to do so, so callers got an unintialized variable back instead and were understandably confused. So set the name properly. libctf/ChangeLog 2021-03-02 Nick Alcock <nick.alcock@oracle.com> * ctf-archive.c (ctf_archive_next): Set the name of parents in single-member archives.
2021-03-02PR27451, -z start_stop_gc for powerpc64Alan Modra7-0/+47
PowerPC64 has its own gc_mark_dynamic_ref. bfd/ PR 27451 * elf64-ppc.c (ppc64_elf_gc_mark_dynamic_ref): Ignore synthesized linker defined start/stop symbols when start_stop_gc. ld/ * testsuite/ld-powerpc/startstop.d, * testsuite/ld-powerpc/startstop.r, * testsuite/ld-powerpc/startstop.s: New test. * testsuite/ld-powerpc/powerpc.exp: Run it.
2021-03-02PowerPC64 undefined weak visibility vs GOT optimisationAlan Modra9-0/+115
Undefined weak symbols with non-default visibility are seen as local by SYMBOL_REFERENCES_LOCAL. This stops a got indirect to relative optimisation for them, so that pies and dlls don't get non-zero values when loading somewhere other than the address they are linked at (which always happens). The optimisation could be allowed for pdes, but I thought it best not to allow it there too. bfd/ * elf64-ppc.c (ppc64_elf_relocate_section): Don't optimise got indirect to pc-relative or toc-relative for undefined symbols. ld/ * testsuite/ld-powerpc/weak1.d, * testsuite/ld-powerpc/weak1.r, * testsuite/ld-powerpc/weak1.s, * testsuite/ld-powerpc/weak1so.d, * testsuite/ld-powerpc/weak1so.r: New tests. * testsuite/ld-powerpc/powerpc.exp: Run them.
2021-03-02Automatic date update in version.inGDB Administrator1-1/+1
2021-03-01Add DWARF-5 section names to PE and PEP linker scripts.Nick Clifton3-31/+144
PR 27268 * scripttempl/pe.sc: Add DWARF-5 section names. * scripttempl/pep.sc: Likewise.
2021-03-01Warn for missing separate debug files only if neededH.J. Lu3-23/+54
We shouldn't warn missing separate debug files when debug info isn't needed. PR binutils/27486 * dwarf.c (load_separate_debug_info): Issue warning only if do_debug_links is set. * testsuite/binutils-all/compress.exp: Run objdump and readelf with missing debug file.
2021-03-01PR27451, -z start_stop_gcAlan Modra14-4/+95
When --gc-sections is in effect, a reference from a retained section to __start_SECNAME or __stop_SECNAME causes all input sections named SECNAME to also be retained, if SECNAME is representable as a C identifier and either __start_SECNAME or __stop_SECNAME is synthesized by the linker. Add an option to disable that feature, effectively ignoring any relocation that references a synthesized linker defined __start_ or __stop_ symbol. PR 27451 include/ * bfdlink.h (struct bfd_link_info): Add start_stop_gc. bfd/ * elflink.c (_bfd_elf_gc_mark_rsec): Ignore synthesized linker defined start/stop symbols when start_stop_gc. (bfd_elf_gc_mark_dynamic_ref_symbol): Likewise. (bfd_elf_define_start_stop): Don't modify ldscript_def syms. * linker.c (bfd_generic_define_start_stop): Likewise. ld/ * emultempl/elf.em: Handle -z start-stop-gc and -z nostart-stop-gc. * lexsup.c (elf_static_list_options): Display help for them. Move help for -z stack-size to here from elf_shlib_list_options. Add help for -z start-stop-visibility and -z undefs. * ld.texi: Document -z start-stop-gc and -z nostart-stop-gc. * NEWS: Mention -z start-stop-gc. * testsuite/ld-gc/start2.s, * testsuite/ld-gc/start2.d: New test. * testsuite/ld-gc/gc.exp: Run it.
2021-03-01Weak references to __start_/__stop_ symbolsAlan Modra2-0/+19
If a weak reference to a __start_foo or __stop_foo symbol ends up having no definition due to all the foo sections being removed for some reason, undef_start_stop currently makes the symbol strong undefined. That risks a linker undefined symbol error. Fix that by making the symbol undefweak and also undo some dynamic symbol state. Note that saving the state of the symbol type at the time lang_init_start_stop runs is not sufficient. The linker may have merged in a shared library reference by that point and made what was an undefweak in regular objects, a strong undefined. So it is necessary to look at the ELF symbol flags to decide whether an undefweak is the proper resolution. Something probably should be done for COFF/PE too, but I'm unsure how to do go about that. * ldlang.c (undef_start_stop): For ELF make undefined start/stop symbols undefweak if that was how they were referenced. Undo dynamic state too.
2021-03-01PR27128, nm -P portable output format regressionAlan Modra10-14/+54
Add nm --without-symbol-versions. binutils/ PR 27128 * doc/binutils.texi: Add nm --with-symbol-versions and --without-symbol-versions documentation. * nm.c (with_symbol_versions): New variable. (enum long_option_values): Delete OPTION_WITH_SYMBOL_VERSIONS. (long_options): Make --with-symbol-versions entry twiddle the flag. Add --without-symbol-versions. (print_symname): Strip version when !with_symbol_versions. Add dynamic version info under control of with_symbol_versions. (main): Remove OPTION_WITH_SYMBOL_VERSIONS case. ld/ * testsuite/ld-elf/pr25708.d: Add --with-symbol-versions to nm. * testsuite/ld-elf/pr27128a.d: Likewise. * testsuite/ld-elf/pr27128b.d: Likewise. * testsuite/ld-elf/pr27128c.d: Likewise. * testsuite/ld-elf/pr27128d.d: Likewise. * testsuite/ld-elf/pr27128e.d: Likewise.
2021-03-01Automatic date update in version.inGDB Administrator1-1/+1
2021-02-28Add missing changes to Makefile.tplH.J. Lu2-0/+13
Update Makefile.tpl to add missing changes in commit af019bfde9b13d628202fe58054ec7ff08d92a0f Author: H.J. Lu <hjl.tools@gmail.com> Date: Sat Jan 9 06:51:15 2021 -0800 Support the PGO build for binutils+gdb "autogen Makefile.def" showed no changes in Makefile.in. PR binutils/26766 * Makefile.tpl (PGO_BUILD_TRAINING_FLAGS_TO_PASS): Add PGO_BUILD_TRAINING=yes. (PGO_BUILD_TRAINING_MFLAGS): New. (all): Pass $(PGO_BUILD_TRAINING_MFLAGS) to the PGO build.
2021-02-28sim: igen: drop config.h & header checkingMike Frysinger12-1125/+58
While the configure script was checking for a bunch of headers, only one of them was conditionally included in the source (unistd.h). The rest were always included. Based on those usage this whole time, we can reasonably assume that the build also has unistd.h. All the other files including config.h never actually used any defines from the header.
2021-02-28sim: igen: delete more unused toolchain settingsMike Frysinger4-122/+7
This package doesn't build any archives or install programs.
2021-02-28sim: igen: delete unused FOR_BUILD varsMike Frysinger4-24/+7
2021-02-28sim: set up build-time compiler settingsMike Frysinger32-277/+313
Some sim dirs were already setting up CFLAGS_FOR_BUILD in inconsistent ways. Move it to a common place for reuse.
2021-02-28sim: use AC_CHECK_TOOL to find arMike Frysinger32-93/+2793
Rather than require $AR be set and then default to `ar`, use the standard AC_CHECK_TOOL helper to find a good prefixed tool. In practice this shouldn't change much as we seem to have macros in the tree that were already setting it up, but we shouldn't rely on that implicitly.
2021-02-28sim: require AC_PROG_CPP explicitlyMike Frysinger62-4206/+4359
All the scripts were using this implicitly already, so there's no real change for them, but we want to call it explicitly as the CPP tool is used to generate nltvals.def.
2021-02-28sim: delete unused SIM_EXTRA_LIBDEPSMike Frysinger6-8/+14
This was last used 15 years ago, so clearly not important enough to keep around. Punt it.
2021-02-27sim: delete redundant SIM_EXTRA_ALLMike Frysinger10-9/+26
We don't need a variable to add a dependency to the "all" target, and having one doesn't really add value. Switch to the target directly for the few ports that actually use this.
2021-02-28Automatic date update in version.inGDB Administrator1-1/+1
2021-02-27[PR gdb/27393] set directories: handle empty dirs.Lancelot SIX4-0/+54
As reported in gdb/27393, the 'directory' and 'set directories' commands fail when parsing an empty dir name: (gdb) set directories "" /home/lsix/dev/gnu/binutils-gdb/gdbsupport/pathstuff.cc:132: internal-error: gdb::unique_xmalloc_ptr<char> gdb_abspath(const char*): Assertion `path != NULL && path[0] != '\0'' failed. or (gdb) dir : /home/lsix/dev/gnu/binutils-gdb/gdbsupport/pathstuff.cc:132: internal-error: gdb::unique_xmalloc_ptr<char> gdb_abspath(const char*): Assertion `path != NULL && path[0] != '\0'' failed. This patch fixes this issue by ignoring any attempt to add an empty name to the source directories list. 'set dir ""' will reset the directories list the same way 'set dir' would do it. Tested on x86_64.
2021-02-26Minor fix in skip_ctf_testsTom Tromey2-1/+7
I noticed an oddity in skip_ctf_tests -- for me it ends up caching the string "!0", because it ends with 'return ![...]'. In Tcl, this is just string concatenation. The result works because the users of this function have unbraced if conditions, like: if [skip_ctf_tests] { ... which works because "if" re-parses the returned string as an expression, and evaluates that. There's only a latent bug here, but this is also un-idiomatic, so I am checking in this patch to fix it. This way, if someone in the future uses a braced condition (which is what I normally recommend), it will continue to work. gdb/testsuite/ChangeLog 2021-02-26 Tom Tromey <tom@tromey.com> * lib/gdb.exp (skip_ctf_tests): Use expr on result.
2021-02-27Automatic date update in version.inGDB Administrator1-1/+1
2021-02-26nm: Add --quiet to suppress "no symbols" diagnosticFangrui Song4-4/+34
PR binutils/27408 * readelf.c (quiet): New option flag. (enum long_option_values): New enum to hold long option value. (long_options): Add --quiet. (usage): Mention --quiet. (display_rel_file): If quiet is enabled, suppress "no symbols". (main): Handle the new option. * NEWS: Mention --quiet. * docs/binutils.texi: Document --quiet.
2021-02-26Correct an error message in the ARM assembler.Nick Clifton5-1/+31
PR 27411 * config/tc-arm.c (do_t_add_sub): Correct error message. * testsuite/gas/arm/pr27411.s: New test. * testsuite/gas/arm/pr27411.d: New test driver. * testsuite/gas/arm/pr27411.l: Expected error output for new test.
2021-02-26Add support for decoding DWARF v5 DW_AT_addr_base tags.Tom de Vries2-3/+40
* dwarf.c (display_debug_addr): Handle dwarf-5 .debug_addr bits.
2021-02-26testsuite: Remove extra \n from expected output of tsv notificationsJan Vrany2-5/+10
Commit 2450ad54 removed extra trailing \n from tsv notifications but did not update gdb.trace/mi-tsv-changed.exp accordingly. This commit removes the extra \n from expected output so gdb.trace/mi-tsv-changed.exp passes again. gdb/testsuite/ChangeLog: * gdb.trace/mi-tsv-changed.exp (test_create_delete_modify_tsv): Remove trailing \n from expected output.
2021-02-26Add support for the split DWARF forms.Tom de Vries2-2/+68
PR 27390 * dwarf.c: (skip_attr_bytes): Add support for DW_FORM_str* and DW_FORM_addrx*. (read_and_display_attr_value): Likewise.
2021-02-26testsuite: note on use_gdb_stub usageMarkus Metzger2-0/+7
Add a note to the comment on use_gdb_stub explaining the use of this check for skipping tests that spawn new inferiors as discussed here: https://sourceware.org/pipermail/gdb-patches/2020-December/174186.html
2021-02-26Add PR27441 testcaseAlan Modra6-0/+36
PR 27441 * testsuite/ld-plugin/pr27441a.c, * testsuite/ld-plugin/pr27441b.c, * testsuite/ld-plugin/pr27441c.c, * testsuite/ld-plugin/pr27441c.d: New test. * testsuite/ld-plugin/lto.exp: Run it.
2021-02-26libctf regen for NEWSAlan Modra2-1/+5
The previous regen was done on a tree without the new NEWS file. * Makefile.in: Regenerate.
2021-02-26Automatic date update in version.inGDB Administrator1-1/+1
2021-02-25Fix date in ChangeLogKevin Buettner1-1/+1
2021-02-25Add comment regarding include order of <sys/ptrace.h> and <asm/ptrace.h>Kevin Buettner2-0/+11
I added the same comment for nat/aarch64-linux-hw-point.c yesterday. Christian suggested adding the comment for the other file that I had identified as including both <sys/ptrace.h> and <asm/ptrace.h>. I searched the sources in gdb/, but found no other files which include both of these headers. If possible, I would prefer to see us use <sys/ptrace.h> when possible, however, from past experience, I've found that this file does not always contain all of the constants, etc. required by the particular source file. gdb/ChangeLog: * nat/aarch64-sve-linux-ptrace.h: Add comment regarding include order for <sys/ptrace.h> and <asm/ptrace.h>.
2021-02-25gdb: relax assertion in target_mourn_inferiorSimon Marchi2-1/+7
As reported in PR 26861, when killing an inferior on macOS, we hit the assert: ../../gdb-10.1/gdb/target.c:2149: internal-error: void target_mourn_inferior(ptid_t): Assertion `ptid == inferior_ptid' failed. This is because darwin_nat_target::kill passes a pid-only ptid to target_mourn_inferior, with the pid of the current inferior: target_mourn_inferior (ptid_t (inf->pid)); ... which doesn't satisfy the assert in target_mourn_inferior: gdb_assert (ptid == inferior_ptid); The reason for this assertion is that target_mourn_inferior is a prototype shared between GDB and GDBserver, so that shared code in gdb/nat (used in both GDB and GDBserver) can call target_mourn_inferior. In GDB's implementation, it is likely that some targets still rely on inferior_ptid being set to "the current thread we are working on". So until targets are completely decoupled from inferior_ptid (at least their mourn_inferior implementations), we need to ensure the passed in ptid matches inferior_ptid, to ensure the calling code called target_mourn_inferior with the right global context. However, I think the assert is a bit too restrictive. The mourn_inferior operation works on an inferior, not a specific thread. And by the time we call mourn_inferior, the threads of the inferior don't exist anymore, the process is gone, so it doesn't really make sense to require inferior_ptid to point a specific thread. I looked at all the target_ops::mourn_inferior implementations, those that read inferior_ptid only care about the pid field, which supports the idea that only the inferior matters. Other implementations look at the current inferior (call `current_inferior ()`). I think it would make sense to change target_mourn_inferior to accept only a pid rather than a ptid. It would then assert that the pid is the same as the current inferior's pid. However, this would be a quite involved change, so I'll keep it for later. To fix the macOS issue immediately, I propose to relax the assert to only compare the pids, as is done in this patch. Another solution would obviously be to make darwin_nat_target::kill pass inferior_ptid to target_mourn_inferior. However, the solution I propose is more in line with where I think we want to go (passing a pid to target_mourn_inferior). gdb/ChangeLog: PR gdb/26861 * target.c (target_mourn_inferior): Only compare pids in target_mourn_inferior. Change-Id: If2439ccc5aa67272ea16148a43c5362ef23fb2b8
2021-02-25Fix initial thread state of non-threaded remote targetsJan Matyas4-4/+36
This change fixes the initial state of the main thread of remote targets which have no concept of threading. Such targets are treated as single-threaded by gdb, and this single thread needs to be initially set to the "resumed" state, in the same manner as threads in thread-aware remote targets (see remote.c, remote_target::remote_add_thread). Without this fix, the following assert was triggered on thread- unaware remote targets: remote_target::select_thread_for_ambiguous_stop_reply(const target_waitstatus*): Assertion `first_resumed_thread != nullptr' failed. The bug can be reproduced using gdbserver * by disabling packets 'T' and 'qThreadInfo', or * by disabling all thread-related packets. The test suite has been updated to include these two scenarios, see gdb.server/stop-reply-no-thread.exp. Change-Id: I2c39c9de17e8d6922a8c1b9e259eb316a554a43d
2021-02-25Add initial support for .debug_sup sections.Nick Clifton6-9/+176
* dwarf.c (get_type_abbrev_from_form): Accept but ignore sup forms. (read_and_display_attr_value): Handle sup forms. (display_debug_sup): New function. Displays the contents of a .debug_sup section. (load_debug_sup_file): New function. Loads the contents of a file referenced by a .debug_sup section. (check_for_and_load_links): Call load_debug_sup_file. (debug_displays): Add entry for .debug_sup. * dwarf.h (enum dwarf_section_display_enum): Add debug_sup. * readelf.c (process_section_headers): Add support for debug_sup. * doc/debug.options.texi: Note that the =links option will display the contents of .debug_sup sections. * NEWS: Mention the new support.
2021-02-25gdb/testsuite: Add a missing -wrap in gdb_test_multipleAndrew Burgess2-1/+5
In commit: commit faeb9f13c179a4c78bc295a0d0bbd788239704d9 Date: Wed Feb 24 12:50:00 2021 +0000 gdb/fortran: add support for ASSOCIATED builtin A test was added that fails to process the trailing gdb prompt inside a gdb_test_multiple call, this will cause a failure if the tests are run with READ1=1, or randomly at other times depending on how the expect buffers are read in. Fixed by adding a -wrap argument. gdb/testsuite/ChangeLog: * gdb.fortran/associated.exp: Add missing '-wrap' argument.
2021-02-25gdb/mi: Remove extra \n from tsv and and traceframe notificationsJan Vrany2-4/+10
An extra \n in calls to fprintf_unfiltered() caused invalid MI records to be emitted: > gdb -i mi3 -ex "target remote :7000" =thread-group-added,id="i1" ~"GNU gdb (GDB) 11.0.50.20201019-git\n" ~"Copyright (C) 2020 Free Software Foundation, Inc.\n" ... ~"Remote debugging using :7001\n" =tsv-created,name="trace_timestamp",initial="0"\n =thread-group-started,id="i1",pid="304973" This commit fixes the problem. gdb/ChangeLog: * gdb/mi/mi-interp.c (mi_traceframe_changed): Remove trailing \n from output. (mi_tsv_created): Likewise. (mi_tsv_deleted): Likewise.
2021-02-25[gdb/symtab] Fix wrong unit_type Dwarf ErrorTom de Vries2-1/+7
When running test-case gdb.dwarf2/fission-mix.exp using gcc-11 (and using the tentative fix for PR27353 to get past that assertion failure), I run into: ... (gdb) file fission-mix^M Reading symbols from fission-mix...^M Dwarf Error: wrong unit_type in compilation unit header \ (is DW_UT_split_compile (0x05), should be DW_UT_type (0x02)) \ [in module fission-mix2.dwo]^M (No debugging symbols found in fission-mix)^M ... The compilation unit that is complained about is: ... Contents of the .debug_info.dwo section (loaded from fission-mix2.dwo): Compilation Unit @ offset 0x0: Length: 0x57 (32-bit) Version: 5 Unit Type: DW_UT_split_compile (5) Abbrev Offset: 0x0 Pointer Size: 8 DWO ID: 0x3e3930d3cc1805df <0><14>: Abbrev Number: 1 (DW_TAG_compile_unit) ... And the dwarf error is triggered here in read_comp_unit_head: ... case DW_UT_split_compile: if (section_kind != rcuh_kind::COMPILE) error (_("Dwarf Error: wrong unit_type in compilation unit header " "(is %s, should be %s) [in module %s]"), dwarf_unit_type_name (cu_header->unit_type), dwarf_unit_type_name (DW_UT_type), filename); break; ... due to passing rcuh_kind::TYPE here in open_and_init_dwo_file: ... create_debug_type_hash_table (per_objfile, dwo_file.get (), &dwo_file->sections.info, dwo_file->tus, rcuh_kind::TYPE); ... Fix this by changing the section_kind argument to create_debug_type_hash_table to rcuh_kind::COMPILE, to reflect that we're passing &dwo_file->sections.info rather than &dwo_file->sections.types. Tested on x86_64-linux. gdb/ChangeLog: 2021-02-25 Tom de Vries <tdevries@suse.de> PR symtab/27354 * dwarf2/read.c (open_and_init_dwo_file): Use rcuh_kind::COMPILE as section_kind for &dwo_file->sections.info.
2021-02-25ld: correct description of behavior for symbols redefined by scriptJan Beulich2-2/+6
Prior to 89753bbf8102 ("Warn when a script redefines a symbol") there was no diagnostic at all. As of that commit, it's a warning, not an error.
2021-02-25gdb/fortran: don't access non-existent type fieldsAndrew Burgess6-18/+243
When attempting to call a Fortran function for which there is no debug information we currently trigger undefined behaviour in GDB by accessing non-existent type fields. The reason is that in order to prepare the arguments, for a call to a Fortran function, we need to know the type of each argument. If the function being called has no debug information then obviously GDB doesn't know about the argument types and we should either give the user an error or pick a suitable default. What we currently do is just assume the field exist and access undefined memory, which is clearly wrong. The reason GDB needs to know the argument type is to tell if the argument is artificial or not, artificial arguments will be passed by value while non-artificial arguments will be passed by reference. An ideal solution for this problem would be to allow the user to cast the function to the correct type, we already do this to some degree with the return value, for example: (gdb) print some_func_ () 'some_func_' has unknown return type; cast the call to its declared return type (gdb) print (integer) some_func_ () $1 = 1 But if we could extend this to allow casting to the full function type, GDB could figure out from the signature what are real parameters, and what are artificial parameters. Maybe something like this: (gdb) print ((integer () (integer, double)) some_other_func_ (1, 2.3) Alas, right now the Fortran expression parser doesn't seem to support parsing function signatures, and we certainly don't have support for figuring out real vs artificial arguments from a signature. Still, I think we can prevent GDB from accessing undefined memory and provide a reasonable default behaviour. In this commit I: - Only ask if the argument is artificial if the type of the argument is actually known. - Unknown arguments are assumed to be artificial and passed by value (non-artificial arguments are pass by reference). - If an artificial argument is prefixed with '&' by the user then we treat the argument as pass-by-reference. With these three changes we avoid undefined behaviour in GDB, and allow the user, in most cases, to get a reasonably natural default behaviour. gdb/ChangeLog: PR fortran/26155 * f-lang.c (fortran_argument_convert): Delete declaration. (fortran_prepare_argument): New function. (evaluate_subexp_f): Move logic to new function fortran_prepare_argument. gdb/testsuite/ChangeLog: PR fortran/26155 * gdb.fortran/call-no-debug-func.f90: New file. * gdb.fortran/call-no-debug-prog.f90: New file. * gdb.fortran/call-no-debug.exp: New file.
2021-02-25gdb/fortran: add support for ASSOCIATED builtinAndrew Burgess7-14/+436
This commit adds support for the ASSOCIATED builtin to the Fortran expression evaluator. The ASSOCIATED builtin takes one or two arguments. When passed a single pointer argument GDB returns a boolean indicating if the pointer is associated with anything. When passed two arguments the second argument should either be some a pointer could point at or a second pointer. If the second argument is a pointer target, then the result from associated indicates if the pointer is pointing at this target. If the second argument is another pointer, then the result from associated indicates if the two pointers are pointing at the same thing. gdb/ChangeLog: * f-exp.y (f77_keywords): Add 'associated'. * f-lang.c (fortran_associated): New function. (evaluate_subexp_f): Handle FORTRAN_ASSOCIATED. (operator_length_f): Likewise. (print_unop_or_binop_subexp_f): New function. (print_subexp_f): Make use of print_unop_or_binop_subexp_f for FORTRAN_ASSOCIATED, FORTRAN_LBOUND, and FORTRAN_UBOUND. (dump_subexp_body_f): Handle FORTRAN_ASSOCIATED. (operator_check_f): Likewise. * std-operator.def: Add FORTRAN_ASSOCIATED. gdb/testsuite/ChangeLog: * gdb.fortran/associated.exp: New file. * gdb.fortran/associated.f90: New file.
2021-02-25gdb/fortran: add support for legacy .xor. operatorAndrew Burgess4-0/+17
gfortran supports .xor. as an alias for .neqv., see: https://gcc.gnu.org/onlinedocs/gfortran/_002eXOR_002e-operator.html this commit adds support for this operator to GDB. gdb/ChangeLog: * f-exp.y (fortran_operators): Add ".xor.". gdb/testsuite/ChangeLog: * gdb.fortran/dot-ops.exp (dot_operations): Test ".xor.".