deliverable/binutils-gdb.git
3 years agogdb.texinfo: Document GMP as mandatory requirement to build GDB
Joel Brobecker [Mon, 21 Dec 2020 02:21:41 +0000 (06:21 +0400)] 
gdb.texinfo: Document GMP as mandatory requirement to build GDB

gdb/doc/ChangeLog

        * gdb.texinfo (Requirements): Add GMP to list of requirements.

3 years agoAutomatic date update in version.in
GDB Administrator [Mon, 21 Dec 2020 00:00:06 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years ago[gdb/testsuite] Add save_target_board_info
Tom de Vries [Sun, 20 Dec 2020 08:35:36 +0000 (09:35 +0100)] 
[gdb/testsuite] Add save_target_board_info

Add a proc save_target_board_info, similar to save_vars, such that we can do:
...
save_target_board_info { multilib_flags } {
    global board
    set board [target_info name]
    unset_board_info multilib_flags
    set_board_info multilib_flags "$override_multilib_flags"
    ...
}
...
and use it in gdb_compile_shlib.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-20  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (save_target_board_info): New proc.
(gdb_compile_shlib): Use save_target_board_info.

3 years agoAutomatic date update in version.in
GDB Administrator [Sun, 20 Dec 2020 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agogold: Move sym declaration just before use
H.J. Lu [Sat, 19 Dec 2020 21:30:39 +0000 (13:30 -0800)] 
gold: Move sym declaration just before use

Move sym declaration just before use to avoid -Wmaybe-uninitialized
warning from GCC 11.

PR gold/27097
* incremental.cc (Sized_relobj_incr::do_add_symbols): Move sym
declaration just before use.
(Sized_incr_dynobj::do_add_symbols): Likewise.
* plugin.cc (Sized_pluginobj::do_add_symbols): Likewise.

3 years ago[gdb/testsuite] Introduce supports_scalar_storage_order_attribute
Tom de Vries [Sat, 19 Dec 2020 15:43:17 +0000 (16:43 +0100)] 
[gdb/testsuite] Introduce supports_scalar_storage_order_attribute

Introduce support test procs:
- supports_scalar_storage_order_attribute, and
- supports_gnuc
and use them in test-case gdb.base/endianity.exp.

Tested on x86_64-linux with gcc-7.5.0, gcc-4.8.5, and clang 10.0.1.

gdb/testsuite/ChangeLog:

2020-12-19  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (supports_scalar_storage_order_attribute)
(supports_gnuc): New proc.
* gdb.base/endianity.exp: Define TEST_SSO.  Eliminate
test_compiler_info calls.  Add unsupported message.
* gdb.base/endianity.c: Use TEST_SSO.

3 years agoDon't compare types of enum fields
Hannes Domani [Mon, 14 Dec 2020 18:06:38 +0000 (19:06 +0100)] 
Don't compare types of enum fields

Comparing types of enum fields results in a crash, because they don't
have a type.

It can be reproduced by comparing the types of 2 instances of the same
enum type in different objects:

enum.h:

    enum e
    {
      zero,
      one,
    };

enum-1.c:

    #include <enum.h>
    int func();
    enum e e1;
    int main()
    {
      return e1 + func();
    }

enum-2.c:

    #include <enum.h>
    enum e e2;
    int func()
    {
      return e2;
    }

$ gcc -g -oenum enum-1.c enum-2.c
$ gdb -q enum.exe
Reading symbols from enum.exe...
(gdb) py print(gdb.parse_and_eval("e1").type==gdb.parse_and_eval("e2").type)

Thread 1 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 6184.0x1cc4]
check_typedef (type=0x0) at C:/src/repos/binutils-gdb.git/gdb/gdbtypes.c:2745
2745      while (type->code () == TYPE_CODE_TYPEDEF)

gdb/ChangeLog:

2020-12-19  Hannes Domani  <ssbssa@yahoo.de>

PR exp/27070
* gdbtypes.c (check_types_equal): Don't compare types of enum fields.

gdb/testsuite/ChangeLog:

2020-12-19  Hannes Domani  <ssbssa@yahoo.de>

PR exp/27070
* gdb.python/compare-enum-type-a.c: New test.
* gdb.python/compare-enum-type-b.c: New test.
* gdb.python/compare-enum-type.exp: New file.
* gdb.python/compare-enum-type.h: New test.

3 years agoWarn about static libs vs. source-highlight only when necessary
Bernd Edlinger [Wed, 16 Dec 2020 18:47:18 +0000 (19:47 +0100)] 
Warn about static libs vs. source-highlight only when necessary

Avoid the error message when source-highlight is actually available.

2020-12-19  Bernd Edlinger  <bernd.edlinger@hotmail.de>

* configure.ac: Move the static libs vs. source-highlight
error message to a better place.
* configure: Regenerate.

3 years agoAutomatic date update in version.in
GDB Administrator [Sat, 19 Dec 2020 00:00:06 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoFix name of main_type field type in pretty printer
Hannes Domani [Fri, 18 Dec 2020 17:35:31 +0000 (18:35 +0100)] 
Fix name of main_type field type in pretty printer

It was renamed from type to m_type.

gdb/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

* gdb-gdb.py.in: Fix main_type field name.

3 years agoRemove erroneous 'a' in gdb.register_window_type documentation
Hannes Domani [Fri, 18 Dec 2020 17:31:52 +0000 (18:31 +0100)] 
Remove erroneous 'a' in gdb.register_window_type documentation

gdb/doc/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

* python.texi (TUI Windows In Python): Remove erroneous 'a'.

3 years agoAdd address keyword to Value.format_string
Hannes Domani [Fri, 18 Dec 2020 16:23:06 +0000 (17:23 +0100)] 
Add address keyword to Value.format_string

This makes it possible to disable the address in the result string:

const char *str = "alpha";

(gdb) py print(gdb.parse_and_eval("str").format_string())
0x404000 "alpha"
(gdb) py print(gdb.parse_and_eval("str").format_string(address=False))
"alpha"

gdb/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

* python/py-value.c (valpy_format_string): Implement address keyword.

gdb/doc/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

* python.texi (Values From Inferior): Document the address keyword.

gdb/testsuite/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

* gdb.python/py-format-string.exp: Add tests for address keyword.

3 years agoFix accessing a method's fields from Python
Hannes Domani [Fri, 18 Dec 2020 15:17:46 +0000 (16:17 +0100)] 
Fix accessing a method's fields from Python

Considering this example:

struct C
{
  int func() { return 1; }
} c;
int main()
{
  return c.func();
}

Accessing the fields of C::func, when requesting the function by its
type, works:

(gdb) py print(gdb.parse_and_eval('C::func').type.fields()[0].type)
C * const

But when trying to do the same via a class instance, it fails:

(gdb) py print(gdb.parse_and_eval('c')['func'].type.fields()[0].type)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: Type is not a structure, union, enum, or function type.
Error while executing Python code.

The difference is that in the former the function type is TYPE_CODE_FUNC:

(gdb) py print(gdb.parse_and_eval('C::func').type.code == gdb.TYPE_CODE_FUNC)
True

And in the latter the function type is TYPE_CODE_METHOD:

(gdb) py print(gdb.parse_and_eval('c')['func'].type.code == gdb.TYPE_CODE_METHOD)
True

So this adds the functionality for TYPE_CODE_METHOD as well.

gdb/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

* python/py-type.c (typy_get_composite): Add TYPE_CODE_METHOD.

gdb/testsuite/ChangeLog:

2020-12-18  Hannes Domani  <ssbssa@yahoo.de>

* gdb.python/py-type.exp: Add tests for TYPE_CODE_METHOD.

3 years agogdb: define COFF file offsets with file_ptr
Jameson Nash [Fri, 18 Dec 2020 19:08:53 +0000 (14:08 -0500)] 
gdb: define COFF file offsets with file_ptr

The arguments to these functions are file_ptr, so these declarations
were accidentally implicitly down-casting them to signed int. This
allows for reading files between 2 and 4 GB in size in my testing (I
don't have a larger dll currently to test). These may not be natively
supported by Windows, but can appear when using split-dwarf information.

This solves a "can't get string table" error resulting from attempting
to pass a negative offset to bfd_seek. I encountered this occuring while
trying to use a debug file for libLLVM.dll, but searching online reveals
at least one other person may have run into a similar problem with
Firefox?

    https://sourceforge.net/p/mingw-w64/mailman/mingw-w64-public/thread/CA+cU71k2bU0azQxjy4-77ynQj1O+TKmgtaTKe59n7Bjub1y7Tg@mail.gmail.com/

With this patch, the debug file appears to load successfully and I can
see debug information in gdb for the library.

gdb/ChangeLog:

* coffread.c (linetab_offset): Change type to file_ptr.
(linetab_size): Likewise.
(enter_linenos): Change parameter type to file_ptr.
(init_lineno): Likewise.
(init_stringtab): Likewise.
(coff_symtab_read): Likewise.
(coff_symfile_read): Change variable types to file_ptr.

Change-Id: I6ae3bf31efc51c826734ade6731ea6b1c32129f3

3 years agoRun fixed_points.exp with -fgnat-encodings=minimal
Tom Tromey [Fri, 18 Dec 2020 15:48:36 +0000 (08:48 -0700)] 
Run fixed_points.exp with -fgnat-encodings=minimal

This changes the test case gdb.ada/fixed_points.exp to also be run
with -fgnat-encodings=minimal.  This change pointed out that the test
case had a few incorrect expected outputs; these are fixed as well.

Note that the Overprecise_Object test only uses the non-legacy output
with GCC trunk.

gdb/testsuite/ChangeLog
2020-12-18  Tom Tromey  <tromey@adacore.com>

* gdb.ada/fixed_points.exp: Also run with
-fgnat-encodings=minimal.  Update expected output.

3 years agold: Build and install only unversioned libdep
H.J. Lu [Fri, 18 Dec 2020 12:30:47 +0000 (04:30 -0800)] 
ld: Build and install only unversioned libdep

Build only unversioned libdep and remove the installed libdep.la since
only a single libdep.so is needed.

PR ld/27082
* Makefile.am
(libdep_la_LDFLAGS): Add -module -avoid-version.
(libdep_la_LINK): New.
(install-data-local): Depend on $(install-bfdpluginLTLIBRARIES)
and remove libdep.la.

3 years agoelf: Copy elf_gnu_osabi_retain only for relocatable link
H.J. Lu [Fri, 18 Dec 2020 12:24:26 +0000 (04:24 -0800)] 
elf: Copy elf_gnu_osabi_retain only for relocatable link

Copy elf_gnu_osabi_retain from input only for relocatable link since
SHF_GNU_RETAIN has no impact on non-relocatable outputs.

bfd/

PR ld/27091
* elflink.c (elf_link_input_bfd): Copy elf_gnu_osabi_retain
from input only for relocatable link.

ld/

PR ld/27091
* testsuite/ld-elf/retain7.s: New file.
* testsuite/ld-elf/retain7a.d: Likewise.
* testsuite/ld-elf/retain7b.d: Likewise.

3 years agoAssorted tidies
Alan Modra [Thu, 17 Dec 2020 23:08:00 +0000 (09:38 +1030)] 
Assorted tidies

bfd/
* elf32-microblaze.c (dbg): Delete unused variable.
* elf32-nds32.c (relax_group_section_id_list): Make static.
* som.c (reloc_queue): Make static.
* xtensa-isa.c (xtisa_errno, xtisa_error_msg): Make static.
include/
* xtensa-isa-internal.h (xtisa_errno, xtisa_error_msg): Delete.

3 years agoRemove some static buffers
Alan Modra [Thu, 17 Dec 2020 12:51:11 +0000 (23:21 +1030)] 
Remove some static buffers

Fixes possible overflow of a static buffer for powerpc with translated
messages, and on v850 when symbol names are large.

* archive.c (_bfd_ar_spacepad, _bfd_ar_sizepad): Use auto buf.
* coff-mcore.c (coff_mcore_relocate_section): Likewise.
* elf32-ppc.c (ppc_elf_unhandled_reloc): Use asprintf in place
of fixed size and possibly too small buf for translated message.
* elf64-ppc.c (ppc64_elf_unhandled_reloc): Likewise.
* elf32-v850.c (v850_elf_check_relocs): Likewise.
* ecoff.c (ecoff_type_to_string): Pass in return string buff rather
than using static buffer2.  Delete dead code.  Remove unnecessary
parentheses.
(_bfd_ecoff_print_symbol): Pass auto buff to ecoff_type_to_string.
* elf32-rx.c (describe_flags): Pass in return string buf rather
than using static buf.
(rx_elf_merge_private_bfd_data): Pass buf to describe_flags.
(rx_elf_print_private_bfd_data): Likewise.
* mach-o.c (cpusubtype): Pass in return string buffer rather than
using static buffer.
(bfd_mach_o_bfd_print_private_bfd_data): Pass buff to cpusubtype.
* opncls.c (separate_debug_file_exists): Make buffer an auto var.
(bfd_fill_in_gnu_debuglink_section): Likewise.
* peXXigen.c (rsrc_resource_name): Pass in return string buffer
rather than using static buffer.
(rsrc_sort_entries): Pass buff to rsrc_resource_name.
* vms-alpha.c (_bfd_vms_write_emh): Pass tbuf to get_vms_time_string.
* vms-misc.c (get_vms_time_string): Pass in return string tbuf
rather than using static tbuf.
* vms.h (get_vms_time_string): Update prototype.

3 years agoConstify more arrays
Alan Modra [Wed, 16 Dec 2020 22:03:39 +0000 (08:33 +1030)] 
Constify more arrays

bfd/
* coff-z80.c (bfd_howto_type): Make typedef const.
* elf32-z80.c (bfd_howto_type): Likewise.
* elf32-m32c.c (EncodingTable): Likewise.
* elf32-csky.c (csky_arch_for_merge): Likewise.
(csky_archs): Use typedef.
* elf32-m68hc11.c (m68hc11_direct_relax_table): Make const.
(find_relaxable_insn, m68hc11_elf_relax_section): Adjust to suit.
* elf32-ppc.c (ppc_alt_plt): Make const.
* elf32-rl78.c (relax_addr16): Likewise.
* targets.c (_bfd_associated_vector): Likewise.
(bfd_target_vector, bfd_associated_vector): Likewise.
* libbfd-in.h (bfd_target_vector, bfd_associated_vector): Likewise.
* libbfd.h: Regenerate.
include/
* opcode/arc-attrs.h (CONFLICT_LIST): Make const.

3 years agoStatically initialise target common sections
Alan Modra [Wed, 16 Dec 2020 21:14:48 +0000 (07:44 +1030)] 
Statically initialise target common sections

This tidies initialisation of target common sections, doing so using a
static initialiser rather than via code and deleting unnecessary
symbol_ptr_ptr variables (the one in asection is used instead).

The patch also initialises ecoff.c:bfd_debug_section using
BFD_FAKE_SECTION.  That does change bfd_debug_section slightly,
output_section was NULL now bfd_debug_section, and symbol_ptr_ptr
was NULL now &bfd_debug_section.symbol, but I believe those changes
are safe.

bfd/
* ecoff.c (bfd_debug_section): Init using BFD_FAKE_SECTION.
(ecoff_scom_section, ecoff_scom_symbol): Statically init using
BFD_FAKE_SECTION and GLOBAL_SYM_INIT.  Delete initialisation code.
(ecoff_scom_symbol_ptr): Delete.
* elf32-m32r.c (m32r_elf_scom_section, m32r_elf_scom_symbol),
(m32r_elf_scom_symbol_ptr),
* elf32-score.c (score_elf_scom_section, score_elf_scom_symbol),
(score_elf_scom_symbol_ptr),
* elf32-score7.c (score_elf_scom_section, score_elf_scom_symbol),
(score_elf_scom_symbol_ptr),
* elf32-tic6x.c (tic6x_elf_scom_section, tic6x_elf_scom_symbol),
(tic6x_elf_scom_symbol_ptr),
* elf32-v850.c (v850_elf_scom_section, v850_elf_scom_symbol),
(v850_elf_scom_symbol_ptr),
(v850_elf_tcom_section, v850_elf_tcom_symbol),
(v850_elf_tcom_symbol_ptr),
(v850_elf_zcom_section, v850_elf_zcom_symbol),
(v850_elf_zcom_symbol_ptr),
* elf64-mmix.c (mmix_elf_reg_section, mmix_elf_reg_section_symbol),
(mmix_elf_reg_section_symbol_ptr),
* elfxx-mips.c (mips_elf_scom_section, mips_elf_scom_symbol),
(mips_elf_scom_symbol_ptr): Likewise.
gas/
* ecoff.c (ecoff_frob_symbol): Rename scom_section to
ecoff_scom_section and statically initialise.

3 years agoAutomatic date update in version.in
GDB Administrator [Fri, 18 Dec 2020 00:00:17 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoRemove a use of n_spaces
Tom Tromey [Thu, 17 Dec 2020 20:37:20 +0000 (13:37 -0700)] 
Remove a use of n_spaces

While removing printfi_filtered, I found a spot that used n_spaces
where the now-ordinary "%*s" approach would do.  This patch makes this
change.

Tested on x86-64 Fedora 32.

gdb/ChangeLog
2020-12-17  Tom Tromey  <tromey@adacore.com>

* printcmd.c (print_variable_and_value): Don't use n_spaces.

3 years agoRemove printfi_filtered and fprintfi_filtered
Tom Tromey [Thu, 17 Dec 2020 20:29:38 +0000 (13:29 -0700)] 
Remove printfi_filtered and fprintfi_filtered

After seeing Simon's patch, I thought maybe it was finally time to
remove printfi_filtered and fprintfi_filtered, in favor of using the
"%*s" approach to indenting.

In this patch I took the straightforward approach of always adding a
leading "%*s", even when the format already started with "%s", to
avoid the trickier form of:

    printf ("%*s", -indent, string)

Regression tested on x86-64 Fedora 32.
Let me know what you think.

gdb/ChangeLog
2020-12-17  Tom Tromey  <tromey@adacore.com>

* gdbtypes.c (print_args, dump_fn_fieldlists, print_cplus_stuff)
(print_gnat_stuff, print_fixed_point_type_info)
(recursive_dump_type): Update.
* go32-nat.c (go32_sysinfo, display_descriptor): Update.
* c-typeprint.c (c_type_print_base_struct_union)
(c_type_print_base_1): Update.
* rust-lang.c (rust_internal_print_type): Update.
* f-typeprint.c (f_language::f_type_print_base): Update.
* utils.h (fprintfi_filtered, printfi_filtered): Remove.
* m2-typeprint.c (m2_record_fields): Update.
* p-typeprint.c (pascal_type_print_base): Update.
* compile/compile-loc2c.c (push, pushf, unary, binary)
(do_compile_dwarf_expr_to_c): Update.
* utils.c (fprintfi_filtered, printfi_filtered): Remove.

3 years agogdb/doc: fix "show check range" command name
Simon Marchi [Thu, 17 Dec 2020 14:39:33 +0000 (09:39 -0500)] 
gdb/doc: fix "show check range" command name

gdb/doc/ChangeLog:

PR gdb/27088
* gdb.texinfo (Range Checking): Fix "show check range" command
name.

Change-Id: I0248ef76d205ac49ed71b813aafe3e630c2ffc2e

3 years agoChange parameters to language_defn::post_parser
Tom Tromey [Wed, 16 Dec 2020 22:49:40 +0000 (15:49 -0700)] 
Change parameters to language_defn::post_parser

In the expression rewrite, Ada type resolution will be done at parse
time rather than in a post-parse pass.  At this point,
language_defn::post_parser will be removed.  However, for this to
work, the information available to post_parser must be made available
during the actual parse.

This patch refactors this code slightly to make this possible.  In
particular, "void_context_p" is passed to the parser_state
constructor, and the parser state is then passed to the post_parser
method.

gdb/ChangeLog
2020-12-16  Tom Tromey  <tom@tromey.com>

* rust-exp.y (rust_lex_tests): Update.
* parser-defs.h (parser_state): Add void_p parameter.
<void_context_p>: New member.
* parse.c (parse_exp_in_context): Update.
* language.h (language_defn::post_parser): Remove void_context_p,
completing, tracker parameters.  Add parser state.
* ada-lang.c (ada_language::post_parser): Update.

3 years agoAutomatic date update in version.in
GDB Administrator [Thu, 17 Dec 2020 00:00:18 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoChange void_context_p to bool
Tom Tromey [Wed, 16 Dec 2020 22:12:55 +0000 (15:12 -0700)] 
Change void_context_p to bool

This patch changes void_context_p to bool, as a prerequisite to the
change to post_parser that I submitted here:

https://sourceware.org/pipermail/gdb-patches/2020-December/174080.html

Tested by rebuilding.

Note that nothing in-tree passes true here.  I don't know why this is,
but there is a use of this internally in AdaCore's tree.  I will try
to submit that patch, if it is needed.  (And if not, I will come back
around and remove this.)

gdb/ChangeLog
2020-12-16  Tom Tromey  <tom@tromey.com>

* parse.c (parse_exp_1, parse_expression_for_completion): Update.
(parse_exp_in_context): Change void_context_p to bool.
* language.h (struct language_defn) <post_parser>: Change
void_context_p to bool.
* ada-lang.c (class ada_language) <post_parser>: Update.

3 years agogdb/testsuite: make some tests in gdb.base enable non-stop using GDBFLAGS
Simon Marchi [Wed, 16 Dec 2020 21:43:18 +0000 (16:43 -0500)] 
gdb/testsuite: make some tests in gdb.base enable non-stop using GDBFLAGS

For the same reason as explained in commit 7cb2893dfab1 ("gdb/testsuite:
gdb.mi/mi-nonstop-exit.exp: enable non-stop using GDBFLAGS").

Note that the use of

    set GDBFLAGS "$GDBFLAGS ..."

instead of

    append GDBFLAGS "..."

is intentional.  "append" is silent when appending to a non-existent
variable.  So if this code if moved to a proc (as is the case already
for step-sw-breakpoint-adjust-pc.exp) and we forget to add "global
GDBFLAGS", the flag won't be added to the global GDBFLAGS, and we won't
actually enable non-stop, and it might go unnoticed.  Using the "set"
version will turn into an error if we forget the "global".

This makes these test work correctly with native-extended-gdbserver.
Some of them were silently failing because we runto_main is silent when
it fails.

gdb/testsuite/ChangeLog:

* gdb.base/async-shell.exp: Enable non-stop through GDBFLAGS.
* gdb.base/continue-all-already-running.exp: Likewise.
* gdb.base/moribund-step.exp: Likewise.
* gdb.base/step-sw-breakpoint-adjust-pc.exp: Likewise.

Change-Id: I19ef05d07a0ec4a9c9476af2ba6e1ea1159ee437

3 years agold: Skip libdep plugin if not all plugin hooks are available
H.J. Lu [Wed, 16 Dec 2020 21:40:42 +0000 (13:40 -0800)] 
ld: Skip libdep plugin if not all plugin hooks are available

Skip plugin if not all required plugin hooks are available.

2020-12-16  Howard Chu <hyc@symas.com>
    H.J. Lu  <hongjiu.lu@intel.com>

PR ld/27081
* libdep_plugin.c (onload): Skip if not all required plugin hooks
are available.
* testsuite/config/default.exp (dep_plug_opt): New.
* testsuite/ld-elf/elf.exp: Pass $dep_plug_opt to nm.
* testsuite/ld-elf/pr26391.fd: New file.

3 years ago[gdb/testsuite] Fix prompt regexp in batch-preserve-term-settings.exp
Tom de Vries [Wed, 16 Dec 2020 20:32:59 +0000 (21:32 +0100)] 
[gdb/testsuite] Fix prompt regexp in batch-preserve-term-settings.exp

On openSUSE Leap 15.2, when running test-case
gdb.base/batch-preserve-term-settings.exp I get:
...
spawn /bin/sh^M
PS1="gdb-subshell$ "^M
sh-4.4$ PS1="gdb-subshell$ "^M
gdb-subshell$ PASS: gdb.base/batch-preserve-term-settings.exp: batch run: \
  spawn shell
...
but on Ubuntu 18.04.5, I get instead:
...
spawn /bin/sh^M
PS1="gdb-subshell$ "^M
$ gdb-subshell$ FAIL: gdb.base/batch-preserve-term-settings.exp: batch run: \
  spawn shell (timeout)
...

Fix this by making the regexp recognize the second pattern as well.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-16  Tom de Vries  <tdevries@suse.de>

* gdb.base/batch-preserve-term-settings.exp:

3 years ago[gdb] Print progress for debuginfod
Martin Liska [Wed, 16 Dec 2020 17:18:40 +0000 (18:18 +0100)] 
[gdb] Print progress for debuginfod

Prints progress like:

Downloading 4.89 MB separate debug info for /usr/lib64/libgcrypt.so.20.
Downloading 1.10 MB separate debug info for /usr/lib64/liblzma.so.5.
Downloading 1.31 MB separate debug info for /usr/lib64/liblz4.so.1.
Downloading 0.96 MB separate debug info for /usr/lib64/libsmime3.so.
[###                                                                    ]

Tested on x86_64-linux.

ChangeLog:

2020-12-16  Martin Liska  <mliska@suse.cz>
    Tom de Vries  <tdevries@suse.de>

* gdb/debuginfod-support.c (struct user_data): Remove has_printed
field.  Add meter field.
(progressfn): Print progress using meter.

3 years ago[gdb/cli] Add a progress meter
Tom Tromey [Wed, 16 Dec 2020 17:18:40 +0000 (18:18 +0100)] 
[gdb/cli] Add a progress meter

Add a progress meter.  It's not used anywhere yet.

gdb/ChangeLog:

2020-12-16  Tom Tromey  <tom@tromey.com>
    Tom Tromey  <tromey@redhat.com>
    Tom de Vries  <tdevries@suse.de>

* utils.h (get_chars_per_line): Declare.
* utils.c (get_chars_per_line): New function.
(fputs_maybe_filtered): Handle '\r'.
* ui-out.h (ui_out::progress_meter): New class.
(ui_out::progress, ui_out::do_progress_start)
(ui_out::do_progress_notify, ui_out::do_progress_end): New
methods.
* ui-out.c (do_progress_end)
(make_cleanup_ui_out_progress_begin_end, ui_out_progress): New
functions.
* mi/mi-out.h (mi_ui_out::do_progress_start)
(mi_ui_out::do_progress_notify, mi_ui_out::do_progress_end): New
methods.
* cli-out.h (struct cli_ui_out) <do_progress_start,
do_progress_notify, do_progress_end>: New methods.
<enum meter_stat, struct cli_progress_info>: New.
<m_meters>: New member.
* cli-out.c (cli_ui_out::do_progress_start)
(cli_ui_out::do_progress_notify, cli_ui_out::do_progress_end): New
methods.

3 years ago[gdb/testsuite] Fix shlib compilation with target board unix/-pie/-fPIE
Tom de Vries [Wed, 16 Dec 2020 17:18:40 +0000 (18:18 +0100)] 
[gdb/testsuite] Fix shlib compilation with target board unix/-pie/-fPIE

When running test-case gdb.base/info-shared.exp with target board
unix/-pie/-fPIE, we run into:
...
spawn -ignore SIGHUP gcc -fno-stack-protector \
  outputs/gdb.base/info-shared/info-shared-solib1.c.o \
  -fdiagnostics-color=never -fPIC -shared -Wl,-soname,info-shared-solib1.so \
  -lm -fPIE -pie -o outputs/gdb.base/info-shared/info-shared-solib1.so^M
ld: Scrt1.o: in function `_start':^M
start.S:104: undefined reference to `main'^M
collect2: error: ld returned 1 exit status^M
compiler exited with status 1
...

The intention of the -pie/-fPIE flags is to build and test PIE executables on
platforms where that is not the default.  However, the flags clash with the
flags required to build shared libraries.

Fix this by filtering out PIE-related flags out of the multilib_flags settings
in compile_shared_lib.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-16  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (gdb_compile_shlib_1): Factor out of ...
(gdb_compile_shlib): ... here.  Filter out PIE-related flags.

3 years agoRecord FPSR for SIMD/FP data instructions
Luis Machado [Mon, 14 Dec 2020 14:40:01 +0000 (11:40 -0300)] 
Record FPSR for SIMD/FP data instructions

I noticed this failure in gdb.reverse/reverse-insn.exp:

FAIL: gdb.reverse/insn-reverse.exp: adv_simd_vect_shift: compare registers on insn 0:fcvtzs     s0, s0, #1

Turns out we're not recording changes to the FPSR.  The SIMD/FP data
instructions may set bits in the FPSR, so it needs to be recorded for
proper reverse operations.

gdb/ChangeLog:

2020-12-16  Luis Machado  <luis.machado@linaro.org>

* aarch64-tdep.c (aarch64_record_data_proc_simd_fp): Record FPSR.

3 years agoFix TBI handling for watchpoints
Luis Machado [Thu, 10 Dec 2020 19:51:20 +0000 (16:51 -0300)] 
Fix TBI handling for watchpoints

When inserting hw watchpoints, we take care of masking off the top byte
of the address (and sign-extending it if needed).  This guarantees we won't
pass tagged addresses to the kernel via ptrace.

However, from the kernel documentation on tagged pointers...

"Non-zero tags are not preserved when delivering signals. This means that
signal handlers in applications making use of tags cannot rely on the tag
information for user virtual addresses being maintained for fields inside
siginfo_t.

One exception to this rule is for signals raised in response to watchpoint
debug exceptions, where the tag information will be preserved."

So the stopped data address after a hw watchpoint hit can be potentially
tagged, and we don't handle this in GDB at the moment.  This results in
GDB missing a hw watchpoint hit and attempting to step over an unsteppable
hw watchpoint, causing it to spin endlessly.

The following patch fixes this by adjusting the stopped data address and adds
some tests to expose the problem.

gdb/ChangeLog:

2020-12-16  Luis Machado  <luis.machado@linaro.org>

* aarch64-linux-nat.c
(aarch64_linux_nat_target::stopped_data_address): Handle the TBI.

gdbserver/ChangeLog:

2020-12-16  Luis Machado  <luis.machado@linaro.org>

* linux-aarch64-low.cc (address_significant): New function.
(aarch64_target::low_stopped_data_address): Handle the TBI.

gdb/testsuite/ChangeLog:

2020-12-16  Luis Machado  <luis.machado@linaro.org>

* gdb.arch/aarch64-tagged-pointer.c (main): Add a few more
pointer-based memory accesses.
* gdb.arch/aarch64-tagged-pointer.exp: Exercise additional
hw watchpoint cases.

3 years agoconstify elfNN_bed
Alan Modra [Tue, 15 Dec 2020 14:12:21 +0000 (00:42 +1030)] 
constify elfNN_bed

elfNN_bed was made writable as an expedient means of communicating
ld -z max-page-size and ld -z common-page-size values to BFD linker
code, and even for objcopy to communicate segment alignment between
copy_private_bfd_data, rewrite_elf_program_header and
assign_file_positions_for_load_sections.  Some time later elfNN_bed
elf_osabi was written by gas.  It turns out none of these
modifications to elfNN_bed was necessary, so make it const again.

include/
* bfdlink.h (struct bfd_link_info): Add maxpagesize and
commonpagesize.
bfd/
* elfxx-target.h (elfNN_bed): Constify.
* bfd.c (bfd_elf_set_pagesize): Delete.
(bfd_emul_set_maxpagesize, bfd_emul_set_commonpagesize): Delete.
* elf.c (get_program_header_size): Get commonpagesize from
link info.
(_bfd_elf_map_sections_to_segments): Get maxpagesize from link info.
(assign_file_positions_for_load_sections): Likewise.
(assign_file_positions_for_non_load_sections): Likewise.
(rewrite_elf_program_header): Add maxpagesize param.  Set map_p_align.
(copy_private_bfd_data): Don't call bfd_elf_set_maxpagesize.
Instead pass maxpagesize to rewrite_elf_program_header.
* elf32-nds32.c (relax_range_measurement): Add link_info param.
Get maxpagesize from link_info.  Adjust caller.
* bfd-in2.h: Regenerate.
gas/
* config/obj-elf.c (obj_elf_section): Don't set elf_osabi here.
(obj_elf_type): Likewise.
ld/
* ld.h (ld_config_type): Delete maxpagesize and commonpagesize.
* emultempl/elf.em: Use link_info rather than config
for maxpagesize and commonpagesize.
* emultempl/ppc32elf.em: Likewise.
* ldexp.c (fold_binary, fold_name): Likewise.
* ldemul.c (after_parse_default): Likewise.
(set_output_arch_default): Don't call bfd_emul_set_maxpagesize
or bfd_emul_set_commonpagesize.

3 years agoelflink.c constify
Alan Modra [Tue, 15 Dec 2020 14:10:15 +0000 (00:40 +1030)] 
elflink.c constify

* elflink.c (elf_flags_to_names): Constify.

3 years agoXCOFF constify
Alan Modra [Tue, 15 Dec 2020 11:40:27 +0000 (22:10 +1030)] 
XCOFF constify

There are occasions where it is reasonable to use a macro defining
function parameters, but this isn't one of them.  Use typedefs
instead, which also simplifies declaring a const array of function
pointers.

* libxcoff.h (struct xcoff_backend_data_rec): Constify
_xcoff_glink_code.
(XCOFF_RELOC_FUNCTION_ARGS, XCOFF_COMPLAIN_FUNCTION_ARGS): Delete.
(xcoff_reloc_function, xcoff_complain_function): New typedef.
(xcoff_calculate_relocation, xcoff_complain_overflow),
(xcoff_reloc_type_noop, xcoff_reloc_type_fail),
(xcoff_reloc_type_pos, xcoff_reloc_type_neg),
(xcoff_reloc_type_rel, xcoff_reloc_type_toc),
(xcoff_reloc_type_ba, xcoff_reloc_type_crel): Update declaration.
* coff-rs6000.c (xcoff_reloc_type_br): Declare using typedef.
(xcoff_complain_overflow_dont_func): Likewise.
(xcoff_complain_overflow_bitfield_func): Likewise.
(xcoff_complain_overflow_signed_func): Likewise.
(xcoff_complain_overflow_unsigned_func): Likewise.
(xcoff_calculate_relocation, xcoff_complain_overflow): Constify.
(xcoff_glink_code): Constify.
* coff64-rs6000.c (xcoff64_reloc_type_br): Declare using typedef.
(xcoff64_calculate_relocation, xcoff64_glink_code): Constify.

3 years agoxtensa constify
Alan Modra [Tue, 15 Dec 2020 11:39:06 +0000 (22:09 +1030)] 
xtensa constify

Move lots of read-only arrays to .rodata.

include/
* xtensa-isa-internal.h (xtensa_format_internal),
(xtensa_slot_internal, xtensa_operand_internal),
(xtensa_arg_internal, xtensa_iclass_internal),
(xtensa_opcode_internal, xtensa_regfile_internal),
(xtensa_interface_internal, xtensa_funcUnit_internal),
(xtensa_state_internal, xtensa_sysreg_internal): Constify.
bfd/
* elf32-xtensa.c (narrowable, widenable): Constify.
* xtensa-modules.c: Constify many arrays.

3 years agoppc64 constify
Alan Modra [Tue, 15 Dec 2020 11:38:46 +0000 (22:08 +1030)] 
ppc64 constify

Nothing to see here.

* elf64-ppc.c (synthetic_opd): Constify.

3 years agoarc constify
Alan Modra [Tue, 15 Dec 2020 11:38:20 +0000 (22:08 +1030)] 
arc constify

Move a read-only array to .rodata.

* arc-plt.h (plt_versions): Constify.
* elf32-arc.c (arc_get_plt_version): Constify return pointer,
adjust uses throughout.

3 years agoLose some COFF/PE static vars, and peicode.h constify
Alan Modra [Tue, 15 Dec 2020 11:39:30 +0000 (22:09 +1030)] 
Lose some COFF/PE static vars, and peicode.h constify

This patch tidies some COFF and PE code that unnecessarily used static
variables to communicate between functions.

* coffcode.h (pelength, peheader): Delete static variables.
(coff_apply_checksum): Instead, define them as auto vars, and pass..
(coff_read_word, coff_compute_checksum): ..to here.  Delete
unnecessary forward declarations.
* pei-x86_64.c (pdata_count): Delete static variable.
(struct pex64_paps): New.
(pex64_print_all_pdata_sections, pex64_bfd_print_pdata): Pass
a pex64_paps for counting.
* peicode.h (jtab): Constify.

3 years agogdb: multi-line support for "document" command
Rae Kim [Wed, 16 Dec 2020 03:51:09 +0000 (22:51 -0500)] 
gdb: multi-line support for "document" command

"document" command executed in python, gdb.execute("document
<comname>\n...\nend\n"), will wait for user input. Python extension stops
working from that point.

multi-line suport was introduced in commit 56bcdbea2. But "document" support
seem to be implemented.

gdb/ChangeLog:

2020-12-02  Rae Kim  <rae.kim@gmail.com>

* cli/cli-script.c (do_document_command): Rename from
document_command. Handle multi-line input.
(multi_line_command_p): Handle document_control.
(build_command_line): Likewise.
(execute_control_command_1): Likewise.
(process_next_line): Likewise.
(document_command): Call do_document_command.
* cli/cli-script.h (enum command_control_type): Add
document_control.

gdb/testsuite/ChangeLog:

2020-12-02  Rae Kim  <rae.kim@gmail.com>
* gdb.base/document.exp: New test.

Change-Id: Ice262b980c05051de4c106af9f3fde5b2a6df6fe

3 years agoAdd expected type parameter to evaluate_expression
Tom Tromey [Wed, 16 Dec 2020 01:35:13 +0000 (18:35 -0700)] 
Add expected type parameter to evaluate_expression

While working on the expression rewrite, I found a few spots that
called the internal functions of the expression evaluator, just to
pass in an expected type.  This patch adds a parameter to
evaluate_expression so that these functions can avoid this dependency.

Regression tested on x86-64 Fedora 28.

gdb/ChangeLog
2020-12-15  Tom Tromey  <tom@tromey.com>

* stap-probe.c (stap_probe::evaluate_argument): Use
evaluate_expression.
* dtrace-probe.c (dtrace_probe::evaluate_argument): Use
evaluate_expression.
* value.h (evaluate_expression): Add expect_type parameter.
* objc-lang.c (print_object_command): Call evaluate_expression.
* eval.c (evaluate_expression): Add expect_type parameter.

3 years agoIntroduce expression::first_opcode
Tom Tromey [Wed, 16 Dec 2020 01:14:42 +0000 (18:14 -0700)] 
Introduce expression::first_opcode

This adds a new helper method, expression::first_opcode, that extracts
the outermost opcode of an expression.  This simplifies some patches
in the expression rewrite series.

Note that this patch requires the earlier patch to avoid manual
dissection of OP_TYPE operations.

2020-12-15  Tom Tromey  <tom@tromey.com>

* varobj.c (varobj_create): Use first_opcode.
* value.c (init_if_undefined_command): Use first_opcode.
* typeprint.c (whatis_exp): Use first_opcode.
* tracepoint.c (validate_actionline): Use first_opcode.
(encode_actions_1): Use first_opcode.
* stack.c (return_command): Use first_opcode.
* expression.h (struct expression) <first_opcode>: New method.
* eval.c (parse_and_eval_type): Use first_opcode.
* dtrace-probe.c (dtrace_process_dof_probe): Use first_opcode.

3 years agoClean up arguments to evaluate_subexp_do_call
Tom Tromey [Wed, 16 Dec 2020 00:53:34 +0000 (17:53 -0700)] 
Clean up arguments to evaluate_subexp_do_call

I noticed hat evaluate_subexp_do_call takes an array of arguments and
a count -- but, unlike the usual convention, the count does not
include the first element.

This patch changes this function to match call_function_by_hand --
passing the callee separately, and using an array_view for the
arguments.  This makes it simpler to understand.

Regression tested on x86-64 Fedora 28.

gdb/ChangeLog
2020-12-15  Tom Tromey  <tom@tromey.com>

* f-lang.c (evaluate_subexp_f): Update.
* expression.h (evaluate_subexp_do_call): Update.
* eval.c (evaluate_subexp_do_call): Add callee parameter.  Replace
nargs, argvec with array_view.
(evaluate_funcall): Update.

3 years agoC++-ify Ada component interval handling
Tom Tromey [Wed, 16 Dec 2020 00:39:57 +0000 (17:39 -0700)] 
C++-ify Ada component interval handling

The Ada component interval handling code, used for aggregate
assignments, does a pre-pass over the sub-expressions so that it can
size an array.  For my expression rewrite, it was handy to C++-ify
this.

gdb/ChangeLog
2020-12-15  Tom Tromey  <tom@tromey.com>

* ada-lang.c (num_component_specs): Remove.
(assign_aggregate): Update.
(aggregate_assign_positional, aggregate_assign_from_choices)
(aggregate_assign_others, add_component_interval): Change
arguments.

3 years agoAutomatic date update in version.in
GDB Administrator [Wed, 16 Dec 2020 00:00:15 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoCosmetic improvements for OSABI access.
Cary Coutant [Tue, 15 Dec 2020 22:37:22 +0000 (14:37 -0800)] 
Cosmetic improvements for OSABI access.

Add accessor methods to elfcpp::Ehdr class for EI_OSABI and EI_ABIVERSION;
use those to simplify initialization of Osabi class and eliminate the need
to template the class.

elfcpp/
* elfcpp.h (class Ehdr): Add get_ei_osabi and get_ei_abiversion methods.

gold/
* dwp.cc (class Dwo_file): Use new Ehdr::get_ei_osabi and
get_ei_abiversion methods.
* incremental.cc (make_sized_incremental_binary): Likewise.
* object.cc (Sized_relobj_file::Sized_relobj_file): Likewise.
(make_elf_sized_object): Likewise.
* object.h (class Osabi): Make the class untemplated.

3 years agogold: Add missing ChangeLog entries for commit ff4bc37d7
H.J. Lu [Tue, 15 Dec 2020 15:37:59 +0000 (07:37 -0800)] 
gold: Add missing ChangeLog entries for commit ff4bc37d7

3 years agoHighlight deprecated commands using title style
Tom Tromey [Tue, 15 Dec 2020 15:07:32 +0000 (08:07 -0700)] 
Highlight deprecated commands using title style

After Andrew's latest patch, I noticed that the deprecation warnings
could use the (so-called) title style when printing command names.
This patch implements this idea.

gdb/ChangeLog
2020-12-15  Tom Tromey  <tromey@adacore.com>

* cli/cli-decode.c (deprecated_cmd_warning): Use title style for
command names.

gdb/testsuite/ChangeLog
2020-12-15  Tom Tromey  <tromey@adacore.com>

* gdb.base/style.exp: Add deprecation tests.

3 years agoPR27071, gas bugs uncovered by fuzzing
Alan Modra [Tue, 15 Dec 2020 11:24:09 +0000 (21:54 +1030)] 
PR27071, gas bugs uncovered by fuzzing

PR 27071
* config/obj-elf.c (elf_obj_symbol_clone_hook): New function.
(elf_format_ops): Set symbol_clone_hook.
* config/obj-elf.h (elf_obj_symbol_clone_hook): Declare.
(obj_symbol_clone_hook): Define.
* listing.c (buffer_line): Avoid integer overflow on paper_width
set to zero.

3 years agoAdd support for the SDIV and UDIV instructions to the ARM simulator.
Jens Bauer [Tue, 15 Dec 2020 12:40:35 +0000 (12:40 +0000)] 
Add support for the SDIV and UDIV instructions to the ARM simulator.

* armemu.c (handle_v6_insn): Add support for SDIV and UDIV.
* thumbemu.c (handle_T2_insn): Likewise.

3 years ago[gdb/testsuite] Handle PS1 quirk in gdb.base/multi-line-starts-subshell.exp
Tom de Vries [Tue, 15 Dec 2020 09:18:23 +0000 (10:18 +0100)] 
[gdb/testsuite] Handle PS1 quirk in gdb.base/multi-line-starts-subshell.exp

On SLE-11, I run into:
...
(gdb) if 1^M
 >shell HOME=/dev/null PS1="gdb-subshell$ " /bin/sh^M
 >end^M
hostname:/dir> FAIL: gdb.base/multi-line-starts-subshell.exp: \
  spawn subshell from multi-line (timeout)
...

The problem is that the PS1 setting has no effect, due to a bug on older
openSUSE/SLE version.  The mechanism there is:
- /etc/profile sets ENV=/etc/bash.bashrc
- /bin/sh is started
- /bin/sh executes ENV, in other words /etc/bash.bashrc
- during the execution of /etc/bash.bashrc, PS1 is set unconditionally

Fix this by setting PS1 after spawning the subshell.

Tested on x86_64-linux.

2020-12-15  Tom de Vries  <tdevries@suse.de>

PR testsuite/26952
* gdb.base/multi-line-starts-subshell.exp: Set PS1 after spawning
shell.

3 years agoImplement and document -z unique / -z nounique handling in gold
Vivek Das Mohapatra [Mon, 14 Dec 2020 17:25:55 +0000 (17:25 +0000)] 
Implement and document -z unique / -z nounique handling in gold

* layout.cc (Layout::finish_dynamic_section): Set DF_GNU_1_UNIQUE.
* options.h (class General_options): Handle -z unique, -z nounique.

3 years agoDefine DT_GNU_FLAGS_1 and DF_GNU_1_UNIQUE for gold
Vivek Das Mohapatra [Mon, 14 Dec 2020 17:25:54 +0000 (17:25 +0000)] 
Define DT_GNU_FLAGS_1 and DF_GNU_1_UNIQUE for gold

* elfcpp.h (enum DT): New enum member DT_GNU_FLAGS_1.
(enum DF_GNU_1): New enum DF_GNU_1 containing DF_GNU_1_UNIQUE.

3 years agoHandle DT_GNU_FLAGS_1 in readelf
Vivek Das Mohapatra [Mon, 14 Dec 2020 17:25:53 +0000 (17:25 +0000)] 
Handle DT_GNU_FLAGS_1 in readelf

* readelf.c (get_dynamic_type): Handle DT_GNU_FLAGS_1.
(process_dynamic_section): Likewise.

3 years agoDocument -z unique/-z nounique in the ld man page and help output
Vivek Das Mohapatra [Mon, 14 Dec 2020 17:25:52 +0000 (17:25 +0000)] 
Document -z unique/-z nounique in the ld man page and help output

* ld.texi (Options): Document -z unique and -z nounique.
* lexsup.c (elf_shlib_list_options): Likewise.

3 years agoHandle -z unique/-z nounique in ld
Vivek Das Mohapatra [Mon, 14 Dec 2020 17:25:51 +0000 (17:25 +0000)] 
Handle -z unique/-z nounique in ld

Add (or suppress) a DT_GNU_FLAGS_1 dynamic section
with a bit flag value of DF_GNU_1_UNIQUE.

bfd/
* elflink.c (bfd_elf_size_dynamic_sections): Call
_bfd_elf_add_dynamic_entry to add a DT_GNU_FLAGS_1 section.
include/
* bfdlink.h (struct bfd_link_info): New field gnu_flags_1.
ld/
* emultempl/elf.em (gld${EMULATION_NAME}_handle_option):
Parse -z unique / -z nounique options.

3 years agoDefine a new DT_GNU_FLAGS_1 dynamic section for ld, readelf et al
Vivek Das Mohapatra [Mon, 14 Dec 2020 17:25:50 +0000 (17:25 +0000)] 
Define a new DT_GNU_FLAGS_1 dynamic section for ld, readelf et al

DT_GNU_FLAGS_1 added to the DT_VALRNGLO-DT_VALRNGHI range.
DT_GNU_FLAGS_1 value DF_GNU_1_UNIQUE added.

* elf/common.h (DT_GNU_FLAGS_1, DF_GNU_1_UNIQUE): Define.

3 years agogdb/testsuite: fix typo in gdb_test_multiple doc
Simon Marchi [Tue, 15 Dec 2020 04:45:17 +0000 (23:45 -0500)] 
gdb/testsuite: fix typo in gdb_test_multiple doc

gdb/testsuite/ChangeLog:

* lib/gdb.exp (gdb_test_multiple): Fix typo in doc.

Change-Id: Ieb188b3382395ce951bfba5a5f25aaea0f89ebf9

3 years agoAutomatic date update in version.in
GDB Administrator [Tue, 15 Dec 2020 00:00:17 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoKeep input SHF_GNU_RETAIN sections and strip output SHF_GNU_RETAIN for GNU/FreBSD...
Cary Coutant [Mon, 14 Dec 2020 23:46:47 +0000 (15:46 -0800)] 
Keep input SHF_GNU_RETAIN sections and strip output SHF_GNU_RETAIN for GNU/FreBSD ELFOSABIs.

2020-12-14  H.J. Lu  <hjl.tools@gmail.com>
    Cary Coutant  <ccoutant@gmail.com>

elfcpp/
PR gold/27039
* elfcpp.h (SHF): Add SHF_GNU_RETAIN.

gold/
     PR gold/27039
* layout.cc (Layout::layout): Strip SHF_GNU_RETAIN.
* object.cc (Sized_relobj_file::Sized_relobj_file): Initialize osabi_.
(Sized_relobj_file::do_layout): Keep SHF_GNU_RETAIN sections for
GNU/FreBSD ELFOSABIs.
* object.h (Osabi) New class.
(Sized_relobj_file): Add osabi() and osabi_.
* testsuite/Makefile.am (check_SCRIPTS): Add retain.sh.
(check_DATA): Add retain_1.out retain_2.out.
(MOSTLYCLEANFILES): Add retain_1 retain_2.
(retain_1.out): New target.
(retain_1): Likewise.
(retain_1.o): Likewise.
(retain_2.out): Likewise.
(retain_2): Likewise.
(retain_2.o): Likewise.
* testsuite/Makefile.in: Regenerate.
* testsuite/retain.sh: New file.
* testsuite/retain_1.s: Likewise.
* testsuite/retain_2.s: Likewise.

3 years agoAdd form used for SPECIAL_expr as comment in testsuite Dwarf Assembler
Mark Wielaard [Mon, 14 Dec 2020 19:00:50 +0000 (20:00 +0100)] 
Add form used for SPECIAL_expr as comment in testsuite Dwarf Assembler

Replace the "SPECIAL_expr" comment with either "DW_FORM_block" or
"DW_FORM_exprloc" in the abbrev.

gdb/testsuite/ChangeLog:

* lib/dwarf.exp (Dwarf::_handle_attribute): Handle SPECIAL_expr
specially, set attr_form_comment to the actual FORM string used.

3 years agoUse DW_FORM_exprloc in testsuite Dwarf Assembler for DWARF version 4+.
Mark Wielaard [Mon, 14 Dec 2020 16:38:09 +0000 (17:38 +0100)] 
Use DW_FORM_exprloc in testsuite Dwarf Assembler for DWARF version 4+.

Since DWARF version 4 expressions are represented by DW_FORM_exprloc
instead of a block form. Support this in the testsuite Dwarf Assembler
by setting the SPECIAL_expr form once we know the CU version.

This doesn't change any testsuite results, it just makes the produced
DWARF valid. gdb also accepts expressions in block form for DWARF
version 4 and above, but this is technically incorrect.

gdb/testsuite/ChangeLog:

* lib/dwarf.exp (Dwarf::_read_constants): Don't set
_constants(SPECIAL_expr) here, but set it...
(Dwarf::cu): ...here based on _cu_version.

3 years ago[gdb/testsuite] Don't pass -fPIC to gdb_compile_shlib
Tom de Vries [Mon, 14 Dec 2020 17:16:40 +0000 (18:16 +0100)] 
[gdb/testsuite] Don't pass -fPIC to gdb_compile_shlib

When running test-case gdb.base/info-shared.exp, I see in gdb.log:
...
Executing on host: \
  gcc ... -fPIC -fpic -c -o info-shared-solib1.c.o info-shared-solib1.c
...

The -fPIC comes from the test-case:
...
if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 \
         [list additional_flags=-fPIC]] != "" } {
...
but the -fpic, which overrides the -fPIC comes from gdb_compile_shlib.

The proc gdb_compile_shlib adds the -fpic or similar dependent on platform
and compiler.  However, in some cases it doesn't add anything, which is
probably why all those test-case pass -fPIC.

Fix this by removing -fPIC from all the calls to gdb_compile_shlib, and
ensuring that gdb_compile_shlib takes care of adding it, if required.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-14  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (gdb_compile_shlib): Make sure it's not necessary to
pass -fPIC.
* gdb.ada/catch_ex_std.exp: Don't pass -fPIC to gdb_compile_shlib.
* gdb.base/break-probes.exp: Same.
* gdb.base/ctxobj.exp: Same.
* gdb.base/dso2dso.exp: Same.
* gdb.base/global-var-nested-by-dso.exp: Same.
* gdb.base/info-shared.exp: Same.
* gdb.base/jit-reader-simple.exp: Same.
* gdb.base/print-file-var.exp: Same.
* gdb.base/skip-solib.exp: Same.
* gdb.btrace/dlopen.exp: Same.

3 years agoDo not manually dissect OP_TYPE operations
Tom Tromey [Mon, 14 Dec 2020 16:43:20 +0000 (09:43 -0700)] 
Do not manually dissect OP_TYPE operations

Some code in GDB will examine the structure of an expression to see if
it starts with OP_TYPE, and then proceed to extract the type by hand.

There is no need to do this dissection manually.  evaluate_type does
the same thing via an "allowed" API.

This patch changes such code to use evaluate_type.  In two cases this
simplifies the code.

Regression tested on x86-64 Fedora 28.

gdb/ChangeLog
2020-12-14  Tom Tromey  <tom@tromey.com>

* dtrace-probe.c (dtrace_process_dof_probe): Use value_type.
* typeprint.c (whatis_exp): Always use evaluate_type.
(maintenance_print_type): Likewise.  Simplify.

3 years ago[gdb/testsuite] Handle missing xz in gdb.base/gnu-debugdata.exp
Tom de Vries [Mon, 14 Dec 2020 16:05:11 +0000 (17:05 +0100)] 
[gdb/testsuite] Handle missing xz in gdb.base/gnu-debugdata.exp

When running test-case gdb.base/gnu-debugdata.exp on SLE-11, I run into:
...
FAIL: gdb.base/gnu-debugdata.exp: xz
...

The fact that xz is not installed does not mean there's a fail, merely that
the test is unsupported.

Fix this by detecting the "spawn failed" reply in run_on_host and issuing
UNSUPPORTED instead.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-14  Tom de Vries  <tdevries@suse.de>

PR testsuite/26963
* lib/gdb.exp (run_on_host): Declare test unsupported if spawn fails.

3 years ago[gdb/testsuite] Handle no glibc debuginfo in gdb.base/solib-corrupted.exp
Tom de Vries [Mon, 14 Dec 2020 16:05:11 +0000 (17:05 +0100)] 
[gdb/testsuite] Handle no glibc debuginfo in gdb.base/solib-corrupted.exp

When running test-case gdb.base/solib-corrupted.exp on SLE-11, I get:
...
(gdb) PASS: gdb.base/solib-corrupted.exp: normal list
p/x _r_debug->r_map->l_next = _r_debug->r_map^M
'_r_debug' has unknown type; cast it to its declared type^M
(gdb) FAIL: gdb.base/solib-corrupted.exp: make solibs looping
...

The reason that _r_debug has unknown type is that glibc debuginfo is not
installed.  The test-case attempts to detect this but doesn't handle this
particular error string.

Fix this by adding the "unknown type" line to the regexp detecting missing
glibc debuginfo.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-14  Tom de Vries  <tdevries@suse.de>

PR testsuite/26962
* gdb.base/solib-corrupted.exp: Handle "'_r_debug' has unknown type;
cast it to its declared type".

3 years ago[gdb/testsuite] Handle shell prompt in batch-preserve-term-settings.exp
Tom de Vries [Mon, 14 Dec 2020 16:05:11 +0000 (17:05 +0100)] 
[gdb/testsuite] Handle shell prompt in batch-preserve-term-settings.exp

On SLE-11, I run into:
...
FAIL: gdb.base/batch-preserve-term-settings.exp: batch run: spawn shell \
  (timeout)
...

The problem is that the shell prompt has PS1="\h:\w> ", but the test expects
a shell prompt ending in a space preceded by either '$' or '#':
...
set shell_prompt_re "\[$#\] "
...

We could easily fix this by adding '>' to shell_prompt_re, but this wouldn't
work for other PS1 setting.

Fix this instead by setting the shell prompt to "gdb-subshell$ " (as in
gdb.base/multi-line-starts-subshell.exp).

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-14  Tom de Vries  <tdevries@suse.de>

PR testsuite/26951
* gdb.base/batch-preserve-term-settings.exp: Use "gdb-subshell$ " as
shell prompt.

3 years agoHandle block-local names for Ada
Tom Tromey [Mon, 14 Dec 2020 15:14:06 +0000 (08:14 -0700)] 
Handle block-local names for Ada

GNAT can generate a mangled name with "B_N" (where N is a number) in
the middle, like "hello__B_1__fourth.0".  This is used for names local
to a block.  Multiple levels of block-local name can also occur, a
possibility that was neglected by v1 of this patch.  This patch
changes gdb to handle these names.

The wild name matcher is updated a straightforward way.  The full
matcher is rewritten.  The hash function is updated to ensure that
this works.

This version does not seem to have the performance problems that
affected v1.  In particular, the previously-slow "bt" problem has been
fixed.

gdb/ChangeLog
2020-12-14  Tom Tromey  <tromey@adacore.com>

* dictionary.c (language_defn::search_name_hash): Ignore "B".
* ada-lang.c (advance_wild_match): Ignore "B".
(full_match): Remove.
(do_full_match): Rewrite.

gdb/testsuite/ChangeLog
2020-12-14  Tom Tromey  <tromey@adacore.com>

* gdb.ada/nested.exp: Add new tests.
* gdb.ada/nested/hello.adb (Fourth, Fifth): New procedures.

3 years agoUse exact match in get_var_value
Tom Tromey [Mon, 14 Dec 2020 15:14:06 +0000 (08:14 -0700)] 
Use exact match in get_var_value

get_var_value is only used when an exact match is needed.  This
changes this function to ensure this sort of matching is done.

gdb/ChangeLog
2020-12-14  Tom Tromey  <tromey@adacore.com>

* ada-lang.c (get_var_value): Only consider exact matches.

3 years agoBe more careful when rewriting thick pointer array type
Tom Tromey [Mon, 14 Dec 2020 14:42:23 +0000 (07:42 -0700)] 
Be more careful when rewriting thick pointer array type

To handle thick pointers with -fgnat-encodings=minimal, gdb will
rewrite the underlying array type to remove the bounds.  However, if
the same DWARF type is used both for a thick pointer and for an
ordinary array, this will have the side effect of removing the bounds
from the array.  This breaks the printing of objects of this type.

This patch fixes the problem by copying the array type, its range, and
its bounds.

gdb/ChangeLog
2020-12-14  Tom Tromey  <tromey@adacore.com>

* dwarf2/read.c (rewrite_array_type): New function.
        (quirk_ada_thick_pointer_struct): Use rewrite_array_type.

gdb/testsuite/ChangeLog
2020-12-14  Tom Tromey  <tromey@adacore.com>

* gdb.dwarf2/ada-thick-pointer.exp: New file.

3 years agoHandle fixed-point division by zero
Tom Tromey [Mon, 14 Dec 2020 14:35:45 +0000 (07:35 -0700)] 
Handle fixed-point division by zero

fixed_point_binop did not account for division by zero.  This would
lead to gdb getting SIGFPE and subsequently cause some test cases to
hang.

gdb/ChangeLog
2020-12-14  Tom Tromey  <tromey@adacore.com>

* valarith.c (fixed_point_binop): Call error on division by zero.

gdb/testsuite/ChangeLog
2020-12-14  Tom Tromey  <tromey@adacore.com>

* gdb.dwarf2/dw2-fixed-point.exp: Add test for division by zero.

3 years agoAdd a plugin for processing static library dependencies.
Howard Chu [Mon, 14 Dec 2020 14:26:11 +0000 (14:26 +0000)] 
Add a plugin for processing static library dependencies.

* libdep_plugin.c: New file: Processes archives that contain a
special library dependencies element.
* Makefile.am: Add build rules for libdep_plugin.
* Makefile.in: Regenerate.
* NEWS: Mention the new plugin.
* ld.texi: Document the new plugin.

3 years agoPut bfd_section_from_shdr loop detection array in elf_tdata
Alan Modra [Mon, 14 Dec 2020 09:06:47 +0000 (19:36 +1030)] 
Put bfd_section_from_shdr loop detection array in elf_tdata

The static variables used by bfd_section_from_shdr to detect loops
in ELF sections have a problem:  Comparing a BFD pointer doesn't
guarantee that the current bfd is the same as the one previously used
to allocate the sections_being_created array.  For example, doing
   size bad_elf_1 bad_elf_2
with two corrupted ELF files containing section loops will leave the
section_being_created array allocated for the first file and since
bfd_close is called for bad_elf_1 before bfd_elf_2 is opened, it is
possible that the BFD for the second file is allocated in the same
memory as the first file.  If bad_elf_2 has more sections than
bad_elf_1 then we might write beyond the end of the array.

So this patch implements the FIXME Nick put in a comment about
attaching the array to the BFD.

* elf-bfd.h (struct elf_obj_tdata): Add being_created.
* elf.c (bfd_section_from_shdr): Delete static vars for loop
detection.  Use new tdata variable instead.
* elfcode.h (elf_object_p): Allocate being_created.

3 years agoPR26836, memory leak in parse_args
Alan Modra [Mon, 14 Dec 2020 09:04:20 +0000 (19:34 +1030)] 
PR26836, memory leak in parse_args

PR 26836
* lexsup.c (parse_args): Free really_longopts, longopts and
shortopts.

3 years agoFix a use of an uninitialised variable in the bfd linker.
Nick Clifton [Mon, 14 Dec 2020 12:40:13 +0000 (12:40 +0000)] 
Fix a use of an uninitialised variable in the bfd linker.

PR 27050
* lexsup.c (parse_args): Ensure that the longind local variable is
set.

3 years agoSolaris 11.4 ld build failure
Alan Modra [Mon, 14 Dec 2020 01:14:43 +0000 (11:44 +1030)] 
Solaris 11.4 ld build failure

/usr/include/sys/mman.h:81:0: note: this is the location of the previous definition
 #define SHARED  0x10

PR 27064
* deffilep.y (SHARED_K): Rename from SHARED.  Update uses.

3 years agorx-elf FAIL: SHF_GNU_RETAIN sections 27
Alan Modra [Sun, 13 Dec 2020 23:27:55 +0000 (09:57 +1030)] 
rx-elf FAIL: SHF_GNU_RETAIN sections 27

rx-elf is an odd target with non-standard names for default text, data
and bss sections.  This patch tweaks a new test to make it pass.

* testsuite/gas/elf/section27.s: Reorder .text, .data and .bss
so that output section order does not depend on those sections
being already created.  Use ".section .text" rather than ".text".

3 years agosim/mips/cp1.c: Include <stdlib.h> for abort() declaration
Pavel I. Kryukov [Mon, 14 Dec 2020 03:02:05 +0000 (07:02 +0400)] 
sim/mips/cp1.c: Include <stdlib.h> for abort() declaration

sim/mips/ChangeLog:

* cp1.c: Include <stdlib.h>

3 years agoRe-enable incremental tests that were failing with GCC 9+.
Cary Coutant [Mon, 14 Dec 2020 00:50:13 +0000 (16:50 -0800)] 
Re-enable incremental tests that were failing with GCC 9+.

gold/
PR gold/23539
PR gold/24123
* testsuite/Makefile.am (incremental_copy_test): Re-enable for GCC 9+.
(incremental_comdat_test_1): Likewise.
* testsuite/Makefile.in: Regenerate.

3 years agoAutomatic date update in version.in
GDB Administrator [Mon, 14 Dec 2020 00:00:11 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoFix incremental tests using gcc 9, which adds Gnu properties sections.
Cary Coutant [Sun, 13 Dec 2020 23:20:10 +0000 (15:20 -0800)] 
Fix incremental tests using gcc 9, which adds Gnu properties sections.

During an incremental link, we should simply ignore the Gnu properties
sections. We were not handling them properly -- failing to process the
properties from the base file. While that could be fixed, the property
sections are meant for deployed binaries, and incremental linking is
for development, so keeping the properties sections just adds to the
likelihood of forcing a full link sooner.

gold/
PR gold/23539
* object.cc (Sized_relobj_file::layout_gnu_property_section): Ignore
Gnu properties during incremental links.

3 years agoFix incremental linking with rodata merge sections.
Cary Coutant [Sun, 13 Dec 2020 23:19:41 +0000 (15:19 -0800)] 
Fix incremental linking with rodata merge sections.

When processing the incremental update, incoming .rodata merge sections
do not match the corresponding section in the base file, because the
SHF_MERGE flag had not been masked out of the latter.

gold/
PR gold/24123
* layout.cc (Layout::init_fixed_output_section): Mask out flags that
should be ignored when matching sections.

3 years agoUpdate ELF headers and readelf with recent e_machine assignments.
Cary Coutant [Fri, 11 Dec 2020 22:05:53 +0000 (14:05 -0800)] 
Update ELF headers and readelf with recent e_machine assignments.

binutils/
* readelf.c (get_machine_name): Update list of e_machine values.

include/
* elf/common.h: Update list of e_machine values.

3 years agoConstify parse_and_eval_type
Tom Tromey [Sun, 13 Dec 2020 16:51:42 +0000 (09:51 -0700)] 
Constify parse_and_eval_type

I noticed that the argumen to parse_and_eval_type could be "const".
This patch implements this change.

I wonder if this could be removed.  It's only called via
check_stub_method_group, which seems questionable to me.  However, I
didn't look into doing this.

gdb/ChangeLog
2020-12-13  Tom Tromey  <tom@tromey.com>

* gdbtypes.c (safe_parse_type): Make argument const.
* value.h (parse_and_eval_type): Make argument const.
* eval.c (parse_and_eval_type): Make argument const.

3 years ago[gdb/testsuite] Fix gdb.base/endianity.exp with gcc-4.8
Tom de Vries [Sun, 13 Dec 2020 16:22:40 +0000 (17:22 +0100)] 
[gdb/testsuite] Fix gdb.base/endianity.exp with gcc-4.8

When running test-case gdb.base/endianity.exp using gcc-4.8, we get:
...
(gdb) x/x &o.v^M
0x7fffffffd120: 0x00000004^M
(gdb) XFAIL: gdb.base/endianity.exp: x/x &o.v
x/xh &o.w^M
0x7fffffffd124: 0x0003^M
(gdb) FAIL: gdb.base/endianity.exp: x/xh &o.w
...

The gcc 4.8 compiler does not support the scalar_storage_order attribute, so
the testcase is compiled without that attribute, and the expected results are
different.

Fix this by rather than xfailing, skipping the tests if the compiler does not
support the scalar_storage_order attribute.

Tested on x86_64-linux, with gcc-4.8, gcc-7, and clang-10.

gdb/testsuite/ChangeLog:

2020-12-13  Tom de Vries  <tdevries@suse.de>

PR testsuite/26953
* gdb.base/endianity.exp: Skip tests requiring scalar_storage_order
attribute support if compiler doesn't support it.

3 years ago[gdb/testsuite] Handle ada in gdb_compile_shlib
Tom de Vries [Sun, 13 Dec 2020 15:25:19 +0000 (16:25 +0100)] 
[gdb/testsuite] Handle ada in gdb_compile_shlib

The single test-case in the testsuite that creates an ada shared library is
gdb.ada/catch_ex_std.exp.

The test-case does use gdb_compile_shlib, but with a few tweaks that make sure
things are properly handled for ada.

Move the ada-specific code to gdb_compile_shlib, such that gdb_compile_sh can
be used for ada shared libs without tweaks.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-13  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (gdb_compile_shlib): Handle ada.
* gdb.ada/catch_ex_std.exp: Use gdb_compile_shlib to compile from
source to shared lib.  Add ada to options.

3 years ago[gdb/testsuite] Avoid gnatbind/gnatlink in gdb.ada/catch_ex_std.exp
Tom de Vries [Sun, 13 Dec 2020 15:25:19 +0000 (16:25 +0100)] 
[gdb/testsuite] Avoid gnatbind/gnatlink in gdb.ada/catch_ex_std.exp

There's a single test-case in the testsuite that explicitly calls gnatbind and
gnatlink: gdb.ada/catch_ex_std.exp.

Instead, use gnatmake and pass specific gnatbind and gnatlink options using
gnatmake passthrough options -bargs and -largs.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-13  Tom de Vries  <tdevries@suse.de>

* gdb.ada/catch_ex_std.exp: Use gnatmake -bargs and -largs instead of
calling gnatbind and gnatlink.

3 years agogdb: new command 'maint flush dcache'
Andrew Burgess [Fri, 20 Nov 2020 19:34:21 +0000 (19:34 +0000)] 
gdb: new command 'maint flush dcache'

Add a new command to flush the dcache.

gdb/ChangeLog:

* NEWS: Mention new commands.
* target-dcache.c: Add 'cli/cli-cmds.h' include.
(maint_flush_dcache_command): New function.
(_initialize_target_dcache): Create new 'maint flush dcache'
command.

gdb/doc/ChangeLog:

* gdb.texinfo (Caching Target Data): Document 'maint flush
dcache'.

gdb/testsuite/ChangeLog:

* gdb.base/dcache-flush.c: New file.
* gdb.base/dcache-flush.exp: New file.

3 years agogdb: introduce new 'maint flush ' prefix command
Andrew Burgess [Fri, 20 Nov 2020 19:08:06 +0000 (19:08 +0000)] 
gdb: introduce new 'maint flush ' prefix command

We currently have two flushing commands 'flushregs' and 'maint
flush-symbol-cache'.  I'm planning to add at least one more so I
thought it might be nice if we bundled these together into one place.

And so I created the 'maint flush ' command prefix.  Currently there
are two commands:

  (gdb) maint flush symbol-cache
  (gdb) maint flush register-cache

Unfortunately, even though both of the existing flush commands are
maintenance commands, I don't know how keen we about deleting existing
commands for fear of breaking things in the wild.  So, both of the
existing flush commands 'maint flush-symbol-cache' and 'flushregs' are
still around as deprecated aliases to the new commands.

I've updated the testsuite to use the new command syntax, and updated
the documentation too.

gdb/ChangeLog:

* NEWS: Mention new commands, and that the old commands are now
deprecated.
* cli/cli-cmds.c (maintenanceflushlist): Define.
* cli/cli-cmds.h (maintenanceflushlist): Declare.
* maint.c (_initialize_maint_cmds): Initialise
maintenanceflushlist.
* regcache.c: Add 'cli/cli-cmds.h' include.
(reg_flush_command): Add header comment.
(_initialize_regcache): Create new 'maint flush register-cache'
command, make 'flushregs' an alias.
* symtab.c: Add 'cli/cli-cmds.h' include.
(_initialize_symtab): Create new 'maint flush symbol-cache'
command, make old command an alias.

gdb/doc/ChangeLog:

* gdb.texinfo (Symbols): Document 'maint flush symbol-cache'.
(Maintenance Commands): Document 'maint flush register-cache'.

gdb/testsuite/ChangeLog:

* gdb.base/c-linkage-name.exp: Update to use new 'maint flush ...'
commands.
* gdb.base/killed-outside.exp: Likewise.
* gdb.opt/inline-bt.exp: Likewise.
* gdb.perf/gmonster-null-lookup.py: Likewise.
* gdb.perf/gmonster-print-cerr.py: Likewise.
* gdb.perf/gmonster-ptype-string.py: Likewise.
* gdb.python/py-unwind.exp: Likewise.

3 years agox86: Do not dump DS/CS segment overrides for branch hints
Borislav Petkov [Fri, 11 Dec 2020 23:12:24 +0000 (00:12 +0100)] 
x86: Do not dump DS/CS segment overrides for branch hints

I've made all labels normal labels so that there's no confusion between
the different targets which is which and I match them in the .d files
with .* as Alan suggested.

Hex offsets I match with [0-9a-fx]+ since some targets prefix them with
0x, some don't, etc.

* testsuite/gas/i386/align-branch-9.s: Don't use labels that are
automatically local for ELF targets.
* testsuite/gas/i386/branch.s: Likewise.
* testsuite/gas/i386/x86-64-align-branch-9.s: Likewise.
* testsuite/gas/i386/x86-64-branch.s: Likewise.
* testsuite/gas/i386/align-branch-9.d: Adjust to match more targets.
* testsuite/gas/i386/branch.d: Likewise.
* testsuite/gas/i386/ilp32/x86-64-branch.d: Likewise.
* testsuite/gas/i386/x86-64-align-branch-9.d: Likewise.
* testsuite/gas/i386/x86-64-branch.d: Likewise.

3 years agoAutomatic date update in version.in
GDB Administrator [Sun, 13 Dec 2020 00:00:18 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoAutomatic date update in version.in
GDB Administrator [Sat, 12 Dec 2020 00:00:19 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agogdb: improve the warning given for deprecated aliases with a prefix
Andrew Burgess [Thu, 10 Dec 2020 16:03:31 +0000 (16:03 +0000)] 
gdb: improve the warning given for deprecated aliases with a prefix

Consider this GDB session:

  (gdb) define set xxx_yyy
  Type commands for definition of "set xxx_yyy".
  End with a line saying just "end".
  >echo in set xxx_yyy command\n
  >end
  (gdb) alias set qqq_aaa=set xxx_yyy
  (gdb) maintenance deprecate set qqq_aaa
  (gdb) set qqq_aaa
  Warning: 'qqq_aaa', an alias for the command 'xxx_yyy' is deprecated.
  No alternative known.

  in set xxx_yyy command
  (gdb)

Notice the warning mentions 'qqq_aaa' and 'xxx_yyy', I consider this
to be wrong.  I think the proper warning should read:

  (gdb) set qqq_aaa
  Warning: 'set qqq_aaa', an alias for the command 'set xxx_yyy', is deprecated.
  No alternative known.

With the 'set' prefixes added and a comma before the final 'is
deprecated'.  That is what this patch does.  The expected results are
updated as needed.

gdb/ChangeLog:

* cli/cli-decode.c (deprecated_cmd_warning): Ignore the prefix
result from lookup_cmd_composition_1, use the prefixes from both
the command and the alias instead.
(lookup_cmd_composition_1): Initial prefix command is the based on
the search list being passed in.  Simplify the logic for tracking
the prefix command.  Replace a use of alloca with a local
std::string.

gdb/testsuite/ChangeLog:

* gdb.base/commands.exp: Update expected results.

3 years agogdb: make deprecated_cmd_warning i18n friendly
Andrew Burgess [Thu, 10 Dec 2020 14:47:18 +0000 (14:47 +0000)] 
gdb: make deprecated_cmd_warning i18n friendly

Rewrite deprecated_cmd_warning to be i18n friendly.  While I'm going
through the function I also cleaned up some whitespace issues,
replaced uses of NULL with nullptr, and moved some comments to avoid
having to add { ... }.

Though the message being printed has a 'Warning: ' prefix I could have
changed from using printf_filtered to use warning, however, I haven't
done that in this commit as that would change what GDB outputs and I
wanted this commit NOT to change the output.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* cli/cli-decode.c (deprecated_cmd_warning): Use nullptr instead
of NULL.  Don't print message piece by piece, but sentence at a
time to allow internationalisation.  Some whitespace cleanup.

3 years agogdb: give deprecated command warning for aliases with a prefix
Andrew Burgess [Thu, 10 Dec 2020 13:19:40 +0000 (13:19 +0000)] 
gdb: give deprecated command warning for aliases with a prefix

I noticed that deprecated aliases that have a prefix don't give a
deprecated command warning.  For example looking in mi/mi-main.c we
see this:

  c = add_alias_cmd ("target-async", "mi-async", class_run, 0, &setlist);
  deprecate_cmd (c, "set mi-async");
  c = add_alias_cmd ("target-async", "mi-async", class_run, 0, &showlist);
  deprecate_cmd (c, "show mi-async");

So both 'set target-async' and 'show target-async' are deprecated and
should be giving a warning, however, in use we see no warning given.

This is a consequence of how the code that should give this
warning (deprecated_cmd_warning) performs a second command lookup in
order to distinguish between aliases and real commands, and that the
code that calls this (lookup_cmd_1) strips off prefix commands as it
calls itself recursively.

As a result when we are considering an alias like 'set target-async'
we first enter lookup_cmd_1 with text = "set target-async", we spot
the 'set' command prefix and then recursively call lookup_cmd_1 with
text = "target-async".

We spot that 'target-async' is a known alias but that it is
deprecated, and so call deprecated_cmd_warning passing in the value of
text, which remember is now "target-async".

In deprecated_cmd_warning we again perform a command lookup starting
from the top-level cmdlist, but now we're trying to find just
"target-async", this fails (as this command requires the 'set' prefix,
and so no warning is given.

I resolved this issue by passing a command list to the function
deprecated_cmd_warning, this is the list in which the command can be
found.

A new test is added to cover this case.

However, there is an additional problem which will be addressed in a
subsequent patch.

Consider this GDB session:

  (gdb) define set xxx_yyy
  Type commands for definition of "set xxx_yyy".
  End with a line saying just "end".
  >echo in set xxx_yyy command\n
  >end
  (gdb) alias set qqq_aaa=set xxx_yyy
  (gdb) maintenance deprecate set qqq_aaa
  (gdb) set qqq_aaa
  Warning: 'qqq_aaa', an alias for the command 'xxx_yyy' is deprecated.
  No alternative known.

  in set xxx_yyy command
  (gdb)

Notice the warning mentions 'qqq_aaa' and 'xxx_yyy', I consider this
to be wrong.  I think the proper warning should read:

  (gdb) set qqq_aaa
  Warning: 'set qqq_aaa', an alias for the command 'set xxx_yyy' is deprecated.
  No alternative known.

With the 'set' prefixes added.  A later patch will resolve this
issue.

gdb/ChangeLog:

PR cli/15104
* cli/cli-decode.c (lookup_cmd_1): Pass command list to
deprecated_cmd_warning.
(deprecated_cmd_warning): Take extra parameter, call
lookup_cmd_composition_1 and pass new parameter through.
(lookup_cmd_composition_1): New function, takes implementation of
lookup_cmd_composition but with extra parameter.
(lookup_cmd_composition): Now calls lookup_cmd_composition_1
passing in cmdlist.
* command.h (deprecated_cmd_warning): Add extra parameter to
declaration.
* top.c (execute_command): Pass cmdlist to deprecated_cmd_warning.

gdb/testsuite/ChangeLog:

PR cli/15104
* gdb.base/commands.exp: Add additional tests.
* gdb.base/completion.exp: Add additional tests.

3 years agogdb: don't warn about deprecated aliases during tab completion
Andrew Burgess [Tue, 8 Dec 2020 17:32:34 +0000 (17:32 +0000)] 
gdb: don't warn about deprecated aliases during tab completion

Consider this gdb session, where on line #3 tab completion is used:

  (gdb) alias xxx_yyy_zzz=break
  (gdb) maint deprecate xxx_yyy_zzz
  (gdb) xxx_yyy_<TAB>

The third line then updates to look like this:

  (gdb) xxx_yyy_Warning: 'xxx_yyy_zzz', an alias for the command 'break' is deprecated.
  No alternative known.

  zzz

What's happened is during tab completion the alias has been resolved
to the actual command being aliased, and at this stage the warning is
issued.  Clearly this is not what we want during tab completion.

In this commit I add a new parameter to the lookup function, a boolean
that indicates if the lookup is being done as part of completion.
This flag is used to suppress the warning.  Now we get the expected
behaviour, the alias completes without any warning, but the warning is
still given once the user executes the alias.

gdb/ChangeLog:

* cli/cli-decode.c (lookup_cmd_1): Move header comment into
command.h, add extra parameter, and use this to guard giving a
warning.
* command.h (lookup_cmd_1): Add comment from cli/cli-decode.c,
include argument names in declaration, add new argument.
* completer.c (complete_line_internal_1): Remove unneeded
brackets, pass extra argument to lookup_cmd_1.

gdb/testsuite/ChangeLog:

* gdb.base/completion.exp: Add additional tests.

This page took 0.053595 seconds and 4 git commands to generate.