H.J. Lu [Wed, 24 Jun 2020 11:00:19 +0000 (04:00 -0700)]
cris: Don't generate unnecessary dynamic tags
Dynamic tags, DT_JMPREL, PLTREL and PLTRELSZ, are needed only if there
are relocation entries for PLT. Don't generate them if there are no
relocation entries for PLT.
bfd/
PR ld/26083
* elf32-cris.c (elf_cris_size_dynamic_sections): Call
_bfd_elf_add_dynamic_tags.
ld/
PR ld/26083
* testsuite/ld-cris/libdso-15b.d: Updated.
* testsuite/ld-cris/libdso-1c.d: Likewise.
* testsuite/ld-cris/libdso-1d.d: Likewise.
* testsuite/ld-cris/libdso-15c.d: New file.
H.J. Lu [Wed, 24 Jun 2020 10:56:05 +0000 (03:56 -0700)]
ld: Set non_ir_ref_regular on source for assignment
We need to set non_ir_ref_regular on the source for assignment to get
the correct LTO resolution:
190
a27be7f4ad90c5ce PREVAILING_DEF real_g
instead of
190
30c3b2d8f967f5ea PREVAILING_DEF_IRONLY real_g
PR ld/26163
* ldexp.c (exp_fold_tree_1): Set non_ir_ref_regular on the source
for assignment.
* testsuite/ld-plugin/lto.exp: Run ld/26163 test.
* testsuite/ld-plugin/pr26163a.c: New file.
* testsuite/ld-plugin/pr26163b.c: Likewise.
Alan Modra [Wed, 24 Jun 2020 04:47:38 +0000 (14:17 +0930)]
ld --help output
It's best if help message output does not contain tabs, since we don't
know tab stop settings or even if tabs are handled by the output
device. This reverts some 2020-06-23 changes and fixes the csky help
message.
* lexsup.c (elf_shlib_list_options): Properly format help message.
(elf_plt_unwind_list_options): Likewise.
* emultempl/cskyelf.em (PARSE_AND_LIST_OPTIONS): Likewise.
Alan Modra [Wed, 24 Jun 2020 00:54:32 +0000 (10:24 +0930)]
ubsan: alpha-vms: shift exponent
536874240 is too large
C_OPR_ASH is supposed to be an arithmetic shift. By the look of it,
this operator implemented logical shifts since the original binutils
support was added. This patch corrects that and avoids some nonsense
ubsan complaints. I chose to implement infinite precision shifts
rather than masking shift counts to the word size as the spec I had is
silent on what is supposed to happen with overlarge shift counts.
* vms-alpha.c (_bfd_vms_slurp_etir <ETIR__C_OPR_ASH>): Implement
shifts without undefined behaviour.
GDB Administrator [Wed, 24 Jun 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in
Andrew Burgess [Tue, 9 Jun 2020 22:08:54 +0000 (23:08 +0100)]
gdb: New maintenance command to print XML target description
This commit adds a new maintenance command that dumps the current
target description as an XML document. This is a maintenance command
as I currently only see this being useful for GDB developers, or for
people debugging a new remote target.
By default the command will print whatever the current target
description is, whether this was delivered by the remote, loaded by
the user from a file, or if it is a built in target within GDB.
The command can also take an optional filename argument. In this case
GDB loads a target description from the file, and then reprints it.
This could be useful for testing GDB's parsing of target descriptions,
or to check that GDB can successfully parse a particular XML
description.
It is worth noting that the XML description printed will not be an
exact copy of the document fed into GDB. For example this minimal
input file:
<target>
<feature name="abc">
<reg name="r1" bitsize="32"/>
</feature>
</target>
Will produce this output:
(gdb) maint print xml-tdesc path/to/file.xml
<?xml version="1.0"?>
<!DOCTYPE target SYSTEM "gdb-target.dtd">
<target>
<feature name="abc">
<reg name="r1" bitsize="32" type="int" regnum="0"/>
</feature>
</target>
Notice that GDB filled in both the 'type' and 'regnum' fields of the
<reg>. I think this is actually a positive as it means we get to
really understand how GDB processed the document, if GDB made some
assumptions that differ to those the user expected then hopefully this
will bring those issues to the users attention.
To implement this I have tweaked the output produced by the
print_xml_feature which is defined within the gdbsupport/ directory.
The changes I have made to this class are:
1. The <architecture>...</architecture> tags are now not produced if
the architecture name is NULL.
2. The <osabi>...</osabi> tags get a newline at the end.
3. And, the whole XML document is indented using white space in a
nested fashion (as in the example output above).
I think that these changes should be fine, the print_xml_feature class
is used:
1. In gdbserver to generate an XML document to send as the target
description to GDB.
2. In GDB as part of a self-check function, a target_desc is
converted to XML then parsed back into a target_desc. We then check
the before and after target_desc objects are the same.
3. In the new 'maint print xml-tdesc' command.
In all of these use cases adding the extra white space should be fine.
gdbsupport/ChangeLog:
* tdesc.cc (print_xml_feature::visit_pre): Use add_line to add
output content, and call indent as needed in all overloaded
variants.
(print_xml_feature::visit_post): Likewise.
(print_xml_feature::visit): Likewise.
(print_xml_feature::add_line): Two new overloaded functions.
* tdesc.h (print_xml_feature::indent): New member function.
(print_xml_feature::add_line): Two new overloaded member
functions.
(print_xml_feature::m_depth): New member variable.
gdb/ChangeLog:
* target-descriptions.c (tdesc_architecture_name): Protect against
NULL pointer dereference.
(maint_print_xml_tdesc_cmd): New function.
(_initialize_target_descriptions): Register new 'maint print
xml-tdesc' command and give it the filename completer.
* NEWS: Mention new 'maint print xml-tdesc' command.
gdb/testsuite/ChangeLog:
* gdb.xml/tdesc-reload.c: New file.
* gdb.xml/tdesc-reload.exp: New file.
* gdb.xml/maint-xml-dump-01.xml: New file.
* gdb.xml/maint-xml-dump-02.xml: New file.
* gdb.xml/maint-xml-dump.exp: New file.
gdb/doc/ChangeLog:
* gdb.texinfo (Maintenance Commands): Document new 'maint print
xml-desc' command.
Andrew Burgess [Thu, 11 Jun 2020 21:36:29 +0000 (22:36 +0100)]
gdb: Print compatible information within print_xml_feature
The gdbsupport directory contains a helper class print_xml_feature
that is shared between gdb and gdbserver. This class is used for
printing an XML representation of a target_desc object.
Currently this class doesn't have the ability to print the
<compatible> entities that can appear within a target description, I
guess no targets have needed that functionality yet.
The print_xml_feature classes API is based around operating on the
target_desc class, however, the sharing between gdb and gdbserver is
purely textural, we rely on their being a class called target_desc in
both gdb and gdbserver, but there is no shared implementation. We
then have a set of functions declared that operate on an object of
type target_desc, and again these functions have completely separate
implementations.
Currently then the gdb version of target_desc contains a vector of
bfd_arch_info pointers which represents the compatible entries from a
target description. The gdbserver version of target_desc has no such
information. Further, the gdbserver code doesn't seem to include the
bfd headers, and so doesn't know about the bfd types.
I was reluctant to include the bfd headers into gdbserver just so I
can reference the compatible information, which isn't (currently) even
needed in gdbserver.
So, the approach I take in this patch is to wrap the compatible
information into a new helper class. This class is declared in the
gdbsupport library, but implemented separately in both gdb and
gdbserver.
In gdbserver the class is empty. The compatible information within
the gdbserver is an empty list, of empty classes.
In gdb the class contains a pointer to the bfd_arch_info object.
With this in place we can now add support to print_xml_feature for
printing the compatible information if it is present. In the
gdbserver code this will never happen, as the gdbserver never has any
compatible information. But in gdb, this code will trigger when
appropriate.
gdb/ChangeLog:
* target-descriptions.c (class tdesc_compatible_info): New class.
(struct target_desc): Change type of compatible vector.
(tdesc_compatible_p): Update for change in type of
target_desc::compatible.
(tdesc_compatible_info_list): New function.
(tdesc_compatible_info_arch_name): New function.
(tdesc_add_compatible): Update for change in type of
target_desc::compatible.
(print_c_tdesc::visit_pre): Likewise.
gdbserver/ChangeLog:
* tdesc.cc (struct tdesc_compatible_info): New struct.
(tdesc_compatible_info_list): New function.
(tdesc_compatible_info_arch_name): New function.
gdbsupport/ChangeLog:
* tdesc.cc (print_xml_feature::visit_pre): Print compatible
information.
* tdesc.h (struct tdesc_compatible_info): Declare new struct.
(tdesc_compatible_info_up): New typedef.
(tdesc_compatible_info_list): Declare new function.
(tdesc_compatible_info_arch_name): Declare new function.
Andrew Burgess [Tue, 9 Jun 2020 18:00:55 +0000 (19:00 +0100)]
gdb: Allow target description to be dumped even when it is remote
The maintenance command 'maintenance print c-tdesc' can only print the
target description if it was loaded from a local file, or if the local
filename is passed to the maintenance command as an argument.
Sometimes it would be nice to know what target description GDB was
given by the remote, however, if I connect to a remote target and try
this command I see this:
(gdb) maintenance print c-tdesc
The current target description did not come from an XML file.
(gdb)
Which is not very helpful.
This commit changes things so that if the description came from the
remote end then GDB will use a fake filename 'fetched from target' as
the filename for the description, GDB will then create the C
description of the target as though it came from this file. Example
output would look like this (I snipped the feature creation from the
middle as that hasn't changed):
(gdb) maintenance print c-tdesc
/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
Original: fetched from target */
#include "defs.h"
#include "osabi.h"
#include "target-descriptions.h"
struct target_desc *tdesc_fetched_from_target;
static void
initialize_tdesc_fetched_from_target (void)
{
struct target_desc *result = allocate_target_description ();
struct tdesc_feature *feature;
/* ... features created here ... */
tdesc_fetched_from_target = result;
}
(gdb)
In order to support using 'fetched from target' I had to update the
print_c_tdesc code to handle filenames that include a space. This has
the benefit that we can now print out real files with spaces in the
name, for example the file 'with space.xml':
(gdb) maint print c-tdesc with space.xml
I originally added this functionality so I could inspect the
description passed to GDB by the remote target. After using this for
a while I realised that actually having GDB recreate the XML would be
even better, so a later commit will add that functionality too.
Still, given how small this patch is I thought it might be nice to
include this in GDB anyway.
While I was working on this anyway I've added filename command
completion to this command.
gdb/ChangeLog:
* target-descriptions.c (print_c_tdesc::print_c_tdesc): Change
whitespace to underscore.
(maint_print_c_tdesc_cmd): Use fake filename for target
descriptions that came from the target.
(_initialize_target_descriptions): Add filename command completion
for 'maint print c-tdesc'.
Simon Marchi [Tue, 23 Jun 2020 19:40:23 +0000 (15:40 -0400)]
gdb: add some more empty lines in loc.c
Add some empty lines at places I forgot in the previous patch.
gdb/ChangeLog:
* dwarf2/loc.c (decode_debug_loclists_addresses): Add empty
lines.
Change-Id: I8a9f3766ede1ce750e0703023285dca873bce0da
Simon Marchi [Tue, 23 Jun 2020 19:26:36 +0000 (15:26 -0400)]
gdb: add empty lines in loc.c
I always found that some switch statements in this file were a bit too
packed. I think having empty lines between each case helps with
reading. I'm pushing this as obvious, I hope it won't be too
controversial.
gdb/ChangeLog:
* dwarf2/loc.c (decode_debug_loc_dwo_addresses): Add empty
lines.
(dwarf2_find_location_expression): Likewise.
(call_site_parameter_matches): Likewise.
(dwarf2_compile_expr_to_ax): Likewise.
(disassemble_dwarf_expression): Likewise.
(loclist_describe_location): Likewise.
Change-Id: I381366a0468ff1793faa612c46ef48a9d4773192
Roland McGrath [Tue, 23 Jun 2020 19:01:24 +0000 (12:01 -0700)]
PR 22843: ld, gold: Add --dependency-file option.
gold/
* options.h (class General_options): Add --dependency-file option.
* fileread.cc (File_read::files_read): New static variable.
(File_read::open): Add the file to the files_read list.
(File_read::record_file_read): New static member function.
(File_read::write_dependency_file): New static member function.
* fileread.h (class File_read): Declare them.
* layout.cc (Layout::read_layout_from_file): Call record_file_read.
(Close_task_runner::run): Call write_dependency_file if
--dependency-file was passed.
ld/
* NEWS: Note --dependency-file.
* ld.texi (Options): Document --dependency-file.
* ldlex.h (enum option_values): Add OPTION_DEPENDENCY_FILE.
* ld.h (ld_config_type): New member dependency_file.
* lexsup.c (ld_options, parse_args): Parse --dependency-file.
* ldmain.c (struct dependency_file): New type.
(dependency_files, dependency_files_tail): New static variables.
(track_dependency_files): New function.
(write_dependency_file): New function.
(main): Call it when --dependency-file was passed.
* ldfile.c (ldfile_try_open_bfd): Call track_dependency_files.
(ldfile_open_command_file_1): Likewise.
* ldelf.c (ldelf_try_needed): Likewise.
* pe-dll.c (pe_implied_import_dll): Likewise.
Pedro Alves [Tue, 23 Jun 2020 14:18:41 +0000 (15:18 +0100)]
Fix "maint selftest" regression, add struct scoped_mock_context
This commit:
commit
3922b302645fda04da42a5279399578ae2f6206c
Author: Pedro Alves <palves@redhat.com>
AuthorDate: Thu Jun 18 21:28:37 2020 +0100
Decouple inferior_ptid/inferior_thread(); dup ptids in thread list (PR 25412)
caused a regression for gdb.gdb/unittest.exp when GDB is configured
with --enable-targets=all. The failure is:
gdb/thread.c:95: internal-error: thread_info* inferior_thread(): Assertion `current_thread_ != nullptr' failed.
The problem is in this line in regcache.c:cooked_read_test:
/* Switch to the mock thread. */
scoped_restore restore_inferior_ptid
= make_scoped_restore (&inferior_ptid, mock_ptid);
Both gdbarch-selftest.c and regcache.c set up a similar mock context,
but the series the patch above belongs to only updated the
gdbarch-selftest.c context to not write to inferior_ptid directly, and
missed updating regcache.c's.
Instead of copying the fix over to regcache.c, share the mock context
setup code in a new RAII class, based on gdbarch-selftest.c's version.
Also remove the "target already pushed" error from regcache.c, like it
had been removed from gdbarch-selftest.c in the multi-target series.
That check is unnecessary because each inferior now has its own target
stack, and the unit test pushes a target on a separate (mock)
inferior, not the current inferior on entry.
gdb/ChangeLog:
2020-06-23 Pedro Alves <palves@redhat.com>
* gdbarch-selftests.c: Don't include inferior.h, gdbthread.h or
progspace-and-thread.h. Include scoped-mock-context.h instead.
(register_to_value_test): Use scoped_mock_context.
* regcache.c: Include "scoped-mock-context.h".
(cooked_read_test): Don't error out if a target is already pushed.
Use scoped_mock_context. Adjust.
* scoped-mock-context.h: New file.
Sandra Loosemore [Tue, 23 Jun 2020 16:33:31 +0000 (09:33 -0700)]
Adjust command completion output when TUI is disabled
The history-scrolling commands "+", "-", "<" and ">" are only known to
GDB when TUI is enabled. This means the "complete pipe " command
produces different output depending on whether TUI is present, which
in turn caused
FAIL: gdb.base/shell.exp: cmd complete "pipe "
This patch provides different patterns for that test depending on
whether or not TUI is available.
2020-06-23 Sandra Loosemore <sandra@codesourcery.com>
gdb/testsuite/
* lib/completion-support.exp (test_gdb_completion_offers_commands):
Adjust for omitted commands when TUI is disabled.
H.J. Lu [Tue, 23 Jun 2020 16:19:05 +0000 (09:19 -0700)]
Add a testcase for PR binutils/26160
PR binutils/26160
* testsuite/binutils-all/pr26160.dwp.bz2: New file.
* testsuite/binutils-all/pr26160.r: Likewise.
* testsuite/binutils-all/readelf.exp: Run PR binutils/26160 test.
Alan Modra [Tue, 23 Jun 2020 14:20:56 +0000 (23:50 +0930)]
PR26150, Assertion when asm() defines global symbols, -flto and --start-group
If an archive map contains symbols that aren't actually defined by the
indexed element for any reason, then loading that element will leave
the symbol undefined (or common). This leads to the possibility of
the element being loaded again should the archive be searched again
due to the action of --start-group/--end-group. The testcase
triggering this problem was an archive containing fat lto objects,
with the archive map incorrectly created by ar rather than gcc-ar.
PR 26150
* ldlang.c (ldlang_add_file): Assert that we aren't adding the
current end of link.next list again too.
* ldmain.c (add_archive_element): Don't load archive elements
again that have already been loaded.
Nick Clifton [Tue, 23 Jun 2020 15:06:38 +0000 (16:06 +0100)]
Fix decoding of indexed DWARF strings using pre-DWARF-5 string offset sections. Fix display of .debug_str_offsets.dwo sections.
PR 26160
* dwarf.c (fetch_indexed_string): Detect and handle old style
.debug_str_offset tables.
(display_debug_str_offsets): Likewise. Also add support for
.debug_str_offsets.dwo sections.
Gary Benson [Tue, 23 Jun 2020 14:11:27 +0000 (15:11 +0100)]
Improve -Wunused-value testcase build failures fix
This commit improves upon my previous -Wunused-value fix by
replacing the various dummy variables with casts to void, as
suggested by Pedro.
gdb/testsuite/ChangeLog:
* gdb.cp/namespace.cc: Improve -Wunused-value fix.
* gdb.cp/nsimport.cc: Likewise.
* gdb.cp/nsnested.cc: Likewise.
* gdb.cp/nsnoimports.cc: Likewise.
* gdb.cp/nsusing.cc: Likewise.
* gdb.cp/smartp.cc: Likewise.
* gdb.python/py-pp-integral.c: Likewise.
* gdb.python/py-pp-re-notag.c: Likewise.
H.J. Lu [Tue, 23 Jun 2020 13:50:23 +0000 (06:50 -0700)]
Add a testcase for PR binutils/26112
PR binutils/26112
* testsuite/binutils-all/pr26112.o.bz2: New file.
* testsuite/binutils-all/pr26112.r: Likewise.
* testsuite/binutils-all/readelf.exp: Run PR binutils/26112 test.
Andrew Burgess [Thu, 18 Jun 2020 21:01:33 +0000 (22:01 +0100)]
gdb: Convert language la_is_string_type_p field to a method
This commit changes the language_data::la_is_string_type_p function
pointer member variable into a member function of language_defn.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Delete la_is_string_type_p
initializer.
(ada_language::is_string_type_p): New member function.
* c-lang.c (c_language_data): Delete la_is_string_type_p
initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_is_string_type_p): Delete function, implementation
moved to f_language::is_string_type_p.
(f_language_data): Delete la_is_string_type_p initializer.
(f_language::is_string_type_p): New member function,
implementation from f_is_string_type_p.
* go-lang.c (go_is_string_type_p): Delete function, implementation
moved to go_language::is_string_type_p.
(go_language_data): Delete la_is_string_type_p initializer.
(go_language::is_string_type_p): New member function,
implementation from go_is_string_type_p.
* language.c (language_defn::is_string_type_p): Define new member
function.
(default_is_string_type_p): Make static, add comment copied from
header file.
(unknown_language_data): Delete la_is_string_type_p initializer.
(unknown_language::is_string_type_p): New member function.
(auto_language_data): Delete la_is_string_type_p initializer.
(auto_language::is_string_type_p): New member function.
* language.h (language_data): Delete la_is_string_type_p field.
(language_defn::is_string_type_p): Declare new function.
(default_is_string_type_p): Delete desclaration, move comment to
definition.
* m2-lang.c (m2_is_string_type_p): Delete function, implementation
moved to m2_language::is_string_type_p.
(m2_language_data): Delete la_is_string_type_p initializer.
(m2_language::is_string_type_p): New member function,
implementation from m2_is_string_type_p.
* objc-lang.c (objc_language_data): Delete la_is_string_type_p
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_is_string_type_p): Delete function,
implementation moved to pascal_language::is_string_type_p.
(pascal_language_data): Delete la_is_string_type_p initializer.
(pascal_language::is_string_type_p): New member function,
implementation from pascal_is_string_type_p.
* rust-lang.c (rust_is_string_type_p): Delete function,
implementation moved to rust_language::is_string_type_p.
(rust_language_data): Delete la_is_string_type_p initializer.
(rust_language::is_string_type_p): New member function,
implementation from rust_is_string_type_p.
* valprint.c (val_print_scalar_or_string_type_p): Update call to
is_string_type_p.
Andrew Burgess [Thu, 18 Jun 2020 20:38:50 +0000 (21:38 +0100)]
gdb: Convert language la_print_typedef field to a method
This commit changes the language_data::la_print_typedef function
pointer member variable into a member function of language_defn.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Delete la_print_typedef
initializer.
(ada_language::print_typedef): New member function.
* c-lang.c (c_language_data): Delete la_print_typedef initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
(f_language::print_typedef): New member function.
* go-lang.c (go_language_data): Delete la_print_typedef
initializer.
* language.c (language_defn::print_typedef): Define member
function.
(unknown_language_data): Delete la_print_typedef initializer.
(unknown_language::print_typedef): New member function.
(auto_language_data): Delete la_print_typedef initializer.
(auto_language::print_typedef): New member function.
* language.h (language_data): Delete la_print_typedef field.
(language_defn::print_typedef): Declare new member function.
(LA_PRINT_TYPEDEF): Update call to print_typedef.
(default_print_typedef): Delete declaration.
* m2-lang.c (m2_language_data): Delete la_print_typedef
initializer.
(m2_language::print_typedef): New member function.
* objc-lang.c (objc_language_data): Delete la_print_typedef
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
(pascal_language::print_typedef): New member function.
* rust-lang.c (rust_print_typedef): Delete function,
implementation moved to rust_language::print_typedef.
(rust_language): Delete la_print_typedef initializer.
(rust_language::print_typedef): New member function,
implementation from rust_print_typedef.
* typeprint.c (default_print_typedef): Delete.
Andrew Burgess [Wed, 3 Jun 2020 15:44:05 +0000 (16:44 +0100)]
gdb: Convert language la_printstr field to a method
This commit changes the language_data::la_printstr function pointer
member variable into a member function of language_defn.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Delete la_printstr initializer.
(ada_language::printstr): New member function.
* c-lang.c (c_language_data): Delete la_printstr initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_printstr): Rename to f_language::printstr.
(f_language_data): Delete la_printstr initializer.
(f_language::printstr): New member function, implementation from
f_printstr.
* go-lang.c (go_language_data): Delete la_printstr initializer.
* language.c (language_defn::printstr): Define new member
function.
(unk_lang_printstr): Delete.
(unknown_language_data): Delete la_printstr initializer.
(unknown_language::printstr): New member function.
(auto_language_data): Delete la_printstr initializer.
(auto_language::printstr): New member function.
* language.h (language_data): Delete la_printstr field.
(language_defn::printstr): Declare new member function.
(LA_PRINT_STRING): Update call to printstr.
* m2-lang.c (m2_printstr): Rename to m2_language::printstr.
(m2_language_data): Delete la_printstr initializer.
(m2_language::printstr): New member function, implementation from
m2_printstr.
* objc-lang.c (objc_language_data): Delete la_printstr
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_printstr): Rename to pascal_language::printstr.
(pascal_language_data): Delete la_printstr initializer.
(pascal_language::printstr): New member function, implementation
from pascal_printstr.
* p-lang.h (pascal_printstr): Delete declaration.
* rust-lang.c (rust_printstr): Update header comment.
(rust_language_data): Delete la_printstr initializer.
(rust_language::printstr): New member function.
Andrew Burgess [Wed, 3 Jun 2020 14:54:19 +0000 (15:54 +0100)]
gdb: Convert language la_printchar field to a method
This commit changes the language_data::la_printchar function pointer
member variable into a member function of language_defn.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Delete la_printchar initializer.
(ada_language::printchar): New member function.
* c-lang.c (c_language_data): Delete la_printchar initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_printchar): Rename to f_language::printchar.
(f_language_data): Delete la_printchar initializer.
(f_language::printchar): New member function, implementation from
f_printchar.
* go-lang.c (go_language_data): Delete la_printchar initializer.
* language.c (unk_lang_printchar): Delete.
(language_defn::printchar): Define new member function.
(unknown_language_data): Delete la_printchar initializer.
(unknown_language::printchar): New member function.
(auto_language_data): Delete la_printchar initializer.
(auto_language::printchar): New member function.
* language.h (language_data): Delete la_printchar field.
(language_defn::printchar): Declare new member function.
(LA_PRINT_CHAR): Update call to printchar.
* m2-lang.c (m2_language_data): Delete la_printchar initializer.
(m2_language::printchar): New member function.
* objc-lang.c (objc_language_data): Delete la_printchar
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Delete la_printchar
initializer.
(pascal_language::printchar): New member function.
* rust-lang.c (rust_printchar): Rename to
rust_language::printchar.
(rust_language_data): Delete la_printchar initializer.
(rust_language::printchar): New member function, implementation
from rust_printchar.
Andrew Burgess [Tue, 2 Jun 2020 20:54:49 +0000 (21:54 +0100)]
gdb: Convert language la_emitchar field to a method
This commit changes the language_data::la_emitchar function pointer
member variable into a member function of language_defn.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (emit_char): Renamed to ada_language::emitchar.
(ada_language_data): Delete la_emitchar initializer.
(ada_language::emitchar): New member function, implementation from
emit_char.
* c-lang.c (c_language_data): Delete la_emitchar initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_emit_char): Rename to f_language::emitchar.
(f_language_data): Delete la_emitchar initializer.
(f_language::emitchar): New member function, implementation from
f_emit_char.
* go-lang.c (go_language_data): Delete la_emitchar initializer.
* language.c (unk_lang_emit_char): Delete.
(language_defn::emitchar): New member function definition.
(unknown_language_data): Delete la_emitchar initializer.
(unknown_language::emitchar): New member function.
(auto_language_data): Delete la_emitchar initializer.
(auto_language::emitchar): New member function.
* language.h (language_data): Delete la_emitchar field.
(language_defn::emitchar): New member field declaration.
(LA_EMIT_CHAR): Update call to emitchar.
* m2-lang.c (m2_emit_char): Rename to m2_language::emitchar.
(m2_language_data): Delete la_emitchar initializer.
(m2_language::emitchar): New member function, implementation from
m2_emit_char.
* objc-lang.c (objc_language_data): Delete la_emitchar
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_emit_char): Rename to pascal_language::emitchar.
(pascal_language_data): Delete la_emitchar initializer.
(pascal_language::emitchar): New member function, implementation
from pascal_emit_char.
* rust-lang.c (rust_emitchar): Rename to rust_language::emitchar.
(rust_language_data): Delete la_emitchar initializer.
(rust_language::emitchar): New member function, implementation
from rust_emitchar.
Andrew Burgess [Tue, 2 Jun 2020 13:57:40 +0000 (14:57 +0100)]
gdb: Convert language la_post_parser field to a method
This commit changes the language_data::la_post_parser function pointer
member variable into a member function of language_defn.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (resolve): Rename to ada_language::post_parser.
(ada_language_data): Delete la_post_parser initializer.
(ada_language::post_parser): New member function.
* c-lang.c (c_language_data): Delete la_post_parser initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Delete la_post_parser field.
(language_defn::post_parser): New member function.
* m2-lang.c (m2_language_data): Delete la_post_parser initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* parse.c (parse_exp_in_context): Update call to post_parser.
(null_post_parser): Delete definition.
* parser-defs.h (null_post_parser): Delete declaration.
* rust-lang.c (rust_language_data): Delete la_post_parser
initializer.
Andrew Burgess [Tue, 2 Jun 2020 13:48:04 +0000 (14:48 +0100)]
gdb: Convert language la_parser field to a method
This commit changes the language_data::la_parser function pointer
member variable into a member function of language_defn.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (parse): Rename to ada_language::parser.
(ada_language_data): Delete la_parser initializer.
(ada_language::parser): New member function, implementation from
parse.
* c-lang.c (c_language_data): Delete la_parser initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
(d_language::parser): New member function.
* f-lang.c (f_language_data): Delete la_parser initializer.
(f_language::parser): New member function.
* go-lang.c (go_language_data): Delete la_parser initializer.
(go_language::parser): New member function.
* language.c (unk_lang_parser): Delete.
(language_defn::parser): Define new member function.
(unknown_language_data): Delete la_parser initializer.
(unknown_language::parser): New member function.
(auto_language_data): Delete la_parser initializer.
(auto_language::parser): New member function.
* language.h (language_data): Delete la_parser field.
(language_defn::parser): Declare new member function.
* m2-lang.c (m2_language_data): Delete la_parser initializer.
(m2_language::parser): New member function.
* objc-lang.c (objc_language_data): Delete la_parser initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
(pascal_language::parser): New member function.
* parse.c (parse_exp_in_context): Update call to parser.
* rust-lang.c (rust_language_data): Delete la_parser initializer.
(rust_language::parser): New member function.
H.J. Lu [Tue, 23 Jun 2020 12:07:31 +0000 (05:07 -0700)]
ELF: Add _bfd_elf_add_dynamic_tags
All ELF backends with shared library support need to add dynamic tags.
Add dt_pltgot_required and dt_jmprel_required to elf_link_hash_table to
indicate that DT_PLTGOT and DT_JMPREL are required dynamic tags.
1. Add _bfd_elf_add_dynamic_tags to add common dynamic tags.
2. Add _bfd_elf_maybe_vxworks_add_dynamic_tags to add common VxWorks
dynamic tags.
* elf-bfd.h (elf_link_hash_table): Add dt_pltgot_required and
dt_jmprel_required.
(_bfd_elf_add_dynamic_tags): New.
* elf-m10300.c (_bfd_mn10300_elf_size_dynamic_sections): Call
_bfd_elf_add_dynamic_tags.
* elf32-arc.c (elf_arc_size_dynamic_sections): Likewise.
* elf32-bfin.c (elf32_bfinfdpic_size_dynamic_sections): Likewise.
* elf32-cr16.c (_bfd_cr16_elf_size_dynamic_sections): Likewise.
* elf32-frv.c (elf32_frvfdpic_size_dynamic_sections): Likewise.
* elf32-lm32.c (lm32_elf_size_dynamic_sections): Likewise.
* elf32-m32r.c (m32r_elf_size_dynamic_sections): Likewise.
* elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise.
* elf32-microblaze.c (microblaze_elf_size_dynamic_sections):
Likewise.
* elf32-nds32.c (nds32_elf_size_dynamic_sections): Likewise.
* elf32-nios2.c (nios2_elf32_size_dynamic_sections): Likewise.
* elf32-or1k.c (or1k_elf_size_dynamic_sections): Likewise.
* elf32-s390.c (elf_s390_size_dynamic_sections): Likewise.
* elf32-tilepro.c (tilepro_elf_size_dynamic_sections): Likewise.
* elf32-vax.c (elf_vax_size_dynamic_sections): Likewise.
* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Likewise.
* elf64-s390.c (elf_s390_size_dynamic_sections): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_size_dynamic_sections):
Likewise.
* elfnn-riscv.c (riscv_elf_size_dynamic_sections): Likewise.
* elfxx-tilegx.c (tilegx_elf_size_dynamic_sections): Likewise.
* elf32-arm.c (elf32_arm_size_dynamic_sections): Call
_bfd_elf_maybe_vxworks_add_dynamic_tags.
* elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections):
Likewise.
* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Likewise.
(_bfd_x86_elf_size_dynamic_sections): Likewise.
* elfxx-x86.h (elf_x86_link_hash_table): Remove dt_reloc,
dt_reloc_sz and dt_reloc_ent.
* elf-vxworks.c (_bfd_elf_maybe_vxworks_add_dynamic_tags): New.
* elf-vxworks.h (_bfd_elf_maybe_vxworks_add_dynamic_tags):
Likewise.
* elf32-hppa.c (elf32_hppa_link_hash_table_create): Set
etab.dt_pltgot_required.
(elf32_hppa_size_dynamic_sections): Call
_bfd_elf_add_dynamic_tags.
* elf32-metag.c (elf_metag_link_hash_table_create): Set
etab.dt_pltgot_required.
(elf_metag_size_dynamic_sections): Call _bfd_elf_add_dynamic_tags.
* elf32-sh.c (sh_elf_link_hash_table_create): Set
root.dt_pltgot_required for FDPIC output.
(sh_elf_size_dynamic_sections): Call
_bfd_elf_maybe_vxworks_add_dynamic_tags.
* elf32-xtensa.c (elf_xtensa_link_hash_table_create): Set
elf.dt_pltgot_required.
(elf_xtensa_size_dynamic_sections): Call
_bfd_elf_add_dynamic_tags.
* elf64-hppa.c (elf64_hppa_hash_table_create): Set
root.dt_pltgot_required.
(elf64_hppa_size_dynamic_sections): Call
_bfd_elf_add_dynamic_tags.
* elfnn-ia64.c (elfNN_ia64_hash_table_create): Set
root.dt_pltgot_required.
(elfNN_ia64_size_dynamic_sections): Set root.dt_jmprel_required
for rel_pltoff_sec. Call _bfd_elf_add_dynamic_tags.
* elflink.c (_bfd_elf_add_dynamic_tags): New.
Gary Benson [Tue, 23 Jun 2020 11:25:34 +0000 (12:25 +0100)]
Avoid testcase build failures with -Wunused-value
A number of testcases fail to build with -Wunused-value enabled.
This commit adds dummy values to avoid this.
gdb/testsuite/ChangeLog:
* gdb.cp/namespace.cc: Avoid build failure with -Wunused-value.
* gdb.cp/nsimport.cc: Likewise.
* gdb.cp/nsnested.cc: Likewise.
* gdb.cp/nsnoimports.cc: Likewise.
* gdb.cp/nsusing.cc: Likewise.
* gdb.cp/smartp.cc: Likewise.
* gdb.python/py-pp-integral.c: Likewise.
* gdb.python/py-pp-re-notag.c: Likewise.
Andrew Burgess [Tue, 23 Jun 2020 09:02:47 +0000 (10:02 +0100)]
gdb: Add --with-python-libdir to gdb's --configuration output
Commit:
commit
d13c7322fe1266984024644154003a19664610ea
Date: Fri Jan 17 00:10:22 2020 +0000
gdb: Allow more control over where to find python libraries
Added a new configuration option --with-python-libdir, but failed to
add this option to the output of 'gdb --configuration'. This commit
fixes this mistake.
gdb/ChangeLog:
* top.c (print_gdb_configuration): Print --with-python-libdir
configuration value.
Nelson Chu [Mon, 22 Jun 2020 08:11:18 +0000 (16:11 +0800)]
RISC-V: Generate ELF priv attributes if priv instruction are explicited used.
We should generate the ELF priv attributes only if,
1. The priv attributes are already set in the assembly file.
2. The CSR are explicited used.
3. The privileged instruction are explicited used.
* There are four privileged instruction defined in the v1.11 priv spec:
`mret`, `sret`, `wfi` and `sfence.vma`.
* `sfence.vm` is dropped in the v1.10 priv spec.
* `uret` is actually a N-ext instruction. So it is better to regard it as
an user instruction rather than the priv instruction.
* `hret` is used to return from traps in H-mode. H-mode is removed since
the v1.10 priv spec, but probably be added in the new hypervisor spec.
Therefore, `hret` should be controlled by the hypervisor spec rather than
priv spec in the future.
* `dret` is a debug instruction. We should record the debug spec versions
once it is explicited used in the future.
gas/
* config/tc-riscv.c (explicit_priv_attr): Rename explicit_csr to
explicit_priv_attr. It used to indicate CSR or priv instructions are
explictly used.
(riscv_is_priv_insn): Return True if it is a privileged instruction.
(riscv_ip): Call riscv_is_priv_insn to check whether the instruction
is privileged or not. If it is, then set explicit_priv_attr to TRUE.
(riscv_write_out_attrs): Clarification of when to generate the elf
priv spec attributes.
* testsuite/gas/riscv/attribute-11.s: Add comments.
* testsuite/gas/riscv/attribute-14.s: New testcase. Use symbol
`priv_insn_<n>` to decide which priv instruction is expected to used.
(<n> is a to g.)
* testsuite/gas/riscv/attribute-14a.d: Likewise.
* testsuite/gas/riscv/attribute-14b.d: Likewise.
* testsuite/gas/riscv/attribute-14c.d: Likewise.
* testsuite/gas/riscv/attribute-14d.d: Likewise.
* testsuite/gas/riscv/attribute-14e.d: Likewise.
Alan Modra [Mon, 22 Jun 2020 02:20:46 +0000 (11:50 +0930)]
Correct bfin XPASSes
bfin-elf and bfin-linux differ. This patch fixes these:
bfin-linux-uclibc -XPASS: PR ld/14170
bfin-linux-uclibc -XPASS: pr17068 link --as-needed lib in group
bfin-linux-uclibc -XPASS: -Bsymbolic-functions
bfin-linux-uclibc -XPASS: pr22374 function pointer initialization
* testsuite/ld-elf/shared.exp (pr14170): Clear xfail for
bfin-*-linux*.
(pr17068, symbolic-func.so, pr22374): Likewise.
Alan Modra [Mon, 22 Jun 2020 02:13:30 +0000 (11:43 +0930)]
binutils objdump.exp remote_file typo
* testsuite/binutils-all/objdump.exp (bintest.a): Correct
remote_file delete command.
GDB Administrator [Tue, 23 Jun 2020 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in
Philippe Waroquiers [Mon, 24 Jun 2019 22:50:29 +0000 (00:50 +0200)]
NEWS and documentation for alias default-args related concept and commands.
gdb/ChangeLog
2020-06-22 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* NEWS: Mention change to the alias command.
gdb/doc/ChangeLog
2020-06-22 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.texinfo (Command aliases default args): New node documenting
how to use default args for a command using aliases.
(Aliases): Document the new 'DEFAULT-ARGS...' option.
(Help): Update help aliases text and describe when full alias
definition is provided.
Philippe Waroquiers [Sun, 23 Jun 2019 21:13:57 +0000 (23:13 +0200)]
Add tests for new alias default-args related commands and arguments.
Test the new default-args behaviour and completion for the alias command.
Note that gdb.base/default-args.exp is somewhat copied from
with.exp (the test of the with command), while default-exp.c
is a plain copy of with.c.
gdb/testsuite/ChangeLog
2020-06-22 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.base/default-args.exp: New test.
* gdb.base/default-args.c: New file.
* gdb.base/alias.exp: Update expected error msg for alias foo=bar.
* gdb.base/default.exp: Update to new help text.
* gdb.base/help.exp: Likewise.
* gdb.base/page.exp: Likewise.
* gdb.base/style.exp: Likewise.
* gdb.guile/guile.exp: Likewise.
* gdb.python/python.exp: Likewise.
Philippe Waroquiers [Wed, 19 Jun 2019 10:49:55 +0000 (12:49 +0200)]
default-args: allow to define default arguments for aliases
Currently, a user can define an alias, but cannot have default
arguments for this alias.
This patch modifies the 'alias' command so that default args can
be provided.
(gdb) h alias
Define a new command that is an alias of an existing command.
Usage: alias [-a] [--] ALIAS = COMMAND [DEFAULT-ARGS...]
ALIAS is the name of the alias command to create.
COMMAND is the command being aliased to.
Options:
-a
Specify that ALIAS is an abbreviation of COMMAND.
Abbreviations are not used in command completion..
GDB will automatically prepend the provided DEFAULT-ARGS to the list
of arguments explicitly provided when using ALIAS.
Use "help aliases" to list all user defined aliases and their default args.
Examples:
Make "spe" an alias of "set print elements":
alias spe set print elements
Make "elms" an alias of "elements" in the "set print" command:
alias -a set print elms set print elements
Make "btf" an alias of "backtrace -full -past-entry -past-main" :
alias btf = backtrace -full -past-entry -past-main
Make "wLapPeu" an alias of 2 nested "with":
alias wLapPeu = with language pascal -- with print elements unlimited --
(gdb)
The way 'default-args' is implemented makes it trivial to set default
args also for GDB commands (such as "backtrace") and for GDB pre-defined
aliases (such as "bt"). It was however deemed better to not allow to
define default arguments for pre-defined commands and aliases, to avoid
users believing that e.g. default args for "backtrace" would apply to "bt".
If needed, default-args could be allowed for GDB predefined commands
and aliases by adding a command
'set default-args GDB_COMMAND_OR_PREDEFINED_ALIAS [DEFAULT-ARGS...]'.
* 'alias' command now has a completer that helps to complete:
- ALIAS (if the user defines an alias after a prefix),
- the aliased COMMAND
- the possible options for the aliased COMMAND.
* Help and apropos commands show the definitions of the aliases
that have default arguments, e.g.
(gdb) help backtrace
backtrace, btf, where, bt
alias btf = backtrace -full -past-entry -past-main
Print backtrace of all stack frames, or innermost COUNT frames.
Usage: backtrace [OPTION]... [QUALIFIER]... [COUNT | -COUNT]
Options:
-entry-values no|only|preferred|if-needed|both|compact|default
Set printing of function arguments at function entry.
...
gdb/ChangeLog
2020-06-22 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* cli/cli-cmds.c (lookup_cmd_for_default_args)
(alias_command_completer)
(make_alias_options_def_group): New functions.
(alias_opts, alias_option_defs): New struct and array.
(alias_usage_error): Update usage.
(alias_command): Handles optional DEFAULT-ARGS... arguments.
Use option framework.
(_initialize_cli_cmds): Update alias command help.
Update aliases command help.
(show_user):
Add NULL for new default_args lookup_cmd argument.
(valid_command_p): Rename to validate_aliased_command.
Add NULL for new default_args lookup_cmd argument. Verify that the
aliased_command has no default args.
* cli/cli-decode.c (help_cmd): Show aliases definitions.
(lookup_cmd_1, lookup_cmd): New argument default_args.
(add_alias_cmd):
Add NULL for new default_args lookup_cmd argument.
(print_help_for_command): Show default args under the layout
alias some_alias = some_aliased_cmd some_alias_default_arg.
* cli/cli-decode.h (struct cmd_list_element): New member default_args.
xfree default_args in destructor.
* cli/cli-script.c (process_next_line, do_define_command):
Add NULL for new default_args lookup_cmd argument.
* command.h: Declare new default_args argument in lookup_cmd
and lookup_cmd_1.
* completer.c (complete_line_internal_1):
Add NULL for new default_args lookup_cmd or lookup_cmd_1 argument.
* guile/scm-cmd.c (gdbscm_parse_command_name): Likewise.
* guile/scm-param.c (add_setshow_generic, pascm_parameter_defined_p):
Likewise.
* infcmd.c (_initialize_infcmd): Likewise.
* python/py-auto-load.c (gdbpy_initialize_auto_load): Likewise.
* python/py-cmd.c (gdbpy_parse_command_name): Likewise.
* python/py-param.c (add_setshow_generic): Likewise.
* remote.c (_initialize_remote): Likewise.
* top.c (execute_command): Prepend default_args if command has some.
(set_verbose):
Add NULL for new default_args lookup_cmd or lookup_cmd_1 argument.
* tracepoint.c (validate_actionline, encode_actions_1):
Add NULL for new default_args lookup_cmd or lookup_cmd_1 argument.
Sandra Loosemore [Mon, 22 Jun 2020 17:10:02 +0000 (10:10 -0700)]
Disable parts of gdb.base/source-dir.exp on remote host
One set of tests in this file does a lot of complicated directory
manipulations to force a specific DW_AT_comp_dir format and gdb
directory search path. As it's written, everything assumes host ==
build, and it does not seem to me that there is any obvious way to
rewrite this so it will work in general on remote host. For instance,
our harness for testing on remote Windows host normally does all
compilation and GDB execution in $cwd using relative pathnames and I'm
not sure all these directory tricks would set up the scenario it's
trying to test even if they were correctly performed on host rather
than build. So I think it's reasonable just to disable this on remote
host instead.
I also noted that it's using the wrong search path syntax for Windows
host in the "set directories" command and conditionalized that while I
was looking at it. That's a necessary fix to make this work in a
situation where host == build and it's Windows, but I'm not actually
set up to test that it's sufficient, too.
2020-06-22 Sandra Loosemore <sandra@codesourcery.com>
gdb/testsuite/
* gdb.base/source-dir.exp (test_truncated_comp_dir): Skip on
remote host. Fix search path syntax on Windows host.
Nick Clifton [Mon, 22 Jun 2020 16:44:56 +0000 (17:44 +0100)]
Add support for decoding the DW_MACRO_define_strx and DW_MACRO_undef_strx operands found in DWARF-5 .debug_macro sections.
PR 26112
* dwarf.c (display_debug_str_offsets): Add code to display the
contents of the .debug_str_offsets section.
(display_debug_macro): Add support for DW_MACRO_define_strx and
DW_MACRO_undef_strx.
Alex Coplan [Mon, 22 Jun 2020 13:51:04 +0000 (14:51 +0100)]
aarch64: Normalize and sort feature bit macros
This patch normalizes and sorts the feature bit macros in
include/opcode/aarch64.h such that it's easy to tell which bits are
allocated and where it's safe to add new feature bits.
Testing:
* Testsuite run on aarch64-none-elf.
include/ChangeLog:
2020-06-22 Alex Coplan <alex.coplan@arm.com>
* opcode/aarch64.h (AARCH64_FEATURE_SHA2): Normalize.
(AARCH64_FEATURE_AES): Likewise.
(AARCH64_FEATURE_V8_4): Likewise.
(AARCH64_FEATURE_SM4): Likewise.
(AARCH64_FEATURE_SHA3): Likewise.
(AARCH64_FEATURE_V8): Likewise.
(AARCH64_FEATURE_V8_2): Likewise.
(AARCH64_FEATURE_V8_3): Likewise.
(AARCH64_FEATURE_FP): Likewise.
(AARCH64_FEATURE_SIMD): Likewise.
(AARCH64_FEATURE_CRC): Likewise.
(AARCH64_FEATURE_LSE): Likewise.
(AARCH64_FEATURE_PAN): Likewise.
(AARCH64_FEATURE_LOR): Likewise.
(AARCH64_FEATURE_RDMA): Likewise.
(AARCH64_FEATURE_V8_1): Likewise.
(AARCH64_FEATURE_F16): Likewise.
(AARCH64_FEATURE_RAS): Likewise.
(AARCH64_FEATURE_PROFILE): Likewise.
(AARCH64_FEATURE_SVE): Likewise.
(AARCH64_FEATURE_RCPC): Likewise.
(AARCH64_FEATURE_COMPNUM): Likewise.
(AARCH64_FEATURE_DOTPROD): Likewise.
(AARCH64_FEATURE_F16_FML): Likewise.
(AARCH64_FEATURE_V8_5): Likewise.
(AARCH64_FEATURE_V8_6): Likewise.
(AARCH64_FEATURE_BFLOAT16): Likewise.
(AARCH64_FEATURE_FLAGMANIP): Likewise.
(AARCH64_FEATURE_FRINTTS): Likewise.
(AARCH64_FEATURE_SB): Likewise.
(AARCH64_FEATURE_PREDRES): Likewise.
(AARCH64_FEATURE_CVADP): Likewise.
(AARCH64_FEATURE_RNG): Likewise.
(AARCH64_FEATURE_BTI): Likewise.
(AARCH64_FEATURE_SCXTNUM): Likewise.
(AARCH64_FEATURE_ID_PFR2): Likewise.
(AARCH64_FEATURE_SSBS): Likewise.
(AARCH64_FEATURE_MEMTAG): Likewise.
(AARCH64_FEATURE_TME): Likewise.
(AARCH64_FEATURE_I8MM): Likewise.
(AARCH64_FEATURE_F32MM): Likewise.
(AARCH64_FEATURE_F64MM): Likewise.
(AARCH64_FEATURE_SVE2): Likewise.
(AARCH64_FEATURE_SVE2_AES): Likewise.
(AARCH64_FEATURE_SVE2_BITPERM): Likewise.
(AARCH64_FEATURE_SVE2_SM4): Likewise.
(AARCH64_FEATURE_SVE2_SHA3): Likewise.
Saagar Jha [Mon, 22 Jun 2020 13:29:20 +0000 (14:29 +0100)]
Recognize some new Mach-O load commands
bfd
* mach-o.c: Support the new load commands by reading a linkedit data
command for them.
binutils
* od-macho.c: Dump linkedit data for new load commands.
include
* mach-o/loader.h: Add declarations of two new Mach-O load
commands.
Tankut Baris Aktemur [Mon, 22 Jun 2020 12:13:48 +0000 (14:13 +0200)]
gdbserver/linux-low: use std::list to store pending signals
Use std::list to store pending signals instead of a manually-managed
linked list. This is a refactoring.
In the existing code, pending signals are kept in a manually-created
linked list with "prev" pointers. A new pending signal is thus
inserted to the beginning of the list. When consuming, GDB goes until
the end of the list, following the "prev" pointers, and processes the
final item. With this patch, a new item is added to the end of the
list and the item at the front of the list is consumed. In other
words, the list elements used to be stored in reverse order; with this
patch, they are stored in their order of arrival. This causes a change
in the debug messages that print the pending signals. Otherwise, no
behavioral change is expected.
gdbserver/ChangeLog:
2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Use std::list to stop pending signal instead of manually-created
linked list.
* linux-low.h: Include <list>.
(struct pending_signal): Move here from linux-low.cc.
(struct lwp_info) <pending_signals>
<pending_signals_to_report>: Update the type.
* linux-low.cc (struct pending_signals): Remove.
(linux_process_target::delete_lwp)
(linux_process_target::add_lwp)
(enqueue_one_deferred_signal)
(dequeue_one_deferred_signal)
(enqueue_pending_signal)
(linux_process_target::resume_one_lwp_throw)
(linux_process_target::thread_needs_step_over)
(linux_process_target::resume_one_thread)
(linux_process_target::proceed_one_lwp): Update the use of pending
signal list.
Tankut Baris Aktemur [Mon, 22 Jun 2020 12:03:33 +0000 (14:03 +0200)]
gdb/jit: return bool in jit_breakpoint_re_set_internal and jit_read_descriptor
This is a minor refactoring that converts the return type of
jit_read_descriptor and jit_breakpoint_re_set_internal functions
from 'int' to 'bool'.
The return value logic of jit_breakpoint_re_set_internal has been
reversed. With this patch it now returns true if the jit breakpoint
has been successfully initialized.
gdb/ChangeLog:
2020-06-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* jit.c (jit_read_descriptor): Use bool as the return type.
(jit_breakpoint_re_set_internal): Use bool as the return type.
Invert the return value logic; return true if the jit breakpoint
has been successfully initialized.
(jit_inferior_init): Update the call to
jit_breakpoint_re_set_internal.
Pedro Alves [Mon, 22 Jun 2020 09:54:08 +0000 (10:54 +0100)]
Solaris, target_wait(), don't rely on inferior_ptid
Debugging on Solaris is broken, with the procfs target backend failing
with:
procfs: couldn't find pid 0 in procinfo list.
as soon as you start a program.
The problem is procfs_target::wait assuming that inferior_ptid is
meaningful on entry, but, since the multi-target series, inferior_ptid
is null_ptid before we call target_wait, in infrun.c:
static ptid_t
do_target_wait_1 (inferior *inf, ptid_t ptid,
target_waitstatus *status, int options)
{
...
/* We know that we are looking for an event in the target of inferior
INF, but we don't know which thread the event might come from. As
such we want to make sure that INFERIOR_PTID is reset so that none of
the wait code relies on it - doing so is always a mistake. */
switch_to_inferior_no_thread (inf);
This patch tweaks the backend to remove the assumption that
inferior_ptid points at something. sol-thread.c (the thread_stratum
that sits on top of procfs.c) also has the same issue.
Some spots in procfs_target::wait were returning
TARGET_WAITKIND_SPURIOUS+inferior_ptid. This commit replaces those
with waiting again without returning to the core. This fixes the
relying on inferior_ptid, and also should fix the issue discussed
here:
https://sourceware.org/pipermail/gdb/2020-May/048616.html
https://sourceware.org/pipermail/gdb/2020-June/048660.html
gdb/ChangeLog:
2020-06-22 Pedro Alves <palves@redhat.com>
PR gdb/25939
* procfs.c (procfs_target::wait): Don't reference inferior_ptid.
Use the current inferior instead. Don't return
TARGET_WAITKIND_SPURIOUS/inferior_ptid -- instead continue and
wait again.
* sol-thread.c (sol_thread_target::wait): Don't reference
inferior_ptid.
(ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs)
(sol_update_thread_list_callback): Use the current inferior's pid
instead of inferior_ptid.
Nelson Chu [Fri, 12 Jun 2020 15:06:49 +0000 (23:06 +0800)]
RISC-V: Report warning when linking the objects with different priv specs.
We do know some conflicts among different privileged specs. For linker,
the safest approach is that don't allow the object linked with others which
may cause conflicts. But this may cause inconvenience since not all objects
with conflicting priv specs are linked will cause problems. But it is hard
to know the detailed conflict cases for linker, so we probably need a option
to tell linker that we do know there are no conflicts, or we are willing to
take risks to link the objects with conflicted priv specs. But the option
is still under discussion.
Therefore, we can report warnings rather than errors when linking the objects
with conflicted priv specs. This not only makes the linker more flexible,
but also warns people that the conflicts may happen. We also need to update
the output priv spec version once the input priv spec is newer.
bfd/
* elfxx-riscv.c (struct priv_spec_t priv_specs[]): Move them from
opcodes/riscv-opc.c to bfd/elfxx-riscv.c, since we need it in linker.
(riscv_get_priv_spec_class): Likewise.
(riscv_get_priv_spec_name): Likewise.
(riscv_get_priv_spec_class_from_numbers): New function, convert
the version numbers into string, then call riscv_get_priv_spec_class
to get the priv spec class.
* elfxx-riscv.h (riscv_get_priv_spec_class): Move forward declaration
from include/opcode/riscv.h to bfd/elfxx-riscv.h.
(riscv_get_priv_spec_name): Likewise.
(riscv_get_priv_spec_class_from_numbers): New forward declaration.
(opcode/riscv.h): Include it in the header rather than elfxx-riscv.c.
* elfnn-riscv.c (riscv_merge_attributes): Get the priv spec classes
of input and output objects form their priv spec attributes by
riscv_get_priv_spec_class_from_numbers. Report warning rather than
errors when linking objects with differnet priv spec versions. We do
know v1.9.1 may have conflicts to other versions, so report the
warning, too. After that, update the output priv spec version to the
newest one so far.
gas/
* config/tc-riscv.c (buf_size, buf): Remove the unused variables.
(riscv_set_default_priv_spec): Get the priv spec version from the
priv spec attributes by riscv_get_priv_spec_class_from_numbers.
include/
* opcode/riscv.h (riscv_get_priv_spec_class): Move the function
forward declarations to bfd/elfxx-riscv.h.
(riscv_get_priv_spec_name): Likewise.
opcodes/
* riscv-opc.c: Move the structures and functions to bfd/elfxx-riscv.c.
* riscv-dis.c: Include elfxx-riscv.h.
ld/
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d: Updated.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d: Updated.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d: Updated.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d: Updated.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d: Updated.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d: Updated.
Nelson Chu [Tue, 9 Jun 2020 07:33:08 +0000 (15:33 +0800)]
RISC-V: Don't assume the priv attributes are in order when handling them.
There is no guarantee that the priv attributes should be defined in order.
Therefore, we shouldn't have the order assumption when handling them in the
riscv_merge_attributes. Set priv_attrs_merged to TRUE if we have handled
all of the priv attributes.
bfd/
* elfnn-riscv.c (riscv_merge_attributes): Once we meet one of the
priv attributes, we will check the conflicts for all of them (major,
minor and revision), and then set the priv_attrs_merged to TRUE to
indicate that we have handled all of the priv attributes. Remove
the unused boolean priv_may_conflict, in_priv_zero and out_priv_zero.
GDB Administrator [Mon, 22 Jun 2020 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in
Rainer Orth [Sun, 21 Jun 2020 16:51:58 +0000 (18:51 +0200)]
Various procfs.c cleanups
While reading through procfs.c, I noticed a couple of cleanup
opportunities:
* Some comments and code allowed for portability across different
targets. Since procfs.c is Solaris-only for some time now, those can
go.
* Likewise, there were some references to the old ioctl-based /proc left.
* The code still allowed for SYS_exec. However, it is no longer present
in either Solaris 11.3, 11.4, or Illumos. Checking the OpenSolaris
sources, I found that it had already been removed in 2010 well before
the Solaris 11 release.
* Some blocks of #if 0 code can go:
** References to struct procinfo.{g,fp}regs_dirty which are no longer
defined.
** Code handling the PR_ASLWP flag where <sys/procfs.h> has
#define PR_ASLWP 0x00000040 /* obsolete flag; never set */
Tested on amd64-pc-solaris2.11.
* procfs.c: Cleanup many comments.
(READ_WATCHFLAG, WRITE_WATCHFLAG, EXEC_WATCHFLAG)
(AFTER_WATCHFLAG): Replace by value.
(MAIN_PROC_NAME_FORMAT): Inline ...
(create_procinfo): ... here.
(procfs_debug_inferior): Remove SYS_exec handling.
(syscall_is_exec): Likewise.
(procfs_set_exec_trap): Likewise.
(syscall_is_lwp_exit): Inline in callers.
(syscall_is_exit): Likewise.
(syscall_is_exec): Likewise.
(syscall_is_lwp_create): Likewise.
(invalidate_cache): Remove #if 0 code.
(make_signal_thread_runnable): Remove.
(procfs_target::resume): Remove #if 0 code.
Rainer Orth [Sun, 21 Jun 2020 16:32:27 +0000 (18:32 +0200)]
[PR gdb/25939] Move push_target call earlier in procfs.c
Since the multi-target patch, the run command fails on Solaris with an
assertion failure even for a trivial program:
$ ./gdb -D ./data-directory ./hello
GNU gdb (GDB) 10.0.50.
20200106-git
[...]
Reading symbols from ./hello...
(gdb) run
Starting program: /vol/obj/gnu/gdb/gdb/reghunt/no-resync/122448/gdb/hello
/vol/src/gnu/gdb/hg/master/reghunt/gdb/thread.c:336: internal-error:
thread_info::thread_info(inferior*, ptid_t): Assertion `inf_ != NULL'
failed.
Here's the start of the corresponding stack trace:
#0 internal_error (
file=file@entry=0x966150
"/vol/src/gnu/gdb/hg/master/reghunt/gdb/thread.c", line=line@entry=336,
fmt=0x9ddb94 "%s: Assertion `%s' failed.")
at /vol/src/gnu/gdb/hg/master/reghunt/gdb/gdbsupport/errors.c:51
#1 0x0000000000ef81f4 in thread_info::thread_info (this=0x1212020,
inf_=<optimized out>, ptid_=...)
at /vol/src/gnu/gdb/hg/master/reghunt/gdb/thread.c:344
#2 0x0000000000ef82cd in new_thread (inf=inf@entry=0x0, ptid=...)
at /vol/src/gnu/gdb/hg/master/reghunt/gdb/thread.c:239
#3 0x0000000000efac3c in add_thread_silent (
targ=targ@entry=0x11b0940 <the_procfs_target>, ptid=...)
at /vol/src/gnu/gdb/hg/master/reghunt/gdb/thread.c:304
#4 0x0000000000d90692 in procfs_target::create_inferior (
this=0x11b0940 <the_procfs_target>,
exec_file=0x13dbef0
"/vol/obj/gnu/gdb/gdb/reghunt/no-resync/122448/gdb/hello", allargs="",
env=0x13c48f0, from_tty=<optimized out>)
at /vol/src/gnu/gdb/hg/master/reghunt/gdb/gdbsupport/ptid.h:47
#5 0x0000000000c84e64 in run_command_1 (args=<optimized out>, from_tty=1,
run_how=run_how@entry=RUN_NORMAL)
at /vol/gcc-9/include/c++/9.1.0/bits/basic_string.h:263
#6 0x0000000000c85007 in run_command (args=<optimized out>,
from_tty=<optimized out>)
at /vol/src/gnu/gdb/hg/master/reghunt/gdb/infcmd.c:687
Looking closer, I found that in add_thread_silent as called from
procfs.c (procfs_target::create_inferior) find_inferior_ptid returns
NULL. The all_inferiors (targ) iterator comes up empty.
Going from there, I see that in add_thread_silent
m_target_stack = {m_top = file_stratum, m_stack = {0x20190e0
<the_dummy_target>, 0x200b8c0 <exec_ops>, 0x0, 0x0, 0x0, 0x0, 0x0}}}
i.e. the_procfs_target is missing compared to the_amd64_linux_nat_target
on Linux/x86_64.
Moving the push_target call earlier allows debugging to get over the
initial assertion failure. I run instead into
procfs: couldn't find pid 0 in procinfo list.
which is fixed by
https://sourceware.org/pipermail/gdb-patches/2020-June/169674.html
Both patches tested together on amd64-pc-solaris2.11.
PR gdb/25939
* procfs.c (procfs_target::procfs_init_inferior): Move push_target
call ...
(procfs_target::create_inferior): ... here.
Alan Modra [Sun, 21 Jun 2020 11:24:24 +0000 (20:54 +0930)]
PR26132, ar creates invalid libraries for some targets with plugins enabled
PR 26132
* configure.ac: Disable plugins by default for some targets.
* plugin.c: Comment typo fix.
* configure: Regenerate.
Alan Modra [Sun, 21 Jun 2020 04:53:46 +0000 (14:23 +0930)]
Do without ld ENABLE_PLUGINS
Instead, use BFD_SUPPORTS_PLUGINS.
* ldfile.c: Replace uses of ENABLE_PLUGINS with BFD_SUPPORTS_PLUGINS.
* ldlang.c: Likewise.
* ldlang.h: Likewise.
* ldlex.h: Likewise.
* ldmain.c: Likewise.
* lexsup.c: Likewise.
* plugin.c: Wrap body of file in #if BFD_SUPPORTS_PLUGINS.
* testplug.c: Likewise.
* testplug2.c: Likewise.
* testplug3.c: Likewise.
* testplug4.c: Likewise.
* configure.ac (ENABLE_PLUGINS): Don't define AM_CONTITIONAL.
* Makefile.am: Remove ENABLE_PLUGINS conditionals.
(PLUGIN_CFLAGS): Don't define.
(PLUGIN_C, PLUGIN_H, PLUGIN_OBJECT): Likewise. Substitute all
uses with plugin file name.
* configure: Regenerate.
* Makefile.in: Regenerate.
Philippe Waroquiers [Sat, 23 May 2020 12:54:31 +0000 (14:54 +0200)]
Ensure 'exec-file has changed' check has priority over 'exec-file-mismatch' check
Following the implementation of exec-file-mismatch based on build-id,
an attach to a process that runs a modified exec-file was triggering
the exec-file-mismatch handling, giving a warning such as:
warning: Mismatch between current exec-file /bd/home/philippe/gdb/git/build_termours/gdb/testsuite/outputs/gdb.base/attach/attach
and automatically determined exec-file /bd/home/philippe/gdb/git/build_termours/gdb/testsuite/outputs/gdb.base/attach/attach
exec-file-mismatch handling is currently "ask"
as the build-ids differ when an exec-file is recompiled.
This patch ensures that the exec-file-mismatch check is done with an up to date
build-id. With this, exec-file-mismatch check will only trigger when the
PID file really differs from the (build-id refreshed) current exec-file.
Note that the additional check does not (yet) reload the symbols if
the exec-file is changed: this reload will happen later if needed.
gdb/ChangeLog
2020-06-21 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* exec.c (validate_exec_file): Ensure the build-id is up to
date by calling reopen_exec_file (that checks file timestamp
to decide to re-read the file).
gdb/testsuite/ChangeLog
2020-06-21 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.base/attach.exp: Test priority of 'exec-file' changed
over 'exec-file-mismatch'.
* gdb.base/attach.c: Mark should_exit volatile.
* gdb.base/attach2.c: Likewise. Add a comment explaining
why the sleep cannot be big.
* gdb.base/attach3.c: New file.
Sandra Loosemore [Sun, 21 Jun 2020 02:37:49 +0000 (19:37 -0700)]
Adjust gdb.mi/mi-sym-info.exp filename patterns.
2020-06-20 Sandra Loosemore <sandra@codesourcery.com>
* gdb.mi/mi-sym-info.exp: Adjust filename patterns to make directory
prefix optional.
Sandra Loosemore [Sun, 21 Jun 2020 00:23:53 +0000 (17:23 -0700)]
Fix gdb.base/list-missing-source.exp on remote host.
2020-06-20 Sandra Loosemore <sandra@codesourcery.com>
gdb/testsuite/
* gdb.base/list-missing-source.exp: Correct $srcfile manipulation
for remote host.
GDB Administrator [Sun, 21 Jun 2020 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Sat, 20 Jun 2020 06:23:37 +0000 (15:53 +0930)]
Remove perror from ld_assemble, ld_compile and ld_nm
ERROR should really be reserved for errors in the testsuite framework,
not just normal errors from the tools under test. Removing use of
perror has been suggested before but without action, over concerns
that some test failures might be missed. This patch removes uses of
perror in ld_assemble, ld_compile and ld_nm, and updates numerous
places that ignored the result of these functions by inappropriately
returning an "unresolved" test status. Net result over my large set
of targets look good, in some cases improving the diagnostics, eg:
i386-msdos -ERROR: tmpdir/script: nm failed
i386-msdos -ERROR: tmpdir/script: nm failed
i386-msdos -ERROR: tmpdir/script: nm failed
i386-msdos -ERROR: tmpdir/script: nm failed
i386-msdos +FAIL: script
i386-msdos +FAIL: MRI script
i386-msdos +FAIL: MEMORY
i386-msdos +FAIL: MEMORY with symbols
* testsuite/lib/ld-lib.exp (default_ld_compile): Don't perror on
a compiler error.
(default_ld_assemble): Similarly for an assembler error.
(default_ld_nm): Similarly for an nm error.
(run_ld_link_tests): Report ld_assemble errors as a fail.
(check_as_cfi): Remove now unnecessary perror substitution.
* testsuite/ld-elf/exclude.exp: Report ld_nm error return as test
fails rather then unresolved.
* testsuite/ld-gc/gc.exp: Likewise.
* testsuite/ld-scripts/alignof.exp: Likewise.
* testsuite/ld-scripts/defined.exp: Likewise.
* testsuite/ld-scripts/script.exp: Likewise.
* testsuite/ld-scripts/sizeof.exp: Likewise.
* testsuite/ld-selective/selective.exp: Likewise.
* testsuite/ld-scripts/extern.exp: Likewise. Return on ld_link
failure.
* testsuite/ld-elfweak/elfweak.exp: Report compiler errors as
test unresolved.
* testsuite/ld-fastcall/fastcall.exp: Report assember errors as
test fails.
* testsuite/ld-i386/i386.exp (iamcu_tests): Likewise.
* testsuite/ld-ia64/line.exp: Likewise.
* testsuite/ld-mep/mep.exp: Likewise.
* testsuite/ld-mips-elf/mips-elf-flags.exp: Likewise.
* testsuite/ld-nios2/nios2.exp: Likewise.
* testsuite/ld-scripts/alignof.exp: Likewise.
* testsuite/ld-x86-64/line.exp: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-scripts/log2.exp: Formatting.
* testsuite/ld-tic6x/tic6x.exp: Report ld_link errors as a test fail.
Alan Modra [Sat, 20 Jun 2020 01:17:32 +0000 (10:47 +0930)]
ecoff testsuite fixes
The aim of this change is to remove a whole lot of "assembly failed"
errors for ecoff targets.
* testsuite/ld-alpha/alpha.exp: Exclude *ecoff targets.
* testsuite/ld-elf/binutils.exp: Likewise.
* testsuite/ld-elf/tls.exp: Likewise.
* testsuite/ld-elf/tls_common.exp: Likewise.
* testsuite/ld-scripts/phdrs2.exp: Likewise.
Alan Modra [Sat, 20 Jun 2020 01:11:40 +0000 (10:41 +0930)]
SH gas configure and ld tests
All current SH gas targets use BFD. sh-coff was incorrectly reported
as unsupported.
gas/
* configure.tgt: Set bfd_gas for all SH targets.
ld/
* testsuite/ld-sh/sh.exp: Don't run relax tests for non-ELF.
Fail when ld_assemble fails. Use elseif to reduce indentation.
GDB Administrator [Sat, 20 Jun 2020 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in
Sandra Loosemore [Fri, 19 Jun 2020 16:15:38 +0000 (09:15 -0700)]
Fixes for gdb.xml/tdesc-regs.exp.
2020-06-19 Sandra Loosemore <sandra@codesourcery.com>
Hafiz Abid Qadeer <abidh@codesourcery.com>
* gdb.xml/tdesc-regs.exp (load_description): Correct pathname of
file sent to remote host.
(top level): Allow int32_t as type of 32-bit register.
Tom de Vries [Fri, 19 Jun 2020 15:55:52 +0000 (17:55 +0200)]
[gdb/testsuite] Limit default_target_compile override
The file lib/future.exp contains an override of dejagnu's
default_target_compile.
The override is activated if dejagnu's default_target_compile is missing
support for one or more languages.
However, if the override is activated, it's active for all languages.
This unnecessarily extends the scope of potential problems in the override to
languages that don't need the override.
Fix this by limiting the scope of the override.
Also add a note stating for which languages the override is active, as a
reminder that support for those languages needs to be ported to dejagnu. With
my system dejagnu 1.6.1, as well as with current dejagnu trunk, that gives us:
...
NOTE: Dejagnu's default_target_compile is missing support for Go, using \
local override
NOTE: Dejagnu's default_target_compile is missing support for Rust, using \
local override
...
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-06-19 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gdb_note): New proc.
* lib/future.exp (gdb_default_target_compile_1): Factor out of ...
(gdb_default_target_compile): ... here. Only call
gdb_default_target_compile_1 if use_gdb_compile(<lang>) is set.
(use_gdb_compile): Change to array.
(toplevel): Update sets of use_gdb_compile to specify language.
Warn about default_target_compile override. Store dejagnu's version
of default_target_compile in dejagnu_default_target_compile.
Nick Clifton [Fri, 19 Jun 2020 09:25:43 +0000 (10:25 +0100)]
Silence warnings about incompatible plugins.
I have been looking at a Fedora bug report[1] from a user who was
receiving warning messages from the BFD library about incompatible
plugins. It turns out that they had both 32-bit and 64-bit versions
of the same plugin installed, and the BFD library was attempting to
load all of them.
After thinking about it for a while, it seemed to me that the simplest
solution was to not warn about incompatible plugins whilst attempting
to create a list of viable plugins.
[1]: https://bugzilla.redhat.com/show_bug.cgi?id=
1836618
* plugin.c (try_load_plugin): Suppress the error message about
being unable to open a plugin if creating a list of viable
plugins.
Alan Modra [Fri, 19 Jun 2020 03:26:12 +0000 (12:56 +0930)]
Re: ld testsuite fixes for alpha
I missed some.
* testsuite/ld-plugin/pr22983.1.d: Accept st_other notations.
* testsuite/ld-plugin/pr22983.2.d: Likewise.
* testsuite/ld-plugin/pr22983.4.d: Likewise.
Alan Modra [Fri, 19 Jun 2020 00:30:30 +0000 (10:00 +0930)]
ld testsuite fixes for alpha
Some tests failed just due to st_other info, eg. [NOPV], being
emitted by readelf or objdump. Fix that. Also since alpha doesn't
support ifunc, don't run the ifunc tests for alpha.
* testsuite/ld-elf/dynamic-1.rd: Accept st_other notations.
* testsuite/ld-elf/rdynamic-1.rd: Likewise.
* testsuite/ld-elf/pr9676.rd: Likewise.
* testsuite/ld-elf/pr9679.rd: Likewise.
* testsuite/ld-elfvers/vers30.dsym: Likewise.
* testsuite/ld-elfvers/vers31.dsym: Likewise.
* testsuite/ld-plugin/pr22983.3.d: Likewise.
* testsuite/ld-ifunc/ifunc.exp: Exclude alpha.
Alan Modra [Thu, 18 Jun 2020 23:47:20 +0000 (09:17 +0930)]
Emit a warning when -z relro is unsupported
ld silently accepts -z relro and -z norelro for targets that lack the
necessary GNU_RELRO support. This patch makes those targets emit a
warning instead, and adds testsuite infrastructure to detect when
relro is unsupported.
binutils/
* testsuite/config/default.exp (ld_elf_shared_opt): Don't set.
* testsuite/lib/binutils-common.exp (check_relro_support): New proc.
(run_dump_test): Use check_relro_support to decide whether to pass
extra ld option "-z norelro".
ld/
* emultempl/elf.em (gld${EMULATION_NAME}_handle_option): Omit
-z relro and -z norelro when target support for GNU_RELRO is lacking.
(gld${EMULATION_NAME}_before_parse): Ignore RELRO default too.
* emultempl/aarch64elf.em (gld${EMULATION_NAME}_before_parse): Ignore
RELRO default when target support for GNU_RELRO is lacking.
* emultempl/armelf.em (gld${EMULATION_NAME}_before_parse): Likewise.
* emultempl/linux.em (gld${EMULATION_NAME}_before_parse): Likewise.
* emultempl/scoreelf.em (gld${EMULATION_NAME}_before_parse): Likewise.
* testsuite/config/default.exp (ld_elf_shared_opt): Don't set.
* testsuite/ld-elf/pr16322.d: xfail when no relro support.
* testsuite/ld-elf/pr22393-1a.d: Likewise.
* testsuite/ld-elf/pr22393-1b.d: Likewise.
* testsuite/ld-elf/shared.exp (pr20995-2.so, pr20995-2): Likewise.
* testsuite/lib/ld-lib.exp (run_ld_link_tests): Use check_relro_support
to decide whether to pass extra ld option "-z norelro".
GDB Administrator [Fri, 19 Jun 2020 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
Pedro Alves [Thu, 18 Jun 2020 20:28:37 +0000 (21:28 +0100)]
Decouple inferior_ptid/inferior_thread(); dup ptids in thread list (PR 25412)
In PR 25412, Simon noticed that after the multi-target series, the
tid-reuse.exp testcase manages to create a duplicate thread in the
thread list. Or rather, two threads with the same PTID.
add_thread_silent has code in place to detect the case of a new thread
reusing some older thread's ptid, but it doesn't work correctly
anymore when the old thread is NOT the current thread and it has a
refcount higher than 0. Either condition prevents a thread from being
deleted, but the refcount case wasn't being considered. I think the
reason that case wasn't considered is that that code predates
thread_info refcounting. Back when it was originally written,
delete_thread always deleted the thread.
That add_thread_silent code in question has some now-unnecessary
warts, BTW. For instance, this:
/* Make switch_to_thread not read from the thread. */
new_thr->state = THREAD_EXITED;
... used to be required because switch_to_thread would update
'stop_pc' otherwise. I.e., it would read registers from an exited
thread otherwise. switch_to_thread no longer reads the stop_pc, since:
commit
f2ffa92bbce9dd5fbedc138ac2a3bc8a88327d09
Author: Pedro Alves <palves@redhat.com>
AuthorDate: Thu Jun 28 20:18:24 2018 +0100
gdb: Eliminate the 'stop_pc' global
Also, if the ptid of the now-gone current thread is reused, we
currently return from add_thread_silent with the current thread
pointing at the _new_ thread. Either pointing at the old thread, or
at no thread selected would be reasonable. But pointing at an
unrelated thread (the new thread that happens to reuse the ptid) is
just broken. Seems like I was the one who wrote it like that but I
have no clue why, FWIW.
Currently, an exited thread kept in the thread list still holds its
original ptid. The idea was that we need the ptid to be able to
temporarily switch to another thread and then switch back to the
original thread, because thread switching is really inferior_ptid
switching. Switching back to the original thread requires a ptid
lookup.
Now, in order to avoid exited threads with the same ptid as a live
thread in the same thread list, one thing I considered (and tried) was
to change an exited thread's ptid to minus_one_ptid. However, with
that, there's a case that we won't handle well, which is if we end up
with more than one exited thread in the list, since then all exited
threads will all have the same ptid. Since inferior_thread() relies
on inferior_ptid, may well return the wrong thread.
My next attempt to address this, was to switch an exited thread's ptid
to a globally unique "exited" ptid, which is a ptid with pid == -1 and
tid == 'the thread's global GDB thread number'. Note that GDB assumes
that the GDB global thread number is monotonically increasing and
doesn't wrap around. (We should probably make GDB thread numbers
64-bit to prevent that happening in practice; they're currently signed
32-bit.) This attempt went a long way, but still ran into a number of
issues. It was a major hack too, obviously.
My next attempt is the one that I'm proposing, which is to bite the
bullet and break the connection between inferior_ptid and
inferior_thread(), aka the current thread. I.e., make the current
thread be a global thread_info pointer that is written to directly by
switch_to_thread, etc., and making inferior_thread() return that
pointer, instead of having inferior_thread() lookup up the
inferior_ptid thread, by ptid_t. You can look at this as a
continuation of the effort of using more thread_info pointers instead
of ptids when possible.
By making the current thread a global thread_info pointer, we can make
switch_to_thread simply write to the global thread pointer, which
makes scoped_restore_current_thread able to restore back to an exited
thread without relying on unrelyable ptid look ups. I.e., this makes
it not a real problem to have more than one thread with the same ptid
in the thread list. There will always be only one live thread with a
given ptid, so code that looks up a live thread by ptid will always be
able to find the right one.
This change required auditing the whole codebase for places where we
were writing to inferior_ptid directly to change the current thread,
and change them to use switch_to_thread instead or one of its
siblings, because otherwise inferior_thread() would return a thread
unrelated to the changed-to inferior_ptid. That was all (hopefully)
done in previous patches.
After this, inferior_ptid is mainly used by target backend code. It
is also relied on by a number of target methods. E.g., the
target_resume interface and the memory reading routines -- we still
need it there because we need to be able to access memory off of
processes for which we don't have a corresponding inferior/thread
object, like when handling forks. Maybe we could pass down a context
explicitly to target_read_memory, etc.
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
PR gdb/25412
* gdbthread.h (delete_thread, delete_thread_silent)
(find_thread_ptid): Update comments.
* thread.c (current_thread_): New global.
(is_current_thread): Move higher, and reimplement.
(inferior_thread): Reimplement.
(set_thread_exited): Use bool. Add assertions.
(add_thread_silent): Simplify thread-reuse handling by always
calling delete_thread.
(delete_thread): Remove intro comment.
(find_thread_ptid): Skip exited threads.
(switch_to_thread_no_regs): Write to current_thread_.
(switch_to_no_thread): Check CURRENT_THREAD_ instead of
INFERIOR_PTID. Clear current_thread_.
Pedro Alves [Thu, 18 Jun 2020 20:28:36 +0000 (21:28 +0100)]
Don't write to inferior_ptid in aix-thread.c
There are other writes in the file, but they seem more harmless. This
one is changing the current thread permanently.
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* aix-thread.c (pd_update): Use switch_to_thread.
Pedro Alves [Thu, 18 Jun 2020 20:28:36 +0000 (21:28 +0100)]
Don't write to inferior_ptid in ravenscar-thread.c
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* ravenscar-thread.c (ravenscar_thread_target): Update.
(ravenscar_thread_target::update_inferior_ptid): Rename to ...
(ravenscar_thread_target::add_active_thread): ... this. Don't
set m_base_ptid here. Update to avoid referencing inferior_ptid.
(ravenscar_thread_target::wait): Don't write to inferior_ptid.
Pedro Alves [Thu, 18 Jun 2020 20:28:35 +0000 (21:28 +0100)]
Don't write to inferior_ptid in windows-nat.c, part II
Writing to inferior_ptid in
windows_nat_target::get_windows_debug_event is just incorrect and not
necessary. We'll report the event to GDB's core, which then takes
care of switching inferior_ptid / current thread.
Related (see windows_nat_target::get_windows_debug_event), there's
also a "current_windows_thread" global that is just begging to get out
of sync with core GDB's current thread. This patch removes it.
gdbserver already does not have an equivalent global in win32-low.cc.
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* nat/windows-nat.c (current_windows_thread): Remove.
* nat/windows-nat.h (current_windows_thread): Remove.
* windows-nat.c (windows_nat_target::stopped_by_sw_breakpoint):
Adjust.
(display_selectors): Adjust to fetch the current
windows_thread_info based on inferior_ptid.
(fake_create_process): No longer write to current_windows_thread.
(windows_nat_target::get_windows_debug_event):
Don't set inferior_ptid or current_windows_thread.
(windows_nat_target::wait): Adjust to not rely on
current_windows_thread.
(do_initial_windows_stuff): Now a method of windows_nat_target.
Switch to the last_ptid thread.
(windows_nat_target::attach): Adjust.
(windows_nat_target::detach): Use switch_to_no_thread instead of
writing to inferior_ptid directly.
(windows_nat_target::create_inferior): Adjust.
Pedro Alves [Thu, 18 Jun 2020 20:28:34 +0000 (21:28 +0100)]
Don't write to inferior_ptid in windows-nat.c, part I
The inferior_ptid hack in do_initial_win32_stuff, added back in 2008:
https://sourceware.org/ml/gdb-patches/2008-10/msg00012.html
with:
commit
9f9d052e600ed9436f9fd558d62a189c8cc3d43e
Author: Pierre Muller <muller@sourceware.org>
AuthorDate: Thu Oct 2 14:20:07 2008 +0000
* win32-nat.c (do_initial_win32_stuff): Set inferior_ptid.
is no longer needed. Back then, current_inferior looked like this:
struct inferior*
current_inferior (void)
{
struct inferior *inf = find_inferior_pid (ptid_get_pid (inferior_ptid));
gdb_assert (inf);
return inf;
}
Nowadays, current_inferior() just returns the global current_inferior_
pointer, which didn't exist back then.
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* windows-nat.c (do_initial_windows_stuff): No longer set inferior_ptid.
Pedro Alves [Thu, 18 Jun 2020 20:28:33 +0000 (21:28 +0100)]
Don't write to inferior_ptid in go32-nat.c
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* go32-nat.c (go32_nat_target::create_inferior): Switch to thread
after creating it, instead of writing to inferior_ptid. Don't
write to inferior_ptid.
Pedro Alves [Thu, 18 Jun 2020 20:28:32 +0000 (21:28 +0100)]
Don't write to inferior_ptid in fork-child.c
This is no longer necessary. All targets that call fork_inferior now
also call switch_to_thread as soon as they add the main thread.
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* fork-child.c (postfork_hook): Don't write to inferior_ptid.
Pedro Alves [Thu, 18 Jun 2020 20:28:32 +0000 (21:28 +0100)]
Don't write to inferior_ptid in bsd-kvm.c
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* bsd-kvm.c (bsd_kvm_target_open): Switch to thread after adding
it, instead of writing to inferior_ptid.
Pedro Alves [Thu, 18 Jun 2020 20:28:31 +0000 (21:28 +0100)]
Don't write to inferior_ptid in btrace_fetch
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* btrace.c (btrace_fetch): Use switch_to_thread instead of writing
to inferior_ptid.
Pedro Alves [Thu, 18 Jun 2020 20:28:30 +0000 (21:28 +0100)]
Don't write to inferior_ptid in bsd-kvm.c
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* bsd-kvm.c (bsd_kvm_target::close): Use switch_to_no_thread
instead of writing to inferior_ptid directly.
Pedro Alves [Thu, 18 Jun 2020 20:28:29 +0000 (21:28 +0100)]
Don't write to inferior_ptid in corelow.c
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* corelow.c (core_target::close): Use switch_to_no_thread instead
of writing to inferior_ptid directly.
(add_to_thread_list, core_target_open): Use switch_to_thread
instead of writing to inferior_ptid directly.
Pedro Alves [Thu, 18 Jun 2020 20:28:28 +0000 (21:28 +0100)]
Don't write to inferior_ptid in darwin-nat.c
Untested.
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* darwin-nat.c (darwin_nat_target::decode_message): Don't write to
inferior_ptid.
(darwin_nat_target::stop_inferior, darwin_nat_target::kill): Avoid
inferior_ptid.
(darwin_attach_pid): Use switch_to_no_thread instead of writing to
inferior_ptid directly.
(darwin_nat_target::init_thread_list): Switch to thread, instead
of writing to inferior_ptid.
(darwin_nat_target::attach): Don't write to inferior_ptid.
(darwin_nat_target::get_ada_task_ptid): Avoid inferior_ptid.
Pedro Alves [Thu, 18 Jun 2020 20:28:28 +0000 (21:28 +0100)]
Don't write to inferior_ptid in gnu-nat.c
Untested.
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* gnu-nat.c (gnu_nat_target::create_inferior): Switch to the added
thread.
(gnu_nat_target::attach): Don't write to inferior_ptid directly.
Instead use switch_to_thread.
(gnu_nat_target::detach): Use switch_to_no_thread
instead of writing to inferior_ptid directly. Used passed-in
inferior instead of looking up the inferior by pid.
Pedro Alves [Thu, 18 Jun 2020 20:28:27 +0000 (21:28 +0100)]
Don't write to inferior_ptid in go32-nat.c
generic_mourn_inferior already takes care of switching to no thread.
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* go32-nat.c (go32_nat_target::create_inferior): Don't write to
inferior_ptid.
Pedro Alves [Thu, 18 Jun 2020 20:28:26 +0000 (21:28 +0100)]
Don't write to inferior_ptid in nto-procfs.c
A best effort patch, which fixes some bit rot and removes some
inferior_ptid references -- this port clearly hasn't been built in a
long while.
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* nto-procfs.c (nto_procfs_target::update_thread_list): Avoid
inferior_ptid.
(nto_procfs_target::attach): Avoid inferior_ptid. Switch to
thread.
(nto_procfs_target::detach): Avoid referencing
inferior_ptid. Use switch_to_no_thread instead of writing to
inferior_ptid directly.
(nto_procfs_target::mourn_inferior): Use switch_to_no_thread
instead of writing to inferior_ptid directly.
(nto_procfs_target::create_inferior): Avoid inferior_ptid. Switch
to thread.
Pedro Alves [Thu, 18 Jun 2020 20:28:25 +0000 (21:28 +0100)]
Don't write to inferior_ptid in remote-sim.c
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* remote-sim.c (gdbsim_target::create_inferior): Switch to thread
after creating it, instead of writing to inferior_ptid.
(gdbsim_target_open): Use switch_to_no_thread instead of writing
to inferior_ptid directly.
(gdbsim_target::wait): Don't write to inferior_ptid.
Pedro Alves [Thu, 18 Jun 2020 20:28:24 +0000 (21:28 +0100)]
Don't write to inferior_ptid in remote.c
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* remote.c (remote_target::remote_notice_new_inferior): Use
switch_to_thread instead of writing to inferior_ptid directly.
(remote_target::add_current_inferior_and_thread): Use
switch_to_no_thread instead of writing to inferior_ptid directly.
(extended_remote_target::attach): Use switch_to_inferior_no_thread
and switch_to_thread instead of using set_current_inferior or
writing to inferior_ptid directly.
Pedro Alves [Thu, 18 Jun 2020 20:28:24 +0000 (21:28 +0100)]
Don't write to inferior_ptid in tracectf.c
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* tracectf.c (ctf_target_open): Switch to added thread instead of
writing to inferior_ptid directly.
(ctf_target::close): Use switch_to_no_thread instead of writing to
inferior_ptid directly.
Pedro Alves [Thu, 18 Jun 2020 20:28:23 +0000 (21:28 +0100)]
Don't write to inferior_ptid in tracefile-tfile.c
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* tracefile-tfile.c (tfile_target_open): Don't write to
inferior_ptid directly, instead switch to added thread.
(tfile_target::close): Use switch_to_no_thread instead of writing
to inferior_ptid directly.
Pedro Alves [Thu, 18 Jun 2020 20:28:22 +0000 (21:28 +0100)]
Don't write to inferior_ptid in procfs.c
The inferior_ptid write in procfs_do_thread_registers should be
unnecessary because the target_fetch_registers method should (and
does) extract the ptid from the regcache.
Not tested.
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* procfs.c (procfs_target::attach): Don't write to inferior_ptid.
(procfs_target::detach): Use switch_to_no_thread
instead of writing to inferior_ptid directly.
(do_attach): Change return type to void. Switch to the added
thread.
(procfs_target::create_inferior): Switch to the added thread.
(procfs_do_thread_registers): Don't write to inferior_ptid.
Pedro Alves [Thu, 18 Jun 2020 20:28:21 +0000 (21:28 +0100)]
Don't write to inferior_ptid in infrun.c
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* infrun.c (generic_mourn_inferior): Use switch_to_thread instead
of writing to inferior_ptid.
(scoped_restore_exited_inferior): Delete.
(handle_vfork_child_exec_or_exit): Simplify using
scoped_restore_current_pspace_and_thread. Use switch_to_thread
instead of writing to inferior_ptid.
(THREAD_STOPPED_BY): Delete.
(thread_stopped_by_watchpoint, thread_stopped_by_sw_breakpoint)
(thread_stopped_by_hw_breakpoint): Delete.
(save_waitstatus): Use
scoped_restore_current_thread+switch_to_thread, and call
target_stopped_by_watchpoint instead of
thread_stopped_by_watchpoint, target_stopped_by_sw_breakpoint
instead of thread_stopped_by_sw_breakpoint, and
target_stopped_by_hw_breakpoint instead of
thread_stopped_by_hw_breakpoint.
(handle_inferior_event)
<TARGET_WAITKIND_EXITED/TARGET_WAITKIND_SIGNALLED>: Don't write to
inferior_ptid directly, nor
set_current_inferior/set_current_program_space. Use
switch_to_thread / switch_to_inferior_no_thread instead.
Pedro Alves [Thu, 18 Jun 2020 20:28:20 +0000 (21:28 +0100)]
Don't write to inferior_ptid in target.c
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* target.c (generic_mourn_inferior): Use switch_to_no_thread
instead of writing to inferior_ptid.
Pedro Alves [Thu, 18 Jun 2020 20:28:20 +0000 (21:28 +0100)]
Don't write to inferior_ptid in inf-ptrace.c
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* inf-ptrace.c (inf_ptrace_target::create_inferior): Switch to the
added thread.
(inf_ptrace_target::attach): Don't write to inferior_ptid. Switch
to the added thread.
(inf_ptrace_target::detach_success): Use switch_to_no_thread
instead of writing to inferior_ptid.
Pedro Alves [Thu, 18 Jun 2020 20:28:19 +0000 (21:28 +0100)]
Don't write to inferior_ptid in gdbarch-selftests.c, mock address_space too
Use switch_to_thread instead of writing to inferior_ptid. This
requires a couple of improvements to the mocking environment. One is
to mock a pspace too, and assigning it to the inferior. In turn, this
requires heap-allocating the address space, so that the regular
program_space dtor destroys the address space correctly.
(Note that new the mock program_space is allocated on the stack, and
thus depends on the previous patch that eliminated
delete_program_space.)
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* gdbarch-selftests.c: Include "progspace-and-thread.h".
(register_to_value_test): Mock a program_space too. Heap-allocate
the address space. Don't write to inferior_ptid. Use
switch_to_thread instead.
Pedro Alves [Thu, 18 Jun 2020 20:28:18 +0000 (21:28 +0100)]
gcore, handle exited threads better
An early (and since discarded) version of this series tried to make
exited threads have distinct PTID between each other, and that change
exposed a problem in linux-tdep.c... This was exposed by the
gdb.threads/gcore-stale-thread.exp testcase, which is exactly about
calling gcore with an exited thread selected:
(gdb) [Thread 0x7ffff7fb6740 (LWP 31523) exited]
PASS: gdb.threads/gcore-stale-thread.exp: continue to breakpoint: break-here
gcore /home/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.threads/gcore-stale-thread/gcore-stale-thread.core
/home/pedro/gdb/binutils-gdb/build/../src/gdb/inferior.c:66: internal-error: void set_current_inferior(inferior*): Assertion `inf != NULL' failed.
A problem internal to GDB has been detected,
That was find_inferior_ptid being called on the "exited" ptid, which
on that previous (and discarded attempt) had pid==-1. The problem is
that linux-tdep.c, where it looks for the signalled thread, isn't
considering exited threads. Also, while at it, that code isn't
considering multi-target either, since it is using
iterate_over_threads which iterates over all threads of all targets.
Fixed by switching to range-for iteration instead.
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* linux-tdep.c (find_signalled_thread(thread_info *,void *)):
Delete.
(find_signalled_thread()): New, factored out from
linux_make_corefile_notes and adjusted to handle exited threads.
(linux_make_corefile_notes): Adjust to use the new
find_signalled_thread.
Pedro Alves [Thu, 18 Jun 2020 20:28:17 +0000 (21:28 +0100)]
Don't write to inferior_ptid in linux_get_siginfo_data
gdb/ChangeLog:
2020-06-18 Pedro Alves <palves@redhat.com>
* linux-tdep.c (btrace_fetch): Save/restore current thread instead
of saving/restoring inferior_ptid.
Tom de Vries [Thu, 18 Jun 2020 13:06:04 +0000 (15:06 +0200)]
[gdb/testsuite] Move code from gdb_init to default_gdb_init
If a baseboard file wants to override a proc foo, but also use the original
proc, it'll have to do something like:
...
rename foo save_foo
proc foo { } {
...
set res [save_foo]
...
return res
}
...
This adds a new proc named save_foo, which introduces the risk of clashing with
an existing proc.
There's a pattern in the gdb testsuite procs, that facilitates this override:
...
proc default_foo { } {
...
}
proc foo { } {
return [default_foo]
}
...
such that in a baseboard file we don't need the rename:
...
proc foo { } {
...
set res [default_foo]
...
return res
}
...
The exception to the pattern though is gdb_init, which has a default_gdb_init
counterpart, but contains much more code than just the call to
default_gdb_init.
Fix this by moving all but the call to default_gdb_init to default_gdb_init.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-06-18 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gdb_init): Move all but call to default_gdb_init to ...
(default_gdb_init): ... here.
Jan Beulich [Thu, 18 Jun 2020 07:13:49 +0000 (09:13 +0200)]
x86: also test alternative VMGEXIT encoding
gas/
* testsuite/gas/i386/arch-13.s: Add alternative VMGEXIT case.
* testsuite/gas/i386/arch-13.d: Extend -march=. Adjust
expectations.
opcodes/
* i386-dis.c (prefix_table): Revert the last vmgexit change.
Fangrui Song [Thu, 18 Jun 2020 09:46:18 +0000 (10:46 +0100)]
[PATCH] gold: Set DF_1_PIE for -pie
PR gold/26039
* layout.cc (Layout::finish_dynamic_section): Set DF_1_PIE.
elfcpp/
* elfcpp.h (enum DF_1): New enum member DF_1_PIE.
Sandra Loosemore [Thu, 18 Jun 2020 04:57:16 +0000 (21:57 -0700)]
Fix TUI support checks in gdb.tui tests.
2020-06-17 Sandra Loosemore <sandra@codesourcery.com>
gdb/testsuite/
* gdb.tui/basic.exp: Skip test when TUI is unsupported, don't
just say UNSUPPORTED.
* gdb.tui/corefile-run.exp: Likewise.
* gdb.tui/empty.exp: Likewise.
* gdb.tui/list-before.exp: Likewise.
* gdb.tui/list.exp: Likewise.
* gdb.tui/main.exp: Likewise.
* gdb.tui/regs.exp: Likewise.
* gdb.tui/resize.exp: Likewise.
* gdb.tui/tui-layout-asm-short-prog.exp: Likewise.
* gdb.tui/tui-layout-asm.exp: Likewise.
* gdb.tui/tui-missing-src.exp: Likewise.
* gdb.tui/winheight.exp: Likewise.
* gdb.tui/new-layout.exp: Likewise. Also move check earlier.
Tom Tromey [Tue, 16 Jun 2020 23:45:36 +0000 (17:45 -0600)]
Remove unnecessary TUI declarations
I found some unnecessary declarations (and one unused macro) in the
TUI. This patch removes them.
gdb/ChangeLog
2020-06-17 Tom Tromey <tom@tromey.com>
* tui/tui-win.h (tui_scroll_forward, tui_scroll_backward)
(tui_scroll_left, tui_scroll_right, struct tui_win_info): Don't
declare.
* tui/tui-data.h (MIN_CMD_WIN_HEIGHT): Remove.
GDB Administrator [Thu, 18 Jun 2020 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in
Keith Seitz [Wed, 17 Jun 2020 22:07:45 +0000 (15:07 -0700)]
Fix typo in my gdb.debuginfod entry.
Sandra Loosemore [Wed, 17 Jun 2020 20:43:32 +0000 (13:43 -0700)]
Fix TCL error in gdb.python/py-format-string.exp.
2020-06-17 Sandra Loosemore <sandra@codesourcery.com>
gdb/testsuite/
* gdb.python/py-format-string.exp: Move test for python support
earlier, out of function body.
Simon Marchi [Wed, 17 Jun 2020 18:48:46 +0000 (14:48 -0400)]
gdb: check for partial symtab presence in dwarf2_initialize_objfile
This patch fixes an internal error that is triggered when loading the
same binary twice with the index-cache on:
$ ./gdb -q -nx --data-directory=data-directory
(gdb) set index-cache on
(gdb) shell mktemp -d
/tmp/tmp.BLgouVoPq4
(gdb) set index-cache directory /tmp/tmp.BLgouVoPq4
(gdb) file a.out
Reading symbols from a.out...
(gdb) file a.out
Load new symbol table from "a.out"? (y or n) y
Reading symbols from a.out...
/home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:2540: internal-error: void create_cus_from_index(dwarf2_per_bfd*, const gdb_byte*, offset_type, const gdb_byte*, offset_type): Assertion `per_bfd->all_comp_units.empty ()' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
This is what happens:
1. We load the binary the first time, partial symtabs are created,
per_bfd->all_comp_units is filled from those.
2. Because index-cache is on, we also generate an index in the cache.
3. We load the binary a second time, in dwarf2_initialize_objfile we
check: was an index already loaded for this BFD? No, so we try to
read the index and fill the per-bfd using it. We do find an index,
it's in the cache.
4. The function create_cus_from_index asserts (rightfully) that
per_cu->all_comp_units is empty, and the assertion fails.
This assertion verifies that we are not reading an index for a BFD for
which we have already built partial symtabs or read another index.
The index-cache gives a situation that isn't currently accounted for: a
BFD for which we have built the partial symtabs the first time, but has
an index the second time.
This patch addresses it by checking for the presence of partial symtabs
in dwarf2_initialize_objfile. If there are, we don't try reading the
index.
gdb/ChangeLog:
* dwarf2/read.c (dwarf2_initialize_objfile): Check for presence
of partial symtabs.
gdb/testsuite/ChangeLog:
* gdb.base/index-cache-load-twice.c: New.
* gdb.base/index-cache-load-twice.exp: New.
Change-Id: Ie05474c44823fcdff852b73170dd28dfd66cb6a2
Simon Marchi [Wed, 17 Jun 2020 18:42:35 +0000 (14:42 -0400)]
gdb/regformats: remove unused regformats/reg-*.dat
I believe that the .dat files starting with `reg-` are the manually
written ones, the other being generated from xml files from the features
directory.
This patch removes the manually-written files that are no longer needed.
They are unused since the recent series that removed a bunch of
gdbserver ports.
gdb/ChangeLog:
* regformats/reg-arm.dat: Remove.
* regformats/reg-bfin.dat: Remove.
* regformats/reg-cris.dat: Remove.
* regformats/reg-crisv32.dat: Remove.
* regformats/reg-m32r.dat: Remove.
* regformats/reg-tilegx.dat: Remove.
* regformats/reg-tilegx32.dat: Remove.
Change-Id: I55ab6e45e3d0d316cda93f863c51fc9b867adfaa