deliverable/binutils-gdb.git
3 years agogdbsupport: re-generate configure & friends
Simon Marchi [Sun, 9 May 2021 01:27:49 +0000 (21:27 -0400)] 
gdbsupport: re-generate configure & friends

I get these changes when re-generating the autoconf stuff in gdbsupport,
fallouts from 4655f8509fd4 ("Don't run personality syscall at configure
time; don't check it at all").

gdbsupport/ChangeLog:

* Makefile.in: Re-generate.
* config.in: Re-generate.
* configure: Re-generate.

Change-Id: Ie1876ee58d6f4f1cf25fa14900eecf4c85a744c1

3 years agogdb, gdbserver: make status_to_str return std::string
Simon Marchi [Sun, 9 May 2021 01:06:41 +0000 (21:06 -0400)] 
gdb, gdbserver: make status_to_str return std::string

Instead of using a static buffer.  This is safer, and we don't really
mind about any extra dynamic allocation here, since it's only used for
debug purposes.

gdb/ChangeLog:

* nat/linux-waitpid.c (status_to_str): Return std::string.
* nat/linux-waitpid.h (status_to_str): Likewise.
* linux-nat.c (linux_nat_post_attach_wait): Adjust.
(linux_nat_target::attach): Adjust.
(linux_handle_extended_wait): Adjust.
(wait_lwp): Adjust.
(stop_wait_callback): Adjust.
(linux_nat_filter_event): Adjust.
(linux_nat_wait_1): Adjust.
* nat/linux-waitpid.c (status_to_str): Adjust.
* nat/linux-waitpid.h (status_to_str): Adjust.

gdbserver/ChangeLog:

* linux-low.cc (linux_process_target::wait_for_event_filtered):
Adjust to status_to_str returning std::string.

Change-Id: Ia8aead70270438a5690f243e6faafff6c38ff757

3 years agogdb: add missing space in infrun_debug_printf
Simon Marchi [Sun, 9 May 2021 00:37:27 +0000 (20:37 -0400)] 
gdb: add missing space in infrun_debug_printf

gdb/ChangeLog:

* infrun.h (infrun_debug_printf): Add missing space.

Change-Id: I476096a098451ff2019ab38caa41ebfef0e04a1c

3 years agoAutomatic date update in version.in
GDB Administrator [Sun, 9 May 2021 00:00:37 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agosim: h8300: clean up various warnings
Mike Frysinger [Sat, 8 May 2021 16:41:04 +0000 (12:41 -0400)] 
sim: h8300: clean up various warnings

A random grab bag of minor fixes to enable -Werror for this port.

Disable h8_set_macS for now as it's unused.
Initialize trace & intMask before using them.
Mark local set_h8300h function static.

3 years agosim: touch modules target
Mike Frysinger [Sat, 8 May 2021 16:34:03 +0000 (12:34 -0400)] 
sim: touch modules target

If there are no updates to the file, touch the result so we don't
keep trying to regenerate it.

3 years agosim: cgen: tweak trace format
Mike Frysinger [Sun, 2 May 2021 02:29:50 +0000 (22:29 -0400)] 
sim: cgen: tweak trace format

Fixes build warnings when the address size isn't an integer.

3 years agosim: cgen: namespace mode_names a bit
Mike Frysinger [Sun, 2 May 2021 02:11:41 +0000 (22:11 -0400)] 
sim: cgen: namespace mode_names a bit

These are exported in the library linkage, so add a cgen_ prefix.

3 years agosim: cgen: tweak cgen_rtx_error to fix warnings
Mike Frysinger [Sun, 2 May 2021 02:05:25 +0000 (22:05 -0400)] 
sim: cgen: tweak cgen_rtx_error to fix warnings

The function was missing a prototype, and passing a constant string
as the format string instead of going through a %s format.

3 years agosim: cgen: tweak initializers to avoid warnings
Mike Frysinger [Sun, 2 May 2021 02:03:05 +0000 (22:03 -0400)] 
sim: cgen: tweak initializers to avoid warnings

Use {} instead of {0} to avoid warnings:

common/cgen-utils.c:59:1: warning: missing braces around initializer [-Wmissing-braces]
   59 | {
      | ^
   60 |   {
   61 |     VIRTUAL_INSN_X_INVALID, "--invalid--", NULL, 0, { V, { 0 } }
      |                                                            {{}}

Generated code should be the same.

3 years agobinutils: update release docs process
Mike Frysinger [Sun, 2 May 2021 16:58:11 +0000 (12:58 -0400)] 
binutils: update release docs process

Now that we generate multiple html & pdf forms, update the release
process to show how they get updated.

3 years agosupport generating multi-html pages in parallel
Mike Frysinger [Sun, 2 May 2021 16:50:39 +0000 (12:50 -0400)] 
support generating multi-html pages in parallel

Use the pattern from other projects where we generate the html pages
in a dir named the same as the project.  So now we have:
gas/doc/gas.html - single html page
gas/doc/gas/ - multiple html pages

This works for projects that have a doc/ subdir already, but gprof &
ld require a little tweaking since they generate their docs in their
respective toplevels.

3 years agogenerate single html manual page by default
Mike Frysinger [Sun, 2 May 2021 16:09:00 +0000 (12:09 -0400)] 
generate single html manual page by default

This better matches other GNU projects like autoconf/automake where
the html manual is the single page form.  We'll support the multi-page
form in a follow up change.

3 years agosim: add html & pdf stubs
Mike Frysinger [Sat, 8 May 2021 15:53:37 +0000 (11:53 -0400)] 
sim: add html & pdf stubs

We stub out the info targets already since we don't provide any.

3 years agosim: use htab_eq_string
Tom Tromey [Sat, 8 May 2021 13:50:47 +0000 (07:50 -0600)] 
sim: use htab_eq_string

This changes the sim to use htab_eq_string from libiberty.

sim/common/ChangeLog
2021-05-08  Tom Tromey  <tom@tromey.com>

* sim-options.c (compare_strings): Remove.
(dup_arg_p): Use htab_eq_string.

3 years agoDon't run personality syscall at configure time; don't check it at all
Pedro Alves [Wed, 28 Apr 2021 22:05:15 +0000 (23:05 +0100)] 
Don't run personality syscall at configure time; don't check it at all

Currently, in order to tell whether support for disabling address
space randomization on Linux is available, GDB checks if the
personality syscall works, at configure time.  I.e., it does a run
test, instead of a compile/link test:

  AC_RUN_IFELSE([PERSONALITY_TEST],
[have_personality=true],
[have_personality=false],

This is a bit bogus, because the machine the build is done on may not
(and is when you consider distro gdbs) be the machine that eventually
runs gdb.  It would be better if this were a compile/link test
instead, and then at runtime, GDB coped with the personality syscall
failing.  Actually, GDB already copes.

One environment where this is problematic is building GDB in a Docker
container -- by default, Docker runs the container with seccomp, with
a profile that disables the personality syscall.  You can tell Docker
to use a less restricted seccomp profile, but I think we should just
fix it in GDB.

"man 2 personality" says:

       This system call first appeared in Linux 1.1.20 (and thus first
       in a stable kernel release with Linux 1.2.0); library support
       was added in glibc 2.3.

...

       ADDR_NO_RANDOMIZE (since Linux 2.6.12)
              With this flag set, disable address-space-layout randomization.

glibc 2.3 was released in 2002.
Linux 2.6.12 was released in 2005.

The original patch that added the configure checks was submitted in
2008.  The first version of the patch that was submitted to the list
called personality from common code:

 https://sourceware.org/pipermail/gdb-patches/2008-June/058204.html

and then was moved to Linux-specific code:

 https://sourceware.org/pipermail/gdb-patches/2008-June/058209.html

Since HAVE_PERSONALITY is only checked in Linux code, and
ADDR_NO_RANDOMIZE exists for over 15 years, I propose just completely
removing the configure checks.

If for some odd reason, some remotely modern system still needs a
configure check, then we can revert this commit but drop the
AC_RUN_IFELSE in favor of always doing the AC_LINK_IFELSE
cross-compile fallback.

gdb/ChangeLog:

* linux-nat.c (linux_nat_target::supports_disable_randomization):
Remove references to HAVE_PERSONALITY.
* nat/linux-personality.c: Remove references to HAVE_PERSONALITY.
(maybe_disable_address_space_randomization)
(~maybe_disable_address_space_randomizatio): Remove references to
HAVE_PERSONALITY.
* config.in, configure: Regenerate.

gdbserver/ChangeLog:

* linux-low.cc:
(linux_process_target::supports_disable_randomization): Remove
reference to HAVE_PERSONALITY.
* config.in, configure: Regenerate.

gdbsupport/ChangeLog:

* common.m4 (personality test): Remove.

3 years agoDon't include sys/personality.h in linux-low.cc anymore
Pedro Alves [Sat, 8 May 2021 11:54:43 +0000 (12:54 +0100)] 
Don't include sys/personality.h in linux-low.cc anymore

Lancelot pointed out that since the refactor at:

  https://sourceware.org/pipermail/gdb-patches/2015-January/120503.html

the sys/personality.h include is not needed in linux-low.cc anymore,
as it does not call personality directly itself anymore.

gdbserver/ChangeLog:

* linux-low.cc: Don't include sys/personality.h or define
ADDR_NO_RANDOMIZE.

3 years agosim: m68hc11: fix up cycle buffer printing
Mike Frysinger [Sat, 8 May 2021 01:53:25 +0000 (21:53 -0400)] 
sim: m68hc11: fix up cycle buffer printing

Make sure the local static buffer is large enough, and simplify the
sprintf for merging the fields all into one.  This fixes compiler
warnings from buf possibly being overflowed.

3 years agoAutomatic date update in version.in
GDB Administrator [Sat, 8 May 2021 00:00:38 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agogdb/guile: perform tilde expansion when sourcing guile scripts
Andrew Burgess [Wed, 5 May 2021 15:50:17 +0000 (16:50 +0100)] 
gdb/guile: perform tilde expansion when sourcing guile scripts

Before this patch:

  (gdb) source ~/script.scm
  ERROR: In procedure apply-smob/1:
  ERROR: In procedure primitive-load-path: Unable to find file "~/script.scm" in load path
  Error while executing Scheme code.
  (gdb)

This is because the path is not tilde expanded.  In contrast, when
sourcing a .py or .gdb script the path is tilde expanded.

This commit fixes this oversight, and allows the above source command
to work as expected.

The tilde expansion is done in the generic GDB code before we call the
sourcer function for any particular extension language.

gdb/ChangeLog:

* cli/cli-cmds.c: Add 'gdbsupport/gdb_tilde_expand.h'
include.
(source_script_with_search): Perform tilde expansion.

gdb/testsuite/ChangeLog:

* gdb.guile/guile.exp: Add an extra test.

3 years agogdb/testsuite: use gdb_test_no_output instead of send_gdb
Andrew Burgess [Fri, 7 May 2021 21:14:27 +0000 (22:14 +0100)] 
gdb/testsuite: use gdb_test_no_output instead of send_gdb

I noticed gdb.base/ptype-offsets.exp failing occasionally, this was
due to lines like this in the test script:

  send_gdb "set print type hex on\n"

As this does not match the '(gdb)' prompt that is produced, the prompt
would sometimes be matched against the next test, causing the next
test to think its output was missing and fail.

Fix this by switching to:

  gdb_test_no_output "set print type hex on"

gdb/testsuite/ChangeLog:

* gdb.base/ptype-offsets.exp: Replace use of send_gdb with
gdb_test_no_output.

3 years agogdb: make target_desc_info::filename an std::string
Simon Marchi [Fri, 7 May 2021 20:28:56 +0000 (16:28 -0400)] 
gdb: make target_desc_info::filename an std::string

To make the management of memory automatic.

As to why I chose to make this an std::string and not an
std::unique_xmalloc_ptr<char>: some parts of the code consider both a
NULL value and an empty string value to mean "no filename".
target_desc_info_from_user_p, however, doesn't check for a non-NULL but
empty string value.  So it seems like having two ways of denoting "no
filename" can lead to these kinds of inconsistencies.  Using
std::string, "no filename" is only represented by an empty value.

As a bonus, using an std::string lets us copy target_desc_info objects
using the default assignment operator.

gdb/ChangeLog:

* target-descriptions.c (struct target_desc_info) <filename>:
Make std::string.
(copy_inferior_target_desc_info): Adjust.
(target_desc_info_free): Adjust.
(target_find_description): Adjust.
(set_tdesc_filename_cmd): Adjust.
(show_tdesc_filename_cmd): Adjust.
(unset_tdesc_filename_cmd): Adjust.
(maint_print_c_tdesc_cmd): Adjust.

Change-Id: I4e3a6ad8ccda2b88c202471d4f54249753cad127

3 years agogdb: (de-)allocate target_desc_info with new/delete
Simon Marchi [Fri, 7 May 2021 20:28:56 +0000 (16:28 -0400)] 
gdb: (de-)allocate target_desc_info with new/delete

In preparation for using non-POD types in the struct.

gdb/ChangeLog:

* target-descriptions.c (struct target_desc_info): Initialize
fields.
(get_tdesc_info): Use new.
(target_desc_info_free): Use delete.

Change-Id: I10fdaeeae7cdbd7930ae7adeeb13f7f363c67c7a

3 years agogdb: change target_desc_info::fetched to bool
Simon Marchi [Fri, 7 May 2021 20:28:56 +0000 (16:28 -0400)] 
gdb: change target_desc_info::fetched to bool

gdb/ChangeLog:

* target-descriptions.c (struct target_desc_info) <fetched>:
bool.
(target_find_description): Adjust.
(target_clear_description): Adjust.

Change-Id: Ib69e097b38cf270e674f1249105d535a312954e1

3 years agogdb: remove target description macros
Simon Marchi [Fri, 7 May 2021 20:28:56 +0000 (16:28 -0400)] 
gdb: remove target description macros

In my opinion, the target_desc_fetched, current_target_desc and
target_description_filename macros in target-descriptions.c are not very
useful.  I don't think it's useful to hide that they operate on the
current inferior, as everything currently works under the assumption
that the various tdesc commands operate on the current inferior, and I
don't see that changing in the foreseeable future.

This change also avoids having multiple unnecessary calls to
current_inferior and get_tdesc_info per function.

gdb/ChangeLog:

* target-descriptions.c (struct target_desc_info) <tdesc>:
Adjust doc.
(target_desc_fetched): Remove.
(current_target_desc): Remove.
(target_description_filename): Remove.
(target_find_description): Adjust.
(target_clear_description): Adjust.
(target_current_description): Adjust.
(set_tdesc_filename_cmd): Adjust.
(show_tdesc_filename_cmd): Adjust.
(unset_tdesc_filename_cmd): Adjust.
(maint_print_c_tdesc_cmd): Adjust.
(maint_print_xml_tdesc_cmd): Adjust.

Change-Id: Ibfb581490e949c16d59924e2cac633ede5c26c5b

3 years agosim: Add bfd include path for common testsuite tools
Dimitar Dimitrov [Mon, 5 Apr 2021 16:21:35 +0000 (19:21 +0300)] 
sim: Add bfd include path for common testsuite tools

On a host without installed libbfd, this patch fixes the following
"make check-sim" errors for both pru cross target, and native x86_64:

In file included from ../../../binutils/sim/common/sim-basics.h:131,
                 from testsuite/common/bits32m0.c:13:../../../binutils/sim/../include/gdb/callback.h:55:10: fatal error: bfd.h: No such file or directory
   55 | #include "bfd.h"
      |          ^~~~~~~

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
3 years agoAdd a generic .bss directive for ELF based targets.
Nick Clifton [Fri, 7 May 2021 16:07:41 +0000 (17:07 +0100)] 
Add a generic .bss directive for ELF based targets.

PR 3136
* config/obj-elf.c (elf_pseudo_table): Add entry for .bss.
(obj_elf_bss): New function.  Change to the .bss section.
Support an optional subsection number.
(obj_elf_change_section): Call obj_elf_section_change_hook.
(obj_elf_section): Likewise.
(obj_elf_data): Likewise.
(obj_elf_text): Likewise.
(obj_elf_struct): Likewise.
(obj_elf_subsection): Likewise.
(obj_elf_previous): Likewise.
* config/obj-elf.h (obj_elf_bss): Prototype.
* doc/as.texi (Bss): New node.

3 years agogdb: some int to bool conversion
Andrew Burgess [Fri, 7 May 2021 15:49:24 +0000 (16:49 +0100)] 
gdb: some int to bool conversion

Change int parameter to bool in remote_notice_new_inferior (remote.c)
and notice_new_inferior (infcmd.c), and update the callers.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* infcmd.c (notice_new_inferior): Change parameter type.
* inferior.h (notice_new_inferior): Change parameter type.
* remote.c (remote_notice_new_inferior): Change parameter type to
bool.  Also update type of local variable to bool.
(remote_target::update_thread_list): Change type of local variable
to bool.
(remote_target::process_stop_reply): Pass bool instead of int to
remote_notice_new_inferior.

3 years agogdb: remove reference to current inferior in target_stack::unpush
Simon Marchi [Fri, 7 May 2021 15:52:51 +0000 (11:52 -0400)] 
gdb: remove reference to current inferior in target_stack::unpush

target_stack::unpush needs to get the target beneath the target being
unpushed to update the m_top field (which keeps the stratum of the
top-most target).  It currently does so using target_ops::beneath, which
uses the target stack of the current inferior.  The target stack of the
current inferior is the same as the `this` in the unpush method.

Avoid this detour and remove this reference to the current inferior by
calling target_ops::find_beneath and passing `this` to find the target
beneath `t` in the target stack that is `this`.

gdb/ChangeLog:

* target.c (target_stack::unpush): Call target_ops::find_beneath
to get the target beneath `t`.

Change-Id: If9d9661567c5c16f655d270bd2ec9f1b3aa6dadc

3 years agogdb: make target_close check that the target isn't pushed in all inferiors
Simon Marchi [Fri, 7 May 2021 15:51:19 +0000 (11:51 -0400)] 
gdb: make target_close check that the target isn't pushed in all inferiors

The target_close function currently checks that the target to be closed
isn't pushed in the current inferior:

    gdb_assert (!current_inferior ()->target_is_pushed (targ));

Normally, a target is closed when its refcount has dropped to 0, due to
not being used in any inferior anymore.  I think it would make sense to
change that assert to not only check in the current inferior, but to
check in all inferiors.  It would be quite bad (and a bug) to close a
target while it's still pushed in one of the non-current inferiors.

gdb/ChangeLog:

* target.c (target_close): Check in all inferiors that the
target is not pushed.

Change-Id: I6e37fc3f3476a0593da1e476604642b2de90f1d5

3 years agodebuginfod-support.c: Use long-lived debuginfod_client
Aaron Merey [Fri, 7 May 2021 15:37:16 +0000 (11:37 -0400)] 
debuginfod-support.c: Use long-lived debuginfod_client

Instead of initializing a new debuginfod_client for each query, store
the first initialized client for the remainder of the GDB session and
use it for every debuginfod query.

In conjunction with upcoming changes to libdebuginfod, using one client
for all queries will avoid latency caused by unneccesarily setting up
TCP connections multiple times.

Tested on Fedora 33 x86_64.

gdb/ChangeLog:

* debuginfod-support.c (debuginfod_init): Remove.
(get_debuginfod_client): New function.

3 years agoRemove streq_hash in favor of htab_eq_string
Tom Tromey [Fri, 7 May 2021 15:18:18 +0000 (09:18 -0600)] 
Remove streq_hash in favor of htab_eq_string

Now that libiberty includes htab_eq_string, we can remove the
identical function from gdb.

gdb/ChangeLog
2021-05-07  Tom Tromey  <tom@tromey.com>

* breakpoint.c (ambiguous_names_p): Use htab_eq_string.
* utils.c (streq_hash): Remove.
* utils.h (streq_hash): Don't declare.
* completer.c (completion_tracker::discard_completions): Update
comment.
* ada-lang.c (_initialize_ada_language): Use htab_eq_string.

3 years agogdb: re-format Python files using black 21.4b0
Simon Marchi [Fri, 7 May 2021 14:56:20 +0000 (10:56 -0400)] 
gdb: re-format Python files using black 21.4b0

Re-format all Python files using black [1] version 21.4b0.  The goal is
that from now on, we keep all Python files formatted using black.  And
that we never have to discuss formatting during review (for these files
at least) ever again.

One change is needed in gdb.python/py-prettyprint.exp, because it
matches the string representation of an exception, which shows source
code.  So the change in formatting must be replicated in the expected
regexp.

To document our usage of black I plan on adding this to the "GDB Python
Coding Standards" wiki page [2]:

--8<--

All Python source files under the `gdb/` directory must be formatted
using black version 21.4b0.

This specific version can be installed using:

    $ pip3 install 'black == 21.4b0'

All you need to do to re-format files is run `black <file/directory>`,
and black will re-format any Python file it finds in there.  It runs
quite fast, so the simplest is to do:

    $ black gdb/

from the top-level.

If you notice that black produces changes unrelated to your patch, it's
probably because someone forgot to run it before you.  In this case,
don't include unrelated hunks in your patch.  Push an obvious patch
fixing the formatting and rebase your work on top of that.

-->8--

Once this is merged, I plan on setting a up an `ignoreRevsFile`
config so that git-blame ignores this commit, as described here:

  https://github.com/psf/black#migrating-your-code-style-without-ruining-git-blame

I also plan on working on a git commit hook (checked in the repo) to
automatically check the formatting of the Python files on commit.

[1] https://pypi.org/project/black/
[2] https://sourceware.org/gdb/wiki/Internals%20GDB-Python-Coding-Standards

gdb/ChangeLog:

* Re-format all Python files using black.

gdb/testsuite/ChangeLog:

* Re-format all Python files using black.
* gdb.python/py-prettyprint.exp (run_lang_tests): Adjust.

Change-Id: I28588a22c2406afd6bc2703774ddfff47cd61919

3 years agogdb: add lookup_cmd_exact to simplify a common pattern
Marco Barisione [Fri, 7 May 2021 14:43:30 +0000 (15:43 +0100)] 
gdb: add lookup_cmd_exact to simplify a common pattern

In code dealing with commands, there's a pattern repeated a few times of
calling lookup_cmd with some speficic arguments and then using strcmp
on the returned command to check for an exact match.
As a later patch would add a few more similar lines of code, this patch
adds a new lookup_cmd_exact function which simplify this use case.

gdb/ChangeLog:

* cli/cli-decode.c (lookup_cmd_exact): Add.
* cli/cli-script.c (do_define_command): Use lookup_cmd_exact.
(define_prefix_command): Ditto.
* command.h: Add lookup_cmd_exact.

3 years agoFix .dwsect generation for XCOFF. Handle .function generated with DWARF on XCOFF.
Cl?ment Chigot [Fri, 7 May 2021 14:29:49 +0000 (15:29 +0100)] 
Fix .dwsect generation for XCOFF.  Handle .function generated with DWARF on XCOFF.

gas * config/tc-ppc.c (ppc_function): Update comment for
fifth argument.
(ppc_frob_symbol): Remove ppc_last_function check.
Make sure coff_last_function is reset.
Correctly set fsize when not provided in .function.
* testsuite/gas/ppc/aix.exp: New tests.
* testsuite/gas/ppc/xcoff-function-1-32.d: New test.
* testsuite/gas/ppc/xcoff-function-1-64.d: New test.
* testsuite/gas/ppc/xcoff-function-1.s: New test.

bfd * coff-rs6000.c (xcoff_dwsect_names): Add new DWARF
sections.
* coffgen.c (coff_pointerize_aux): Handle C_DWARF.
(coff_print_symbol): Likewise.
* libxcoff.h (XCOFF_DWSECT_NBR_NAMES): Update.

gas * config/obj-coff.c (coff_frob_symbol): Don't skip C_DWARF.
(coff_adjust_section_syms): Use corrext auxent for C_DWARF.
(coff_frob_section): Likewise.
* config/obj-coff.h (SA_GET_SECT_SCNLEN,
SA_GET_SECT_NRELOC, SA_SET_SECT_SCNLEN,
SA_SET_SECT_NRELOC) New defines.
(SET_SECTION_RELOCS): Adjust for C_DWARF.
* config/tc-ppc.c (ppc_frob_symbol): Don't skip C_DWARF.
(ppc_adjust_symtab): Reorder C_DWARF symbols.
* testsuite/gas/ppc/aix.exp: New tests.
* testsuite/gas/ppc/xcoff-dwsect-2-32.d: New test.
* testsuite/gas/ppc/xcoff-dwsect-2-64.d: New test.
* testsuite/gas/ppc/xcoff-dwsect-2.s: New test.

include * coff/internal.h (C_DWARF): New define.
* coff/xcoff.h (SSUBTYP_DWLOC, SSUBTYP_DWFRAME,
SSUBTYP_DWMAC): New defines.

3 years agoSrop readelf's unwind decoder from complaining about x86 binaries.
Nick Clifton [Fri, 7 May 2021 14:24:14 +0000 (15:24 +0100)] 
Srop readelf's unwind decoder from complaining about x86 binaries.

* readelf.c (no_processor_specific_unwind): New function.
(process_unwind): Use no_processor_specific_unwind for X86
targets.

3 years agolibiberty: add htab_eq_string
Tom Tromey [Thu, 29 Apr 2021 00:44:48 +0000 (18:44 -0600)] 
libiberty: add htab_eq_string

The libiberty hash table includes a helper function for strings, but
no equality function.  Consequently, this equality function has been
reimplemented a number of times in both the gcc and binutils-gdb
source trees.  This patch adds the function to the libiberty hash
table, as a step toward the goal of removing all the copies.

One change to gcc is included here.  Normally I would have put this in
the next patch, but gensupport.c used the most natural name for its
reimplementation of this function, and this can't coexist with the
extern function in libiberty.

include

* hashtab.h (htab_eq_string): Declare.

libiberty

* hashtab.c (htab_eq_string): New function.

3 years ago[gdb/symtab] Fix infinite recursion in dwarf2_cu::get_builder()
Tom de Vries [Fri, 7 May 2021 10:13:05 +0000 (12:13 +0200)] 
[gdb/symtab] Fix infinite recursion in dwarf2_cu::get_builder()

With the test-case attached in PR26327, gdb aborts:
...
$ gdb -q -batch 447.dealII -ex "b main"
Aborted (core dumped)
...
when running out of stack due to infinite recursion:
...
 #8  0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x35e4b40)
     at src/gdb/dwarf2/read.c:700
 #9  0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x22ee2c0)
     at src/gdb/dwarf2/read.c:700
 #10 0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x35e4b40)
     at src/gdb/dwarf2/read.c:700
 #11 0x00000000006aaba6 in dwarf2_cu::get_builder (this=0x22ee2c0)
     at src/gdb/dwarf2/read.c:700
...

We're recursing in this code in dwarf2_cu::get_builder():
...
     /* Otherwise, search ancestors for a valid builder.  */
     if (ancestor != nullptr)
       return ancestor->get_builder ();
...
due to the fact that the ancestor chain is a cycle.

Higher up in the call stack, we find some code that is responsible for
triggering this, in new_symbol:
...
       case DW_TAG_formal_parameter:
         {
           /* If we are inside a function, mark this as an argument.  If
              not, we might be looking at an argument to an inlined function
              when we do not have enough information to show inlined frames;
              pretend it's a local variable in that case so that the user can
              still see it.  */
           struct context_stack *curr
             = cu->get_builder ()->get_current_context_stack ();
           if (curr != nullptr && curr->name != nullptr)
             SYMBOL_IS_ARGUMENT (sym) = 1;
...

This is code that was added to support pre-4.1 gcc, to be able to show
arguments of inlined functions as locals, in the absense of sufficiently
correct debug information.

Removing this code (that is, doing SYMBOL_IS_ARGUMENT (sym) = 1
unconditially), fixes the crash.  The ancestor variable also seems to have
been added specifically to deal with fallout from this code, so remove that as
well.

Tested on x86_64-linux:
- openSUSE Leap 15.2 with gcc 7.5.0, and
- openSUSE Tumbleweed with gcc 10.3.0.

gdb/ChangeLog:

2021-05-07  Tom de Vries  <tdevries@suse.de>

PR symtab/26327
* dwarf2/read.c (struct dwarf2_cu): Remove ancestor.
(dwarf2_cu::get_builder): Remove ancestor-related code.
(new_symbol): Remove code supporting pre-4.1 gcc that show arguments
of inlined functions as locals.
(follow_die_offset, follow_die_sig_1): Remove setting of ancestor.

gdb/doc/ChangeLog:

2021-05-07  Tom de Vries  <tdevries@suse.de>

PR symtab/26327
* gdb.texinfo (Inline Functions): Update.

3 years agox86-64/ELF: clear src_mask for all reloc types
Jan Beulich [Fri, 7 May 2021 10:05:12 +0000 (12:05 +0200)] 
x86-64/ELF: clear src_mask for all reloc types

x86-64 uses rela relocations. The comment next to the field's declaration
says "Non-zero values for ELF USE_RELA targets should be viewed with
suspicion ..." And indeed the fields being non-zero causes section
contents to be accumulated into the final relocated values in addition to
the relocations' addends, which is contrary to the ELF spec.

3 years agox86: don't mix disp and imm processing
Jan Beulich [Fri, 7 May 2021 10:03:12 +0000 (12:03 +0200)] 
x86: don't mix disp and imm processing

Surely disp processing should access the disp operand, not an imm one.
This is not an active issue only because imms and disps are, at the
moment, overlapping fields of the same union.

3 years agox86: move register check in immediate operand parsing
Jan Beulich [Fri, 7 May 2021 10:02:40 +0000 (12:02 +0200)] 
x86: move register check in immediate operand parsing

i386_finalize_immediate() is used for both AT&T and Intel immediate
operand handling. Move an AT&T-only check to i386_immediate(), which at
the same time allows it to cover other cases as well, giving an overall
better / more consistent diagnostic.

3 years agox86: minor improvements to optimize_imm()
Jan Beulich [Fri, 7 May 2021 10:02:07 +0000 (12:02 +0200)] 
x86: minor improvements to optimize_imm()

- Drop a pointless & where just before it was checked that the
  respective bits are clear already anyway.
- Avoid a not really necessary operand_type_set() and a redundant
  operand_type_or() / operand_type_and() pair.

3 years agoWhen computing section link order for a relocateable link, ignore section sizes.
Nick Clifton [Fri, 7 May 2021 09:57:47 +0000 (10:57 +0100)] 
When computing section link order for a relocateable link, ignore section sizes.

* ldelfgen.c (compare_link_order): Ignore section size when
performing a relocateable link.

3 years agogdb/guile: Have gdbscm_safe_source_script return a unique_ptr
Andrew Burgess [Wed, 5 May 2021 20:39:06 +0000 (21:39 +0100)] 
gdb/guile: Have gdbscm_safe_source_script return a unique_ptr

Change gdbscm_safe_source_script to return a
gdb::unique_xmalloc_ptr<char> instead of a raw char*.  Update the
users of this function.

There should be no user visible change after this commit.

gdb/ChangeLog:

* guile/guile-internal.h (gdbscm_safe_source_script): Change
function return type.
* guile/guile.c (gdbscm_source_script): Update to handle change in
gdbscm_safe_source_script.
* guile/scm-objfile.c (gdbscm_source_objfile_script): Likewise.
* guile/scm-safe-call.c (gdbscm_safe_source_script): Change return
type.

3 years agodwarf: Don't omit second operand of '?' operator
Michael Forney [Sat, 1 May 2021 07:55:16 +0000 (00:55 -0700)] 
dwarf: Don't omit second operand of '?' operator

This is a GNU C extension and is not valid in ISO C.

* dwarf.c: Don't omit second operand of '?' operator.

3 years agomultiple definition warnings from script symbols
Alan Modra [Fri, 7 May 2021 01:54:10 +0000 (11:24 +0930)] 
multiple definition warnings from script symbols

In commit 89753bbf81 I enabled a warning for scripts redefining
symbols.  The idea was to not warn for symbols defined by shared
libraries (the h->u.def.section->output_section != NULL test), but the
test failed to take into account absolute symbols.  Absolute symbols
defined in shared libraries are currently indistinguishable from
absolute symbols defined in relocatable objects, at least when only
looking at struct bfd_link_hash_entry.  So, don't warn for any
absolute symbols.

* ldexp.c (update_definedness): Don't return false for absolute
symbols.
* ldmain.c (multiple_definition): Print "warning: " in message
when not a hard error.

3 years agosim: m32c: clean up various warnings
Mike Frysinger [Fri, 7 May 2021 04:31:05 +0000 (00:31 -0400)] 
sim: m32c: clean up various warnings

A random grab bag of minor fixes to enable -Werror for this port.

Check the return values of read & write calls and issue warnings when
they fail.
Fixup funky pointer math as the compiler doesn't like ++ on void*.
Handle short reads with fread().

3 years agosim: m32c: fix warnings about mixing code & decls
Mike Frysinger [Fri, 7 May 2021 04:26:36 +0000 (00:26 -0400)] 
sim: m32c: fix warnings about mixing code & decls

Add scope braces to a bunch of the generated sections to avoid compiler
warnings about mixing code & variable declarations.

3 years agosim: m32c: switch from custom fgets to getline
Mike Frysinger [Fri, 7 May 2021 04:08:43 +0000 (00:08 -0400)] 
sim: m32c: switch from custom fgets to getline

No need to implement this ourselves when POSIX has a nice API.

3 years agosim: m68hc11: fix up last warnings
Mike Frysinger [Fri, 7 May 2021 03:52:05 +0000 (23:52 -0400)] 
sim: m68hc11: fix up last warnings

Change the printf formats a little to fix the last build warnings in
here, and then turn on -Werror by default for the arch port.

3 years agosim: m68hc11: warn when emul_write fails
Mike Frysinger [Fri, 7 May 2021 03:51:10 +0000 (23:51 -0400)] 
sim: m68hc11: warn when emul_write fails

Not sure what we should do here when this fails, so just emit a warning
for now to satisfy unused result compiler warnings.  We can see if any
users actually notice here.

3 years agoRegenerate bfd-in2.h and libbfd.h
Alan Modra [Fri, 7 May 2021 01:31:22 +0000 (11:01 +0930)] 
Regenerate bfd-in2.h and libbfd.h

Commit 0b3e14c90283 edited these by hand.

* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.

3 years agoAutomatic date update in version.in
GDB Administrator [Fri, 7 May 2021 00:00:35 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoRe: elf: Always append ".COUNT" to local symbols
Alan Modra [Thu, 6 May 2021 23:44:38 +0000 (09:14 +0930)] 
Re: elf: Always append ".COUNT" to local symbols

Fixes XPASSes on frv-linux.

* testsuite/ld-elf/pr27825-1.d: Correct xfail.
* testsuite/ld-elf/pr27825-2.d: Likewise.

3 years agogdb: make inferior::args a unique_xmalloc_ptr
Simon Marchi [Thu, 6 May 2021 17:16:26 +0000 (13:16 -0400)] 
gdb: make inferior::args a unique_xmalloc_ptr

Use unique_xmalloc_ptr to avoid manual memory management.

gdb/ChangeLog:

* inferior.h (class inferior) <args>: Change type to
unique_xmalloc_ptr.
* inferior.c (inferior::~inferior): Don't free args.
* infcmd.c (get_inferior_args): Adjust.
(set_inferior_args): Adjust.

Change-Id: I96300e59eb2faf2d80660416a8f5694d243a944e

3 years agogdbserver/server: make some functions void
Tankut Baris Aktemur [Thu, 6 May 2021 13:15:13 +0000 (15:15 +0200)] 
gdbserver/server: make some functions void

The 'handle_v_attach', 'handle_v_run', and 'handle_v_kill' functions'
return values are unused.  They indicate error/success result by
putting packets.  Make the functions void.

Tested by rebuilding.

gdbserver/ChangeLog:
2021-05-06  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* server.cc (handle_v_attach)
(handle_v_run)
(handle_v_kill): Make void.

3 years agoor1k: Support large plt_relocs when generating plt entries
Stafford Horne [Thu, 6 May 2021 11:51:25 +0000 (20:51 +0900)] 
or1k: Support large plt_relocs when generating plt entries

The current PLT generation code will generate invalid code when the PLT
relocation offset exceeds 64k.  This fixes the issue by detecting large
plt_reloc offsets and generare code sequences to create larger plt
relocations.

The "large" plt code needs 2 extra instructions to create 32-bit offsets.

bfd/ChangeLog:

PR 27746
* elf32-or1k.c (PLT_ENTRY_SIZE_LARGE, PLT_MAX_INSN_COUNT,
OR1K_ADD, OR1K_ORI): New macros to help with plt creation.
(elf_or1k_link_hash_table): New field plt_count.
(elf_or1k_link_hash_entry): New field plt_index.
(elf_or1k_plt_entry_size): New function.
(or1k_write_plt_entry): Update to support variable size PLTs.
(or1k_elf_finish_dynamic_sections): Use new or1k_write_plt_entry
API.
(or1k_elf_finish_dynamic_symbol): Update to write large PLTs
when needed.
(allocate_dynrelocs): Use elf_or1k_plt_entry_size to account for
PLT size.

ld/ChangeLog:

PR 27746
testsuite/ld-or1k/or1k.exp (or1kplttests): Add tests for linking
along with gotha() relocations.
testsuite/ld-or1k/gotha1.dd: New file.
testsuite/ld-or1k/gotha1.s: New file.
testsuite/ld-or1k/gotha2.dd: New file.
testsuite/ld-or1k/gotha2.s: New file
testsuite/ld-or1k/pltlib.s (x): Define size to avoid link
failure.

3 years agoor1k: Avoid R_OR1K_GOT16 overflow failures in presence of R_OR1K_GOT_AHI16
Stafford Horne [Thu, 6 May 2021 11:51:25 +0000 (20:51 +0900)] 
or1k: Avoid R_OR1K_GOT16 overflow failures in presence of R_OR1K_GOT_AHI16

Now that we support R_OR1K_GOT_AHI16 we can relax the R_OR1K_GOT16
overflow validation check if the section has R_OR1K_GOT_AHI16.

We cannot simple disable R_OR1K_GOT16 overflow validation as there will
still be binaries that will have only R_OR1K_GOT16.  The
R_OR1K_GOT_AHI16 relocation will only be added by GCC when building with
the option -mcmodel=large.

This assumes that R_OR1K_GOT_AHI16 will come before R_OR1K_GOT16, which
is the code pattern that will be emitted by GCC.

bfd/ChangeLog:

PR 21464
* elf32-or1k.c (or1k_elf_relocate_section): Relax R_OR1K_GOT16
overflow check if we have R_OR1K_GOT_AHI16 followed by
R_OR1K_GOT16.

3 years agoor1k: Implement relocation R_OR1K_GOT_AHI16 for gotha()
Stafford Horne [Thu, 6 May 2021 11:51:24 +0000 (20:51 +0900)] 
or1k: Implement relocation R_OR1K_GOT_AHI16 for gotha()

The gotha() relocation mnemonic will be outputted by OpenRISC GCC when
using the -mcmodel=large option.  This relocation is used along with
got() to generate 32-bit GOT offsets.  This increases the previous GOT
offset limit from the previous 16-bit (64K) limit.

This is needed on large binaries where the GOT grows larger than 64k.

bfd/ChangeLog:

PR 21464
* bfd-in2.h: Add BFD_RELOC_OR1K_GOT_AHI16 relocation.
* elf32-or1k.c (or1k_elf_howto_table, or1k_reloc_map): Likewise.
(or1k_final_link_relocate, or1k_elf_relocate_section,
or1k_elf_check_relocs): Likewise.
* libbfd.h (bfd_reloc_code_real_names): Likewise.
* reloc.c: Likewise.

cpu/ChangeLog:

PR 21464
* or1k.opc (or1k_imm16_relocs, parse_reloc): Define parse logic
for gotha() relocation.

include/ChangeLog:

PR 21464
* elf/or1k.h (elf_or1k_reloc_type): Define R_OR1K_GOT_AHI16 number.

opcodes/ChangeLog:

PR 21464
* or1k-asm.c: Regenerate.

gas/ChangeLog:

PR 21464
* testsuite/gas/or1k/reloc-1.s: Add test for new relocation.
* testsuite/gas/or1k/reloc-1.d: Add test result for new
relocation.

Cc: Giulio Benetti <giulio.benetti@benettiengineering.com>
fixup reloc, add tests

3 years agoor1k: Fix issue with plt link failure for local calls
Stafford Horne [Thu, 6 May 2021 11:51:24 +0000 (20:51 +0900)] 
or1k: Fix issue with plt link failure for local calls

When building protobuf we were seeing the assert failure:

    /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld:
    BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377
    /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld:
    BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377
    /home/giuliobenetti/git/upstream/or1k-binutils-2.36.1/host/lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld:
    BFD (GNU Binutils) 2.36.1 assertion fail elf32-or1k.c:2377
    collect2: error: ld returned 1 exit status

This failure happens while writing out PLT entries, there is a check
"BFD_ASSERT (h->dynindx != -1)" to confirm all plt entries have dynamic
symbol attributes.  This was failing for symbols that were
"forced_local" in previous linking code.

The fix adds logic to or1k_elf_adjust_dynamic_symbol to identify
"forced_local" symbols and exclude them from the the PLT.

bfd/ChangeLog:

PR 27624
* elf32-or1k.c (or1k_elf_adjust_dynamic_symbol): Change
condition used to cleanup plt entries to cleanup forced local
entries.

Cc: Giulio Benetti <giulio.benetti@benettiengineering.com>
3 years agogdb/guile: don't try to print location for watchpoints
Andrew Burgess [Wed, 5 May 2021 15:52:29 +0000 (16:52 +0100)] 
gdb/guile: don't try to print location for watchpoints

Currently, using the guile API, if a user tries to print a breakpoint
object that represents a watchpoint, then GDB will crash.  For
example:

  (gdb) guile (use-modules (gdb))
  (gdb) guile (define wp1 (make-breakpoint "some_variable" #:type BP_WATCHPOINT #:wp-class WP_WRITE))
  (gdb) guile (register-breakpoint! wp1)
  (gdb) guile (display wp1) (newline)
  Aborted (core dumped)

This turns out to be because GDB calls event_location_to_string on the
breakpoints location, and watchpoint breakpoints don't have a
location.

This commit resolves the crash by just skipping the printing of the
location if the breakpoint doesn't have one.

Potentially, we could improve on this by printing details about what
the watchpoint is watching, however, I'm considering this a possible
future enhancement, this commit focuses just on having GDB not crash.

gdb/ChangeLog:

* guile/scm-breakpoint.c (bpscm_print_breakpoint_smob): Only print
breakpoint locations when the breakpoint actually has a location.

gdb/testsuite/ChangeLog:

* gdb.guile/scm-breakpoint.exp (test_watchpoints): Print the
watchpoint object before and after registering it with GDB.

3 years agogdb/testsuite: use proc_with_prefix in gdb.guile/scm-breakpoint.exp
Andrew Burgess [Thu, 6 May 2021 09:37:04 +0000 (10:37 +0100)] 
gdb/testsuite: use proc_with_prefix in gdb.guile/scm-breakpoint.exp

Convert gdb.guile/scm-breakpoint.exp to use proc_with_prefix instead
of using nested with_test_prefix calls.  Allows a level of indentation
to be removed from most of the test procs.

There were two procs that didn't use with_test_prefix, but I converted
them to be proc_with_prefix anyway, for consistency.

gdb/testsuite/ChangeLog:

* gdb.guile/scm-breakpoint.exp (test_bkpt_basic): Convert to
'proc_with_prefix', remove use of 'with_test_prefix', and
reindent.
(test_bkpt_deletion): Likewise.
(test_bkpt_cond_and_cmds): Likewise.
(test_bkpt_invisible): Likewise.
(test_watchpoints): Likewise.
(test_bkpt_internal): Likewise.
(test_bkpt_eval_funcs): Likewise.
(test_bkpt_registration): Likewise.
(test_bkpt_address): Convert to 'proc_with_prefix'.
(test_bkpt_probe): Likewise.

3 years agogdb/testsuite: resolve duplicate test names in gdb.guile/scm-breakpoint.exp
Andrew Burgess [Wed, 5 May 2021 17:57:47 +0000 (18:57 +0100)] 
gdb/testsuite: resolve duplicate test names in gdb.guile/scm-breakpoint.exp

Extend some test names to avoid duplicates.

gdb/testsuite/ChangeLog:

* gdb.guile/scm-breakpoint.exp (test_bkpt_basic): Extend test
names to avoid duplicates.
(test_bkpt_cond_and_cmds): Likewise.
(test_bkpt_eval_funcs): Likewise.

3 years agogdb/mi: add a '--force' flag to the '-break-condition' command
Tankut Baris Aktemur [Thu, 6 May 2021 08:13:06 +0000 (10:13 +0200)] 
gdb/mi: add a '--force' flag to the '-break-condition' command

Add a '--force' flag to the '-break-condition' command to be
able to force conditions.

gdb/ChangeLog:
2021-05-06  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* mi/mi-cmd-break.c (mi_cmd_break_condition): New function.
* mi/mi-cmds.c: Change the binding of "-break-condition" to
mi_cmd_break_condition.
* mi/mi-cmds.h (mi_cmd_break_condition): Declare.
* breakpoint.h (set_breakpoint_condition): Declare a new
overload.
* breakpoint.c (set_breakpoint_condition): New overloaded function
extracted out from ...
(condition_command): ... this.
* NEWS: Mention the change.

gdb/testsuite/ChangeLog:
2021-05-06  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* gdb.mi/mi-break.exp (test_forced_conditions): Add a test
for the -break-condition command's "--force" flag.

gdb/doc/ChangeLog:
2021-05-06  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* gdb.texinfo (GDB/MI Breakpoint Commands): Mention the
'--force' flag of the '-break-condition' command.

3 years agogdb/mi: add a '--force-condition' flag to the '-break-insert' cmd
Tankut Baris Aktemur [Thu, 6 May 2021 08:13:06 +0000 (10:13 +0200)] 
gdb/mi: add a '--force-condition' flag to the '-break-insert' cmd

Add a '--force-condition' flag to the '-break-insert' command to be
able to force conditions.  Because the '-dprintf-insert' command uses
the same mechanism as the '-break-insert' command, it obtains the
'--force-condition' flag, too.

gdb/ChangeLog:
2021-05-06  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* mi/mi-cmd-break.c (mi_cmd_break_insert_1): Recognize the
'--force-condition' flag to force the condition in the
'-break-insert' and '-dprintf-insert' commands.
* NEWS: Mention the change.

gdb/testsuite/ChangeLog:
2021-05-06  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* gdb.mi/mi-break.exp (test_forced_conditions): New proc that
is called by the test.

gdb/doc/ChangeLog:
2021-05-06  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* gdb.texinfo (GDB/MI Breakpoint Commands): Mention the
'--force-condition' flag of the '-break-insert' and
'-dprintf-insert' commands.

3 years agolibctf, ld: fix test results for upstream GCC
Nick Alcock [Thu, 6 May 2021 08:30:58 +0000 (09:30 +0100)] 
libctf, ld: fix test results for upstream GCC

The tests currently in binutils are aimed at the original GCC-based
implementation of CTF, which emitted CTF directly from GCC's internal
representation.  The approach now under review emits CTF from DWARF,
with an eye to eventually doing this for all non-DWARF debuginfo-like
formats GCC supports.  It also uses a different flag to enable
CTF emission (-gctf rather than -gt).

Adjust the testsuite accordingly.

Given that the ld testsuite results are dependent on type ordering,
which we do not guarantee at all, it's amazing how little changes. We
see a few type ordering differences, slices change because the old GCC
was buggy (slices were emitted "backwards", from the wrong end of the
machine word) and its expected results were wrong, and GCC now emits the
underlying integral type for enumerated types, though CTF has no way to
record this yet (coming in v4).

GCC also now emits even hidden symbols into the symtab (and thus
symtypetab), so one symtypetab test changes its expected results
slightly to compensate.

Also add tests for the CTF_K_UNKNOWN nonrepresentable type: this
couldn't be done before now since the only GCC that emits CTF_K_UNKNOWN
for nonrepresentable types is the new one.

ld/ChangeLog
2021-05-06  Nick Alcock  <nick.alcock@oracle.com>

* testsuite/ld-ctf/ctf.exp: Use -gctf, not -gt.
* testsuite/lib/ld-lib.exp: Likewise.
* testsuite/ld-ctf/nonrepresentable-1.c: New test for nonrepresentable types.
* testsuite/ld-ctf/nonrepresentable-2.c: Likewise.
* testsuite/ld-ctf/nonrepresentable.d: Likewise.
* testsuite/ld-ctf/array.d: Larger type section.
* testsuite/ld-ctf/data-func-conflicted.d: Likewise.
* testsuite/ld-ctf/enums.d: Likewise.
* testsuite/ld-ctf/conflicting-enums.d: Don't compare types.
* testsuite/ld-ctf/cross-tu-cyclic-conflicting.d: Changed type order.
* testsuite/ld-ctf/cross-tu-noncyclic.d: Likewise.
* testsuite/ld-ctf/slice.d: Adjust for improved slice emission.

libctf/ChangeLog
2021-05-06  Nick Alcock  <nick.alcock@oracle.com>

* testsuite/lib/ctf-lib.exp: Use -gctf, not -gt.
* testsuite/libctf-regression/nonstatic-var-section-ld-r.lk:
Hidden symbols now get into the symtypetab anyway.

3 years agolibctf, include: support an alternative encoding for nonrepresentable types
Nick Alcock [Thu, 6 May 2021 08:30:58 +0000 (09:30 +0100)] 
libctf, include: support an alternative encoding for nonrepresentable types

Before now, types that could not be encoded in CTF were represented as
references to type ID 0, which does not itself appear in the
dictionary. This choice is annoying in several ways, principally that it
forces generators and consumers of CTF to grow special cases for types
that are referenced in valid dicts but don't appear.

Allow an alternative representation (which will become the only
representation in format v4) whereby nonrepresentable types are encoded
as actual types with kind CTF_K_UNKNOWN (an already-existing kind
theoretically but not in practice used for padding, with value 0).
This is backward-compatible, because CTF_K_UNKNOWN was not used anywhere
before now: it was used in old-format function symtypetabs, but these
were never emitted by any compiler and the code to handle them in libctf
likely never worked and was removed last year, in favour of new-format
symtypetabs that contain only type IDs, not type kinds.

In order to link this type, we need an API addition to let us add types
of unknown kind to the dict: we let them optionally have names so that
GCC can emit many different unknown types and those types with identical
names will be deduplicated together.  There are also small tweaks to the
deduplicator to actually dedup such types, to let opening of dicts with
unknown types with names work, to return the ECTF_NONREPRESENTABLE error
on resolution of such types (like ID 0), and to print their names as
something useful but not a valid C identifier, mostly for the sake of
the dumper.

Tests added in the next commit.

include/ChangeLog
2021-05-06  Nick Alcock  <nick.alcock@oracle.com>

* ctf.h (CTF_K_UNKNOWN): Document that it can be used for
nonrepresentable types, not just padding.
* ctf-api.h (ctf_add_unknown): New.

libctf/ChangeLog
2021-05-06  Nick Alcock  <nick.alcock@oracle.com>

* ctf-open.c (init_types): Unknown types may have names.
* ctf-types.c (ctf_type_resolve): CTF_K_UNKNOWN is as
non-representable as type ID 0.
(ctf_type_aname): Print unknown types.
* ctf-dedup.c (ctf_dedup_hash_type): Do not early-exit for
CTF_K_UNKNOWN types: they have real hash values now.
(ctf_dedup_rwalk_one_output_mapping): Treat CTF_K_UNKNOWN types
like other types with no referents: call the callback and do not
skip them.
(ctf_dedup_emit_type): Emit via...
* ctf-create.c (ctf_add_unknown): ... this new function.
* libctf.ver (LIBCTF_1.2): Add it.

3 years agosim: h8300 special case test
Yoshinori Sato [Tue, 4 May 2021 13:22:58 +0000 (22:22 +0900)] 
sim: h8300 special case test

In "mov. [bwl] reg, @ -reg", added a special case test
using the same register.

3 years agosim: m32c/rl78/rx: fix command parsing
Mike Frysinger [Wed, 5 May 2021 18:54:33 +0000 (14:54 -0400)] 
sim: m32c/rl78/rx: fix command parsing

Use buildargv to avoid writing to const memory and freeing invalid
pointers, and to avoid doing any string parsing ourselves.

3 years agoelf: Always append ".COUNT" to local symbols
H.J. Lu [Thu, 6 May 2021 03:28:39 +0000 (20:28 -0700)] 
elf: Always append ".COUNT" to local symbols

Always append ".COUNT" to local symbols to avoid potential conflicts
with existing local symbol "XXX.COUNT".

bfd/

PR ld/27825
* elflink.c (elf_link_output_symstrtab): Always append ".COUNT"
to local symbols.

ld/

PR ld/27825
* testsuite/ld-elf/pr27825-1.d: New file.
* testsuite/ld-elf/pr27825-1a.s: Likewise.
* testsuite/ld-elf/pr27825-1b.s: Likewise.
* testsuite/ld-elf/pr27825-2.d: Likewise.
* testsuite/ld-elf/pr27825-2a.s: Likewise.
* testsuite/ld-elf/pr27825-2b.s: Likewise.

3 years agoAutomatic date update in version.in
GDB Administrator [Thu, 6 May 2021 00:00:37 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years ago[gdb/testsuite] Fix timeout in gdb.threads/detach-step-over.exp with readnow
Tom de Vries [Wed, 5 May 2021 13:13:17 +0000 (15:13 +0200)] 
[gdb/testsuite] Fix timeout in gdb.threads/detach-step-over.exp with readnow

When running test-case gdb.threads/detach-step-over.exp with target board
readnow, I run into:
...
Reading symbols from /lib64/libc.so.6...^M
Reading symbols from \
  /usr/lib/debug/lib64/libc-2.26.so-2.26-lp152.26.6.1.x86_64.debug...^M
Expanding full symbols from \
  /usr/lib/debug/lib64/libc-2.26.so-2.26-lp152.26.6.1.x86_64.debug...^M
FAIL: gdb.threads/detach-step-over.exp: \
  breakpoint-condition-evaluation=host: target-non-stop=on: non-stop=on: \
  displaced=off: iter 2: attach (timeout)
...

Fix this by doing exp_continue when encountering the "Reading symbols" or
"Expanding full symbols" lines.

This is still fragile and times out with a higher load, similated f.i. by
stress -c 5.  Fix that by using a timeout factor of 2.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-05-05  Tom de Vries  <tdevries@suse.de>

* gdb.threads/detach-step-over.exp: Do exp_continue when encountering
"Reading symbols" or "Expanding full symbols" lines.  Using timeout
factor of 2 for attach.

3 years ago[gdb/testsuite] Fix gdb.threads/fork-plus-threads.exp with readnow
Tom de Vries [Wed, 5 May 2021 07:07:27 +0000 (09:07 +0200)] 
[gdb/testsuite] Fix gdb.threads/fork-plus-threads.exp with readnow

When running test-case gdb.threads/fork-plus-threads.exp with target board
readnow, I run into:
...
[LWP 9362 exited]^M
[New LWP 9365]^M
[New LWP 9363]^M
[New LWP 9364]^M
FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: \
  inferior 1 exited (timeout)
...

There is code in the test-case to prevent timeouts with readnow:
...
       -re "Thread \[^\r\n\]+ exited" {
           # Avoid timeout with check-read1
           exp_continue
       }
       -re "New Thread \[^\r\n\]+" {
           # Avoid timeout with check-read1
           exp_continue
       }
...
but this doesn't trigger because we get LWP rather than Thread.

Fix this by making these regexps accept LWP as well.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-05-05  Tom de Vries  <tdevries@suse.de>

* gdb.threads/fork-plus-threads.exp: Handle "New LWP <n>" and
"LWP <n> exited" messages.

3 years agoasan: stack-buffer-overflow vms-lib.c:367
Alan Modra [Wed, 5 May 2021 04:03:00 +0000 (13:33 +0930)] 
asan: stack-buffer-overflow vms-lib.c:367

* vms-lib.c (vms_traverse_index): Account for vms_kbn size when
sanity checking keylen.

3 years agosim: rl78: clean up various warnings
Mike Frysinger [Wed, 5 May 2021 02:56:31 +0000 (22:56 -0400)] 
sim: rl78: clean up various warnings

A random grab bag of minor fixes to enable -Werror for this port.

Fix local prototypes for a bunch of functions (e.g. adding static).
Add missing includes for missing prototypes.
Move local variable decls from the middle of functions to the top
of the scope.
Fix a logic error when processing commands where p was reassigned
to cmd and then has its leading whitespace scanned a 2nd time.
Handle short reads with fread().

3 years agogdb: update Type.fields doc based on actual GDB behavior
Simon Marchi [Wed, 5 May 2021 02:19:05 +0000 (22:19 -0400)] 
gdb: update Type.fields doc based on actual GDB behavior

I noticed two errors in the Type.fields documentation:

1. It is possible to call `fields` on an array type, in which case it
   returns one field representing the array's range.  It is not
   mentioned.

2. When calling `fields` on a type that doesn't have fields (by nature,
   like an int), GDB raises a TypeError.  It does not return an empty
   sequence, as currently documented.

Fix these, and change the text into a bullet list.  I find it easier to
read than one big paragraph.

The first issue is already tested in gdb.python/py-type.exp, but the
second one doesn't seem tested.  Add a test in gdb.python/py-type.exp
for it.

gdb/doc/ChangeLog:

* python.texi (Types In Python): Re-organize Type.fields doc.
Mention handling of array types.  Correct doc for when calling
the method on another type.

gdb/testsuite/ChangeLog:

* gdb.python/py-type.exp (test_fields): Test calling fields on
an int type.

Change-Id: I11c688177504cb070b81a4446ac91dec50b56a22

3 years agosim: m68hc11: tweak types to fix warnings
Mike Frysinger [Sun, 2 May 2021 02:37:49 +0000 (22:37 -0400)] 
sim: m68hc11: tweak types to fix warnings

The hw attach API wants unsigned addresses.
The write API wants signed chars.

3 years agosim: mips: include stdlib.h for memory prototypes
Mike Frysinger [Wed, 5 May 2021 02:03:37 +0000 (22:03 -0400)] 
sim: mips: include stdlib.h for memory prototypes

This file uses free() and friends, so include it to fix missing
prototype warnings.

3 years agosim: mips: always enable device models
Mike Frysinger [Tue, 4 May 2021 12:39:17 +0000 (08:39 -0400)] 
sim: mips: always enable device models

There's no need to restrict these to only specific targets as the user
can select them at runtime if they want them.  Always build them so we
can improve build coverage too.

3 years agosim: mips: delete unused constant variables
Mike Frysinger [Tue, 4 May 2021 12:38:29 +0000 (08:38 -0400)] 
sim: mips: delete unused constant variables

Since these never change, inline and delete them.

3 years agosim: mcore: fix build time warnings
Mike Frysinger [Tue, 4 May 2021 12:35:40 +0000 (08:35 -0400)] 
sim: mcore: fix build time warnings

Once we fix a minor const warning we can enable -Werror in here.

3 years agosim: remove sys/times.h in most places
Mike Frysinger [Tue, 4 May 2021 12:33:24 +0000 (08:33 -0400)] 
sim: remove sys/times.h in most places

The v850 port used this, and then it got copied to other ports even
though it wasn't needed.  Clean it up to avoid portability issues on
platforms not providing this (e.g. mingw64 for Windows).

3 years agosim: mips: fix qh_acc table
Mike Frysinger [Sun, 2 May 2021 01:17:12 +0000 (21:17 -0400)] 
sim: mips: fix qh_acc table

The AccAddLQH func was unused, and looking at this table, it looks
like it's due to a typo.

3 years agosim: hw: localize init callback
Mike Frysinger [Sun, 2 May 2021 03:37:35 +0000 (23:37 -0400)] 
sim: hw: localize init callback

Now that we don't need to hardcode the module init list in a single
place, move the hw init logic out to the sim-hw file.

3 years agosim: microblaze: enable some basic trace points
Mike Frysinger [Tue, 27 Apr 2021 03:17:15 +0000 (23:17 -0400)] 
sim: microblaze: enable some basic trace points

This isn't super complete, but it's useful enough as-is.

3 years agosim: microblaze: hook up libgloss syscalls
Mike Frysinger [Tue, 27 Apr 2021 03:14:11 +0000 (23:14 -0400)] 
sim: microblaze: hook up libgloss syscalls

When in the virtual environment, have brki 8 trigger libgloss syscalls
like other ports.  This also matches the ABI that Linux uses for its
syscalls (ignoring the syscall table differences).

3 years agoPowerPC undefweak testcase
Alan Modra [Wed, 5 May 2021 01:05:31 +0000 (10:35 +0930)] 
PowerPC undefweak testcase

Test for commit 4916030821bb and b293661219c3.

* testsuite/ld-powerpc/empty.s: New file.
* testsuite/ld-powerpc/undefweak.d,
* testsuite/ld-powerpc/undefweak.s: New testcase.
* testsuite/ld-powerpc/powerpc.exp: Run it.

3 years agoAutomatic date update in version.in
GDB Administrator [Wed, 5 May 2021 00:00:35 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoAdd missing stdlib.h includes to sim
Tom Tromey [Tue, 4 May 2021 14:56:12 +0000 (08:56 -0600)] 
Add missing stdlib.h includes to sim

This updates the various "mloop.in" files to emit an include of
stdlib.h, to avoid warnings about 'abort' being undeclared.

One such warning now remains, in mn10300.igen.  I don't know offhand
the best way to fix this one.

2021-05-04  Tom Tromey  <tromey@adacore.com>

* mloop.in: Include <stdlib.h>.

sim/iq2000/ChangeLog
2021-05-04  Tom Tromey  <tromey@adacore.com>

* mloop.in: Include <stdlib.h>.

sim/lm32/ChangeLog
2021-05-04  Tom Tromey  <tromey@adacore.com>

* mloop.in: Include <stdlib.h>.

sim/m32r/ChangeLog
2021-05-04  Tom Tromey  <tromey@adacore.com>

* mloop.in: Include <stdlib.h>.

sim/or1k/ChangeLog
2021-05-04  Tom Tromey  <tromey@adacore.com>

* mloop.in: Include <stdlib.h>.

3 years agoFix igen build
Tom Tromey [Tue, 4 May 2021 14:45:46 +0000 (08:45 -0600)] 
Fix igen build

The igen build fails for me like:

gcc  -g -O2 -c ../../binutils-gdb/sim/igen/igen.c -o igen/igen.o
In file included from ../../binutils-gdb/sim/igen/igen.c:26:
../../binutils-gdb/sim/igen/lf.h:22:10: fatal error: ansidecl.h: No such file or directory

This patch fixes the problem by arranging for igen to find the
libiberty includes.

This seems slightly hacky to me, because libiberty is not a "build"
library, so it can't be linked against.  However, since igen currently
only includes the header, it seems relatively safe.

2021-05-04  Tom Tromey  <tromey@adacore.com>

* Makefile.in: Rebuild.
* Makefile.am (AM_CPPFLAGS): New variable.

3 years agoAdd config.h to generated_files for sim
Tom Tromey [Tue, 4 May 2021 14:37:13 +0000 (08:37 -0600)] 
Add config.h to generated_files for sim

I noticed that config.h isn't in 'generated_files' in the sim
subdirectories.  This causes it to sometimes be rebuilt too late.

2021-05-04  Tom Tromey  <tromey@adacore.com>

* Make-common.in (generated_files): Add config.h.

3 years agognulib: import gendocs
Mike Frysinger [Sun, 2 May 2021 16:05:44 +0000 (12:05 -0400)] 
gnulib: import gendocs

This will be used to generate more complete docs for the binutils site.

3 years agognulib: import getline
Mike Frysinger [Sat, 1 May 2021 22:00:27 +0000 (18:00 -0400)] 
gnulib: import getline

We use getline in sim today which breaks on older systems that are
not compliant with the latest POSIX standard.  For example, mingw64
for Windows omits getline so we fail to build there.

3 years agogdb/testsuite: adjust gdb.python/flexible-array-member.exp expected pattern
Simon Marchi [Tue, 4 May 2021 15:20:09 +0000 (11:20 -0400)] 
gdb/testsuite: adjust gdb.python/flexible-array-member.exp expected pattern

The `Type.range ()` tests in gdb.python/flexible-array-member.exp pass
when the test is compiled with gcc 9 or later, but not with gcc 8 or
earlier:

    $ make check TESTS="gdb.python/flexible-array-member.exp" RUNTESTFLAGS="CC_FOR_TARGET='gcc-8'"

    python print(zs['items'].type.range())^M
    (0, 0)^M
    (gdb) FAIL: gdb.python/flexible-array-member.exp: python print(zs['items'].type.range())
    python print(zso['items'].type.range())^M
    (0, 0)^M
    (gdb) FAIL: gdb.python/flexible-array-member.exp: python print(zso['items'].type.range())

The value that we get for the upper bound of a flexible array member
declared with a "0" size is 0 with gcc <= 8 and is -1 for gcc >= 9.
This is due to different debug info.  For this member, gcc 8 does:

    0x000000d5:   DW_TAG_array_type
                    DW_AT_type [DW_FORM_ref4]       (0x00000034 "int")
                    DW_AT_sibling [DW_FORM_ref4]    (0x000000e4)

    0x000000de:     DW_TAG_subrange_type
                      DW_AT_type [DW_FORM_ref4]     (0x0000002d "long unsigned int")

For the same type, gcc 9 does:

    0x000000d5:   DW_TAG_array_type
                    DW_AT_type [DW_FORM_ref4]       (0x00000034 "int")
                    DW_AT_sibling [DW_FORM_ref4]    (0x000000e5)

    0x000000de:     DW_TAG_subrange_type
                      DW_AT_type [DW_FORM_ref4]     (0x0000002d "long unsigned int")
                      DW_AT_count [DW_FORM_data1]   (0x00)

Ideally, GDB would present a consistent and documented value for an
array member declared with size 0, regardless of how the debug info
looks like.  But for now, just change the test to accept the two
values, to get rid of the failure and make the test in sync

I also realized (by looking at the py-type.exp test) that calling the
fields method on an array type yields one field representing the "index"
of the array.  The type of that field is of type range
(gdb.TYPE_CODE_RANGE).  When calling `.range()` on that range type, it
yields the same range tuple as when calling `.range()` on the array type
itself.  For completeness, add some tests to access the range tuple
through that range type as well.

gdb/testsuite/ChangeLog:

* gdb.python/flexible-array-member.exp: Adjust expected range
value for member declared with 0 size.  Test accessing range
tuple through range type.

Change-Id: Ie4e06d99fe9315527f04577888f48284d649ca4c

3 years agoDefine bfd_realloc(ptr,0) to return allocated memory, whilst bfd_realloc_or_free...
Nick Clifton [Tue, 4 May 2021 13:29:04 +0000 (14:29 +0100)] 
Define bfd_realloc(ptr,0) to return allocated memory, whilst bfd_realloc_or_free(ptr,0) frees ptr.

* libbfd.c (bfd_malloc): Provide some documenation.  Treat a size
of 0 as 1.
(bfd_realloc): Likewise.
(bfd_zmalloc): Likewise.
(bfd_realloc_or_free): Provide some documentation.  Treat a size
of 0 as a request to free.
* libbfd-in.h (bfd_realloc): Remove prototype.
(bfd_realloc_or_free): Remove prototype.
(bfd_zmalloc): Remove prototype.
* libbfd.h: Regenerate.

3 years agoReplace AC_PROG_CC with AC_PROG_CC_C99 in top level configure file.
Nick Clifton [Tue, 4 May 2021 12:40:34 +0000 (13:40 +0100)] 
Replace AC_PROG_CC with AC_PROG_CC_C99 in top level configure file.

2021-05-04  Nick Clifton  <nickc@redhat.com>

* configure.ac (AC_PROG_CC): Replace with AC_PROG_CC_C99.
* configure: Regenerate.

3 years agosim: add support for build-time ar & ranlib
Mike Frysinger [Sat, 1 May 2021 21:16:23 +0000 (17:16 -0400)] 
sim: add support for build-time ar & ranlib

This is needed when building for a target whose ar & ranlib are
incompatible with the current build system.  For example, building
for Windows on a Linux system.

Then manually import the automake rule for libigen.a, but tweak the
tool variables to use the FOR_BUILD variants.

3 years agosim: clean up bfd_vma printing
Mike Frysinger [Tue, 4 May 2021 03:27:16 +0000 (23:27 -0400)] 
sim: clean up bfd_vma printing

A lot of this code predates the bfd_vma format define, so we have a
random mix of casts to known types so we can printf the value.  Use
the BFD_VMA_FMT that now exists to simplify and reliability output
across different build configs.

3 years ago[gdb/guile] Don't allow libguile to change libgmp mem fns
Tom de Vries [Tue, 4 May 2021 08:26:16 +0000 (10:26 +0200)] 
[gdb/guile] Don't allow libguile to change libgmp mem fns

Since gdb commit 880ae75a2b7 "gdb delay guile initialization until
gdbscm_finish_initialization" I'm running into:
...
(gdb) print My_Var > 10.0^M
free(): invalid pointer^M
ERROR: GDB process no longer exists
GDB process exited with wait status 5995 exp9 0 0 CHILDKILLED SIGABRT SIGABRT
UNRESOLVED: gdb.ada/fixed_cmp.exp: gnat_encodings=all: print My_Var > 10.0
...

The problem is that both gdb and libguile try to set the libgmp memory functions,
and since the gdb commit the ones from libguile are effective, which results
in gdb freeing some memory in a way that is not compatible with the way that
memory was actually allocated.

The fact that libguile tries to set the libgmp memory functions is a bug which
should be fixed starting version v3.0.6.

Meanwhile, work around this in gdb by not allowing libguile to set the libgomp
memory functions.

Tested on x86_64-linux.

gdb/ChangeLog:

2021-05-04  Tom de Vries  <tdevries@suse.de>

PR guile/27806
* guile/guile.c (gdbscm_initialize): Don't let guile change libgmp
memory functions.

3 years agoAutomatic date update in version.in
GDB Administrator [Tue, 4 May 2021 00:00:34 +0000 (00:00 +0000)] 
Automatic date update in version.in

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