Andrew Burgess [Tue, 18 May 2021 13:27:25 +0000 (14:27 +0100)]
gdb: change info sources to group results by objfile
Currently the 'info sources' command lists all of the known source
files together, regardless of their source, e.g. here is a session
debugging a test application that makes use of a shared library:
(gdb) info sources
Source files for which symbols have been read in:
/tmp/info-sources/test.c, /usr/include/stdc-predef.h,
/tmp/info-sources/header.h, /tmp/info-sources/helper.c
Source files for which symbols will be read in on demand:
(gdb)
In this commit I change the format of the 'info sources' results so
that the results are grouped by the object file that uses that source
file. Here's the same session with the new output format:
(gdb) info sources
/tmp/info-sources/test.x:
/tmp/info-sources/test.c, /usr/include/stdc-predef.h,
/tmp/info-sources/header.h
/lib64/ld-linux-x86-64.so.2:
(Objfile has no debug information.)
system-supplied DSO at 0x7ffff7fcf000:
(Objfile has no debug information.)
/tmp/info-sources/libhelper.so:
/tmp/info-sources/helper.c, /usr/include/stdc-predef.h,
/tmp/info-sources/header.h
/lib64/libc.so.6:
(Objfile has no debug information.)
(gdb)
Notice that in the new output some source files are repeated,
e.g. /tmp/info-sources/header.h, as multiple objfiles use this source
file.
Further, some object files are tagged with the message '(Objfile has
no debug information.)', it is also possible to see the message '(Full
debug information has not yet been read for this file.)', which is
printed when some symtabs within an objfile have not yet been
expanded.
All of the existing regular expression based filtering still works.
An original version of this patch added the new format as an option to
'info sources', however, it was felt that the new layout was so much
better than the old style that GDB should just switch to the new
result format completely.
gdb/ChangeLog:
* NEWS: Mention changes to 'info sources'.
* symtab.c (info_sources_filter::print): Delete.
(struct output_source_filename_data) <print_header>: Delete
declaration. <printed_filename_p>: New member function.
(output_source_filename_data::print_header): Delete.
(info_sources_worker): Update group-by-objfile style output to
make it CLI suitable, simplify non-group-by-objfile now this is
only used from the MI.
(info_sources_command): Make group-by-objfile be the default for
CLI info sources command.
* symtab.h (struct info_sources_filter) <print>: Delete.
gdb/doc/ChangeLog:
* gdb.texinfo (Symbols): Document new output format for 'info
sources'.
gdb/testsuite/ChangeLog:
* gdb.base/info_sources_2-header.h: New file.
* gdb.base/info_sources_2-lib.c: New file.
* gdb.base/info_sources_2-test.c: New file.
* gdb.base/info_sources_2.exp: New file.
Andrew Burgess [Tue, 18 May 2021 13:18:22 +0000 (14:18 +0100)]
gdb/mi: add new --group-by-objfile flag for -file-list-exec-source-files
This commit adds a new option '--group-by-objfile' to the MI command
-file-list-exec-source-files. With this option the output format is
changed; instead of a single list of source files the results are now
a list of objfiles. For each objfile all of the source files
associated with that objfile are listed.
Here is an example of the new output format taken from the
documentation (the newlines are added just for readability):
-file-list-exec-source-files --group-by-objfile
^done,files=[{filename="/tmp/info-sources/test.x",
debug-info="fully-read",
sources=[{file="test.c",
fullname="/tmp/info-sources/test.c",
debug-fully-read="true"},
{file="/usr/include/stdc-predef.h",
fullname="/usr/include/stdc-predef.h",
debug-fully-read="true"},
{file="header.h",
fullname="/tmp/info-sources/header.h",
debug-fully-read="true"}]},
{filename="/lib64/ld-linux-x86-64.so.2",
debug-info="none",
sources=[]},
{filename="system-supplied DSO at 0x7ffff7fcf000",
debug-info="none",
sources=[]},
{filename="/tmp/info-sources/libhelper.so",
debug-info="fully-read",
sources=[{file="helper.c",
fullname="/tmp/info-sources/helper.c",
debug-fully-read="true"},
{file="/usr/include/stdc-predef.h",
fullname="/usr/include/stdc-predef.h",
debug-fully-read="true"},
{file="header.h",
fullname="/tmp/info-sources/header.h",
debug-fully-read="true"}]},
{filename="/lib64/libc.so.6",
debug-info="none",
sources=[]}]
In the above output the 'debug-info' field associated with each
objfile will have one of the values 'none', 'partially-read', or
'fully-read'. For example, /lib64/libc.so.6 has the value 'none',
this indicates that this object file has no debug information
associated with it, unsurprisingly then, the sources list of this
object file is empty.
An object file that was compiled with debug, for example
/tmp/info-sources/libhelper.so, has the value 'fully-read' above
indicating that this object file does have debug information, and the
information is fully read into GDB. At different times this field
might have the value 'partially-read' indicating that that the object
file has debug information, but it has not been fully read into GDB
yet.
Source files can appear at most once for any single objfile, but can
appear multiple times in total, if the same source file is part of
multiple objfiles, for example /tmp/info-sources/header.h in the above
output.
The new output format is hidden behind a command option to ensure that
the default output is unchanged, this ensures backward compatibility.
The behaviour of the CLI "info sources" command is unchanged after
this commit.
gdb/ChangeLog:
* NEWS: Mention additions to -file-list-exec-source-files.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Add
--group-by-objfile option.
* symtab.c (isrc_flag_option_def): Rename to...
(isrc_match_flag_option_def): ...this.
(info_sources_option_defs): Rename to...
(info_sources_match_option_defs): ...this, and update to rename of
isrc_flag_option_def.
(struct filename_grouping_opts): New struct.
(isrc_grouping_flag_option_def): New type.
(info_sources_grouping_option_defs): New static global.
(make_info_sources_options_def_group): Update to return two option
groups.
(info_sources_command_completer): Update for changes to
make_info_sources_options_def_group.
(info_sources_worker): Add extra parameter, use this to display
alternative output format.
(info_sources_command): Pass extra parameter to
info_sources_worker.
(_initialize_symtab): Update for changes to
make_info_sources_options_def_group.
* symtab.h (info_sources_worker): Add extra parameter.
gdb/doc/ChangeLog:
* gdb.texinfo (GDB/MI File Commands): Document --group-by-objfile
extension for -file-list-exec-source-files.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-info-sources.exp: Add additional tests.
Andrew Burgess [Tue, 18 May 2021 12:46:19 +0000 (13:46 +0100)]
gdb/mi: add regexp filtering to -file-list-exec-source-files
This commit extends the existing MI command
-file-list-exec-source-files to provide the same regular expression
based filtering that the equivalent CLI command "info sources"
provides.
The new command syntax is:
-file-list-exec-source-files [--basename | --dirname] [--] [REGEXP]
All options are optional, which ensures the command is backward
compatible.
As part of this work I have unified the CLI and MI code.
As a result of the unified code I now provide additional information
in the MI command output, there is now a new field 'debug-fully-read'
included with each source file. This field which has the values
'true' or 'false', indicates if the source file is from a compilation
unit that has had its debug information fully read. However, as this
is additional information, a well written front-end should just ignore
this field if it doesn't understand it, so things should still be
backward compatible.
gdb/ChangeLog:
* NEWS: Mention additions to -file-list-exec-source-files.
* mi/mi-cmd-file.c (print_partial_file_name): Delete.
(mi_cmd_file_list_exec_source_files): Rewrite to handle command
options, and make use of info_sources_worker.
* symtab.c (struct info_sources_filter): Moved to symtab.h.
(info_sources_filter::print): Take uiout argument, produce output
through uiout.
(struct output_source_filename_data)
<output_source_filename_data>: Take uiout argument, store into
m_uiout. <output>: Rewrite comment, add additional arguments to
declaration. <operator()>: Send more arguments to
output. <m_uiout>: New member variable.
(output_source_filename_data::output): Take extra arguments,
produce output through m_uiout, and structure for MI.
(output_source_filename_data::print_header): Produce output
through m_uiout.
(info_sources_worker): New function, the implementation is taken
from info_sources_command, but modified so produce output through
a ui_out.
(info_sources_command): The second half of this function has gone
to become info_sources_worker.
* symtab.h (struct info_sources_filter): Moved from symtab.c, add
extra parameter to print member function.
(info_sources_worker): Declare.
gdb/doc/ChangeLog:
* gdb.texinfo (GDB/MI File Commands): Document extensions to
-file-list-exec-source-files.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/dw2-filename.exp: Update expected results.
* gdb.mi/mi-file.exp: Likewise.
* gdb.mi/mi-info-sources-base.c: New file.
* gdb.mi/mi-info-sources.c: New file.
* gdb.mi/mi-info-sources.exp: New file.
Andrew Burgess [Thu, 1 Apr 2021 13:51:24 +0000 (14:51 +0100)]
gdb: make struct output_source_filename_data more C++ like
In a future commit I'm going to be making some changes to the 'info
sources' command. While looking at the code I noticed that things
could be improved by making struct output_source_filename_data more
C++ like (private member variables, and more member functions).
That's what this commit does.
The 'info sources' filename filtering is split out into a separate
class in this commit. In a future commit this new filter
class (info_sources_filter) will move into the header file and be used
from the MI code.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* symtab.c (struct info_sources_filter): New.
(info_sources_filter::info_sources_filter): New function.
(info_sources_filter::matches): New function.
(info_sources_filter::print): New function.
(struct filename_partial_match_opts): Moved to later in the file
and update the comment.
(struct output_source_filename_data)
<output_source_filename_data>: New constructor. <regexp>: Delete,
this is now in info_sources_filter. <c_regexp>: Delete, this is
now in info_sources_filter. <reset_output>: New member function.
<filename_seen_cache>: Rename to m_filename_seen_cache, change
from being a pointer, to being an actual object. <first>: Rename
to m_first. <print_header>: New member function. <partial_match>:
Delete.
(output_source_filename_data::output): Update now
m_filename_seen_cache is no longer a pointer, and for other member
variable name changes. Add a header comment.
(print_info_sources_header): Renamed to...
(output_source_filename_data::print_header): ...this. Update now
it's a member function and to take account of member variable
renaming.
(info_sources_command): Add a header comment, delete stack local
filename_seen_cache, initialization of output_source_filename_data
is now done by the constructor. Call print_header member function
instead of print_info_sources_header, call reset_output member
function instead of manually performing the reset.
Andrew Burgess [Thu, 15 Apr 2021 10:29:55 +0000 (11:29 +0100)]
gdb: add new function quick_symbol_functions::has_unexpanded_symbols
Adds a new function to the quick_symbol_functions API to let us know
if there are any unexpanded symbols. This functionality is required
by a later commit. After this commit the functionality is unused, and
untested.
The new function objfile::has_unexpanded_symtabs is added to the
symfile-debug.c file which is a little strange, but this
is (currently) where many of the other objfile::* functions (that call
onto the quick_symbol_functions) are defined, so I'm reluctant to
break this pattern.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* dwarf2/read.c (struct dwarf2_base_index_functions)
<has_unexpanded_symtabs>: Declare.
(dwarf2_base_index_functions::has_unexpanded_symtabs): Define new
function.
* objfiles.h (struct objfile) <has_unexpanded_symtabs>: Declare.
* psympriv.h (struct psymbol_functions) <has_unexpanded_symtabs>:
Declare.
* psymtab.c (psymbol_functions::has_unexpanded_symtabs): Define
new function.
* quick-symbol.h (struct quick_symbol_functions)
<has_unexpanded_symtabs>: Declare.
* symfile-debug.c (objfile::has_unexpanded_symtabs): Define new
function.
Andrew Burgess [Wed, 23 Jun 2021 21:55:16 +0000 (22:55 +0100)]
gdb: fix invalid arg coercion when calling static member functions
In this commit:
commit
7022349d5c86bae74b49225515f42d2e221bd368
Date: Mon Sep 4 20:21:13 2017 +0100
Stop assuming no-debug-info functions return int
A new if case was added to call_function_by_hand_dummy to decide if a
function should be considered prototyped or not. Previously the code
was structured like this:
if (COND_1)
ACTION_1
else if (COND_2)
ACTION_2
else
ACTION_3
With the new block the code now looks like this:
if (COND_1)
ACTION_1
if (NEW_COND)
NEW_ACTION
else if (COND_2)
ACTION_2
else
ACTION_3
Notice the new block was added as and 'if' not 'else if'. I'm running
into a case where GDB executes ACTION_1 and then ACTION_2. Prior to
the above commit GDB would only have executed ACTION_1.
The actions in the code in question are trying to figure out if a
function should be considered prototyped or not. When a function is
not prototyped some arguments will be coerced, e.g. floats to doubles.
The COND_1 / ACTION_1 are a very broad, any member function should be
considered prototyped, however, after the above patch GDB is now
executing the later ACTION_2 which checks to see if the function's
type has the 'prototyped' flag set - this is not the case for the
member functions I'm testing, and so GDB treats the function as
unprototyped and casts the float argument to a double.
I believe that adding the new check as 'if' rather than 'else if' was
a mistake, and so in this commit I add in the missing 'else'.
gdb/ChangeLog:
* infcall.c (call_function_by_hand_dummy): Add missing 'else' when
setting prototyped flag.
gdb/testsuite/ChangeLog:
* gdb.cp/method-call-in-c.cc (struct foo_type): Add static member
function static_method.
(global_var): New global.
(main): Use new static_method to ensure it is compiled in.
* gdb.cp/method-call-in-c.exp: Test calls to static member
function.
Andrew Burgess [Tue, 22 Jun 2021 18:27:53 +0000 (19:27 +0100)]
gdb: use gdb::optional instead of passing a pointer to gdb::array_view
Following on from the previous commit, this commit changes the API of
value_struct_elt to take gdb::optional<gdb::array_view<value *>>
instead of a pointer to the gdb::array_view.
This makes the optional nature of the array_view parameter explicit.
This commit is purely a refactoring commit, there should be no user
visible change after this commit.
I have deliberately kept this refactor separate from the previous two
commits as this is a more extensive change, and I'm not 100% sure that
using gdb::optional for the parameter type, instead of a pointer, is
going to be to everyone's taste. If there's push back on this patch
then this one can be dropped from the series.
gdb/ChangeLog:
* ada-lang.c (desc_bounds): Use '{}' instead of NULL to indicate
an empty gdb::optional when calling value_struct_elt.
(desc_data): Likewise.
(desc_one_bound): Likewise.
* eval.c (structop_base_operation::evaluate_funcall): Pass
gdb::array_view, not a gdb::array_view* to value_struct_elt.
(eval_op_structop_struct): Use '{}' instead of NULL to indicate
an empty gdb::optional when calling value_struct_elt.
(eval_op_structop_ptr): Likewise.
* f-lang.c (fortran_structop_operation::evaluate): Likewise.
* guile/scm-value.c (gdbscm_value_field): Likewise.
* m2-lang.c (eval_op_m2_high): Likewise.
(eval_op_m2_subscript): Likewise.
* opencl-lang.c (opencl_structop_operation::evaluate): Likewise.
* python/py-value.c (valpy_getitem): Likewise.
* rust-lang.c (rust_val_print_str): Likewise.
(rust_range): Likewise.
(rust_subscript): Likewise.
(eval_op_rust_structop): Likewise.
(rust_aggregate_operation::evaluate): Likewise.
* valarith.c (value_user_defined_op): Likewise.
* valops.c (search_struct_method): Change parameter type, update
function body accordingly, and update header comment.
(value_struct_elt): Change parameter type, update function body
accordingly.
* value.h (value_struct_elt): Update declaration.
Andrew Burgess [Tue, 22 Jun 2021 09:17:53 +0000 (10:17 +0100)]
gdb: replace NULL terminated array with array_view
After the previous commit, this commit updates the value_struct_elt
function to take an array_view rather than a NULL terminated array of
values.
The requirement for a NULL terminated array of values actually stems
from typecmp, so the change from an array to array_view needs to be
propagated through to this function.
While making this change I noticed that this fixes another bug, in
value_x_binop and value_x_unop GDB creates an array of values which
doesn't have a NULL at the end. An array_view of this array is passed
to value_user_defined_op, which then unpacks the array_view and passed
the raw array to value_struct_elt, but only if the language is not
C++.
As value_x_binop and value_x_unop can only request member functions
with the names of C++ operators, then most of the time, assuming the
inferior is not a C++ program, then GDB will not find a matching
member function with the call to value_struct_elt, and so typecmp will
never be called, and so, GDB will avoid undefined behaviour.
However, it is worth remembering that, when GDB's language is set to
"auto", the current language is selected based on the language of the
current compilation unit. As C++ programs usually link against libc,
which is written in C, then, if the inferior is stopped in libc GDB
will set the language to C. And so, it is possible that we will end
up using value_struct_elt to try and lookup, and match, a C++
operator. If this occurs then GDB will experience undefined
behaviour.
I have extended the test added in the previous commit to also cover
this case.
Finally, this commit changes the API from passing around a pointer to
an array to passing around a pointer to an array_view. The reason for
this is that we need to be able to distinguish between the cases where
we call value_struct_elt with no arguments, i.e. we are looking up a
struct member, but we either don't have the arguments we want to pass
yet, or we don't expect there to be any need for GDB to use the
argument types to resolve any overloading; and the second case where
we call value_struct_elt looking for a function that takes no
arguments, that is, the argument list is empty.
NOTE: While writing this I realise that if we pass an array_view at
all then it will always have at least one item in it, the `this'
pointer for the object we are planning to call the method on. So we
could, I guess, pass an empty array_view to indicate the case where we
don't know anything about the arguments, and when the array_view is
length 1 or more, it means we do have the arguments. However, though
we could do this, I don't think this would be better, the length 0 vs
length 1 difference seems a little too subtle, I think that there's a
better solution...
I think a better solution would be to wrap the array_view in a
gdb::optional, this would make the whole, do we have an array view or
not question explicit.
I haven't done this as part of this commit as making that change is
much more extensive, every user of value_struct_elt will need to be
updated, and as this commit already contains a bug fix, I wanted to
keep the large refactoring in a separate commit, so, check out the
next commit for the use of gdb::optional.
gdb/ChangeLog:
PR gdb/27994
* eval.c (structop_base_operation::evaluate_funcall): Pass
array_view instead of array to value_struct_elt.
* valarith.c (value_user_defined_op): Likewise.
* valops.c (typecmp): Change parameter type from array pointer to
array_view. Update header comment, and update body accordingly.
(search_struct_method): Likewise.
(value_struct_elt): Likewise.
* value.h (value_struct_elt): Update declaration.
gdb/testsuite/ChangeLog:
PR gdb/27994
* gdb.cp/method-call-in-c.cc (struct foo_type): Add operator+=,
change initial value of var member variable.
(main): Make use of foo_type's operator+=.
* gdb.cp/method-call-in-c.exp: Test use of operator+=.
Andrew Burgess [Mon, 21 Jun 2021 22:33:11 +0000 (23:33 +0100)]
gdb: fix regression in evaluate_funcall for non C++ like cases
This regression, as it is exposed by the test added in this commit,
first became noticable with this commit:
commit
d182f2797922a305fbd1ef6a483cc39a56b43e02
Date: Mon Mar 8 07:27:57 2021 -0700
Convert c-exp.y to use operations
But, this commit only added converted the C expression parser to make
use of code that was added in this commit:
commit
a00b7254fb614af557de7ae7cc0eb39a0ce0e408
Date: Mon Mar 8 07:27:57 2021 -0700
Implement function call operations
And it was this second commit that actually introduced the bugs (there
are two).
In structop_base_operation::evaluate_funcall we build up an argument
list in the vector vals. Later in this function the argument list
might be passed to value_struct_elt.
Prior to commit
a00b7254fb614 the vals vector (or argvec as it used to
be called) stored the value for the function callee in the argvec at
index 0. This 'callee' value is what ends up being passed to
evaluate_subexp_do_call, and represents the function to be called, the
value contents are the address of the function, and the value type is
the function signature. The remaining items held in the argvec were
the values to pass to the function. For a non-static member function
the `this' pointer would be at index 1 in the array.
After commit
a00b7254fb614 this callee value is now held in a separate
variable, not the vals array. So, for non-static member functions,
the `this' pointer is now at index 0, with any other arguments after
that.
What this means is that previous, when we called value_struct_elt we
would pass the address of argvec[1] as this was the first argument.
But now we should be passing the address of vals[0]. Unfortunately,
we are still passing vals[1], effectively skipping the first
argument.
The second issue is that, prior to commit
a00b7254fb614, the argvec
array was NULL terminated. This is required as value_struct_elt
calls search_struct_method, which calls typecmp, and typecmp requires
that the array have a NULL at the end.
After commit
a00b7254fb614 this NULL has been lost, and we are
therefore violating the API requirements of typecmp.
This commit fixes both of these regressions. I also extended the
header comments on search_struct_method and value_struct_elt to make
it clearer that the array required a NULL marker at the end.
You will notice in the test attached to this commit that I test
calling a non-static member function, but not calling a static member
function. The reason for this is that calling static member functions
is currently broken due to a different bug. That will be fixed in a
later patch in this series, at which time I'll add a test for calling
a static member function.
gdb/ChangeLog:
PR gdb/27994
* eval.c (structop_base_operation::evaluate_funcall): Add a
nullptr to the end of the args array, which should not be included
in the argument array_view. Pass all the arguments through to
value_struct_elt.
* valops.c (search_struct_method): Update header comment.
(value_struct_elt): Likewise.
gdb/testsuite/ChangeLog:
PR gdb/27994
* gdb.cp/method-call-in-c.cc: New file.
* gdb.cp/method-call-in-c.exp: New file.
Tom Tromey [Fri, 25 Jun 2021 18:34:41 +0000 (12:34 -0600)]
Change how .debug_aranges padding is skipped
When GCC emits .debug_aranges, it adds padding to align the contents
to two times the address size. GCC has done this for many years --
but there is nothing in the DWARF standard that says this should be
done, and LLVM does not seem to add this padding.
It's simple to detect if the padding exists, though: if the contents
of one .debug_aranges CU (excluding the header) are not a multiple of
the alignment that GCC uses, then anything extra must be padding.
This patch changes gdb to correctly read both styles. It removes the
requirement that the padding bytes be zero, as this seemed
unnecessarily pedantic to me.
gdb/ChangeLog
2021-06-25 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (create_addrmap_from_aranges): Change padding
logic.
gdb/testsuite/ChangeLog
2021-06-25 Tom Tromey <tom@tromey.com>
* lib/gdb.exp (add_gdb_index, ensure_gdb_index): Add "style"
parameter.
* gdb.rust/dwindex.exp: New file.
* gdb.rust/dwindex.rs: New file.
Tom Tromey [Fri, 25 Jun 2021 18:23:04 +0000 (12:23 -0600)]
Remove dwarf2_cu::language
dwarf2_cu has a 'language' value, but dwarf2_per_cu_data also holds a
value of this same type. There doesn't seem to be any reason to keep
two copies of this value. This patch removes the field from
dwarf2_cu, and arranges to set the value in the per-CU object instead.
Note that the value must still be set when expanding the full CU.
This is needed because the CUs will not be scanned when a DWARF index
is in use.
gdb/ChangeLog
2021-06-25 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (process_psymtab_comp_unit): Don't set 'lang'.
(scan_partial_symbols, partial_die_parent_scope)
(add_partial_symbol, add_partial_subprogram)
(compute_delayed_physnames, rust_union_quirks)
(process_full_comp_unit, process_full_type_unit)
(process_imported_unit_die, process_die, dw2_linkage_name)
(dwarf2_compute_name, dwarf2_physname, read_import_statement)
(read_file_scope, queue_and_load_dwo_tu, read_func_scope)
(read_variable, dwarf2_get_subprogram_pc_bounds)
(dwarf2_attach_fields_to_type, dwarf2_add_member_fn)
(dwarf2_attach_fn_fields_to_type)
(quirk_ada_thick_pointer_struct, read_structure_type)
(handle_struct_member_die, process_structure_scope)
(read_array_type, read_array_order, prototyped_function_p)
(read_subroutine_type, dwarf2_init_complex_target_type)
(read_base_type, read_subrange_type, read_unspecified_type)
(load_partial_dies, partial_die_info::fixup, set_cu_language)
(new_symbol, need_gnat_info, determine_prefix, typename_concat)
(dwarf2_canonicalize_name, follow_die_offset)
(prepare_one_comp_unit): Update.
* dwarf2/cu.c (dwarf2_cu::start_symtab): Update.
Tom Tromey [Fri, 25 Jun 2021 18:23:04 +0000 (12:23 -0600)]
Consolidate CU language setting
The DWARF reader currently sets the CU's language in two different
spots. It is primarily done in prepare_one_comp_unit, but
read_file_scope also checks the producer and may change the language
based on the result.
This patch consolidates all language-setting into
prepare_one_comp_unit. set_cu_language is renamed and changed not to
set language_defn; instead that is done in prepare_one_comp_unit after
the correct language enum value is chosen.
This fixes a minor latent bug, which is that read_file_scope could set
the language enum value to language_opencl, but then neglected to
reset language_defn in this case.
gdb/ChangeLog
2021-06-25 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (read_file_scope): Don't call set_cu_language.
(dwarf_lang_to_enum_language): Rename from set_cu_language. Don't
set language_defn. Handle DW_LANG_OpenCL.
(prepare_one_comp_unit): Check producer and set language_defn.
Andrew Burgess [Wed, 5 May 2021 14:26:28 +0000 (15:26 +0100)]
gdb/python: allow for catchpoint type breakpoints in python
This commit adds initial support for catchpoints to the python
breakpoint API.
This commit adds a BP_CATCHPOINT constant which corresponds to
GDB's internal bp_catchpoint. The new constant is documented in the
manual.
The user can't create breakpoints with type BP_CATCHPOINT after this
commit, but breakpoints that already exist, obtained with the
`gdb.breakpoints` function, can now have this type. Additionally,
when a stop event is reported for hitting a catchpoint, GDB will now
report a BreakpointEvent with the attached breakpoint being of type
BP_CATCHPOINT - previously GDB would report a generic StopEvent in
this situation.
gdb/ChangeLog:
* NEWS: Mention Python BP_CATCHPOINT feature.
* python/py-breakpoint.c (pybp_codes): Add bp_catchpoint support.
(bppy_init): Likewise.
(gdbpy_breakpoint_created): Likewise.
gdb/doc/ChangeLog:
* python.texinfo (Breakpoints In Python): Add BP_CATCHPOINT
description.
gdb/testsuite/ChangeLog:
* gdb.python/py-breakpoint.c (do_throw): New function.
(main): Call do_throw.
* gdb.python/py-breakpoint.exp (test_catchpoints): New proc.
Andrew Burgess [Wed, 5 May 2021 15:53:09 +0000 (16:53 +0100)]
gdb/guile: allow for catchpoint type breakpoints in guile
This commit adds initial support for catchpoints to the guile
breakpoint API.
This commit adds a BP_CATCHPOINT constant which corresponds to
GDB's internal bp_catchpoint. The new constant is documented in the
manual.
The user can't create breakpoints with type BP_CATCHPOINT after this
commit, but breakpoints that already exist, obtained with
the (breakpoints) function, can now have this type.
gdb/ChangeLog:
* guile/scm-breakpoint.c (bpscm_type_to_string): Handle
bp_catchpoint.
(bpscm_want_scm_wrapper_p): Likewise.
(gdbscm_make_breakpoint): Likewise.
(breakpoint_integer_constants): Likewise.
gdb/doc/ChangeLog:
* guile.texinfo (Breakpoints In Guile): Add BP_CATCHPOINT
description.
gdb/testsuite/ChangeLog:
* gdb.guile/scm-breakpoint.exp (test_catchpoints): New proc.
Andrew Burgess [Mon, 10 May 2021 08:53:52 +0000 (09:53 +0100)]
gdb/guile: improve the errors when creating breakpoints
When creating a breakpoint using the guile API, if an invalid
breakpoint type number was used then the error would report the wrong
argument position, like this:
(gdb) guile (define wp2 (make-breakpoint "result" #:wp-class WP_WRITE #:type 999))
ERROR: In procedure make-breakpoint:
ERROR: In procedure gdbscm_make_breakpoint: Out of range: invalid breakpoint type in position 3: 999
Error while executing Scheme code.
(gdb)
The 'position 3' here is actually pointing at WP_WRITE, when it should
say 'position 5' and point to the 999. This commit fixes this.
However, you also get errors like this:
(gdb) guile (define wp2 (make-breakpoint "result" #:wp-class WP_WRITE #:type BP_NONE))
ERROR: In procedure make-breakpoint:
ERROR: In procedure gdbscm_make_breakpoint: Out of range: invalid breakpoint type in position 3: 0
Error while executing Scheme code.
The BP_NONE is a valid breakpoint type, it's just not valid for
creating breakpoints through the 'make-breakpoint' API. The use of
'0' in the error message (which is the value of BP_NONE) is not
great. This commit changes the error in this case to:
(gdb) guile (define wp2 (make-breakpoint "result" #:wp-class WP_WRITE #:type BP_NONE))
ERROR: In procedure make-breakpoint:
ERROR: In procedure gdbscm_make_breakpoint: unsupported breakpoint type in position 5: "BP_NONE"
Error while executing Scheme code.
Which seems better; we now use the name of the type, and report that
this type is unsupported.
gdb/ChangeLog:
* guile/scm-breakpoint.c (gdbscm_make_breakpoint): Split the error
for invalid breakpoint numbers, and unsupported breakpoint
numbers.
gdb/testsuite/ChangeLog:
* gdb.guile/scm-breakpoint.exp (test_watchpoints): Add new tests.
Carl Love [Wed, 16 Jun 2021 17:07:39 +0000 (12:07 -0500)]
Add ISA 3.1 check to powerpc-plxv-norel.exp
This patch adds a file with the ISA 3.1 check. The ISA 3.1 check is
added to the test to ensure the test is only run on ISA 3.1 or newer.
gdb/testsuite/ChangeLog
2021-06-25 Carl Love <cel@us.ibm.com>
* gdb.arch/powerpc-plxv-norel.exp: Add call to skip_power_isa_3_1_tests.
* lib/gdb.exp(skip_power_isa_3_1_tests): New gdb_caching_proc test.
Tom Tromey [Fri, 25 Jun 2021 14:40:37 +0000 (08:40 -0600)]
Use gdb::function_view in addrmap_foreach
While working on the DWARF psymtab replacement, I needed
addrmap_foreach to accept a gdb::function_view. This seemed like a
worthwhile change on its own, so I've written it separately for
submission.
Regression tested on x86-64 Fedora 32.
gdb/ChangeLog
2021-06-25 Tom Tromey <tom@tromey.com>
* dwarf2/index-write.c (struct addrmap_index_data): Add
initializers.
<operator()>: Declare.
(addrmap_index_data::operator()): Rename from
add_address_entry_worker. Remove 'datap' parameter.
(write_address_map): Update.
* psymtab.c (struct dump_psymtab_addrmap_data): Remove
(dump_psymtab_addrmap_1): Remove 'data' parameter, add other
parameters.
(dump_psymtab_addrmap): Update.
* addrmap.c (struct addrmap_funcs) <foreach>: Remove 'data'
parameter.
(addrmap_foreach, addrmap_fixed_foreach): Likewise.
(struct mutable_foreach_data): Remove.
(addrmap_mutable_foreach_worker): Update.
(addrmap_mutable_foreach): Remove 'data' parameter.
* addrmap.h (addrmap_foreach_fn): Use gdb::function_view.
(addrmap_foreach): Remove 'data' parameter.
Tom Tromey [Fri, 25 Jun 2021 14:01:15 +0000 (08:01 -0600)]
Decode Ada types in Python layer
GNAT emits encoded type names, but these aren't usually of interest to
users. The Ada language code in gdb hides this oddity -- but the
Python layer does not. This patch changes the Python code to use the
decoded Ada type name, when appropriate.
I looked at decoding Ada type names during construction, as that would
be cleaner. However, the Ada support in gdb relies on the encodings
at various points, so this isn't really doable right now.
2021-06-25 Tom Tromey <tromey@adacore.com>
* python/py-type.c (typy_get_name): Decode an Ada type name.
gdb/testsuite/ChangeLog
2021-06-25 Tom Tromey <tromey@adacore.com>
* gdb.ada/py_range.exp: Add type name test cases.
Tom Tromey [Fri, 25 Jun 2021 14:01:15 +0000 (08:01 -0600)]
Add non-wrapping mode to ada_decode
When ada_decode encounters a name that it cannot decode, it simply
wraps it in <...>, which is used elsewhere in the Ada code to indicate
that a verbatim match should be done.
A subequent patch needed the ability to suppress this wrapping, so
this patch adds a new mode to ada_decode.
2021-06-25 Tom Tromey <tromey@adacore.com>
* ada-lang.c (ada_decode): Add wrap parameter.
* ada-lang.h (ada_decode): Add wrap parameter.
Luis Machado [Mon, 17 May 2021 14:41:09 +0000 (11:41 -0300)]
Update the core file architecture if a target description is present
At the moment, the core target has its own gdbarch (m_core_gdbarch), and that
gets set from the core_bfd on the core target's constructor.
That gdbarch doesn't contain a target description because it is constructed
before we get a chance to fetch the target description.
As a result, some hooks that depend on the target description being set are
not set, and that leads to problems. One of the examples is
gdbarch_report_signal_info, which is used to show AArch64 tag violation
information.
Fix this by reading the target description before fetching the core file's
gdbarch.
gdb/ChangeLog:
2021-06-25 Luis Machado <luis.machado@linaro.org>
* corelow.c (core_target::core_target) Update to read target
description.
Mike Frysinger [Thu, 24 Jun 2021 00:19:53 +0000 (20:19 -0400)]
sim: cris: fix a few missing prototype warnings
Add a stub prototype for the dump function meant to be called by devs
from gdb, and trim unused functions that aren't supposed to be used.
Mike Frysinger [Thu, 24 Jun 2021 04:14:15 +0000 (00:14 -0400)]
sim: callback: extend syscall interface to handle 7 args
The Linux syscall interface, depending on architecture, handles up to
7 arguments. Extend the callback API to handle those.
GDB Administrator [Fri, 25 Jun 2021 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Thu, 24 Jun 2021 10:55:08 +0000 (12:55 +0200)]
[gdb/testsuite] Fix duplicate in gdb.base/info-macros.exp
When running test-case gdb.base/info-macros.exp, I run into:
...
PASS: gdb.base/info-macros.exp: info macro --
PASS: gdb.base/info-macros.exp: info macro --
DUPLICATE: gdb.base/info-macros.exp: info macro --
PASS: gdb.base/info-macros.exp: info macro --
...
These messages come from gdb_test calls using the following commands:
- "info macro --"
- "info macro -- "
- "info macro -- ".
Apparantly the test names get stripped of trailing whitespace, and the first
two end up identical.
Fix this by explicitly specifying an <EOL> after the trailing whitespace in
the test name, such that we have:
...
PASS: gdb.base/info-macros.exp: info macro --
PASS: gdb.base/info-macros.exp: info macro -- <EOL>
PASS: gdb.base/info-macros.exp: info macro -- <EOL>
...
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-06-24 Tom de Vries <tdevries@suse.de>
* gdb.base/info-macros.exp: Add <EOL> after trailing whitespace in
test names.
Tom de Vries [Thu, 24 Jun 2021 10:08:54 +0000 (12:08 +0200)]
[gdb/testsuite] Fix duplicate in gdb.base/argv0-symlink.exp
I found the following duplicates in gdb.base/argv0-symlink.exp:
...
DUPLICATE: gdb.base/argv0-symlink.exp: set print repeats 10000
DUPLICATE: gdb.base/argv0-symlink.exp: set print elements 10000
...
Fix these by using with_test_prefix "file symlink" / "dir symlink".
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-06-24 Tom de Vries <tdevries@suse.de>
* gdb.base/argv0-symlink.exp: Use with_test_prefix.
Clément Chigot [Tue, 22 Jun 2021 08:15:06 +0000 (10:15 +0200)]
gas: update csect alignment for PPC prefixed instructions on XCOFF
Power10 prefixed instructions must not cross 64-byte boundaries.
This is already handled.
However, on XCOFF, the csect must be updated to match the new
alignment.
* config/tc-ppc.c (md_assemble): Update ppc_current_csect
alignment when finding prefixed instructions.
Mike Frysinger [Mon, 21 Jun 2021 03:50:35 +0000 (23:50 -0400)]
sim: syscall: handle killing the sim itself
If code tries to send a signal to itself, the callback layer ignores
it and forces the caller to handle it. This allows the sim to turn
that into an engine halt rather than actually killing the sim.
Mike Frysinger [Mon, 21 Jun 2021 03:42:20 +0000 (23:42 -0400)]
sim: cris: override getpid callback
The cris linux syscall layers assume getpid returns a constant,
so add a custom function to provide that.
Mike Frysinger [Mon, 21 Jun 2021 03:06:10 +0000 (23:06 -0400)]
sim: callback: add a kill interface
This will make it easier to emulate the syscall. If the kill target
is the sim itself, don't do anything. This forces the higher layers
to make a decision as to how to handle this event: like halting the
overall engine process.
GDB Administrator [Thu, 24 Jun 2021 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in
Mike Frysinger [Wed, 23 Jun 2021 02:31:12 +0000 (22:31 -0400)]
sim: switch common srcdir to abs_srcdir
We rewrite srcdir in subdir Makefiles that we generate from the common
parent dir since it points to the parent dir. Since @srcdir@ can be a
variety of formats (relative & absolute), switch to @abs_srcdir@ which
is a lot easier to adjust. Our use of srcdir in here should handle it.
Tom de Vries [Wed, 23 Jun 2021 21:46:04 +0000 (23:46 +0200)]
[gdb/testsuite] Rewrite gdb_test_lines
On Ubuntu 20.04, when the debug info package for libc is not installed,
I get:
FAIL: gdb.base/info-types-c++.exp: info types
FAIL: gdb.base/info-types-c.exp: info types
The reason is that the output of info types is exactly:
(gdb) info types
All defined types:
File /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.base/info-types.c:
52: typedef enum {...} anon_enum_t;
45: typedef struct {...} anon_struct_t;
68: typedef union {...} anon_union_t;
28: typedef struct baz_t baz;
31: typedef struct baz_t * baz_ptr;
21: struct baz_t;
double
33: enum enum_t;
float
int
38: typedef enum enum_t my_enum_t;
17: typedef float my_float_t;
16: typedef int my_int_t;
54: typedef enum {...} nested_anon_enum_t;
47: typedef struct {...} nested_anon_struct_t;
70: typedef union {...} nested_anon_union_t;
30: typedef struct baz_t nested_baz;
29: typedef struct baz_t nested_baz_t;
39: typedef enum enum_t nested_enum_t;
19: typedef float nested_float_t;
18: typedef int nested_int_t;
62: typedef union union_t nested_union_t;
56: union union_t;
unsigned int
(gdb)
The lines we expect in the test contain an empty line at the end:
...
"62:\[\t \]+typedef union union_t nested_union_t;" \
"56:\[\t \]+union union_t;" \
"--optional" "\[\t \]+unsigned int" \
""]
This is written with the supposition that other files will be listed, so
an empty line will be included to separate the symbols from this file
from the next one. This empty line is not included when info-types.c is
the only file listed.
Fix this by rewriting gdb_test_lines to accept a single, plain tcl multiline
regexp, such that we can write:
...
"62:\[\t \]+typedef union union_t nested_union_t;" \
"56:\[\t \]+union union_t;(" \
"\[\t \]+unsigned int)?" \
"($|\r\n.*)"]
...
Tested affected test-cases:
- gdb.base/info-types-c.exp
- gdb.base/info-types-c++.exp
- gdb.base/info-macros.exp
- gdb.cp/cplusfuncs.exp
on x86_64-linux (openSUSE Leap 15.2), both with check and check-read1.
Also tested the first two with gcc-4.8.
Also tested on ubuntu 18.04.
gdb/testsuite/ChangeLog:
2021-06-23 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gdb_test_lines): Rewrite to accept single
multiline tcl regexp.
* gdb.base/info-types.exp.tcl: Update. Make empty line at end of
regexp optional.
* gdb.base/info-macros.exp: Update.
* gdb.cp/cplusfuncs.exp: Update.
GDB Administrator [Wed, 23 Jun 2021 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in
Mike Frysinger [Mon, 21 Jun 2021 04:10:22 +0000 (00:10 -0400)]
sim: cris: fix a few warnings
Include header for hw funcs called, adjust prototype to match the
args given to it, and adjust cast to match the function.
Mike Frysinger [Sun, 20 Jun 2021 16:53:38 +0000 (12:53 -0400)]
sim: callback: add missing cb_target_to_host_signal
There's been a prototype for this forever, but the implementation was
missing. Probably because there weren't any callers, but we'll start
using it to implement the kill function.
Mike Frysinger [Mon, 21 Jun 2021 02:55:44 +0000 (22:55 -0400)]
sim: callback: generate signal map
We've been generating the syscall/errno/open maps, but not the signal
map, even though we've been including them in the source constants.
Mike Frysinger [Sun, 20 Jun 2021 16:38:27 +0000 (12:38 -0400)]
sim: callback: add a getpid interface
Rather than hit the OS interface directly, use the existing callback
layer so the instantiator can decide behavior.
Mike Frysinger [Sun, 20 Jun 2021 05:04:34 +0000 (01:04 -0400)]
sim: rx: merge with common configure script
Move the unique configure flag to acinclude.m4 so the common code
can include it, then delete the rx configure logic entirely.
Mike Frysinger [Sun, 20 Jun 2021 01:33:30 +0000 (21:33 -0400)]
sim: drop configure scripts for simple ports
These ports only use the pieces that have been unified, so we can
merge them into the common configure script and get rid of their
unique one entirely.
We still compile & link separate run programs, and have dedicated
subdir Makefiles, but the configure script portion is merged.
Simon Marchi [Tue, 22 Jun 2021 19:07:50 +0000 (15:07 -0400)]
gdb: fix python/lib/gdb/__init__.py formatting
Run black to fix this formatting.
gdb/ChangeLog:
* python/lib/gdb/__init__.py: Format.
Change-Id: I68ea306d1991bf7243b2c8aeeb11719d668851e5
Simon Marchi [Tue, 22 Jun 2021 18:57:29 +0000 (14:57 -0400)]
gdb: remove unnecessary parameter wait_ptid from do_target_wait
do_target_wait has a wait_ptid parameter, to filter what ptid we wait
on. The sole caller of do_target_wait passes minus_one_ptid, meaning
"all ptids". So in practice, this parameter is not needed, remove it.
gdb/ChangeLog:
* infrun.c (do_target_wait): Remove wait_ptid parameter.
(fetch_inferior_event): Adjust.
Change-Id: I54119beb43db678e4b2081dc490f89e7ff878e74
Simon Marchi [Tue, 22 Jun 2021 18:16:01 +0000 (14:16 -0400)]
gdb/python: print name of unwinder that claimed frame in debug message
If we have multiple registered unwinders, this will helps identify which
unwinder was chosen and make it easier to track down potential problems.
Unwinders have a mandatory name argument, which we can use in the
message.
First, make gdb._execute_unwinders return a tuple containing the name,
in addition to the UnwindInfo. Then, make pyuw_sniffer include the name
in the debug message.
I moved the debug message earlier. I think it's good to print it as
early as possible, so that we see it in case an assert is hit in the
loop below, for example.
gdb/ChangeLog:
* python/lib/gdb/__init__.py (_execute_unwinders): Return tuple
with name of chosen unwinder.
* python/py-unwind.c (pyuw_sniffer): Print name of chosen
unwinder in debug message.
Change-Id: Id603545b44a97df2a39dd1872fe1f38ad5059f03
Andreas Schwab [Mon, 21 Jun 2021 09:38:23 +0000 (11:38 +0200)]
gdb: Support DW_LLE_start_end
Without that it is impossible to debug on riscv64.
gdb/
PR symtab/27999
* dwarf2/loc.c (decode_debug_loclists_addresses): Support
DW_LLE_start_end.
gdb/testsuite/
PR symtab/27999
* lib/dwarf.exp (start_end): New proc inside loclists.
* gdb.dwarf2/loclists-start-end.exp: New file.
* gdb.dwarf2/loclists-start-end.c: New file.
Tom de Vries [Tue, 22 Jun 2021 13:58:09 +0000 (15:58 +0200)]
[gdb/testsuite] Add gdb.dwarf2/imported-unit-c.exp
This test-case is intended to excercise this code in process_imported_unit_die:
...
/* We're importing a C++ compilation unit with tag DW_TAG_compile_unit
into another compilation unit, at root level. Regard this as a hint,
and ignore it. */
if (die->parent && die->parent->parent == NULL
&& per_cu->unit_type == DW_UT_compile
&& per_cu->lang == language_cplus)
return;
...
in the sense that the test-case should fail if the
"per_cu->lang == language_cplus" clause is removed.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-06-22 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/imported-unit-c.exp: New file.
Nelson Chu [Tue, 22 Jun 2021 04:02:52 +0000 (12:02 +0800)]
RISC-V: Clarify the addends of pc-relative access.
The original discussion was here,
https://github.com/riscv/riscv-elf-psabi-doc/issues/184
After discussing with Kito Cheng, I think the addends of %pcrel_hi
and %pcrel_lo are both allowed in GNU toolchain. However, both of
the them mean the offset of symbols, rather than the pc address.
But the addends of %got_pcrel_hi and it's %pcrel_lo do not look
reasonable. I believe gcc won't generate the got patterns with
addends, so linker should report dangerous relocation errors,
in case the assembly code use them.
Another issue was here,
https://sourceware.org/pipermail/binutils/2021-June/116983.html
At the beginnig, I suppose %pcrel_hi and %pcrel_lo are valid only
when they are in the same input section. But Jim Wilson points out
that gcc may generate %hi and %lo in the different input sections,
when -freorder-blocks-and-partition option is used. So that a memory
references for a loop may have the %hi outside the loop, but the %lo
remain in the loop. However, it is hard to create the testcases,
to see if %pcrel_hi and %pcrel_lo have the same behavior.
Unfortunately, I notice that the current pcrel resolver cannot
work for the above case. For now we build a hash table for pcrel
at the start of riscv_elf_relocate_section, and then free the hash
at the end. But riscv_elf_relocate_section only handles an input
section at a time, so that means we can only resolve the %pcrel_hi
and %pcrel_lo which are in the same input section. Otherwise, like
the above case, we will report "%pcrel_lo missing matching %pcrel_hi"
for them. I have no plan to improve this in the short-term, so maybe
we can wait until someone meets the problem before we deal with it.
bfd/
* elfnn-riscv.c (riscv_pcrel_hi_reloc): Added field to store
the original relocation type, in case the type is converted to
R_RISCV_HI20.
(riscv_pcrel_lo_reloc): Removed unused name field.
(riscv_pcrel_relocs): Added comments.
(riscv_zero_pcrel_hi_reloc): Removed unused input_bfd.
(riscv_record_pcrel_hi_reloc): Updated.
(riscv_record_pcrel_lo_reloc): Likewise.
(riscv_resolve_pcrel_lo_relocs): Likewise. Check the original
type of auipc, to make sure the %pcrel_lo without any addends.
Otherwise, report dangerous relocation error.
(riscv_elf_relocate_section): Updated above functions are changed.
For R_RISCV_GOT_HI20, report dangerous relocation error when addend
isn't zero.
ld/
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
* testsuite/ld-riscv-elf/pcrel-lo-addend-3a.d: New testcase.
* testsuite/ld-riscv-elf/pcrel-lo-addend-3a.s: Likewise.
* testsuite/ld-riscv-elf/pcrel-lo-addend-3b.d: New testcase.
Should report error since the %pcrel_lo with addend refers to
%got_pcrel_hi.
* testsuite/ld-riscv-elf/pcrel-lo-addend-3b.s: Likewise.
* testsuite/ld-riscv-elf/pcrel-lo-addend-3c.d: New testcase.
Should report error since the %got_pcrel_hi with addend.
* testsuite/ld-riscv-elf/pcrel-lo-addend-3c.s: Likewise.
* testsuite/ld-riscv-elf/pcrel-lo-addend-3.ld: Likewise.
Andrew Burgess [Fri, 11 Jun 2021 10:30:47 +0000 (11:30 +0100)]
gdb/remote: handle target dying just before a stepi
I randomly hit a situation where gdbserver crashed immediately before
I issued a 'stepi' to GDB, it turns out that this causes GDB itself to
crash.
What happens is that as part of the stepi we try to insert some
breakpoints into the inferior, so from insert_breakpoints we figure
out what we want to insert, then, eventually, try to send some packets
to the remote to get the breakpoints inserted.
It is only at this point that GDB realises that the target has gone
away. This causes GDB to then enter this call stack:
unpush_and_perror
remote_unpush_target
generic_mourn_inferior
breakpoint_init_inferior
delete_breakpoint
update_global_location_list
So, we realise the target is gone and so delete the breakpoints
associated with that target.
GDB then throws a TARGET_CLOSE_ERROR from unpush_and_error.
This error is caught in insert_breakpoints where we then try to print
a nice error saying something like:
Cannot insert breakpoint %d: some error text here...
To fill in the '%d' we try to read properties of the breakpoint
object.
Which was deleted due to the delete_breakpoint call above.
And so GDB dies...
My proposal in this commit is that, should we catch a
TARGET_CLOSE_ERROR in insert_breakpoints, then we just rethrow the
error.
This will cause the main event loop to print something like:
Remote connection closed
Which I think is fine, I don't think the user will care much which
particular breakpoint GDB was operating on when the connection closed,
just knowing that the connection closed should be enough I think.
I initially added a test to 'gdb.server/server-kill.exp' for this
issue, however, my first attempt was not good enough, the test was
passing even without my fix.
Turns out that the server-kill.exp test actually kills the PID of the
inferior, not the PID of the server. This means that gdbserver is
actually able to send a packet to GDB saying that the inferior has
exited prior to gdbserver itself shutting down. This extra
information was enough to prevent the bug I was seeing manifest.
So, I have extended server-kill.exp to run all of the tests twice, the
first time we still kill the inferior. On the second run we hard kill
the gdbserver itself, this prevents the server from sending anything
to GDB before it exits.
My new test is only expected to fail in this second mode of
operation (killing gdbserver itself), and without my fix, that is what
I see.
gdb/ChangeLog:
* breakpoint.c (insert_bp_location): If we catch a
TARGET_CLOSE_ERROR just rethrow it, the breakpoints might have
been deleted.
gdb/testsuite/ChangeLog:
* gdb.server/server-kill.exp: Introduce global kill_pid_of, and
make use of this in prepare to select which pid we should kill.
Run all the tests twice with a different kill_pid_of value.
(prepare): Make use of kill_pid_of.
(test_stepi): New proc.
Andrew Burgess [Mon, 21 Jun 2021 14:10:14 +0000 (15:10 +0100)]
opcodes: make use of __builtin_popcount when available
This commit provides a small performance improvement when starting up
CGEN based disassemblers by making use of __builtin_popcount.
The #if check used in this commit was copied from bfd/elf32-arm.c
where __builtin_popcount is also used.
I ran into this code while investigating some GDB tests that would
occasionally timeout. One of the reason these tests were having
problems is that the m16c and m32c disassemblers take so long to
initialise themselves. Speeding up count_decodable_bits helps, but is
not a total solution. Still, this felt like an easy win which added
minimal extra complexity, so I figure its worth doing.
opcodes/ChangeLog:
* cgen-dis.c (count_decodable_bits): Use __builtin_popcount when
available.
Alan Modra [Mon, 21 Jun 2021 07:37:05 +0000 (17:07 +0930)]
picojava assembler and disassembler fixes
Commit
54758c3e398d made changes to the picojava support based on
https://sourceware.org/pipermail/binutils/2005-November/045136.html
An update from picojava to picojava II, I think. Unfortunately the
patch neglected any changes to the gas testsuite, resulting in
"FAIL: pj" since that date. This patch makes a few relatively simple
changes to cure the regression.
gas/
* config/tc-pj.c (md_apply_fix): Apply PJ_CODE_REL32 relocs.
* testsuite/gas/pj/ops.s: Update jsr, ret, getstatic,
putstatic, getfield, putfield, invokevirtual, invokespecial,
invokestatic, invokeinterface, goto_w, jsr_w assembly. Delete
version 1 picojava opcodes.
* testsuite/gas/pj/ops.d: Match expected output.
opcodes/
* pj-dis.c (print_insn_pj): Don't print trailing tab. Do
print separator for pcrel insns.
Mike Frysinger [Sun, 20 Jun 2021 00:06:12 +0000 (20:06 -0400)]
sim: unify hardware settings
Move these options up to the common dir so we only test & export
them once across all ports.
Mike Frysinger [Sat, 19 Jun 2021 23:36:39 +0000 (19:36 -0400)]
sim: hw: rework configure option & device selection
The sim-hardware configure option allows builders to select a set of
device models to enable. But this seems like unnecessary overkill:
the existence of individual device models doesn't affect performance
at all as they are only enabled at runtime if the config uses them,
and individually these are all <5KB a piece. Stripping off a total
of ~50KB from a ~1MB binary doesn't seem useful, and it's extremely
unlikely anyone will ever bother.
So let's simplify the configure/make logic by turning sim-hardware
into a boolean option like many of the other sim options. Any ports
that have unique device models will declare them in their Makefile
instead of at configure time. This will allow us to (eventually)
unify the setting into the common dir.
GDB Administrator [Tue, 22 Jun 2021 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
Andrew Burgess [Tue, 4 May 2021 10:41:09 +0000 (11:41 +0100)]
gdb/riscv: add support for vector registers in target descriptions
This commit adds support to RISC-V GDB for vector registers in the
incoming target description.
The vector registers should be described in a feature called
"org.gnu.gdb.riscv.vector", and should contain the register v0 to
v31. There's no restriction on the size or type of these registers,
so the target description can set these up as it requires.
However, if the target feature is present then all of the registers
must be present, and they must all be the same size, these
requirements are, I believe, inline with the RISC-V vector extension.
The DWARF register numbers for the vector registers have been added,
and the code to map between GDB's internal numbering and the DWARF
numbering has been updated.
I have not yet added a feature/riscv/*.xml file for the vector
extension, the consequence of this is that we can't, right now, detect
vector registers on a native target, this patch is all about
supporting vectors on a remote target.
It is worth noting that I don't actually have access to a RISC-V
target with vectors, so the only testing that this patch has had has
been done using 'set tdesc filename ....' to load a target description
to which I have manually added the vector feature. This has shown
that the vector register feature can be successfully parsed, and that
the registers show up in the expected register groups.
Additionally, the RISC-V vector extension is currently at v0.10, which
is also the v1.0 draft release. However, this extension is not yet
finalised. It is possible (but unlikely I think) that the register
set could change between now and the final release of the vector
extension. If this were to happen then we would potentially end up
changing the requirements for the new org.gnu.gdb.riscv.vector
feature. I really don't think it is likely that the register set will
change this late in the process, and even if it did, changing the
feature requirements will not be a problem as far as I am
concerned (when the alternative is GDB just continues without this
feature for now).
gdb/ChangeLog:
* NEWS: Mention new target feature name.
* arch/riscv.c (riscv_create_target_description): GDB doesn't
currently create target descriptions containing vector registers.
* arch/riscv.h (struct riscv_gdbarch_features) <vlen>: New member
variable.
<operator==>: Also compare vlen.
<hash>: Also include vlen.
* riscv-tdep.c (riscv_feature_name_vector): New static global.
(struct riscv_vector_feature): New struct.
(riscv_vector_feature): New static global.
(riscv_register_reggroup_p): Ensure vector registers are part of
the 'all' group, and part of the 'vector' group.
(riscv_dwarf_reg_to_regnum): Handle vector registers.
(riscv_gdbarch_init): Check vector register feature.
* riscv-tdep.h: Add vector registers to GDB's internal register
numbers, and to the DWARF register numbers.
gdb/doc/ChangeLog:
* gdb.texinfo (RISC-V Features): Mention vector register feature.
Andrew Burgess [Wed, 26 May 2021 21:01:59 +0000 (22:01 +0100)]
gdb/python: add PendingFrame.level and Frame.level methods
Add new methods to the PendingFrame and Frame classes to obtain the
stack frame level for each object.
The use of 'level' as the method name is consistent with the existing
attribute RecordFunctionSegment.level (though this is an attribute
rather than a method).
For Frame/PendingFrame I went with methods as these classes currently
only use methods, including for simple data like architecture, so I
want to be consistent with this interface.
gdb/ChangeLog:
* NEWS: Mention the two new methods.
* python/py-frame.c (frapy_level): New function.
(frame_object_methods): Register 'level' method.
* python/py-unwind.c (pending_framepy_level): New function.
(pending_frame_object_methods): Register 'level' method.
gdb/doc/ChangeLog:
* python.texi (Unwinding Frames in Python): Mention
PendingFrame.level.
(Frames In Python): Mention Frame.level.
gdb/testsuite/ChangeLog:
* gdb.python/py-frame.exp: Add Frame.level tests.
* gdb.python/py-pending-frame-level.c: New file.
* gdb.python/py-pending-frame-level.exp: New file.
* gdb.python/py-pending-frame-level.py: New file.
Andrew Burgess [Wed, 26 May 2021 20:28:11 +0000 (21:28 +0100)]
gdb/python: move PyLong_From* calls into py-utils.c
We already have two helper functions in py-utils.c:
gdb_py_object_from_longest (LONGEST l)
gdb_py_object_from_ulongest (ULONGEST l)
these wrap around calls to either PyLong_FromLongLong,
PyLong_FromLong, or PyInt_From_Long (if Python 2 is being used).
There is one place in gdb/python/* where a call to PyLong_FromLong was
added outside of the above utility functions, this was done in the
recent commit:
commit
55789354fcbaf879f3ca8475b647b2747dec486e
Date: Fri May 14 11:56:31 2021 +0200
gdb/python: add a 'connection_num' attribute to Inferior objects
In this commit I replace the direct use of PyLong_FromLong with a call
to gdb_py_object_from_longest. The only real change with this commit,
is that, for Python 2, we will now end up calling PyInt_FromLong
instead of PyLong_FromLong, but this should be invisible to the user.
For Python 3 there should be absolutely no change.
gdb/ChangeLog:
* python/py-inferior.c (infpy_get_connection_num): Call
gdb_py_object_from_longest instead of PyLong_FromLong directly.
Andrew Burgess [Wed, 26 May 2021 14:24:04 +0000 (15:24 +0100)]
gdb/python: handle saving user registers in a frame unwinder
This patch came about because I wanted to write a frame unwinder that
would corrupt the backtrace in a particular way. In order to achieve
what I wanted I ended up trying to write an unwinder like this:
class FrameId(object):
.... snip class definition ....
class TestUnwinder(Unwinder):
def __init__(self):
Unwinder.__init__(self, "some name")
def __call__(self, pending_frame):
pc_desc = pending_frame.architecture().registers().find("pc")
pc = pending_frame.read_register(pc_desc)
sp_desc = pending_frame.architecture().registers().find("sp")
sp = pending_frame.read_register(sp_desc)
# ... snip code to decide if this unwinder applies or not.
fid = FrameId(pc, sp)
unwinder = pending_frame.create_unwind_info(fid)
unwinder.add_saved_register(pc_desc, pc)
unwinder.add_saved_register(sp_desc, sp)
return unwinder
The important things here are the two calls:
unwinder.add_saved_register(pc_desc, pc)
unwinder.add_saved_register(sp_desc, sp)
On x86-64 these would fail with an assertion error:
gdb/regcache.c:168: internal-error: int register_size(gdbarch*, int): Assertion `regnum >= 0 && regnum < gdbarch_num_cooked_regs (gdbarch)' failed.
What happens is that in unwind_infopy_add_saved_register (py-unwind.c)
we call register_size, as register_size should only be called on
cooked (real or pseudo) registers, and 'pc' and 'sp' are implemented
as user registers (at least on x86-64), we trigger the assertion.
A simple fix would be to check in unwind_infopy_add_saved_register if
the register number we are handling is a cooked register or not, if
not we can throw a 'Bad register' error back to the Python code.
However, I think we can do better.
Consider that at the CLI we can do this:
(gdb) set $pc=0x1234
This works because GDB first evaluates '$pc' to get a register value,
then evaluates '0x1234' to create a value encapsulating the
immediate. The contents of the immediate value are then copied back
to the location of the register value representing '$pc'.
The value location for a user-register will (usually) be the location
of the real register that was accessed, so on x86-64 we'd expect this
to be $rip.
So, in this patch I propose that in the unwinder code, when
add_saved_register is called, if it is passed a
user-register (i.e. non-cooked) then we first fetch the register,
extract the real register number from the value's location, and use
that new register number when handling the add_saved_register call.
If either the value location that we get for the user-register is not
a cooked register then we can throw a 'Bad register' error back to the
Python code, but in most cases this will not happen.
gdb/ChangeLog:
* python/py-unwind.c (unwind_infopy_add_saved_register): Handle
saving user registers.
gdb/testsuite/ChangeLog:
* gdb.python/py-unwind-user-regs.c: New file.
* gdb.python/py-unwind-user-regs.exp: New file.
* gdb.python/py-unwind-user-regs.py: New file.
Mike Frysinger [Sun, 20 Jun 2021 16:32:27 +0000 (12:32 -0400)]
sim: cris: clean up printf & abort usage a bit
Inline the stats printf calls to avoid compiler warnings about
non-literal format strings. This in turn highlights bad type
sizes being passed in, so fix the strings to use the right size
type. This in turn highlights the rest of the func using casts
rather than the right type directly, so adjust all of those.
Finally, replace a few abort+sim_engine_halt calls with the
common sim_engine_abort. This provides good output while still
aborting as we want.
GDB Administrator [Mon, 21 Jun 2021 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
Mike Frysinger [Sun, 20 Jun 2021 04:50:30 +0000 (00:50 -0400)]
sim: rx: scope the unique configure flag
This will make it possible to merge into the common configure by
making sure we never collide with other arches.
Mike Frysinger [Sat, 19 Jun 2021 05:36:30 +0000 (01:36 -0400)]
sim: delete SIM_AC_COMMON macro
Now that we've moved all content out to the common file, this is
empty and can be deleted it entirely.
Mike Frysinger [Sat, 19 Jun 2021 14:46:14 +0000 (10:46 -0400)]
sim: unify general maintainer settings
Move these options up to the common dir so we only test & export
them once across all ports. This takes a page from the cgen maint
logic to make $(MAINT) work for non-automake Makefiles which will
allow us to merge it together.
Mike Frysinger [Sat, 19 Jun 2021 14:42:37 +0000 (10:42 -0400)]
sim: unify cgen maintainer settings
Move these options up to the common dir so we only test & export
them once across all ports. It makes it available to targets that
aren't cgen-based, but those will just ignore the settings, so it
shouldn't be an issue.
Mike Frysinger [Sun, 20 Jun 2021 02:24:57 +0000 (22:24 -0400)]
sim: m68hc11: fix unused function warnings with -O0
Mark these functions as unused in case they don't get inlined when
building with -O0.
Mike Frysinger [Wed, 16 Jun 2021 02:45:07 +0000 (22:45 -0400)]
sim: move sim-inline to the common code
This will allow us to build the common code with the same inline
settings as the arch subdirs, and only do the test once.
H.J. Lu [Sun, 20 Jun 2021 03:20:52 +0000 (20:20 -0700)]
x86: Count PLT for GOTOFF relocation against IFUNC symbol
Since GOTOFF relocations against IFUNC symbols must go through PLT,
set PLT reference count to 1 for GOTOFF relocation.
bfd/
PR ld/27998
* elfxx-x86.c (elf_x86_allocate_dynrelocs): Count PLT for GOTOFF
relocation against IFUNC symbols.
(_bfd_x86_elf_adjust_dynamic_symbol): Likewise.
ld/
PR ld/27998
* testsuite/ld-i386/i386.exp: Run PR ld/27998 tests.
* testsuite/ld-i386/pr27998a.d: New file.
* testsuite/ld-i386/pr27998a.s: Likewise.
* testsuite/ld-i386/pr27998b.d: Likewise.
* testsuite/ld-i386/pr27998b.s: Likewise.
Mike Frysinger [Tue, 15 Jun 2021 05:40:33 +0000 (01:40 -0400)]
gdb/gdbserver: switch to AC_CONFIG_MACRO_DIRS
These dirs don't use automake, so use AC_CONFIG_MACRO_DIRS to specify
../config as a search dir for m4 macros. This allows removal of a lot
of hand-written m4_include's from acinclude.m4 files, and simplifies
use of `aclocal` or `autoreconf` as manual -I is not needed.
Simon Marchi [Sun, 20 Jun 2021 02:49:21 +0000 (22:49 -0400)]
sim: move UNUSED before TYPE in SIM_ENDIAN_INLINE's definition
I get this when building with gcc 11:
CC common/common_libcommon_a-sim-load.o
In file included from /home/simark/src/binutils-gdb/sim/common/sim-n-bits.h:27,
from /home/simark/src/binutils-gdb/sim/common/sim-bits.c:259,
from /home/simark/src/binutils-gdb/sim/common/sim-bits.h:599,
from /home/simark/src/binutils-gdb/sim/common/sim-basics.h:122,
from /home/simark/src/binutils-gdb/sim/common/sim-load.c:30:
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:27: error: 'offset_16' defined but not used [-Werror=unused-function]
39 | #define offset_N XCONCAT2(offset_,N)
| ^~~~~~~
/home/simark/src/binutils-gdb/sim/../include/symcat.h:23:26: note: in definition of macro 'CONCAT2'
23 | #define CONCAT2(a,b) a##b
| ^
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:18: note: in expansion of macro 'XCONCAT2'
39 | #define offset_N XCONCAT2(offset_,N)
| ^~~~~~~~
/home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:138:1: note: in expansion of macro 'offset_N'
138 | offset_N (unsigned_N *x,
| ^~~~~~~~
offset_N uses INLINE_SIM_ENDIAN, which uses UNUSED to put the "unused"
attribute. However, it appears after the function's return type, which
seems to make it not apply to the function. Moving it to before the
return type fixes the error.
Change all instances found in that file.
sim/common/ChangeLog:
* sim-inline.h: Move UNUSED before TYPE.
Change-Id: Ide20106683ed7a9ebf35d484dabf70b309cb1ba6
Mike Frysinger [Sun, 20 Jun 2021 02:13:00 +0000 (22:13 -0400)]
sim: unify dtc tool checks
Only one arch uses this currently, but others could too. By moving
it up to the common checks, it'll also let us simplify the moxie code
significantly.
Mike Frysinger [Wed, 16 Jun 2021 02:37:38 +0000 (22:37 -0400)]
sim: ppc: rename inline defines to match common code
Use the same basic names as the common sim inline logic so we can
merge the two. We don't do that here, just prepare for it.
The common code seems to be based on the ppc version but with slightly
different names as it was cleaned up & generalized. I *think* these
concepts are the same, so binding them together is OK, but maybe I'm
misreading them. If so, can always tweak them later.
REVEAL_MODULE -> H_REVEALS_MODULE
INLINE_MODULE -> C_REVEALS_MODULE
Mike Frysinger [Sun, 20 Jun 2021 02:23:14 +0000 (22:23 -0400)]
sim: drop old BUILT_SRC_FROM_COMMON ref
The code that set & used this variable was deleted long ago,
but the clean target was missed. Clean that up now.
GDB Administrator [Sun, 20 Jun 2021 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Sat, 19 Jun 2021 23:33:24 +0000 (16:33 -0700)]
elf: Correct DT_TEXTREL warning in PDE
Change
ld: warning: creating DT_TEXTREL in a PIE
to
ld: warning: creating DT_TEXTREL in a PDE
on PDE.
bfd/
* elflink.c (bfd_elf_final_link): Correct DT_TEXTREL warning in
PDE.
ld/
* testsuite/ld-x86-64/textrel-1.err: New file.
* testsuite/ld-x86-64/textrel-1a.s: Likewise.
* testsuite/ld-x86-64/textrel-1b.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run textrel-1 tests.
Mike Frysinger [Sat, 19 Jun 2021 04:52:10 +0000 (00:52 -0400)]
sim: unify gettext/intl probing logic
Move these options up to the common dir so we only test & export
them once across all ports.
Mike Frysinger [Fri, 18 Jun 2021 15:12:28 +0000 (11:12 -0400)]
sim: unify toolchain dependency logic
The common dir is already probing this info since it's using automake,
so pass it down to the subdirs so they don't have to probe it at all.
Mike Frysinger [Fri, 18 Jun 2021 14:45:03 +0000 (10:45 -0400)]
sim: unify toolchain probing logic
Move these options up to the common dir so we only test & export
them once across all ports.
H.J. Lu [Sat, 19 Jun 2021 02:56:47 +0000 (19:56 -0700)]
elf: Update GNU_PROPERTY_UINT32_[AND|OR]_XXX tests
1. Skip am33_2.0-*-* hppa*-*-hpux* mn10300-*-* since assembly source file
for the HPPA assembler is renamed and modifed by sed. mn10300 has RELA
relocations in .note.gnu.property section which elf_parse_notes doesn't
support.
2. Pass --generate-missing-build-notes=no to assembler.
3. Allow other note sections for xtensa.
* testsuite/ld-elf/property-and-1.d: Skip am33_2.0, hppa-hpux
and mn10300.
Pass --generate-missing-build-notes=no to assembler. Allow
other note sections for xtensa.
* testsuite/ld-elf/property-and-2.d: Likewise.
* testsuite/ld-elf/property-and-3.d: Likewise.
* testsuite/ld-elf/property-and-4.d: Likewise.
* testsuite/ld-elf/property-or-1.d: Likewise.
* testsuite/ld-elf/property-or-2.d: Likewise.
* testsuite/ld-elf/property-or-3.d: Likewise.
* testsuite/ld-elf/property-or-4.d: Likewise.
Mike Frysinger [Fri, 18 Jun 2021 06:03:44 +0000 (02:03 -0400)]
sim: unify bfd library dependency testing logic
Move these options up to the common dir so we only test & export
them once across all ports.
Mike Frysinger [Fri, 18 Jun 2021 05:59:25 +0000 (01:59 -0400)]
sim: mips: drop unused AC_PATH_X call
We don't use anything from X, so no sense in probing the env.
Mike Frysinger [Fri, 18 Jun 2021 05:58:00 +0000 (01:58 -0400)]
sim: unify various library testing logic
Move these options up to the common dir so we only test & export
them once across all ports.
Alan Modra [Sat, 19 Jun 2021 00:55:35 +0000 (10:25 +0930)]
ubsan: vax: pointer overflow
"VAX export class call relocation test" fails with ubsan on a 32-bit
host.
* vax-dis.c (print_insn_vax): Avoid pointer overflow.
Alan Modra [Fri, 18 Jun 2021 12:57:01 +0000 (22:27 +0930)]
ubsan errors when 32-bit bfd
A shift count exceeding the size of the value is undefined behaviour,
and so is negating a signed LONG_MIN.
* config/tc-z80.c (signed_overflow, unsigned_overflow): Avoid UB.
Alan Modra [Fri, 18 Jun 2021 12:56:11 +0000 (22:26 +0930)]
ppc raw test failure when 32-bit bfd
The test contained an expression that can't be evaluated unless
expressions are 64-bit.
* testsuite/gas/ppc/raw.s: Use 0 as pli constant.
* testsuite/gas/ppc/raw.d: Update to suit.
Alan Modra [Fri, 18 Jun 2021 12:55:10 +0000 (22:25 +0930)]
Fix another strncpy warning
* tic30-dis.c (get_register_operand): Don't ask strncpy to fill
entire buffer.
Alan Modra [Fri, 18 Jun 2021 08:54:43 +0000 (18:24 +0930)]
dwarf.c: string_fortify.h strncpy error
In function 'strncpy',
inlined from 'display_debug_lines_decoded' at /home/alan/src/binutils-gdb/binutils/dwarf.c:5434:5,
inlined from 'display_debug_lines' at /home/alan/src/binutils-gdb/binutils/dwarf.c:5567:21:
/usr/include/bits/string_fortified.h:95:10: error: '__builtin_strncpy' specified bound 36 equals destination size [-Werror=stringop-truncation]
No need for strncpy here, the string being copied always fits the
destination buffer.
* dwarf.c (display_debug_lines_decoded): Use memcpy rather than
strncpy when trimming file name length to MAX_FILENAME_LENGTH.
Don't make an unnecessary copy when length is good.
GDB Administrator [Sat, 19 Jun 2021 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in
Carl Love [Wed, 16 Jun 2021 19:51:46 +0000 (14:51 -0500)]
Fix powerpc-power8.exp test with new mnemonics
This patch updates the gdb test to use the new bgetar and bnstarl mnemonics
introduced in commit
5a4037661bccd156d65093f1f0cf2cd43f31e9d9. The test
previously used the bctar and bctarl mnemonics.
gdb/testsuite/ChangeLog
2021-06-17 Carl Love <cel@us.ibm.com>
* gdb.arch/powerpc-power8.exp(bctar, bctarl): Update mnemonics
to bgetar and bgetarl.
* gdb.arch/powerpc-power8.s((bctar, bctarl): Update comments
for mnemonics to bgetar and bnstarl.
H.J. Lu [Fri, 18 Jun 2021 14:32:25 +0000 (07:32 -0700)]
ld.texi: Move -z unique-symbol after -z undefs.
* ld.texi: Move -z unique-symbol after -z undefs.
Mike Frysinger [Fri, 18 Jun 2021 05:14:39 +0000 (01:14 -0400)]
sim: unify -Werror build settings
Move these options up to the common dir so we only test & export
them once across all ports. It also enables -Werror usage on the
common files we've been pulling out of arch subdirs.
H.J. Lu [Fri, 18 Jun 2021 14:18:02 +0000 (07:18 -0700)]
elf: Add GNU_PROPERTY_UINT32_AND_XXX/GNU_PROPERTY_UINT32_OR_XXX
Implement GNU_PROPERTY_UINT32_AND_XXX/GNU_PROPERTY_UINT32_OR_XXX:
https://sourceware.org/pipermail/gnu-gabi/2021q1/000467.html
1. GNU_PROPERTY_UINT32_AND_LO..GNU_PROPERTY_UINT32_AND_HI
#define GNU_PROPERTY_UINT32_AND_LO 0xb0000000
#define GNU_PROPERTY_UINT32_AND_HI 0xb0007fff
A bit in the output pr_data field is set only if it is set in all
relocatable input pr_data fields. If all bits in the the output
pr_data field are zero, this property should be removed from output.
If the bit is 1, all input relocatables have the feature. If the
bit is 0 or the property is missing, the info is unknown.
2. GNU_PROPERTY_UINT32_OR_LO..GNU_PROPERTY_UINT32_OR_HI
#define GNU_PROPERTY_UINT32_OR_LO 0xb0008000
#define GNU_PROPERTY_UINT32_OR_HI 0xb000ffff
A bit in the output pr_data field is set if it is set in any
relocatable input pr_data fields. If all bits in the the output
pr_data field are zero, this property should be removed from output.
If the bit is 1, some input relocatables have the feature. If the
bit is 0 or the property is missing, the info is unknown.
bfd/
* elf-properties.c (_bfd_elf_parse_gnu_properties): Handle
GNU_PROPERTY_UINT32_AND_LO, GNU_PROPERTY_UINT32_AND_HI,
GNU_PROPERTY_UINT32_OR_LO and GNU_PROPERTY_UINT32_OR_HI.
(elf_merge_gnu_properties): Likewise.
binutils/
* readelf.c (print_gnu_property_note): Handle
GNU_PROPERTY_UINT32_AND_LO, GNU_PROPERTY_UINT32_AND_HI,
GNU_PROPERTY_UINT32_OR_LO and GNU_PROPERTY_UINT32_OR_HI.
include/
* elf/common.h (GNU_PROPERTY_UINT32_AND_LO): New.
(GNU_PROPERTY_UINT32_AND_HI): Likewise.
(GNU_PROPERTY_UINT32_OR_LO): Likewise.
(GNU_PROPERTY_UINT32_OR_HI): Likewise.
ld/
* testsuite/ld-elf/property-and-1.d: New file.
* testsuite/ld-elf/property-and-1.s: Likewise.
* testsuite/ld-elf/property-and-2.d: Likewise.
* testsuite/ld-elf/property-and-2.s: Likewise.
* testsuite/ld-elf/property-and-3.d: Likewise.
* testsuite/ld-elf/property-and-3.s: Likewise.
* testsuite/ld-elf/property-and-4.d: Likewise.
* testsuite/ld-elf/property-and-empty.s: Likewise.
* testsuite/ld-elf/property-or-1.d: Likewise.
* testsuite/ld-elf/property-or-1.s: Likewise.
* testsuite/ld-elf/property-or-2.d: Likewise.
* testsuite/ld-elf/property-or-2.s: Likewise.
* testsuite/ld-elf/property-or-3.d: Likewise.
* testsuite/ld-elf/property-or-3.s: Likewise.
* testsuite/ld-elf/property-or-4.d: Likewise.
* testsuite/ld-elf/property-or-empty.s: Likewise.
Mike Frysinger [Fri, 18 Jun 2021 06:14:52 +0000 (02:14 -0400)]
sim: move -Werror disabling to Makefile
For the ports that still don't build with -Werror, rather than disable
the flag at configure time, do it at make time. This will allow us to
unify these tests in the common sim configure script.
Mike Frysinger [Wed, 16 Jun 2021 03:01:45 +0000 (23:01 -0400)]
sim: create a makefile fragment to pass common settings down
As we merge settings from subdirs into the common configure, we
sometimes need to keep the settings working in both dirs. Create
a makefile fragment to pass them down so we don't have to run the
checks twice. For now, the file is empty, but we'll start moving
logic in shortly.
Jan Beulich [Fri, 18 Jun 2021 11:51:52 +0000 (13:51 +0200)]
gas: fold symbol table entries generated for .startof.() / .sizeof.()
When the same such construct is used multiple times in a source file,
there's still no need to emit a separate symbol each time. Under the
assumption that there won't be many of these, use a simple array
lookup method to record previously used symbols.
Mike Frysinger [Mon, 14 Jun 2021 03:16:32 +0000 (23:16 -0400)]
sim: split sim-signal.h include out
The sim-basics.h is too big and includes too many things. This leads
to some arch's sim-main.h having circular loop issues with defs, and
makes it hard to separate out common objects from arch-specific defs.
By splitting up sim-basics.h and killing off sim-main.h, it'll make
it easier to separate out the two.
Mike Frysinger [Mon, 14 Jun 2021 02:27:08 +0000 (22:27 -0400)]
sim: drop core libiberty.h include
This doesn't need to be included for every sim file, so drop it.
Every C file that needs it seems to already include it.
Mike Frysinger [Tue, 15 Jun 2021 23:51:52 +0000 (19:51 -0400)]
sim: overhaul & unify endian settings management
The m4 macro has 2 args: the "wire" settings (which represents the
hardwired port behavior), and the default settings (which are used
if nothing else is specified). If none are specified, the arch is
expected to support both, and the value will be probed based on the
user runtime options or the input program.
Only two arches today set the default value (bpf & mips). We can
probably let this go as it only shows up in one scenario: the sim
is invoked, but with no inputs, and no user endian selection. This
means bpf will not behave like the other arches: an error is shown
and forces the user to make a choice. If an input program is used
though, we'll still switch the default to that. This allows us to
remove the WITH_DEFAULT_TARGET_BYTE_ORDER setting.
For the ports that set a "wire" endian, move it to the runtime init
of the respective sim_open calls. This allows us to change the
WITH_TARGET_BYTE_ORDER to purely a user-selected configure setting
if they want to force a specific endianness.
With all the endian logic moved to runtime selection, we can move
the configure call up to the common dir so we only process it once
across all ports.
The ppc arch was picking the wire endian based on the target used,
but since we weren't doing that for other biendian arches, we can
let this go too. We'll rely on the input selecting the endian, or
make the user decide.
GDB Administrator [Fri, 18 Jun 2021 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
Mike Frysinger [Thu, 17 Jun 2021 23:03:32 +0000 (19:03 -0400)]
sim: ppc: avoid "PAGE_SIZE" name
This define is used for a particular target and depends on the
simulated CPU hardware. It has no relation to the host CPU that
the sim is running on. So rename the common "PAGE_SIZE" here to
better reflect its usage and avoid conflicts with system headers.
Pedro Alves [Thu, 17 Jun 2021 15:23:03 +0000 (16:23 +0100)]
Don't call sigtimedwait for scoped_ignore_sigttou
Because SIGTTOU is sent to the whole process instead of to a specific
thread, consuming a pending SIGTTOU in the destructor of
scoped_ignore_sigttou could consume a SIGTTOU signal raised due to
actions done by some other thread. Simply avoid sigtimedwait in
scoped_ignore_sigttou, thus plugging the race. This works because we
know that when the thread writes to the terminal and the signal is
blocked, the kernel does not raise the signal at all.
Tested on GNU/Linux, Solaris 11 and FreeBSD.
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <pedro@palves.net>
* scoped_ignore_signal.h (scoped_ignore_signal): Add
ConsumePending template parameter.
(scoped_ignore_signal::~scoped_ignore_signal): Skip calling
sigtimedwait if ConsumePending is false.
(scoped_ignore_sigpipe): Initialize with ConsumePending=true.
* scoped_ignore_sigttou.h (scoped_ignore_sigttou)
<m_ignore_signal>: Initialize with ConsumePending=false.
Change-Id: I92f754dbc45c45819dce2ce68b8c067d8d5c61b1
H.J. Lu [Thu, 17 Jun 2021 17:32:27 +0000 (10:32 -0700)]
x86-64: Use $NOPIE_LDFLAGS/$NOPIE_CFLAGS on protected-func-1
PR ld/27973
* testsuite/ld-x86-64/x86-64.exp: Pass $NOPIE_LDFLAGS and
$NOPIE_CFLAGS to protected-func-1 without PIE.
H.J. Lu [Thu, 17 Jun 2021 17:19:29 +0000 (10:19 -0700)]
x86-64: Test protected function pointers
On x86-64, function pointers in executable for external funtions may be
resolved to their PLT entries in executable. If it happens, function
pointers of protected funtions in shared libraries must be resolved to
the PLT entries in executable, not addresses of protected funtions in
shared libraries.
PR ld/27973
* testsuite/ld-x86-64/x86-64.exp: Run protected function tests.
* testsuite/ld-x86-64/protected-func-1.h: New file.
* testsuite/ld-x86-64/protected-func-1a.s: Likewise.
* testsuite/ld-x86-64/protected-func-1b.c: Likewise.
Fangrui Song [Thu, 17 Jun 2021 17:18:28 +0000 (10:18 -0700)]
ld: Add ChangeLog entry for -no-pie