This patch adds new variant (nXS) of DSB memory barrier instruction
available in Armv8.7-a. New nXS variant has different encoding in
comparison with pre Armv8.7-a DSB memory barrier variant thus new
instruction and new operand was added.
DSB memory nXS barrier variant specifies the limitation on the barrier
operation. Allowed values are:
Please note that till now, for barriers, barrier operation was encoded in
4-bit unsigned immediate CRm field (in the range 0 to 15).
For DSB memory nXS barrier variant, barrier operation is a 5-bit unsigned
assembly instruction immediate, encoded in instruction in two bits CRm<3:2>:
CRm<3:2> #imm
00 16
01 20
10 24
11 28
This patch extends current AArch64 barrier instructions with above mapping.
Notable patch changes include:
+ New DSB memory barrier variant encoding for Armv8.7-a.
+ New operand BARRIER_DSB_NXS for above instruction in order to
distinguish between existing and new DSB instruction flavour.
+ New set of DSB nXS barrier options.
+ New instruction inserter and extractor map between instruction
immediate 5-bit value and 2-bit CRm field of the instruction itself (see
FLD_CRm_dsb_nxs).
+ Regeneration of aarch64-[asm|dis|opc]-2.c files.
+ Test cases to cover new instruction assembling and disassembling.
For more details regarding DSB memory barrier instruction and its
Armv8.7-a flavour please refer to Arm A64 Instruction set documentation
for Armv8-A architecture profile, see document pages 132-133 of [0].
aarch64: Add basic support for armv8.7-a architecture
This patch adds support for AArch64 -march=armv8.7-a command line option
in GAS.
Please note that this change ONLY extends -march= command line interface
with a new "armv8.7-a" option. Architectural changes like new instructions
will be added in following patches.
Tom de Vries [Wed, 28 Oct 2020 09:01:32 +0000 (10:01 +0100)]
[gdb/testsuite] Fix gdb.cp/nsalias.exp with -readnow
When running test-case gdb.cp/nsalias.exp with target board readnow, we get:
...
FAIL: gdb.cp/nsalias.exp: complaint for too many recursively imported \
declarations
...
The complaint is not detected, because:
- the complaint is triggered during the file command instead of during
"print N100::x"
- the "set complaints 1" is not effective because it's issued
after the file command
Fix the FAIL by setting the complaints limit earlier, and detecting the
complaint also during the file command.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-10-28 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gdb_file_cmd): Set gdb_file_cmd_msg.
* gdb.cp/nsalias.exp: Set complaints limit before file cmd. Expect
complaint during file command for -readnow.
Tom de Vries [Wed, 28 Oct 2020 09:01:32 +0000 (10:01 +0100)]
[gdb/testsuite] Fix gdb.dwarf2/dw2-filename.exp with -readnow
When running test-case gdb.dwarf2/dw2-filename.exp with target board -readnow,
we run into:
...
FAIL: gdb.dwarf2/dw2-filename.exp: info sources
...
The normal output is:
...
(gdb) info sources^M
Source files for which symbols have been read in:^M
^M
Source files for which symbols will be read in on demand:^M
^M
src/gdb/testsuite/gdb.dwarf2/file1.txt^M
(gdb)
...
but with -readnow file1.txt appears in the "Source files for which symbols
have been read in" catagory instead, as expected.
Fix the FAIL by making the regexp match the -readnow output.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-10-28 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/dw2-filename.exp: Update regexp for -readnow.
Tom de Vries [Wed, 28 Oct 2020 09:01:32 +0000 (10:01 +0100)]
[gdb/testsuite] Fix gdb.dwarf2/dw2-stack-boundary.exp with -readnow
When running test-case gdb.dwarf2/dw2-stack-boundary.exp with target board
readnow, we run into:
...
FAIL: gdb.dwarf2/dw2-stack-boundary.exp: check partial symtab errors
...
The cause for the FAIL is that these complaints are not there:
...
During symbol reading: location description stack underflow^M
During symbol reading: location description stack overflow^M
...
Fix this by KFAILing the complaints for -readnow.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-10-28 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/dw2-stack-boundary.exp: KFAILing the complaints for
-readnow.
Tom de Vries [Tue, 27 Oct 2020 22:17:09 +0000 (23:17 +0100)]
[gdb/testsuite] Fix gdb.base/multi-forks.exp timeout with -readnow
When running test-case gdb.base/multi-forks.exp with target board readnow, we
run into:
...
FAIL: gdb.base/multi-forks.exp: run to exit 1 (timeout)
...
Fix this by using exp_continue.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-10-27 Tom de Vries <tdevries@suse.de>
* gdb.base/multi-forks.exp: Use exp_continue to fix timeout.
Tom de Vries [Tue, 27 Oct 2020 22:17:09 +0000 (23:17 +0100)]
[gdb/testsuite] Fix DUPLICATEs in gdb.base/multi-forks.exp
When running test-case gdb.base/multi-forks.exp I get:
...
DUPLICATE: gdb.base/multi-forks.exp: run to exit 2
DUPLICATE: gdb.base/multi-forks.exp: run to exit 2
...
Tom de Vries [Tue, 27 Oct 2020 22:17:09 +0000 (23:17 +0100)]
[gdb/testsuite] Fix gdb.base/maint.exp FAILs with -readnow
When running test-case gdb.base/maint.exp with target board readnow, we run
into:
...
FAIL: gdb.base/maint.exp: mt expand-symtabs
FAIL: gdb.base/maint.exp: maint print objfiles: psymtabs
FAIL: gdb.base/maint.exp: maint print psymbols -source
FAIL: gdb.base/maint.exp: maint print psymbols -pc
FAIL: gdb.base/maint.exp: maint info line-table with filename of symtab that \
is not currently expanded
...
When using -readnow:
- there are no partial symtabs
- all symtabs are expanded at symbol load time
and these differences from normal behaviour cause the FAILs.
Tom de Vries [Tue, 27 Oct 2020 22:17:09 +0000 (23:17 +0100)]
[gdb/testsuite] Fix gdb.cp/psymtab-parameter.exp with -readnow
When running test-case gdb.cp/psymtab-parameter.exp with target board readnow,
we run into:
...
FAIL: gdb.cp/psymtab-parameter.exp: maintenance info symtabs
...
The FAIL is expected, as mentioned in the comment:
...
# The goal is to keep the CU (Compilation Unit) unexpanded. It would be
# rather XFAIL than FAIL here. For example -readnow breaks it.
gdb_test_no_output "maintenance info symtabs"
...
Fix the FAIL by skipping the command for -readnow.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-10-27 Tom de Vries <tdevries@suse.de>
* gdb.cp/psymtab-parameter.exp: Don't expect unexpanded CU for
-readnow.
Gary Benson [Tue, 27 Oct 2020 17:02:39 +0000 (17:02 +0000)]
Fix gdb.python/py-format-string.exp with Clang
GDB includes the virtual table pointer when formatting polymorphic
C++ objects for printing, but GCC and Clang name these differently:
GCC emits a DW_AT_name of "_vptr.Base" when describing the virtual
table pointer of a type derived from type "Base", whereas Clang
will emit "_vptr$Base" in this situation. This commit fixes a
testcase which failed because of this.
gdb/testsuite/ChangeLog:
* gdb.python/py-format-string.exp (test_deref_refs): Treat
"_vptr$Base" as correct, in addition to "_vptr.Base".
(test_mixed): Likewise.
Nick Clifton [Tue, 27 Oct 2020 16:23:09 +0000 (16:23 +0000)]
Fix seg-fault when running the ld testsuite for the hppa64-linux target.
* elf64-hppa.c (elf_hppa_final_link_relocate): Check that the
symbol's section is being output before adding its offset to the
addend when processing R_PARISC_SECREL32.
Nick Clifton [Tue, 27 Oct 2020 16:17:13 +0000 (16:17 +0000)]
Fix the decoding of DW_FORM_ref_addr DWARF attribute.
* dwarf.c (struct abbrev_list): New structure. Used to collect
lists of abbreviation sets.
(struct abbrev_map): New structure. Used to map CU offsets to
abbreviation offsets.
(record_abbrev_list): New function. A new entry to an
abbreviation list.
(free_all_abbrevs): Update to free abbreviation lists.
(new_abbrev_list): New function. Start a new abbreviation
list.
(find_abbrev_list_by_abbrev_offset): New function.
(find_abbrev_map_by_offset): New function.
(add_abbrev): Add abbrev_list parameter.
(add_abbrev_attr): Likewise.
(process_abbrev_section): Rename to process_abbrev_set and add
list parameter.
(get_type_abbrev_from_form): New function. Attempts to decode the
forms used by DW_AT_type attributes.
(get_type_signedness): Display type names if operating in wide
mode. Use get_type_abbrev_from_form.
(read_and_display_attr_value): Use get_type_abbrev_from_form.
(process_debug_info): Pre-parse the CU headers to collate all the
abbrevs before starting the main scan.
(process_debug_abbrev): Do not free any loaded abbrevs.
(free_debug_memory): Free the abbrev maps.
gdb/breakpoint: use gdb::option for the '-force' flag
Use the gdb::option framework for the '-force' flag of the 'condition'
command. This gives tab-completion ability for the flag.
gdb/ChangeLog:
2020-10-27 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* breakpoint.c (struct condition_command_opts): New struct.
(condition_command_option_defs): New static global.
(make_condition_command_options_def_group): New function.
(condition_completer): Update to consider the '-force' flag.
(condition_command): Use gdb::option for the '-force' flag.
gdb/testsuite/ChangeLog:
2020-10-27 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.base/condbreak.exp: Update the completion tests to
consider the '-force' flag.
Tom de Vries [Tue, 27 Oct 2020 12:28:27 +0000 (13:28 +0100)]
[gdb/testsuite] Fix section matching in find_pc_sect_compunit_symtab
When running test-case gdb.base/list-ambiguous.exp with target board readnow,
we run into:
...
FAIL: gdb.base/list-ambiguous.exp: list ambiguous_fun
...
The test-case contains two static functions ambiguous_fun, one in
list-ambiguous0.c and one in list-ambiguous1.c.
The list command is supposed to show both, but only the one from
list-ambiguous0.c is shown.
This is due to the section check in find_pc_sect_compunit_symtab. It checks
whether the candidate compunit_symtab contains a symbol that has the required
section. This check is only done for GLOBAL_BLOCK symbols.
The check succeeds for the compunit_symtab for list-ambiguous0.c, because it
contains main, but it fails for list-ambiguous0.c because it has no global
symbols.
Fix this by extending the section check to STATIC_BLOCK symbols.
Tested on x86_64-linux.
gdb/ChangeLog:
2020-10-27 Tom de Vries <tdevries@suse.de>
* symtab.c (find_pc_sect_compunit_symtab): Include STATIC_BLOCK
symbols in section check.
Tom de Vries [Tue, 27 Oct 2020 12:28:27 +0000 (13:28 +0100)]
[gdb/symtab] Use early continue in find_pc_sect_compunit_symtab
Function find_pc_sect_compunit_symtab contains a loop:
...
for (compunit_symtab *cust : obj_file->compunits ())
{
...
if (...)
{
/* Lots of code. */
}
}
...
Reduce indentation level and improve readability by using early continue.
Tested on x86_64-linux.
gdb/ChangeLog:
2020-10-27 Tom de Vries <tdevries@suse.de>
* symtab.c (find_pc_sect_compunit_symtab): Use early continue.
gdb/breakpoint: add flags to 'condition' and 'break' commands to force condition
The previous patch made it possible to define a condition if it's
valid at some locations. If the condition is invalid at all of the
locations, it's rejected. However, there may be cases where the user
knows the condition *will* be valid at a location in the future,
e.g. due to a shared library load.
To make it possible that such condition can be defined, this patch
adds an optional '-force' flag to the 'condition' command, and,
respectively, a '-force-condition' flag to the 'break'command. When
the force flag is passed, the condition is not rejected even when it
is invalid for all the current locations (note that all the locations
would be internally disabled in this case).
For instance:
(gdb) break test.c:5
Breakpoint 1 at 0x1155: file test.c, line 5.
(gdb) cond 1 foo == 42
No symbol "foo" in current context.
Defining the condition was not possible because 'foo' is not
available. The user can override this behavior with the '-force'
flag:
(gdb) cond -force 1 foo == 42
warning: failed to validate condition at location 1.1, disabling:
No symbol "foo" in current context.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
stop only if foo == 42
1.1 N 0x0000000000001155 in main at test.c:5
Now the condition is accepted, but the location is automatically
disabled. If a future location has a context in which 'foo' is
available, that location would be enabled.
For the 'break' command, -force-condition has the same result:
(gdb) break test.c:5 -force-condition if foo == 42
warning: failed to validate condition at location 0x1169, disabling:
No symbol "foo" in current context.
Breakpoint 1 at 0x1169: file test.c, line 5.
gdb/ChangeLog:
2020-10-27 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* breakpoint.h (set_breakpoint_condition): Add a new bool parameter.
* breakpoint.c: Update the help text of the 'condition' and 'break'
commands.
(set_breakpoint_condition): Take a new bool parameter
to control whether condition definition should be forced even when
the condition expression is invalid in all of the current locations.
(condition_command): Update the call to 'set_breakpoint_condition'.
(find_condition_and_thread): Take the "-force-condition" flag into
account.
* linespec.c (linespec_keywords): Add "-force-condition" as an
element.
(FORCE_KEYWORD_INDEX): New #define.
(linespec_lexer_lex_keyword): Update to consider "-force-condition"
as a keyword.
* ada-lang.c (create_ada_exception_catchpoint): Ditto.
* guile/scm-breakpoint.c (gdbscm_set_breakpoint_condition_x): Ditto.
* python/py-breakpoint.c (bppy_set_condition): Ditto.
* NEWS: Mention the changes to the 'break' and 'condition' commands.
gdb/testsuite/ChangeLog:
2020-10-27 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.base/condbreak-multi-context.exp: Expand to test forcing
the condition.
* gdb.linespec/cpcompletion.exp: Update to consider the
'-force-condition' keyword.
* gdb.linespec/explicit.exp: Ditto.
* lib/completion-support.exp: Ditto.
gdb/doc/ChangeLog:
2020-10-27 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.texinfo (Set Breaks): Document the '-force-condition' flag
of the 'break'command.
* gdb.texinfo (Conditions): Document the '-force' flag of the
'condition' command.
gdb/breakpoint: disable a bp location if condition is invalid at that location
Currently, for a conditional breakpoint, GDB checks if the condition
can be evaluated in the context of the first symtab and line (SAL).
In case of an error, defining the conditional breakpoint is aborted.
This prevents having a conditional breakpoint whose condition may
actually be meaningful for some of the location contexts. This patch
makes it possible to define conditional BPs by checking all location
contexts. If the condition is meaningful for even one context, the
breakpoint is defined. The locations for which the condition gives
errors are disabled.
The bp_location struct is introduced a new field, 'disabled_by_cond'.
This field denotes whether the location is disabled automatically
because the condition was non-evaluatable. Disabled-by-cond locations
cannot be enabled by the user. But locations that are not
disabled-by-cond can be enabled/disabled by the user manually as
before.
For a concrete example, consider 3 contexts of a function 'func'.
class Base
{
public:
int b = 20;
void func () {}
};
class A : public Base
{
public:
int a = 10;
void func () {}
};
class C : public Base
{
public:
int c = 30;
void func () {}
};
Note that
* the variable 'a' is defined only in the context of A::func.
* the variable 'c' is defined only in the context of C::func.
* the variable 'b' is defined in all the three contexts.
With the existing GDB, it's not possible to define a conditional
breakpoint at 'func' if the condition refers to 'a' or 'c':
(gdb) break func if a == 10
No symbol "a" in current context.
(gdb) break func if c == 30
No symbol "c" in current context.
(gdb) info breakpoints
No breakpoints or watchpoints.
With this patch, it becomes possible:
(gdb) break func if a == 10
warning: failed to validate condition at location 1, disabling:
No symbol "a" in current context.
warning: failed to validate condition at location 3, disabling:
No symbol "a" in current context.
Breakpoint 1 at 0x11b6: func. (3 locations)
(gdb) break func if c == 30
Note: breakpoint 1 also set at pc 0x11ce.
Note: breakpoint 1 also set at pc 0x11c2.
Note: breakpoint 1 also set at pc 0x11b6.
warning: failed to validate condition at location 1, disabling:
No symbol "c" in current context.
warning: failed to validate condition at location 2, disabling:
No symbol "c" in current context.
Breakpoint 2 at 0x11b6: func. (3 locations)
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
stop only if a == 10
1.1 N* 0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
1.2 y 0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
1.3 N* 0x00000000000011ce in C::func() at condbreak-multi-context.cc:39
2 breakpoint keep y <MULTIPLE>
stop only if c == 30
2.1 N* 0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
2.2 N* 0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
2.3 y 0x00000000000011ce in C::func() at condbreak-multi-context.cc:39
(*): Breakpoint condition is invalid at this location.
Here, uppercase 'N' denotes that the location is disabled because of
the invalid condition, as mentioned with a footnote in the legend of
the table. Locations that are disabled by the user are still denoted
with lowercase 'n'. Executing the code hits the breakpoints 1.2 and
2.3 as expected.
Defining a condition on an unconditional breakpoint gives the same
behavior above:
(gdb) break func
Breakpoint 1 at 0x11b6: func. (3 locations)
(gdb) cond 1 a == 10
warning: failed to validate condition at location 1.1, disabling:
No symbol "a" in current context.
warning: failed to validate condition at location 1.3, disabling:
No symbol "a" in current context.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
stop only if a == 10
1.1 N* 0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
1.2 y 0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
1.3 N* 0x00000000000011ce in C::func() at condbreak-multi-context.cc:39
(*): Breakpoint condition is invalid at this location.
Locations that are disabled because of a condition cannot be enabled
by the user:
...
(gdb) enable 1.1
Breakpoint 1's condition is invalid at location 1, cannot enable.
Resetting the condition enables the locations back:
...
(gdb) cond 1
Breakpoint 1's condition is now valid at location 1, enabling.
Breakpoint 1's condition is now valid at location 3, enabling.
Breakpoint 1 now unconditional.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
1.1 y 0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
1.2 y 0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
1.3 y 0x00000000000011ce in C::func() at condbreak-multi-context.cc:39
If a location is disabled by the user, a condition can still be defined
but the location will remain disabled even if the condition is meaningful
for the disabled location:
...
(gdb) disable 1.2
(gdb) cond 1 a == 10
warning: failed to validate condition at location 1.1, disabling:
No symbol "a" in current context.
warning: failed to validate condition at location 1.3, disabling:
No symbol "a" in current context.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
stop only if a == 10
1.1 N* 0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
1.2 n 0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
1.3 N* 0x00000000000011ce in C::func() at condbreak-multi-context.cc:39
(*): Breakpoint condition is invalid at this location.
The condition of a breakpoint can be changed. Locations'
enable/disable states are updated accordingly.
...
(gdb) cond 1 c == 30
warning: failed to validate condition at location 1.1, disabling:
No symbol "c" in current context.
Breakpoint 1's condition is now valid at location 3, enabling.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
stop only if c == 30
1.1 N* 0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
1.2 N* 0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
1.3 y 0x00000000000011ce in C::func() at condbreak-multi-context.cc:39
(*): Breakpoint condition is invalid at this location.
(gdb) cond 1 b == 20
Breakpoint 1's condition is now valid at location 1, enabling.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
stop only if b == 20
1.1 y 0x00000000000011b6 in Base::func() at condbreak-multi-context.cc:23
1.2 n 0x00000000000011c2 in A::func() at condbreak-multi-context.cc:31
1.3 y 0x00000000000011ce in C::func() at condbreak-multi-context.cc:39
# Note that location 1.2 was disabled by the user previously.
If the condition expression is bad for all the locations, it will be
rejected.
(gdb) cond 1 garbage
No symbol "garbage" in current context.
For conditions that are invalid or valid for all the locations of a
breakpoint, the existing behavior is preserved.
Regression-tested on X86_64 Linux.
gdb/ChangeLog:
2020-10-27 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* breakpoint.h (class bp_location) <disabled_by_cond>: New field.
* breakpoint.c (set_breakpoint_location_condition): New function.
(set_breakpoint_condition): Disable a breakpoint location if parsing
the condition string gives an error.
(should_be_inserted): Update to consider the 'disabled_by_cond' field.
(build_target_condition_list): Ditto.
(build_target_command_list): Ditto.
(build_bpstat_chain): Ditto.
(print_one_breakpoint_location): Ditto.
(print_one_breakpoint): Ditto.
(breakpoint_1): Ditto.
(bp_location::bp_location): Ditto.
(locations_are_equal): Ditto.
(update_breakpoint_locations): Ditto.
(enable_disable_bp_num_loc): Ditto.
(init_breakpoint_sal): Use set_breakpoint_location_condition.
(find_condition_and_thread_for_sals): New static function.
(create_breakpoint): Call find_condition_and_thread_for_sals.
(location_to_sals): Call find_condition_and_thread_for_sals instead
of find_condition_and_thread.
gdb/testsuite/ChangeLog:
2020-10-27 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.base/condbreak-multi-context.cc: New file.
* gdb.base/condbreak-multi-context.exp: New file.
gdb/doc/ChangeLog:
2020-10-27 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.texinfo (Set Breaks): Document disabling of breakpoint
locations for which the breakpoint condition is invalid.
Tom Tromey [Mon, 26 Oct 2020 23:10:25 +0000 (17:10 -0600)]
Fix some minor bugs in test suite command logging
I noticed that the test suite command logging would create a file like
"gdb.cmd.-1". I tracked this down to a substraction in
standard_output_file_with_gdb_instance.
Then, I saw that the .in file was not created for MI. This is fixed
by adding a call to default_mi_gdb_start.
Finally, commands might not end up in the .in file in some cases. For
me this happened because the test took a long time, so I got impatient
and killed it. Flushing the file after each write seemed like a good
thing to do here.
gdb/testsuite/ChangeLog
2020-10-26 Tom Tromey <tom@tromey.com>
* lib/mi-support.exp (default_mi_gdb_start): Call
gdb_stdin_log_init.
* lib/gdb.exp (standard_output_file_with_gdb_instance): Don't
subtract one from gdb_instances.
(gdb_stdin_log_write): Flush in_file.
Tom de Vries [Mon, 26 Oct 2020 19:28:47 +0000 (20:28 +0100)]
[gdb/symtab] Read CU base address for enqueued CU
Consider the test-case contained in this patch. It consists of
two CUs:
- cu1, containing a DW_TAG_variable DIE foo
- cu2, containing a DW_TAG_base_type DIE int
where the variable foo has type int, in other words, there's an inter-CU
reference.
When expanding the symtab for cu1, expansion of the symtab for cu2 is
enqueued, and later processed by process_full_comp_unit. However, processing
of .debug_ranges fails because the range is specified relative to a base
address which is considered not to be present because
!cu->base_address.has_value (), and we run into this case in
dwarf2_ranges_process:
...
if (!base.has_value ())
{
/* We have no valid base address for the ranges
data. */
complaint (_("Invalid .debug_ranges data (no base address)"));
return 0;
}
...
Fix this in process_full_comp_unit by setting cu->base_address.
Make range types inherit signed-ness from base type
This passed testing -- but unfortunately, additional testing at
AdaCore showed that this change was incorrect. GNAT, at least, can
emit an unsigned range type whose underlying type is signed.
This patch reverts the code change from the above. I chose not to
reintroduce the FIXME comments, because now we know that they are
incorrect. Instead, this patch also adds a comment to
create_range_type.
gdb/testsuite/ChangeLog
2020-10-26 Tom Tromey <tromey@adacore.com>
* gdb.ada/unsigned_range/foo.adb: New file.
* gdb.ada/unsigned_range/pack.adb: New file.
* gdb.ada/unsigned_range/pack.ads: New file.
* gdb.ada/unsigned_range.exp: New file.
Pedro Alves [Tue, 8 Sep 2020 16:34:41 +0000 (17:34 +0100)]
gdb::handle_eintr, remove need to specify return type
This eliminates the need to specify the return type when using
handle_eintr. We let the compiler deduce it for us.
Also, use lowercase for function parameter names. Uppercase should
only be used on template parameters.
gdb/ChangeLog:
* nat/linux-waitpid.c: Include "gdbsupport/eintr.h".
(my_waitpid): Use gdb::handle_eintr.
gdbserver/ChangeLog:
* netbsd-low.cc (netbsd_waitpid, netbsd_process_target::kill)
(netbsd_qxfer_libraries_svr4): Use gdb::handle_eintr without
explicit type.
gdbsupport/ChangeLog:
* eintr.h (handle_eintr): Replace Ret template parameter with
ErrorValType. Use it as type of the failure value. Deduce the
function's return type using decltype. Use lowercase for function
parameter names.
Tom de Vries [Mon, 26 Oct 2020 15:05:15 +0000 (16:05 +0100)]
[gdb/testsuite] Prevent pagination in GDB_INTERNALFLAGS
When running test-case gdb.base/corefile.exp with target board readnow, we run
into:
...
Reading symbols from outputs/gdb.base/corefile/corefile...^M
Expanding full symbols from outputs/gdb.base/corefile/corefile...^M
[New LWP 2293]^M
Core was generated by `outputs/gdb.base/corefile/co'.^M
Program terminated with signal SIGABRT, Aborted.^M
--Type <RET> for more, q to quit, c to continue without paging--\
FAIL: gdb.base/corefile.exp: (timeout) starting with -core
...
In commit bd447abb24 "Make gdb.base/corefile.exp work on terminals with few
rows", pagination (in the same test-case) is prevented using:
...
set stty_init "rows 25 cols 80"
...
but this doesn't work in our case because using -readnow adds an extra line
"Expanding full symbols".
The test passes when increasing rows to 26. However, increasing the rows by
some n only fixes the problem for n lines, and things will break again if
somehow we end up with n + 1 lines.
Instead, fix this by setting heigth and width in INTERNAL_GDBFLAGS. This
solution was not chosen in commit bd447abb24 because it doesn't handle
pagination due to the introduction text. But it does handle the pagination
due to the extra "Expanding full symbols", and any other line printed during
and after file loading.
Tested on x86_64-linux, with and without readnow.
With -readnow, fixes timeout FAILs in gdb.base/corefile.exp and
gdb.base/reread-readsym.exp.
gdb/testsuite/ChangeLog:
2020-10-26 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (INTERNAL_GDBFLAGS): Set heigth and width.
H.J. Lu [Mon, 26 Oct 2020 13:16:08 +0000 (06:16 -0700)]
gas: Clear all auto-assigned file slots
Since a file slot is auto-assigned for the #APP marker appeared before
the first .file <NUMBER> directive has been seen, clear all auto-assigned
file slots when seeing the first .file <NUMBER> directive.
PR gas/26778
* * dwarf2dbg.c (num_of_auto_assigned): New.
(allocate_filenum): Increment num_of_auto_assigned.
(dwarf2_directive_filename): Clear the slots auto-assigned
before the first .file <NUMBER> directive was seen.
* testsuite/gas/i386/dwarf4-line-1.d: New file.
* testsuite/gas/i386/dwarf4-line-1.s: Likewise.
* testsuite/gas/i386/i386.exp: Run dwarf4-line-1.
Nick Clifton [Mon, 26 Oct 2020 12:39:50 +0000 (12:39 +0000)]
Invoke the linker's error handling script with the keyword "undefined-symbol" when using it to help with undefined symbol errors.
PR 26626
* ldmain.c (undefined_symbol): Use the keyword undefined-symbol
when invoking the error handling script for undefined symbols.
* ld.texi: Update documentation.
Tom de Vries [Mon, 26 Oct 2020 10:08:38 +0000 (11:08 +0100)]
[gdb/testsuite] Add missing ranges base in dw2-objfile-overlap-*.S
When doing a gdb testsuite run with this trigger patch:
...
@@ -14454,6 +14454,7 @@ dwarf2_ranges_process
if (!base.has_value ())
{
+ gdb_assert (false);
/* We have no valid base address for the ranges
data. */
complaint (_("Invalid .debug_ranges data (no base address)"));
...
we run into the assert with test-case gdb.dwarf2/dw2-objfile-overlap.exp.
Fix this by adding the missing .debug_ranges base in
gdb.dwarf2/dw2-objfile-overlap-*.S.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-10-26 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/dw2-objfile-overlap-inner.S: Specify default base address
for CU.
* gdb.dwarf2/dw2-objfile-overlap-outer.S: Same.
Cooper Qu [Mon, 12 Oct 2020 14:29:09 +0000 (22:29 +0800)]
CSKY: Fix and add some instructions for VDSPV1.
gas/
* config/tc-csky.c (get_operand_value): Add handler for
OPRND_TYPE_IMM5b_VSH and OPRND_TYPE_VREG_WITH_INDEX.
* testsuite/gas/csky/csky_vdsp.d : Fix the disassembling
for vector register.
opcodes/
* csky-dis.c (csky_output_operand): Add handler for
OPRND_TYPE_IMM5b_VSH and OPRND_TYPE_VREG_WITH_INDEX.
* csky-opc.h (OPRND_TYPE_VREG_WITH_INDEX): New enum.
(OPRND_TYPE_IMM5b_VSH): New enum.
(csky_v2_opcodes): Fix and add some instructions for VDSPV1.
Simon Marchi [Sun, 25 Oct 2020 03:00:10 +0000 (23:00 -0400)]
gdb: use inferior parameter in add_vsyscall_page
Use the new inferior parameter instead of target_gdbarch. There are
still hidden references to the current context behind core_bfd and
exec_bfd, but this seemed better than nothing.
gdb/ChangeLog:
* symfile-mem.c (add_vsyscall_page): Use inferior parameter
instead of target_gdbarch.
Simon Marchi [Sun, 25 Oct 2020 02:59:51 +0000 (22:59 -0400)]
gdb: make jit.c use the inferior_created inferior parameter
Use the inferior parameter now available in jit_inferior_created_hook.
It is passed down to jit_inferior_init, which uses it as much as
possible instead of the current inferior or current program space.
gdb/ChangeLog:
* jit.c (jit_reader_load_command): Pass current inferior.
(jit_inferior_init): Change parameter type to inferior, use it.
(jit_inferior_created): Remove.
(jit_inferior_created_hook): Pass inferior parameter down.
(_initialize_jit): Use jit_inferior_created_hook instead of
jit_inferior_created.
* jit.h (jit_inferior_created_hook): Add inferior parameter.
* infrun.c (follow_exec): Pass inferior to
jit_inferior_created_hook.
Simon Marchi [Sun, 25 Oct 2020 02:59:29 +0000 (22:59 -0400)]
gdb: pass inferior to check_pid_namespace_match
Pass the inferior argument available in thread_db_inferior_created, and
use it to do most things requiring the inferior.
check_pid_namespace_match is not completely decoupled from the current
inferior yet, there are hidden references behind target_can_run, for
example. But I think this is still a good step forward.
gdb/ChangeLog:
* linux-thread-db.c (check_pid_namespace_match): Add inferior
parameter and use it.
(thread_db_inferior_created): Pass inferior argument.
Simon Marchi [Sun, 25 Oct 2020 02:59:04 +0000 (22:59 -0400)]
gdb: add inferior parameter to inferior_created observable
I think it would make sense for the inferior_created observable to say
which inferior is being dealt with, rather than relying on it being the
current inferior.
This patch adds an inferior parameter to inferior_created, but does not
change the callbacks to use it.
Simon Marchi [Sat, 24 Oct 2020 16:44:18 +0000 (12:44 -0400)]
gdbserver: re-generate configure
I get this diff when I re-generate the configure script in gdbserver,
probably leftovers from e911c6663bb8 ("Require kinfo_get_file and
kinfo_get_vmmap for FreeBSD hosts").
Tom de Vries [Fri, 23 Oct 2020 16:49:48 +0000 (18:49 +0200)]
[gdb/testsuite] Don't use default form in Dwarf::_guess_form
The only possible form for a DW_AT_low_pc attribute is DW_FORM_addr.
When specifying in dwarf assembly a low_pc attribute without explicit form:
...
{low_pc {main_label - 4}}
...
the resulting attribute uses DW_FORM_string, which is misinterpreted by gdb
when reading it as:
...
cu->base_address = attr->as_address ();
...
Stop using DW_FORM_string as default form. Instead, use a default form based
on the attribute name, if possible and unambiguous. Otherwise, error out.
F.i.:
- for DW_AT_low_pc we use DW_FORM_addr.
- For DW_AT_high_pc, we don't specify a default form because it could be
either address or constant class.
- For DW_AT_name, we use DW_FORM_string. While we could encode with
DW_FORM_strp instead, DW_FORM_string is always ok.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-10-23 Tom de Vries <tdevries@suse.de>
* lib/dwarf.exp (Dwarf::_guess_form): Return "" by default instead of
DW_FORM_string.
(Dwarf::_default_form): New proc.
(Dwarf::_handle_DW_TAG): Use _default_form. Error out if no form was
guessed.
Tom de Vries [Fri, 23 Oct 2020 12:55:04 +0000 (14:55 +0200)]
[gdb/testsuite] Use $srcfile in DW_AT_name for CU
In dwarf assembly test-case ada-linkage-name.exp, we have:
...
standard_testfile .c -debug.S
...
cu {} {
DW_TAG_compile_unit {
{DW_AT_name ada-linkage-name.c}
...
Use $srcfile instead of ada-linkage-name.c.
In dwarf assembly test-case atomic-type.exp, we have:
...
standard_testfile .c -dw.S
...
cu {} {
DW_TAG_compile_unit {
{DW_AT_name atomic-type-dw.c}
...
The dwarf generated into atomic-type-dw.S is meant to represent the code in
atomic-type.c, not atomic-type-dw.c, so use $srcfile instead of
atomic-type-dw.c.
Joel Brobecker [Fri, 23 Oct 2020 10:15:15 +0000 (14:15 +0400)]
ada-typeprint.c::ada_print_type: Remove redundant call to ada_check_typedef
This commit removes a call to ada_check_typedef which has already
been done a few lines earlier in the same function, so the second one
is superfluous.
gdb/ChangeLog:
* ada-typeprint.c (ada_print_type): Remove superfluous second call
to ada_check_typedef.
Andrew Burgess [Wed, 16 Sep 2020 15:27:30 +0000 (16:27 +0100)]
gdb: move f_language class into a header file
Moves the f_language class from f-lang.c into f-lang.h. The benefit
of this is that functions declared in other f-*.c files can become
member functions without having to go through a level of indirection.
Some additional support functions have now become private member
functions of the f_language class, these are mostly functions that
then called some other function that was itself a member of the
language_defn class hierarchy.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* f-exp.y (f_parse): Rename to...
(f_language::parser): ...this.
* f-lang.c (f_get_encoding): Rename to...
(f_language::get_encoding): ...this.
(f_op_print_tab): Rename to...
(f_language::op_print_tab): ...this.
(exp_descriptor_f): Rename to...
(f_language::exp_descriptor_tab): ...this.
(class f_language): Moved to f-lang.h.
(f_language::language_arch_info): New function, moved out of class
declaration.
(f_language::search_name_hash): Likewise.
(f_language::lookup_symbol_nonlocal): Likewise.
(f_language::get_symbol_name_matcher_inner): Likewise.
* f-lang.h: Add 'valprint.h' include.
(class f_language): Moved here from f-lang.c.
* f-typeprint.c (f_type_print_args): Delete commented out
declaration.
(f_print_typedef): Rename to...
(f_language::print_typedef): ...this.
(f_print_type): Rename to...
(f_language::print_type): ...this.
(f_type_print_varspec_prefix): Delete declaration and rename to...
(f_language::f_type_print_varspec_prefix): ...this.
(f_type_print_varspec_suffix): Delete declaration and rename to...
(f_language::f_type_print_varspec_suffix): ...this.
(f_type_print_base): Delete declaration and rename to...
(f_language::f_type_print_base): ...this.
* f-valprint.c (f_value_print_inner): Rename to...
(f_language::value_print_inner): ...this.
* parse.c: Delete 'f-lang.h' include.
Andrew Burgess [Sat, 19 Sep 2020 19:38:11 +0000 (20:38 +0100)]
gdb: Rename language_defn::demangle
GDB already has a global symbol `demangle` (a boolean), having a
language method called `demangle` is not a good idea as we often want
to reference `demangle` the control variable inside `demangle` the
member function.
This commit renames `demangle` the member function to
`demangle_symbol`.
There should be no user visible changes after this commit.
Andrew Burgess [Fri, 14 Aug 2020 14:05:48 +0000 (15:05 +0100)]
gdb: remove LA_VALUE_PRINT macro
Remove the LA_VALUE_PRINT macro, and replace its uses with direct
calls to the value_print member function on an appropriate language.
In the global 'value_print' function, we call the value_print method
on the current_language, this is a direct inline replacement of the
old LA_VALUE_PRINT macro.
However, in ada-lang.c, and language.c the macro was being used
within the print_array_index member function of a language class. In
these cases we now call the value_print member function of the current
language class.
In theory, when we are inside (for example) the
ada_language::print_array_index function the current_language should
always be set to Ada, so this change should have no effect. However,
if we ever could get into ada_language::print_array_index with the
current language set to something else (which I think would have been
a bug) then we would now see a change in behaviour. I couldn't find
any cases where this happened though.
There should be no user visible changes after this commit, but it is
not impossible in some edge cases.
Andrew Burgess [Fri, 14 Aug 2020 13:50:48 +0000 (14:50 +0100)]
gdb: move Modula2 language class into a header file
Move the m2_language class from m2-lang.c into m2-lang.h. The benefit
of this move is that we can remove trampoline functions. Currently
the language implementation is split of different m2-* files with
m2-lang.h including declaration for all the language implementation
functions.
Currently the m2_language class in m2-lang.c has member functions that
then call the global functions declared in m2-lang.h.
After this change the m2_language class is declared in m2-lang.h, and
the member functions are the implementations defined in all the m2-*
files.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* m2-exp.y (m2_parse): Rename to...
(m2_language::parser): ...this. Update function signature.
* m2-lang.c (m2_printchar): Renamed to m2_language::printchar.
(m2_op_print): Rename to...
(m2_language::op_print_tab): ...this, and make const.
(exp_descriptor_modula2): Rename to...
(m2_language::exp_descriptor_modula2): ...this.
(class m2_language): Move to m2-lang.h.
(m2_language::language_arch_info): New function, moved out of
class declaration.
(m2_language::printchar): New function, body from m2_printchar.
(m2_language::printstr): New function, moved out of class
declaration.
(m2_language::emitchar): Likewise.
* m2-lang.h (m2_parse): Delete declaration.
(m2_print_typedef): Delete declaration.
(m2_value_print_inner): Delete declaration.
(class m2_language): Class declaration moved from m2-lang.c,
larger functions are left in m2-lang.c.
* m2-typeprint.c (m2_print_typedef): Rename to...
(m2_language::print_typedef): ...this, and update function
signature.
* m2-valprint.c (m2_value_print_inner): Rename to...
(m2_language::value_print_inner): ...this, replace use of
LA_PRINT_STRING with a direct call to printstr member function,
and update recursive call.
Andrew Burgess [Thu, 6 Aug 2020 10:14:37 +0000 (11:14 +0100)]
gdb: Merge auto and unknown language implementations
The auto_language and unknown_language classes are basically the same
except for the language names and store_sym_names_in_linkage_form_p
which the unknown_language overrides to return true, while
auto_language returns the default false.
This commit creates a new parent class from which both of these
languages can inherit. The two base classes are now greatly reduced.
Some of the static helper functions which previously were called from
both of these languages are now only called from one place, and so
I've inlined them into the new class.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* language.c (default_is_string_type_p): Delete, implementation
moved into auto_or_unknown_language::is_string_type_p.
(unk_op_print_tab): Moved into
auto_or_unknown_language::opcode_print_table.
(unknown_language_arch_info): Delete, implementation moved into
auto_or_unknown_language::language_arch_info.
(class auto_or_unknown_language): New class, member functions
copied from unknown_language class, with some updates.
(class unknown_language): Most member functions moved into
auto_or_unknown_language class. Inherit from
auto_or_unknown_language class.
(class auto_language): Inherit from auto_or_unknown_language.
Delete most member functions.
Hannes Domani [Tue, 6 Oct 2020 15:20:20 +0000 (17:20 +0200)]
Remove gdb_assert for TYPE_CODE_METHOD in stabs reader
It's possible to come across TYPE_CODE_UNDEF at this point in
read_member_functions, which according to a comment in read_type
is used for forward references.
Simon Marchi [Thu, 22 Oct 2020 17:28:12 +0000 (13:28 -0400)]
gdb: remove unused macros from target-debug.h
I noticed some clearly stale entries in target-debug.h (which contained
references to VEC). I commented everything in target-debug.h and then
uncommented things until it built again, it pointed out a few unused
macros. Remove them.
Simon Marchi [Thu, 22 Oct 2020 16:58:11 +0000 (12:58 -0400)]
gdb: make target_ops::make_corefile_notes return a unique ptr
Since we converted gdbarch_make_corefile_notes to returning a
gdb::unique_xmalloc_ptr, I figured it would make sense to converted
target_ops::make_corefile_notes as well.
The only implementation of that is in procfs.c, and it should ideally be
re-written as a gdbarch method (see comment in write_gcore_file_1), but
in the mean time I guess it doesn't hurt to throw some unique pointer at
it.
I tested that it builds on Solaris 11 (gcc compile farm machine gcc211),
but I am not able to test it, because I can't get GDB to start a
process (I'll look at that separately).
gdb/ChangeLog:
* target.h (struct target_ops) <make_corefile_notes>:
Change return type to unique pointer.
* target.c (dummy_make_corefile_notes): Likewise.
* exec.c (struct exec_target) <make_corefile_notes>:
Likewise.
(exec_target::make_corefile_notes): Likewise.
* procfs.c (class procfs_target) <make_corefile_notes>:
Likewise.
(procfs_do_thread_registers): Adjust to unique pointer.
(struct procfs_corefile_thread_data): Add constructor.
<note_data>: Change type to unique pointer.
(procfs_corefile_thread_callback): Adjust to unique pointer.
(procfs_target::make_corefile_notes): Change return type to
unique pointer.
* target-delegates.c: Re-generate.
* gcore.c (write_gcore_file_1): Adjust.
* target-debug.h (target_debug_print_gdb_unique_xmalloc_ptr_char):
New.
Tom de Vries [Thu, 22 Oct 2020 15:23:25 +0000 (17:23 +0200)]
[gdb/symtab] Make find_block_in_blockvector more robust
While working on PR25858 I noticed that the following trigger patch:
...
@@ -2918,6 +2918,7 @@ find_pc_sect_compunit_symtab
const struct blockvector *bv;
if (BLOCK_START (b) <= pc
...
triggers this assert, which checks that the returned block indeed
contains pc:
...
@@ -170,7 +170,10 @@ find_block_in_blockvector
...
when running test-case gdb.ada/bp_c_mixed_case.exp.
It's possible that the trigger patch breaks an undocumented invariant: I've
tried a build and test run without the trigger patch and did not manage to
trigger the assert.
For robustness-sake, fix the assert by bailing out if 'BLOCK_START (b) <= pc'
doesn't hold.
Tested on x86_64-linux.
gdb/ChangeLog:
2020-10-22 Tom de Vries <tdevries@suse.de>
* block.c (find_block_in_blockvector): Make sure the returned block
contains pc.
The crash happens here, where htab (a dwarf2_cu::die_hash field) is
unexpectedly NULL while generating partial symbols:
#0 0x000055555fa28188 in htab_find_with_hash (htab=0x0, element=0x7fffffffbfa0, hash=27) at /home/simark/src/binutils-gdb/libiberty/hashtab.c:591
#1 0x000055555cb4eb2e in follow_die_offset (sect_off=(unknown: 27), offset_in_dwz=0, ref_cu=0x7fffffffc110) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:22951
#2 0x000055555cb4edfb in follow_die_ref (src_die=0x0, attr=0x7fffffffc130, ref_cu=0x7fffffffc110) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:22968
#3 0x000055555caa48c5 in partial_die_full_name (pdi=0x621000157e70, cu=0x615000023f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8441
#4 0x000055555caa4d79 in add_partial_symbol (pdi=0x621000157e70, cu=0x615000023f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8469
#5 0x000055555caa7d8c in add_partial_subprogram (pdi=0x621000157e70, lowpc=0x7fffffffc5c0, highpc=0x7fffffffc5e0, set_addrmap=1, cu=0x615000023f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8737
#6 0x000055555caa265c in scan_partial_symbols (first_die=0x621000157e00, lowpc=0x7fffffffc5c0, highpc=0x7fffffffc5e0, set_addrmap=1, cu=0x615000023f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8230
#7 0x000055555ca98e3f in process_psymtab_comp_unit_reader (reader=0x7fffffffc6b0, info_ptr=0x60600009650d "\003int", comp_unit_die=0x621000157d10, pretend_language=language_minimal) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:7614
#8 0x000055555ca9aa2c in process_psymtab_comp_unit (this_cu=0x621000155510, per_objfile=0x613000009f80, want_partial_unit=false, pretend_language=language_minimal) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:7712
#9 0x000055555caa051a in dwarf2_build_psymtabs_hard (per_objfile=0x613000009f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8073
The special thing about this DWARF is that the subprogram at 0x1b is a
template specialization described with DW_AT_specification, and has no
DW_AT_name in itself. To compute the name of this subprogram,
partial_die_full_name needs to load the full DIE for this partial DIE.
The name is generated from the templated function name and the actual
tempalate parameter values of the specialization.
To load the full DIE, partial_die_full_name creates a dummy DWARF
attribute of form DW_FORM_ref_addr that points to our subprogram's DIE,
and calls follow_die_ref on it. This eventually causes
load_full_comp_unit to be called for the exact same CU we are currently
making partial symbols for:
#0 load_full_comp_unit (this_cu=0x621000155510, per_objfile=0x613000009f80, skip_partial=false, pretend_language=language_minimal) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:9238
#1 0x000055555cb4e943 in follow_die_offset (sect_off=(unknown: 27), offset_in_dwz=0, ref_cu=0x7fffffffc110) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:22942
#2 0x000055555cb4edfb in follow_die_ref (src_die=0x0, attr=0x7fffffffc130, ref_cu=0x7fffffffc110) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:22968
#3 0x000055555caa48c5 in partial_die_full_name (pdi=0x621000157e70, cu=0x615000023f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8441
#4 0x000055555caa4d79 in add_partial_symbol (pdi=0x621000157e70, cu=0x615000023f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8469
#5 0x000055555caa7d8c in add_partial_subprogram (pdi=0x621000157e70, lowpc=0x7fffffffc5c0, highpc=0x7fffffffc5e0, set_addrmap=1, cu=0x615000023f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8737
#6 0x000055555caa265c in scan_partial_symbols (first_die=0x621000157e00, lowpc=0x7fffffffc5c0, highpc=0x7fffffffc5e0, set_addrmap=1, cu=0x615000023f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8230
#7 0x000055555ca98e3f in process_psymtab_comp_unit_reader (reader=0x7fffffffc6b0, info_ptr=0x60600009650d "\003int", comp_unit_die=0x621000157d10, pretend_language=language_minimal) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:7614
#8 0x000055555ca9aa2c in process_psymtab_comp_unit (this_cu=0x621000155510, per_objfile=0x613000009f80, want_partial_unit=false, pretend_language=language_minimal) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:7712
#9 0x000055555caa051a in dwarf2_build_psymtabs_hard (per_objfile=0x613000009f80) at /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:8073
load_full_comp_unit creates a cutu_reader for the CU. Since a dwarf2_cu
object already exists for the CU, load_full_comp_unit is expected to
find it and pass it to cutu_reader, so that cutu_reader doesn't create
a new dwarf2_cu for the CU.
And this is the difference between before and after the regression.
Before commit 7188ed02d2a7, the dwarf2_per_cu_data -> dwarf2_cu link was
a simple pointer in dwarf2_per_cu_data. This pointer was set up when
starting the read the partial symbols. So it was already available at
that point where load_full_comp_unit gets called. Post-7188ed02d2a7,
this link is per-objfile, kept in the dwarf2_per_objfile::m_dwarf2_cus
hash map. The entry is only put in the hash map once the partial
symbols have been successfully read, when cutu_reader::keep is called.
Therefore, it is _not_ set at the point load_full_comp_unit is called.
As a consequence, a new dwarf2_cu object gets created and initialized by
load_full_comp_unit (including initializing that dwarf2_cu::die_hash
field). Meanwhile, the dwarf2_cu object created and used by the callers
up the stack does not get initialized for full symbol reading, and the
dwarf2_cu::die_hash field stays unexpectedly NULL.
Solution
--------
Since the caller of load_full_comp_unit knows about the existing
dwarf2_cu object for the CU we are reading (the one load_full_comp_unit
is expected to find), we can simply make it pass it down, instead of
having load_full_comp_unit look up the per-objfile map.
load_full_comp_unit therefore gets a new `existing_cu` parameter. All
other callers get updated to pass `per_objfile->get_cu (per_cu)`, so the
behavior shouldn't change for them, compared to the current HEAD.
A test is added, which is the bare minimum to reproduce the issue.
Notes
-----
The original problem was reproduced by downloading
and loading libtbb.so in GDB. This code was compiled with the Intel
C/C++ compiler. I was not able to reproduce the issue using GCC, I
think because GCC puts a DW_AT_name in the specialized subprogram, so
there's no need for partial_die_full_name to load the full DIE of the
subprogram, and the faulty code doesn't execute.
Luis Machado [Wed, 14 Oct 2020 22:44:03 +0000 (19:44 -0300)]
Fix gdb.base/msym*.exp failures
AArch64 generates functions without a prologue for these two testcases,
therefore we shouldn't expect the function location to be displayed with
an offset.
gdb/testsuite/ChangeLog:
2020-10-22 Luis Machado <luis.machado@linaro.org>
* gdb.base/msym-bp-shl.exp (test_break): Adjust pattern to not
expected an offset from the function.
* gdb.base/msym-bp.exp (test): Likewise.
* NEWS: Docs update.
* testsuite/gas/aarch64/brbe-invalid.d: New test.
* testsuite/gas/aarch64/brbe-invalid.l: New test.
* testsuite/gas/aarch64/brbe-invalid.s: New test.
* testsuite/gas/aarch64/brbe.d: New test.
* testsuite/gas/aarch64/brbe.s: New test.
This patch introduces CSRE (Call Stack Recorder Extension) system
registers.
Note: as this is register only extension we do not want to hide these
registers behind -march flag going forward (they should be enabled by
default).
CSRE feature adds CSR PDEC (Decrements Call stack pointer by the size
of a Call stack record) instruction. This instruction will be added in
a following, separate patch. This change only adds CSRE system
registers.
* NEWS: Docs update.
* testsuite/gas/aarch64/csre-invalid.d: New test.
* testsuite/gas/aarch64/csre-invalid.l: New test.
* testsuite/gas/aarch64/csre-invalid.s: New test.
* testsuite/gas/aarch64/csre.d: New test.
* testsuite/gas/aarch64/csre.s: New test.
H.J. Lu [Thu, 22 Oct 2020 13:10:08 +0000 (06:10 -0700)]
ld: Skip bootstrap tests for -fprofile-generate=
Make plug_opt available to all linker tests. Skip bootstrap tests when
linker is compiled with -fprofile-generate=.
* testsuite/ld-plugin/lto.exp (plug_opt): Moved to ...
* testsuite/config/default.exp (plug_opt): Here. New.
* testsuite/ld-bootstrap/bootstrap.exp: Skip when linker is
compiled with -fprofile-generate=.
It seems commit bb2a67773c uncovered a latent bug when handling a particular
case where things are running within a Docker container using the AUFS storage
driver.
When building the file mappings for a core file, we call
gdbarch_read_core_file_mappings, which in turn passes a couple lambda
callbacks. One pre-loop and one in-loop.
The catch is that commit bb2a67773c reworked the pre-loop lambda and
made it do nothing. Before that commit, we always allocated
m_core_file_mappings in that lambda.
Now, when calling the in-loop lambda, we don't touch m_core_file_mappings
because the bfd is nullptr (given Docker leaks the host system path, and that
file doesn't exist within the container itself).
So, instead, we add an entry to the m_core_unavailable_mappings vector.
When we reach core_target::xfer_partial, we're only checking for an empty
m_core_file_mappings. Given it is now empty, we take the path of reading
the contents from the file, not the core file. This reads back unexpected
results.
The following patch fixes this by also checking for
m_core_unavailable_mappings, given core_target::xfer_memory_via_mappings
already handles the Docker/AUFS situation.
gdb/ChangeLog:
2020-10-22 Luis Machado <luis.machado@linaro.org>
* corelow.c (core_target::xfer_partial): Also check for an empty
m_core_unavailable_mappings vector.
arm: Fix the wrong error message string for mve vldr/vstr (PR26763).
For mve vldr/vstr instructions assembler is throwing wrong error message.
Instead of 'Error: syntax error' assembler fails with 'Error: lo register required'.
This patch fixes the issue.
eg:
$ cat x.s
.syntax unified
.thumb
vldrb.s16 q0, r0
Before this patch:
$ arm-none-eabi-as x.s -march=armv8.1-m.main+mve -mfloat-abi=hard
x.s: Assembler messages:
x.s:4: Error: lo register required -- `vldrb.s16 q0,r0'
After this patch:
$ arm-none-eabi-as x.s -march=armv8.1-m.main+mve -mfloat-abi=hard
x.s: Assembler messages:
x.s:4: Error: syntax error -- `vldrb.s16 q0,r0'
Andrew Burgess [Thu, 8 Oct 2020 15:34:58 +0000 (16:34 +0100)]
gdb/fortran: add support for parsing array strides in expressions
With this commit GDB now understands the syntax of Fortran array
strides, a user can type an expression including an array stride, but
they will only get an error informing them that array strides are not
supported.
This alone is an improvement on what we had before in GDB, better to
give the user a helpful message that a particular feature is not
supported than to just claim a syntax error.
Before:
(gdb) p array (1:10:2, 2:10:2)
A syntax error in expression, near `:2, 2:10:2)'.
Now:
(gdb) p array (1:10:2, 2:10:2)
Fortran array strides are not currently supported
Later commits will allow GDB to handle array strides correctly.
gdb/ChangeLog:
* expprint.c (dump_subexp_body_standard): Print RANGE_HAS_STRIDE.
* expression.h (enum range_type): Add RANGE_HAS_STRIDE.
* f-exp.y (arglist): Allow for a series of subranges.
(subrange): Add cases for subranges with strides.
* f-lang.c (value_f90_subarray): Catch use of array strides and
throw an error.
* parse.c (operator_length_standard): Handle RANGE_HAS_STRIDE.
Andrew Burgess [Fri, 25 Sep 2020 23:09:25 +0000 (00:09 +0100)]
gdb: rename 'enum range_type' to 'enum range_flag'
To avoid confusion with other parts of GDB relating to types and
ranges, rename this enum to make it clearer that it is a set of
individual flags rather than an enumeration of different types of
range.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* expprint.c (print_subexp_standard): Change enum range_type to
range_flag and rename variables to match.
(dump_subexp_body_standard): Likewise.
* expression.h (enum range_type): Rename to...
(enum range_flag): ...this.
(range_types): Rename to...
(range_flags): ...this.
* f-lang.c (value_f90_subarray): Change enum range_type to
range_flag and rename variables to match.
* parse.c (operator_length_standard): Likewise.
* rust-exp.y (rust_parser::convert_ast_to_expression): Change enum
range_type to range_flag.
* rust-lang.c (rust_evaluate_funcall): Likewise.
(rust_range): Likewise.
(rust_compute_range): Likewise.
(rust_subscript): Likewise.
Andrew Burgess [Tue, 5 May 2020 15:03:53 +0000 (16:03 +0100)]
gdb: Convert enum range_type to a bit field enum
The expression range_type enum represents the following ideas:
- Lower bound is set to default,
- Upper bound is set to default,
- Upper bound is exclusive.
There are currently 6 entries in the enum to represent the combination
of all those ideas.
In a future commit I'd like to add stride information to the range,
this could in theory appear with any of the existing enum entries, so
this would take us to 12 enum entries.
This feels like its getting a little out of hand, so in this commit I
switch the range_type enum over to being a flags style enum. There's
one entry to represent no flags being set, then 3 flags to represent
the 3 ideas above. Adding stride information will require adding only
one more enum flag.
I've then gone through and updated the code to handle this change.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* expprint.c (print_subexp_standard): Update to reflect changes to
enum range_type.
(dump_subexp_body_standard): Likewise.
* expression.h (enum range_type): Convert to a bit field enum, and
make the enum unsigned.
* f-exp.y (subrange): Update to reflect changes to enum
range_type.
* f-lang.c (value_f90_subarray): Likewise.
* parse.c (operator_length_standard): Likewise.
* rust-exp.y (rust_parser::convert_ast_to_expression): Likewise.
* rust-lang.c (rust_range): Likewise.
(rust_compute_range): Likewise.
(rust_subscript): Likewise.
Tom Tromey [Wed, 21 Oct 2020 14:54:17 +0000 (08:54 -0600)]
Remove libctf/mkerrors.sed
This patch removes libctf/mkerrors.sed, replacing it with a macro in
ctf-api.h. This simplifies the build and avoids possible unportable
code in the sed script.
2020-10-21 Tom Tromey <tromey@adacore.com>
* ctf-api.h (_CTF_ERRORS): New macro.
libctf/ChangeLog
2020-10-21 Tom Tromey <tromey@adacore.com>
* mkerrors.sed: Remove.
* ctf-error.c (_CTF_FIRST): New define.
(_CTF_ITEM): Define this, not _CTF_STR.
(_ctf_errlist, _ctf_erridx): Use _CTF_ERRORS.
(ERRSTRFIELD): Rewrite.
(ERRSTRFIELD1): Remove.
* Makefile.in: Rebuild.
* Makefile.am (BUILT_SOURCES): Remove.
(ctf-error.h): Remove.
Nick Clifton [Wed, 21 Oct 2020 16:42:42 +0000 (17:42 +0100)]
Work around problem in DWARF decoding library which can result in attempts to read arbitrary bytes as if they were an LEB128 encoded value.
* dwarf.c (skip_attr_bytes): Accept DWARF versions higher than 4
when processing the DW_FORM_ref_addr form.
Skip bytes in DW_FORM_block and DW_FORM_exprloc forms.
Handle DW_FORM_indirect.
(get_type_signedness): Allow a limited amount of recursion.
Do not attempt to decode types that use the DW_FORM_ref_addr form.
(read_and_display_attr_value): Do not attempt to decode types
that use the DW_FORM_ref_addr form.
Simon Marchi [Wed, 21 Oct 2020 14:43:48 +0000 (10:43 -0400)]
gdb: make gdbarch_make_corefile_notes return a unique ptr
This patch starts by making the gdbarch_make_corefile_notes function
return a gdb::unique_xmalloc_ptr<char> and takes care of the fallouts,
mostly in linux-tdep.c and fbsd-tdep.c.
The difficulty in these files is that they use the BFD API for writing
core files, where you pass in a pointer to a malloc-ed buffer (or NULL
in the beginning), it re-allocs it if needed, and returns you the
possibly updated pointer. I therefore used this pattern everywhere:
There is indeed a problem: mode points somewhere into own_buf. And by
the time mode gets formatted as a %s, whatever it points to has been
overwritten. I hacked gdbserver to coerce it into that error path, and
this is the resulting message:
Gary Benson [Wed, 21 Oct 2020 08:54:31 +0000 (09:54 +0100)]
Fix gdb.mi/mi-fullname-deleted.exp with Clang
gdb.mi/mi-fullname-deleted.exp attempts to generate an executable
with a doubled slash in the source filename recorded in its debug
info. This attempt fails when compiling using Clang, causing the
substituted filename test to fail. This commit fixes this issue.
It also expands the comments in the file, to clarify what the test
is attempting to do, and to document where it doesn't succeed.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-fullname-deleted.exp: Fix substituted
fullname test with Clang. Also expand comments generally.
Simon Marchi [Tue, 20 Oct 2020 21:34:30 +0000 (17:34 -0400)]
gdb: make gdbarch predicates return bool
gdbarch predicates (functions suffixed _p to check whether a gdbarch
implements a given method) currently return int. Make them return bool.
There is no expected behavior change.