Simon Marchi [Sun, 4 Oct 2020 16:36:02 +0000 (12:36 -0400)]
gdb/doc: space out list entries, fix one type
I want to add an item to this list, but it's so packed I have trouble
finding where one item ends and the next starts. Add a few empty lines
to make it a bit more readable.
Doing this, I also noticed that an "aix-thread" should in fact be
"aix-solib".
H.J. Lu [Sat, 3 Oct 2020 11:23:55 +0000 (04:23 -0700)]
x86: Update register operand check for AddrPrefixOpReg
When the address size prefix applies to both the memory and the register
operand, we need to extract the address size prefix from the register
operand if the memory operand has no real registers, like symbol, DISP
or symbol(%rip).
NB: GCC always generates symbol(%rip) for RIP-relative addressing for
both x32 and x86-64.
Move the .code16 tests in movdir.s to movdir-16bit to show the correct
output from objdump.
PR gas/26685
* config/tc-i386.c (process_suffix): Also check the register
operand for the address size prefix if the memory operand has
no real registers.
* testsuite/gas/i386/enqcmd-16bit.d: New file.
* testsuite/gas/i386/enqcmd-16bit.s: Likewise.
* testsuite/gas/i386/movdir-16bit.d: Likewise.
* testsuite/gas/i386/movdir-16bit.s: Likewise.
* testsuite/gas/i386/enqcmd.s: Add tests with symbol and DISP.
* testsuite/gas/i386/x86-64-enqcmd.s: Likewise.
* testsuite/gas/i386/x86-64-movdir.s: Likewise.
* testsuite/gas/i386/movdir.s: Add tests with symbol and DISP.
Remove the .code16 test.
* testsuite/gas/i386/i386.exp: Run movdir-16bit and enqcmd-16bit.
* testsuite/gas/i386/x86-64-enqcmd-intel.d: Updated.
* testsuite/gas/i386/x86-64-enqcmd.d: Likewise.
* testsuite/gas/i386/x86-64-movdir-intel.d: Likewise.
* testsuite/gas/i386/x86-64-movdir.d: Likewise.
* testsuite/gas/i386/enqcmd-intel.d: Likewise.
* testsuite/gas/i386/enqcmd.d: Likewise.
* testsuite/gas/i386/movdir-intel.d: Likewise.
* testsuite/gas/i386/movdir.d: Likewise.
* testsuite/gas/i386/x86-64-enqcmd-intel.d: Likewise.
* testsuite/gas/i386/x86-64-enqcmd.d: Likewise.
* testsuite/gas/i386/x86-64-movdir-intel.d: Likewise.
* testsuite/gas/i386/x86-64-movdir.d: Likewise.
Tom Tromey [Fri, 2 Oct 2020 16:23:25 +0000 (10:23 -0600)]
Unconditionally use REG_EXTENDED
skip.c checks whether REG_EXTENDED is defined -- but this should
always be available, and is used unconditionally in other parts of
gdb. This patch removes this check, then further simplifies this
code, removing a declaration and a repeated assertion.
2020-10-02 Tom Tromey <tromey@adacore.com>
* skip.c (skiplist_entry::skiplist_entry): Unconditionally use
REG_EXTENDED.
Simon Marchi [Fri, 2 Oct 2020 19:22:21 +0000 (15:22 -0400)]
gdb: fix some inferior_created observer signatures
I just noticed that in a7aba2668a7b ("gdb: remove arguments from
inferior_created observable"), I forgot to update
aix_thread_inferior_created and procfs_inferior_created, which are in
files I can't compile.
Remove the parameters from aix_thread_inferior_created. And simply
remove procfs_inferior_created, since it's empty anyway.
* server.cc (handle_monitor_command): Handle "set
debug-event-loop".
(captured_main): Handle "--debug-event-loop".
(monitor_show_help): Mention new setting.
(gdbserver_usage): Mention new flag.
gdbsupport/ChangeLog:
* event-loop.h (debug_event_loop): New variable declaration.
(event_loop_debug_printf_1): New function declaration.
(event_loop_debug_printf): New macro.
* event-loop.cc (debug_event_loop): New variable.
(handle_file_event): Add debug print.
(event_loop_debug_printf_1): New function.
Simon Marchi [Fri, 2 Oct 2020 18:45:52 +0000 (14:45 -0400)]
gdb: give names to event loop file handlers
Assign names to event loop file handlers. They will be used in debug
messages when file handlers are invoked.
In GDB, each UI used to get its own unique number, until commit cbe256847e19 ("Remove ui::num"). Re-introduce this field, and use it to
make a unique name for the handler.
I'm not too sure what goes on in ser-base.c, all I know is that it's
what is used when debugging remotely. I've just named the main handler
"serial". It would be good to have unique names there too. For instance
when debugging with two different remote connections, we'd ideally want
the handlers to have unique names. I didn't do it in this patch though.
Simon Marchi [Fri, 2 Oct 2020 14:46:38 +0000 (10:46 -0400)]
gdb: remove arguments from inferior_created observable
I noticed that non of the listeners of the inferior_created observable
used either of the arguments. Remove them. This in turn allows
removing the target parameter of post_create_inferior.
Tested only by rebuilding.
gdb/ChangeLog:
* observable.h <inferior_created>: Remove parameters. Update all
listeners.
* inferior.h (post_create_inferior): Remove target parameter.
Update all callers.
DWARFv5: Handle DW_MACRO_define_strx and DW_MACRO_undef_strx macro entries.
GDB complaints "During symbol reading: unrecognized DW_MACFINO
opcode 0xb" with the testcase given below. Clang is emitting
DW_MACRO_define_strx and DW_MACRO_undef_strx entries in .debug_macro
section which are not supported in GDB. This patch handles them.
DW_MACRO_define_strx and DW_MACRO_undef_strx are added in DWARFv5.
They have two operands. The first operand encodes the line number of
the #define or #undef macro directive. The second operand identifies
a string; it is represented using an unsigned LEB128 encoded value,
which is interpreted as a zero-based index into an array of offsets
in the .debug_str_offsets section. This is as per the section 6.3.2.1
of Dwarf Debugging Information Format Version 5.
Test case used:
#define MAX_SIZE 10
int main(void)
{
int size = 0;
size = size + MAX_SIZE;
gdb/new_gdb/binutils-gdb/build/bin/gdb -q macro.out -ex "set complaints 1" -ex "start"
Reading symbols from macro.out...
During symbol reading: unrecognized DW_MACFINO opcode 0xb
Temporary breakpoint 1 at 0x4004df: file macro.c, line 7.
Starting program: /home/nitika/workspace/macro.out
Temporary breakpoint 1, main () at macro.c:7
7 int size = 0;
(gdb)
Tested by running the testsuite before and after the patch with
-gdwarf-5 and there is no increase in the number of test cases
that fails. Used clang 11.0.0.
gdb/ChangeLog:
* dwarf2/macro.c (dwarf_decode_macro_bytes): Handle DW_MACRO_define_strx
and DW_MACRO_undef_strx.
(dwarf_decode_macros): Likewise
* dwarf2/read.c (dwarf_decode_macros): Pass str_offsets_base in the parameters
which is the value of DW_AT_str_offsets_base.
* dwarf2/macro.h (dwarf_decode_macros): Modify the definition to include
str_offsets_base.
Remove old, no longer needed and no longer valid extern.
../../gdb/i386-nbsd-tdep.c:58:12: error: 'i386nbsd_sc_reg_offset' was declared 'extern' and later 'static' [-fpermissive]
58 | static int i386nbsd_sc_reg_offset[] =
| ^~~~~~~~~~~~~~~~~~~~~~
In file included from ../../gdb/i386-nbsd-tdep.c:31:
../../gdb/i386-tdep.h:480:12: note: previous declaration of 'i386nbsd_sc_reg_offset'
480 | extern int i386nbsd_sc_reg_offset[];
| ^~~~~~~~~~~~~~~~~~~~~~
Remove the old sanity check of sigcontext offsets for NetBSD/i386
NetBSD switched to ucontext, back in 2003 and the sigcontext code
is no longer available for users, except for legacy compat layers.
This code was not available anyway as the pre-processor check
was probably never operational and buildable on NetBSD. The code
inside it does not compile.
Meanwhile, move the offset variable into the ifdef goards and avoid
the error about unused variable.
../../gdb/i386-bsd-nat.c: In function 'void _initialize_i386bsd_nat()':
../../gdb/i386-bsd-nat.c:347:7: error: unused variable 'offset' [-Werror=unused-variable]
347 | int offset;
| ^~~~~~
cc1plus: all warnings being treated as errors
gdb/ChangeLog:
* i386-bsd-nat.c (_initialize_i386bsd_nat): Update.
* i386-nbsd-tdep.c (i386nbsd_sc_reg_offset): Now static.
The support is on part with NetBSD/amd64, thus GPR works,
single step and software breakpoint are operational, and the
SVR4 r_debug integration is functional.
Replace the pre-C++ construct of netbsd_target_ops, netbsd_regset_info
and netbsd_tdesc with C++ inheritance approach found in the Linux
gdbserver code. Add netbsd_amd64_target, that inherits from the
netbsd_process_target class and add proper singleton object for
the_netbsd_target, initialized from netbsd_amd64_target.
Call low_arch_setup () on post process creation, which sets machine
specific properties of the traced process.
Remove global singleton the_netbsd_target object from the generic
gdbserver code.
This refactoring introduces no functional change from the end-user
point of view.
Include the x86-bsd-nat.h header and fix the NetBSD/i386 build
In file included from ../../gdb/i386-nbsd-nat.c:26:
../../gdb/i386-bsd-nat.h:34:53: error: expected template-name before '<' token
34 | class i386_bsd_nat_target : public x86bsd_nat_target<BaseTarget>
| ^
../../gdb/i386-bsd-nat.h:34:53: error: expected '{' before '<' token
../../gdb/i386-nbsd-nat.c:74:45: error: aggregate 'i386_bsd_nat_target<nbsd_nat_target> the_i386_nbsd_nat_target' has incomplete type and cannot be defined
74 | static i386_bsd_nat_target<nbsd_nat_target> the_i386_nbsd_nat_target;
| ^~~~~~~~~~~~~~~~~~~~~~~~
Nick Clifton [Thu, 1 Oct 2020 15:34:05 +0000 (16:34 +0100)]
Add new directive to GAS: .attach_to_group.
* config/obj-elf (elf_pseudo_table): Add attach_to_group.
(obj_elf_attach_to_group): New function.
* doc/as.texi: Document the new directive.
* NEWS: Mention the new feature.
* testsuite/gas/elf/attach-1.s: New test.
* testsuite/gas/elf/attach-1.d: New test driver.
* testsuite/gas/elf/attach-2.s: New test.
* testsuite/gas/elf/attach-2.d: New test driver.
* testsuite/gas/elf/attach-err.s: New test.
* testsuite/gas/elf/attach-err.d: New test driver.
* testsuite/gas/elf/attach-err.err: New test error output.
* testsuite/gas/elf/elf.exp: Run the new tests.
Tom de Vries [Wed, 30 Sep 2020 19:49:01 +0000 (21:49 +0200)]
[gdb] Fix regression in dwarf2_name
Since commit 2c830f5475 "Change some uses of DW_STRING to string method" we
have these regressions:
...
FAIL: gdb.base/info-types-c++.exp: info types
FAIL: gdb.cp/anon-struct.exp: print type of t::t
FAIL: gdb.cp/anon-struct.exp: print type of X::t2
FAIL: gdb.cp/anon-struct.exp: print type of X::t2::t2
FAIL: gdb.cp/anon-struct.exp: print type of t3::~t3
...
Fix these in dwarf2_name by updating attr_name each time attr is updated.
Tested on x86_64-linux.
gdb/ChangeLog:
2020-09-30 Tom de Vries <tdevries@suse.de>
PR symtab/26683
* dwarf2/read.c (dwarf2_name): Update attr_name after attr is updated.
Tom Tromey [Wed, 30 Sep 2020 15:46:36 +0000 (09:46 -0600)]
Fix regression in variant part handling
My series to change DWARF attribute handling to be type-safe
introduced a regression in gdb.ada/variant.exp. handle_variant was
using as_unsigned on an attribute with DW_FORM_sdata. This patch
changes it to use constant_value instead.
2020-09-30 Tom Tromey <tromey@adacore.com>
* dwarf2/read.c (handle_variant): Use constant_value.
Gary Benson [Wed, 30 Sep 2020 09:51:58 +0000 (10:51 +0100)]
Fix gdb.dwarf2/dw2-double-set-die-type.exp with Clang
gdb.dwarf2/dw2-double-set-die-type.exp failed to build with Clang,
because of the following issues:
- One .uleb128 directive was specified with an uppercase U,
causing Clang to fail with the message:
error: unknown directive
This commit converts that directive to all-lowercase.
- The label ".Labbrev1_begin" was referenced but not defined,
causing Clang to fail with the message:
<unknown>:0: error: Undefined temporary symbol
This commit adds the label in the appropriate place.
- The label ".Ldebug_line0" was referenced but not defined,
causing Clang to fail with the message:
<unknown>:0: error: Undefined temporary symbol
This commit removes the reference.
Jeremy Drake [Wed, 30 Sep 2020 09:50:46 +0000 (10:50 +0100)]
After preventing creating an import library for an exe when there are no exports, to avoid a crash, it turned out that some projects expected to be able to create an import library for a dll with no exports, so more closely match the condition to the condition around initializing the dll name.
PR 26588
* emultempl/pe.em (_finish): Generate an import library for DLLs,
even if they have no exports.
* emultempl/pep.em (_finish): Likewise.
Tom Tromey [Wed, 30 Sep 2020 00:49:08 +0000 (18:49 -0600)]
Remove DW_UNSND
This removes DW_UNSND, replacing uses with either as_unsigned or
constant_value, depending primarily on whether or not the form is
already known to be appropriate.
gdb/ChangeLog
2020-09-29 Tom Tromey <tom@tromey.com>
Tom Tromey [Wed, 30 Sep 2020 00:49:08 +0000 (18:49 -0600)]
Add attribute::as_boolean method
This adds a new attribute::as_boolean method, and updates the reader
to use it. The main benefit of this change is that now the code will
respect the attribute's form.
gdb/ChangeLog
2020-09-29 Tom Tromey <tom@tromey.com>
Tom Tromey [Wed, 30 Sep 2020 00:49:08 +0000 (18:49 -0600)]
Add attribute::as_virtuality method
This adds a new attribute::as_virtuality method and changes the DWARF
reader to use it. This also ensures that the attibute's form will now
be respected.
gdb/ChangeLog
2020-09-29 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (dwarf2_add_field, dwarf2_add_member_fn): Update.
* dwarf2/attribute.h (struct attribute) <as_virtuality>: New
method.
* dwarf2/attribute.c (attribute::as_virtuality): New method.
Tom Tromey [Wed, 30 Sep 2020 00:49:08 +0000 (18:49 -0600)]
Change how accessibility is handled in dwarf2/read.c
dwarf2/read.c uses dwarf2_default_access_attribute to check for the
default access attribute. This patch simplifies the code by moving
more of the access processing into this function, changing its name to
reflect the difference. This also ensures that the attribute's form
is respected, by changing to code to use the constant_value method.
gdb/ChangeLog
2020-09-29 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (dwarf2_access_attribute): Rename from
dwarf2_default_access_attribute. Look up attribute.
(dwarf2_add_field, dwarf2_add_type_defn, dwarf2_add_member_fn):
Update.
Tom Tromey [Wed, 30 Sep 2020 00:49:08 +0000 (18:49 -0600)]
Change how reprocessing is done
Currently gdb keeps a vector of attributes that require reprocessing.
However, now that there is a reprocessing flag in the attribute, we
can remove the vector and instead simply loop over attributes a second
time. Normally there are not many attributes, so this should be
reasonably cheap.
gdb/ChangeLog
2020-09-29 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (skip_one_die): Update.
(read_full_die_1): Change how reprocessing is done.
(partial_die_info::read): Update.
(read_attribute_value): Remove need_reprocess parameter.
(read_attribute): Likewise.
* dwarf2/attribute.h (struct attribute) <requires_reprocessing_p>:
New method.
Tom Tromey [Wed, 30 Sep 2020 00:49:08 +0000 (18:49 -0600)]
Add reprocessing flag to struct attribute
Some forms require "reprocessing" -- a second pass to update their
value appropriately. In this case, we'll set the unsigned value on
the attribute, and then later set it to the correct value.
To handle this, we introduce a reprocessing flag to attribute. Then,
we manage this flag to ensure that setting and unsetting is done
properly.
gdb/ChangeLog
2020-09-29 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (read_cutu_die_from_dwo): Use OBSTACK_ZALLOC.
(read_attribute_reprocess, read_attribute_value): Update.
(read_attribute): Clear requires_reprocessing.
* dwarf2/attribute.h (struct attribute) <as_unsigned_reprocess,
form_requires_reprocessing>: New methods.
<string_init>: Clear requires_reprocessing.
<set_unsigned_reprocess>: New method.
<name>: Shrink by one bit.
<requires_reprocessing>: New member.
* dwarf2/attribute.c (attribute::form_requires_reprocessing): New
method.
Tom Tromey [Wed, 30 Sep 2020 00:49:08 +0000 (18:49 -0600)]
Use setter for attribute's unsigned value
This adds form_is_unsigned and an unsigned setter method to struct
attribute, and updates the remaining code. Now DW_UNSND is no longer
used as an lvalue.
gdb/ChangeLog
2020-09-29 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (read_attribute_value): Update.
* dwarf2/attribute.h (struct attribute) <form_is_unsigned,
set_unsigned>: New methods.
* dwarf2/attribute.c (attribute::form_is_unsigned): New method.
Tom Tromey [Wed, 30 Sep 2020 00:49:08 +0000 (18:49 -0600)]
Remove DW_STRING and DW_STRING_IS_CANONICAL
This removes DW_STRING and DW_STRING_IS_CANONICAL, replacing them with
accessor methods on struct attribute. The new code ensures that a
string value will only ever be used when the form allows it.
gdb/ChangeLog
2020-09-29 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (read_cutu_die_from_dwo)
(read_attribute_reprocess, read_attribute_value, read_attribute)
(dwarf2_const_value_attr, dwarf2_name, dump_die_shallow)
(dwarf2_fetch_constant_bytes): Update.
* dwarf2/attribute.h (struct attribute) <form_is_string>: Declare.
<set_string_noncanonical, set_string_canonical>: New methods.
<string_is_canonical>: Update comment.
<canonical_string_p>: Add assert.
(DW_STRING, DW_STRING_IS_CANONICAL): Remove.
* dwarf2/attribute.c (attribute::form_is_string): New method.
(attribute::string): Use it.
Tom Tromey [Wed, 30 Sep 2020 00:49:08 +0000 (18:49 -0600)]
Avoid using DW_* macros in dwarf2/attribute.c
There's no need to use the DW_* accessor macros in dwarf2/attribute.c,
and this is a necessary step toward our goal of removing them
entirely.
gdb/ChangeLog
2020-09-29 Tom Tromey <tom@tromey.com>
* dwarf2/attribute.c (attribute::address): Don't use DW_UNSND or
DW_ADDR.
(attribute::string): Don't use DW_STRING.
(attribute::get_ref_die_offset): Don't use DW_UNSND.
(attribute::constant_value): Don't use DW_UNSND or DW_SND.
Tom Tromey [Wed, 30 Sep 2020 00:49:08 +0000 (18:49 -0600)]
Add attribute::value_as_string method
The full DIE reader checks that an attribute has a "string" form in
some spots, but the partial DIE reader does not. This patch brings
the two readers in sync for one specific case, namely when examining
the linkage name. This avoids regressions in an existing DWARF test
case.
A full fix for this problem would be preferable. An accessor like
DW_STRING should always check the form. However, I haven't attempted
that in this series.
Also the fact that the partial and full readers can disagree like this
is a design flaw.
gdb/ChangeLog
2020-09-29 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (partial_die_info::read) <case
DW_AT_linkage_name>: Use value_as_string.
(dwarf2_string_attr): Use value_as_string.
* dwarf2/attribute.h (struct attribute) <value_as_string>: Declare
method.
* dwarf2/attribute.c (attribute::value_as_string): New method.
Pedro Alves [Tue, 29 Sep 2020 19:08:51 +0000 (20:08 +0100)]
Tweak gdbsupport/valid-expr.h for GCC 6, fix build
With GCC 6.4 and 6.5 (at least), unit tests that use
gdbsupport/valid-expr.h's CHECK_VALID fail to compile, with:
In file included from src/gdb/unittests/offset-type-selftests.c:24:0:
src/gdb/unittests/offset-type-selftests.c: In substitution of 'template<class Expected, template<class ...> class Op, class ... Args> using is_detected_exact = std::is_same<Expected, typename gdb::detection_detail::detector<gdb::nonesuch, void, Op, Args ...>::type> [with Expected = selftests::offset_type::off_A&; Op = selftests::offset_type::check_valid_expr75::archetype; Args = {selftests::offset_type::off_A, selftests::offset_type::off_B}]':
src/gdb/unittests/offset-type-selftests.c:75:1: required from here
src/gdb/../gdbsupport/valid-expr.h:65:20: error: type/value mismatch at argument 2 in template parameter list for 'template<class Expected, template<class ...> class Op, class ... Args> using is_detected_exact = std::is_same<Expected, typename gdb::detection_detail::detector<gdb::nonesuch, void, Op, Args ...>::type>'
archetype, TYPES>::value == VALID, \
^
The important part is the "error: type/value mismatch" error. Seems
like that GCC doesn't understand that archetype is an alias template,
and is being strict in requiring a template class.
The fix here is then to make archetype a template class, to pacify
GCC. The resulting code looks like this:
is_detected_exact<Expected, Op, Args> checks whether Op<Args> is type
Expected:
- For Expected, we pass the explicit EXPR_TYPE, overriding the
default parameter type of archetype.
- For Args we don't pass the last template parameter, so archtype
defaults to the EXPR's decltype.
So in essence, we're really checking whether EXPR_TYPE is the same as
decltype(EXPR).
We need to do the decltype in a template context in order to trigger
SFINAE instead of failing to compile.
The hunk in unittests/enum-flags-selftests.c becomes necessary,
because unlike with the current alias template version, this new
version makes GCC trigger -Wenum-compare warnings as well:
src/gdb/unittests/enum-flags-selftests.c:328:33: error: comparison between 'enum selftests::enum_flags_tests::RE' and 'enum selftests::enum_flags_tests::RE2' [-Werror=enum-compare]
CHECK_VALID (true, bool, RE () != RE2 ())
^
src/gdb/../gdbsupport/valid-expr.h:61:45: note: in definition of macro 'CHECK_VALID_EXPR_INT'
template <TYPENAMES, typename = decltype (EXPR)> \
^
Mark Wielaard [Mon, 28 Sep 2020 22:02:06 +0000 (00:02 +0200)]
binutils: dwarf.c handle DWARF5 DW_LLE_start_end and DW_LLE_start_length.
display_loclists_list only handled DW_LLE_offset_pair as bounded
location description. Also handle DW_LLE_start_end and DW_LLE_start_lenght.
These don't use the base_address.
binutils/ChangeLog:
* dwarf.c (display_loclists_list): Handle DW_LLE_start_end and
DW_LLE_start_length. Only add base_address for DW_LLE_offset_pair.
Tom Tromey [Tue, 29 Sep 2020 01:38:25 +0000 (19:38 -0600)]
Remove target_has_execution macro
This removes the object-like macro target_has_execution, replacing it
with a function call. target_has_execution_current is also now
handled by this function.
gdb/ChangeLog
2020-09-28 Tom Tromey <tom@tromey.com>
Simon Marchi [Mon, 28 Sep 2020 18:21:24 +0000 (14:21 -0400)]
gdb: fix formatting of serial::async_state's enumerators
The comments related to these enumerators are placed under the
corresponding enumerator. This is quite unusual and confusing. Change
it to have the comments above, as usual.
This patch introduces ETMv4 (Embedded Trace Macrocell) system registers for the AArch64 architecture.
gas * testsuite/gas/aarch64/etm-ro-invalid.d: New test.
* testsuite/gas/aarch64/etm-ro-invalid.l: New test.
* testsuite/gas/aarch64/etm-ro-invalid.s: New test.
* testsuite/gas/aarch64/etm-ro.s: New test.
* testsuite/gas/aarch64/etm-wo-invalid.d: New test.
* testsuite/gas/aarch64/etm-wo-invalid.l: New test.
* testsuite/gas/aarch64/etm-wo-invalid.s: New test.
* testsuite/gas/aarch64/etm-wo.s: New test.
* testsuite/gas/aarch64/etm.s: New test.
* testsuite/gas/aarch64/sysreg.d: system register s2_1_c0_c3_0 disassembled
now to trcstatr.
This patch introduces TRBE (Trace Buffer Extension) system registers for the AArch64 architecture.
gas * testsuite/gas/aarch64/trbe-invalid.d: New test.
* testsuite/gas/aarch64/trbe-invalid.l: New test.
* testsuite/gas/aarch64/trbe-invalid.s: New test.
* testsuite/gas/aarch64/trbe.d: New test.
* testsuite/gas/aarch64/trbe.s: New test.
opcodes * aarch64-opc.c: Add TRBE system registers TRBIDR_EL1 , TRBBASER_EL1 ,
TRBLIMITR_EL1 , TRBMAR_EL1 , TRBPTR_EL1, TRBSR_EL1 and TRBTRG_EL1.
Tom Tromey [Mon, 28 Sep 2020 02:30:30 +0000 (20:30 -0600)]
Rewrite tui_puts
This rewrites tui_puts. It now writes as many bytes as possible in a
call to waddnstr, letting curses handle multi-byte sequences properly.
Note that tui_puts_internal remains. It is needed to handle computing
the start line of the readline prompt, which is difficult to do
properly in the case where redisplaying can also cause the command
window to scroll. This might be possible to implement by reverting to
single "character" output, by using mbsrtowcs for its side effects to
find character boundaries in the input. I have not attempted this.
gdb/ChangeLog
2020-09-27 Tom Tromey <tom@tromey.com>
Tom Tromey [Mon, 28 Sep 2020 02:30:30 +0000 (20:30 -0600)]
Use ISCNTRL in tui_copy_source_line
This changes tui_copy_source_line to use ISCNTRL. This lets it work
more nicely with UTF-8 input. Note that this still won't work for
stateful multi-byte encodings; for that much more work would be
required. However, I think this patch does not make gdb any worse in
this scenario.
gdb/ChangeLog
2020-09-27 Tom Tromey <tom@tromey.com>
PR tui/25342:
* tui/tui-winsource.c (tui_copy_source_line): Use ISNCTRL.
Tom Tromey [Mon, 28 Sep 2020 02:30:30 +0000 (20:30 -0600)]
Use a curses pad for source and disassembly windows
This changes the TUI source and disassembly windows to use a curses
pad for their text. This is an important step toward properly
handling non-ASCII characters, because it makes it easy to scroll
horizontally without needing gdb to also understand multi-byte
character boundaries -- this can be wholly delegated to curses.
Horizontal scrolling is probably also faster now, because no
re-rendering is required.
gdb/ChangeLog
2020-09-27 Tom Tromey <tom@tromey.com>
* unittests/tui-selftests.c: Update.
* tui/tui-winsource.h (struct tui_source_window_base)
<extra_margin, show_line_number, refresh_pad>: New methods.
<m_max_length, m_pad>: New members.
(tui_copy_source_line): Update.
* tui/tui-winsource.c (tui_copy_source_line): Remove line_no,
first_col, line_width, ndigits parameters. Add length.
(tui_source_window_base::show_source_line): Write to pad. Line
number now 0-based.
(tui_source_window_base::refresh_pad): New method.
(tui_source_window_base::show_source_content): Write to pad. Call
refresh_pad.
(tui_source_window_base::do_scroll_horizontal): Call refresh_pad,
not refill.
(tui_source_window_base::update_exec_info): Call
show_line_number.
* tui/tui-source.h (struct tui_source_window) <extra_margin>: New
method.
<m_digits>: New member.
* tui/tui-source.c (tui_source_window::set_contents): Set m_digits
and m_max_length.
(tui_source_window::show_line_number): New method.
* tui/tui-io.h (tui_puts): Fix comment.
* tui/tui-disasm.c (tui_disasm_window::set_contents): Set
m_max_length.
Tom Tromey [Mon, 28 Sep 2020 02:30:30 +0000 (20:30 -0600)]
Remove a call to show_source_line from TUI
This removes a call to show_source_line from tui_source_window_base.
This call isn't needed because this function already calls the
'refill' method if the state changed.
gdb/ChangeLog
2020-09-27 Tom Tromey <tom@tromey.com>
Tom Tromey [Mon, 28 Sep 2020 02:30:30 +0000 (20:30 -0600)]
Use an inner window in tui_py_window
This changes tui_py_window to create an inner curses window. This
greatly simplifies tui_py_window::output, beacuse it no longer needs
to be careful to avoid overwriting the window's border. This patch
also makes it a bit easier for a later patch to rewrite
tui_copy_source_line.
gdb/ChangeLog
2020-09-27 Tom Tromey <tom@tromey.com>
* python/py-tui.c (class tui_py_window) <refresh_window>: New
method.
<erase>: Update.
<cursor_x, cursor_y>: Remove.
<m_inner_window>: New member.
(tui_py_window::rerender): Create inner window.
(tui_py_window::output): Write to inner window.
gdb: Fix from_tty argument to gdb.execute in Python.
Prior to commit 56bcdbea2b, the from_tty keyword argument to the
Python function gdb.execute controlled whether the command took input
from the terminal. When from_tty=True, "starti" and similar commands
prompted the user:
(gdb) python gdb.execute("starti", from_tty=True)
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /bin/true
Program stopped.
When from_tty=False, these commands did not prompt the user, and "yes"
was assumed:
However, after commit 56bcdbea2b, the from_tty keyword argument no
longer had this effect. For example, as of commit 7ade7fba75:
(gdb) python gdb.execute("starti", from_tty=True)
The program being debugged has been started already.
Start it from the beginning? (y or n) [answered Y; input not from terminal]
Starting program: /bin/true
Program stopped.
Note the "[answered Y; input not from terminal]" in the output even
though from_tty=True was requested.
Looking at commit 56bcdbea2b, it seems that the behaviour of the
from_tty argument was changed accidentally. The commit message said:
Let gdb.execute handle multi-line commands
This changes the Python API so that gdb.execute can now handle
multi-line commands, like "commands" or "define".
and there was no mention of changing the effect of the from_tty
argument. It looks as though the code for setting the instream to
nullptr was accidentally moved from execute_user_command() to
execute_control_commands() along with the other scoped restores.
Accordingly, the simplest way to fix this is to partially reverse
commit 56bcdbea2b by moving the code for setting the instream to
nullptr back to execute_user_command() where it was to begin with.
Additionally, add a test case to reduce the risk of similar breakage
in future.
gdb/ChangeLog:
PR python/26586
* cli/cli-script.c (execute_control_commands): don't set
instream to nullptr here as this breaks the from_tty argument
to gdb.execute in Python.
(execute_user_command): set instream to nullptr here instead.
gdb/testsuite/ChangeLog:
PR python/26586
* gdb.python/python.exp: add test cases for the from_tty
argument to gdb.execute.
* powerpc.cc (Target_powerpc): Rename power10_stubs_ to
power10_relocs_.
(Target_powerpc::set_power10_relocs): New accessor.
(Target_powerpc::set_power10_stubs): Delete.
(Target_powerpc::power10_stubs): Adjust.
(Target_powerpc::has_localentry0): New accessor.
(ld_0_11): New constant.
(glink_eh_frame_fde_64v1, glink_eh_frame_fde_64v2): Adjust.
(glink_eh_frame_fde_64v2_localentry0): New.
(Output_data_glink::pltresolve_size): Update.
(Output_data_glink::add_eh_frame): Use localentry0 version eh_frame.
(Output_data_glink::do_write): Move r2 save to start of ELFv2 stub
and only emit for has_localentry0. Don't use r2 in the stub.
(Target_powerpc::Scan::local, global): Adjust for
set_power10_relocs renaming.
(Target_powerpc::scan_relocs): Warn and reset plt_localentry0_.
Alan Modra [Sat, 26 Sep 2020 05:40:09 +0000 (15:10 +0930)]
PPC64_OPT_LOCALENTRY is incompatible with tail calls
The save of r2 in __glink_PLTresolve is the culprit. Remove it,
unless we know we need it for --plt-localentry. --plt-localentry
should not be used with power10 pc-relative code that makes tail
calls.
The patch also removes use of r2 as a scratch reg in the ELFv2
__glink_PLTresolve. Using r2 isn't a problem, this is just reducing
the number of scratch regs.
bfd/
* elf64-ppc.c (GLINK_PLTRESOLVE_SIZE): Depend on has_plt_localentry0.
(LD_R0_0R11, ADD_R11_R0_R11): Define.
(ppc64_elf_tls_setup): Disable params->plt_localentry0 when power10
code detected.
(ppc64_elf_size_stubs): Update __glink_PLTresolve eh_frame.
(ppc64_elf_build_stubs): Move r2 save to start of __glink_PLTresolve,
and only emit for has_plt_localentry0. Don't use r2 in the stub.
ld/
* testsuite/ld-powerpc/elfv2so.d,
* testsuite/ld-powerpc/notoc2.d,
* testsuite/ld-powerpc/tlsdesc.wf,
* testsuite/ld-powerpc/tlsdesc2.d,
* testsuite/ld-powerpc/tlsdesc2.wf,
* testsuite/ld-powerpc/tlsopt5.d,
* testsuite/ld-powerpc/tlsopt5.wf,
* testsuite/ld-powerpc/tlsopt6.d,
* testsuite/ld-powerpc/tlsopt6.wf: Update __glink_PLTresolve.
compile_module attempts to request a move constructor, but because
munmap_list doesn't have one it gets implicitly deleted. This is an
warning on clang under -Wdefaulted-function-deleted (which is enabled by
default):
In file included from compile/compile-object-load.c:21:
compile/compile-object-load.h:56:3: error: explicitly defaulted move constructor is implicitly deleted [-Werror,-Wdefaulted-function-deleted]
compile_module (compile_module &&other) = default;
^
compile/compile-object-load.h:86:22: note: move constructor of 'compile_module' is implicitly deleted because field 'munmap_list' has a deleted move constructor
struct munmap_list munmap_list;
^
compile/compile-object-load.h:30:28: note: 'munmap_list' has been explicitly marked deleted here
DISABLE_COPY_AND_ASSIGN (munmap_list);
^
gdb/ChangeLog:
* compile/compile-object-load.h: Give munmap_list a move
constructor.
Simon Marchi [Fri, 25 Sep 2020 14:24:29 +0000 (10:24 -0400)]
Import mklog.py from gcc repo
I've been using the mklog utility from the gcc repo for a while to
generate skeleton of ChangeLog entries. It recently got a rewrite as a
Python script. Unfortunately, to find the repository root, and
eventually to find in which ChangeLog file each entry goes, the new
script assumes it is located in the same git repository that it
generates ChangeLog entries for.
This means that if you make a change in the gcc source tree and run
mklog.py from that same source tree, it works. But if you make changes
in your ~/src/binutils-gdb tree and run ~/src/gcc/contrib/mklog.py, it
won't work.
IIRC, the old script required that you ran it with the project's root
directory as the CWD.
The simplest way to fix this is to import the script in binutils-gdb and
use it from there. It's also nice because we can use it without having
a clone of the gcc repo.
I also thought of adding a "--root" switch to the script to override the
project's base directory. However:
1) It is more work.
2) If the script still lives in the gcc repo, it's less convenient than
having it in binutils-gdb.
* lib/gdb.exp (gdb_compile): Pass "-x c++" explicitly when
compiling C++ programs.
attempted to fix problems with testcases that compile .c files
with the C++ compiler. They pass the "c++" option to gdb_compile,
resulting in the following error when using Clang:
gdb compile failed, clang-10: warning: treating 'c' input as 'c++'
when in C++ mode, this behavior is deprecated [-Wdeprecated]
This fix did not work for gdb.base/infcall-nested-structs-c++.exp,
however: the "-x c++" appeared in the compiler's commandline after
the .c file, so the option was not enabled for that file.
The previous files fixed all used build_executable_from_specs, which
compiles and links in separate steps, using gdb_compile: the compile
step passes $type=object to gdb_compile, while the link step passes
$type=executable.
gdb.base/infcall-nested-structs-c++.exp uses gdb_compile directly
instead, and it passes $type=executable to compile and link all in
one step. Pedro found that DejaGnu's default_target_compile adds
the sources at the end when $type=object, but at the beginning when
$type=executable:
# This is obscure: we put SOURCES at the end when building an
# object, because otherwise, in some situations, libtool will
# become confused about the name of the actual source file.
if {$type == "object"} {
set opts "$add_flags $sources"
} else {
set opts "$sources $add_flags"
}
This commit moves the "-x c++" earlier in the compiler's commandline.
Unfortunately this then broke the testcase that required the original
fix, gdb.compile/compile-cplus.exp: the "-x c++" was being parsed for
the linker pass, causing the compiler to attempt to parse the .o files
as C++. This commit makes passing "-x c++" conditional on the source
being a .c file.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_compile): Pass "-x c++" earlier, and only
for .c files.
Alan Modra [Fri, 25 Sep 2020 00:35:57 +0000 (10:05 +0930)]
asan: readelf buffer overflow and abort
* elfcomm.c (byte_put_little_endian, byte_put_big_endian): Support
more field sizes.
* readelf.c (target_specific_reloc_handling <MSP430>): Limit
allowed reloc_size. Don't read_leb128 outside of section.