1. May 19, 2021
    • Tom de Vries's avatar
      [gdb/testsuite] Fix read1 timeout in gdb.base/info-types-c++.exp · 2129a942
      Tom de Vries authored
      When running test-case gdb.base/info-types-c++.exp with check-read1 I run
      into:
      ...
      425:    typedef const void * std::allocator_traits<std::allocator<std::\
        _Sp_counted_ptr_inplace<std::filesystem::__cxx11::\
        recursive_directory_iterator::_Dir_stack, std::allocator<std::filesystem::\
        __cxx11::recursive_directory_iterator::_Dir_stack>, \
        FAIL: gdb.base/info-types-c++.exp: info types (timeout)
      ...
      
      The corresponding gdb_test_multiple does contain an exp_continue which
      resets the timeout counter every time info for another file is printed, but
      this doesn't help for this timeout because it times out during printing info
      for a single file.
      
      Fix this by processing line-by-line.
      
      Tested on x86_64-linux, both with gcc-7.5.0 and gcc-4.8.5 (the latter is
      different because the "unsigned int" type is missing).
      
      gdb/testsuite/ChangeLog:
      
      2021-05-19  Tom de Vries  <tdevries@suse.de>
      
      	* gdb.base/info-types.exp.tcl: Scan info types output line-by-line.
      2129a942
    • Eli Schwartz's avatar
      Fix a build problem if ENABLE_CHECKING is not defined. · c485e475
      Eli Schwartz authored
      	* dwarf.c (ENABLE_CHECKING): Define to 0 if not previously set.
      c485e475
    • Nick Clifton's avatar
      Warn when the plugin interface runs out of file descriptors. · 83b0a686
      Nick Clifton authored
      	* plugin.c (bfd_plugin_open_input): Inform the user if the limit
      	on the number of open files is reached.  If possible, try to
      	increase this limit before failing.
      83b0a686
    • Alexandra Hájková's avatar
      inflow.c: Do not leak tty. · b534617f
      Alexandra Hájková authored
      In a case open() returns 0 tty might be leaked. While 0 should be
      stdin (and therefore is an unlikely return value from open()), it's
      still the case that the test should be for non-negative return values
      from open().
      
      gdb/ChangeLog:
      
      2021-05-11 Alexandra Hájková <ahajkova@redhat.com>
      
      	* inflow.c (new_tty): Do not leak tty.
      b534617f
    • Alan Modra's avatar
      PR27884, skip_attr_bytes: Assertion (data) <= (end) failed · 1b3892be
      Alan Modra authored
      	PR 27884
      	* dwarf.c (get_type_abbrev_from_form): Replace cu_offset_return
      	param with map_return, and return map for DW_FORM_ref_addr.
      	(get_type_signedness): Adjust calls to get_type_abbrev_from_form.
      	Pass returned cu map start and end to recursive call.
      	(read_and_display_attr_value): Similarly.
      1b3892be
    • Alan Modra's avatar
      PR27879, stack-buffer-overflow on sysdump · 9d9e2a34
      Alan Modra authored
      	PR 27879
      	* sysdump.c (getBARRAY): Sanity check size against max.
      	(getINT): Avoid UB shift left.
      9d9e2a34
    • GDB Administrator's avatar
      Automatic date update in version.in · 75933ce3
      GDB Administrator authored
      75933ce3
    • Mike Frysinger's avatar
      sim: depend on gnulib · 9cc11ab5
      Mike Frysinger authored
      We're going to start using gnulib in the sim, so make sure it exists.
      
      ChangeLog:
      
      	* Makefile.def: Add configure-sim dependency on all-gnulib.
      	* Makefile.in: Regenerated.
      9cc11ab5
    • Mike Frysinger's avatar
      config: delete unused sim macros · 19fa7881
      Mike Frysinger authored
      Nothing in gcc or binutils or gdb or anything anywhere uses these.
      
      config/
      
      	* acinclude.m4 (CYG_AC_PATH_SIM, CYG_AC_PATH_DEVO): Delete.
      19fa7881
  2. May 18, 2021
    • Job Noorman's avatar
      RISC-V: PR27814, Objdump crashes when disassembling a non-ELF RISC-V binary. · 113bb761
      Job Noorman authored
      2021-05-18  Job Noorman  <mtvec@pm.me>
      
      opcodes/
          PR 27814
          * riscv-dis.c (riscv_get_disassembler): Get elf attributes only for
          the elf objects.
      113bb761
    • GDB Administrator's avatar
      Automatic date update in version.in · 549f123c
      GDB Administrator authored
      549f123c
    • Tom Tromey's avatar
      Rename dwarf2/comp-unit.h · cd53fa40
      Tom Tromey authored
      Simon pointed out that dwarf2/cu.h and dwarf2/comp-unit.h seemingly
      mean the same thing.  He suggested renaming the latter to
      comp-unit-head.h, which is what this patch does.
      
      gdb/ChangeLog
      2021-05-17  Tom Tromey  <tom@tromey.com>
      
      	* dwarf2/read.h: Update include.
      	* dwarf2/read.c: Update include.
      	* dwarf2/line-header.c: Update include.
      	* dwarf2/cu.h: Update include.
      	* dwarf2/comp-unit-head.h: Rename from comp-unit.h.
      	* dwarf2/comp-unit-head.c: Rename from comp-unit.c.
      	* Makefile.in (COMMON_SFILES): Update.
      cd53fa40
    • Tom Tromey's avatar
      Change dwarf2_cu marking to use methods · 347212b8
      Tom Tromey authored
      This changes the dwarf2_cu marking functions to be methods on
      dwarf2_cu.
      
      gdb/ChangeLog
      2021-05-17  Tom Tromey  <tom@tromey.com>
      
      	* dwarf2/read.c (maybe_queue_comp_unit)
      	(dwarf2_per_objfile::age_comp_units): Update.
      	(dwarf2_add_dependence, dwarf2_mark_helper, dwarf2_mark): Move to
      	dwarf2_cu methods.
      	* dwarf2/cu.h (struct dwarf2_cu) <mark, clear_mark, is_marked,
      	add_dependence>: New methods.
      	<m_dependencies>: Add "m_" prefix.  Now private.
      	<m_mark>: Add "m_" prefix.
      	* dwarf2/cu.c (dwarf2_cu::dwarf2_cu): Update.
      	(dwarf2_mark_helper): New function.
      	(dwarf2_cu::mark, dwarf2_cu::add_dependence): New methods.
      347212b8
    • Tom Tromey's avatar
      Move some dwarf2_cu methods to new file · 839118f9
      Tom Tromey authored
      This moves some of the dwarf2_cu methods to a new file, dwarf2/cu.c.
      
      gdb/ChangeLog
      2021-05-17  Tom Tromey  <tom@tromey.com>
      
      	* dwarf2/read.c (dwarf2_cu::addr_sized_int_type)
      	(dwarf2_cu::start_symtab, dwarf2_cu::addr_type)
      	(dwarf2_cu::dwarf2_cu): Move to cu.c.
      	* dwarf2/cu.c: New file.
      	* Makefile.in (COMMON_SFILES): Add dwarf2/cu.c.
      839118f9
    • Tom Tromey's avatar
      Move dwarf2_cu to new header file · 8ae78a44
      Tom Tromey authored
      This moves dwarf2_cu and one supporting data structure to a new header
      file.  The main goal, as always with this kind of change, is to make
      the DWARF reader a bit more understandable.
      
      gdb/ChangeLog
      2021-05-17  Tom Tromey  <tom@tromey.com>
      
      	* Makefile.in (HFILES_NO_SRCDIR): Add dwarf2/cu.h.
      	* dwarf2/read.c (struct delayed_method_info, struct dwarf2_cu):
      	Move to cu.h.
      	* dwarf2/cu.h: New file.
      8ae78a44
    • Andrew Burgess's avatar
      gdb: additional settings for emacs in .dir-locals.el · c1c0a7e1
      Andrew Burgess authored
      Two additional settings for developers who use emacs:
      
        1. Set brace-list-open to 0 for C and C++ modes, this ensures we
        format things like:
      
        enum blah
        {
          ....
        };
      
        Instead of the default for the emacs GNU style:
      
        enum blah
          {
            ...
          };
      
        The former seems to be the GDB style.
      
        2. Set sentence-end-double-space to t.  This is actually the default
        value for this setting, but if anyone has customised this to nil in
        general, then forcing this back to t for GDB files will give a
        better behaviour for the paragraph filling.
      
      gdb/ChangeLog:
      
      	* .dir-locals.el: Set sentence-end-double-space for all modes, and
      	set brace-list-open to 0 for C and C++ modes.
      
      gdbserver/ChangeLog:
      
      	* .dir-locals.el: Set sentence-end-double-space for all modes, and
      	set brace-list-open to 0 for C and C++ modes.
      
      gdbsupport/ChangeLog:
      
      	* .dir-locals.el: Set sentence-end-double-space for all modes, and
      	set brace-list-open to 0 for C and C++ modes.
      c1c0a7e1
    • Tom Tromey's avatar
      Avoid crash with GCC trunk · 9e541c79
      Tom Tromey authored
      With GCC trunk, gdb.ada/access_to_packed_array.exp causes a GDB crash.
      The problem is that ptype tries to resolve a dynamic type.  However,
      the inferior is not running, so there are no frames.
      
      This patch updates dwarf2_evaluate_loc_desc::get_frame_base to handle
      this situation.
      
      gdb/ChangeLog
      2021-05-17  Tom Tromey  <tromey@adacore.com>
      
      	* dwarf2/loc.c (dwarf2_evaluate_loc_desc::get_frame_base): Throw
      	if frame is null.
      9e541c79
    • Tom Tromey's avatar
      Fix ubsan build · 59173216
      Tom Tromey authored
      I tried a build using the undefined behavior sanitizer, and gcc gave
      this error:
      
      In file included from /usr/include/string.h:495,
                       from ../gnulib/import/string.h:41,
                       from ../../binutils-gdb/gdb/../gdbsupport/common-defs.h:95,
                       from ../../binutils-gdb/gdb/nat/linux-osdata.c:20:
      In function 'char* strncpy(char*, const char*, size_t)',
          inlined from 'void time_from_time_t(char*, int, TIME_T)' at ../../binutils-gdb/gdb/nat/linux-osdata.c:923:15,
          inlined from 'void time_from_time_t(char*, int, TIME_T)' at ../../binutils-gdb/gdb/nat/linux-osdata.c:911:1,
          inlined from 'void linux_xfer_osdata_sem(buffer*)' at ../../binutils-gdb/gdb/nat/linux-osdata.c:1082:22:
      /usr/include/bits/string_fortified.h:106:34: error: 'char* __builtin_strncpy(char*, const char*, long unsigned int)' specified bound 32 equals destination size [-Werror=stringop-truncation]
      
      This patch fixes the problem by subtracting one from the length
      parameter to strncpy.
      
      I changed a couple of other similar functions -- gcc does not warn
      about these, but I didn't see any substantial difference between the
      different cases, and I think these are just latent warnings, to be
      triggered in the future by a change to inlining heuristics.
      
      gdb/ChangeLog
      2021-05-17  Tom Tromey  <tromey@adacore.com>
      
      	* nat/linux-osdata.c (user_from_uid, time_from_time_t)
      	(group_from_gid): Subtract one from strncpy length.
      59173216
    • Tom Tromey's avatar
      Fix buffer underflow in add_path · baea2f9d
      Tom Tromey authored
      Address sanitizer pointed out a buglet in source.c:add_path.
      In this test, from gdb.base/source-dir.exp:
      
          (gdb) set directories :/foo:/bar
      
      ... 'p[-1]' will result in a buffer underflow.
      This patch fixes the bug by introducing a new check.
      
      2021-05-17  Tom Tromey  <tromey@adacore.com>
      
      	* source.c (add_path): Check 'p' before using 'p[-1]'.
      baea2f9d
    • Tom Tromey's avatar
      Change how dwarf2_per_cu_data is deleted · 473ab964
      Tom Tromey authored
      Address sanitizer pointed out that the patch to use 'delete' for
      dwarf2_per_cu_data introduced a bug -- now it is possible to delete a
      signatured_type using a pointer to its base class.
      
      This patch fixes the problem by introducing a deleter and a unique_ptr
      specialization.  A virtual destructor would be more ordinary here, but
      it seemed wasteful to add a vtable just for this purpose.  If virtual
      methods are ever needed here, we can revisit this.
      
      2021-05-17  Tom Tromey  <tromey@adacore.com>
      
      	* dwarf2/read.h (struct dwarf2_per_cu_data_deleter: New.
      	(dwarf2_per_cu_data_up): New typedef.
      	(struct dwarf2_per_bfd) <allocate_per_cu>: Change return type.
      	<all_comp_units>: Use dwarf2_per_cu_data_up.
      	* dwarf2/read.c (dwarf2_per_cu_data::operator()): New function.
      	(dwarf2_per_bfd::allocate_per_cu): Return dwarf2_per_cu_data_up.
      	(create_cu_from_index_list): Likewise.
      	(create_signatured_type_table_from_index)
      	(create_cus_from_debug_names_list, add_type_unit)
      	(read_comp_units_from_section): Update.
      	(dwarf2_find_containing_comp_unit): Change type of all_comp_units.
      	(run_test): Update.
      473ab964
    • Tom Tromey's avatar
      Replace sort_tu_by_abbrev_offset with operator< · 16e0020b
      Tom Tromey authored
      I noticed that sort_tu_by_abbrev_offset only has a single caller.  It
      seemed simpler to replace it with an implementation of operator<
      instead.
      
      2021-05-17  Tom Tromey  <tom@tromey.com>
      
      	* dwarf2/read.c (tu_abbrev_offset::operator<): New method.
      	(sort_tu_by_abbrev_offset): Remove.
      	(build_type_psymtabs): Update.
      16e0020b
    • Simon Marchi's avatar
      gdb/testsuite: rename .py.in files to .py · 5277208d
      Simon Marchi authored
      I noticed these files because they weren't considered by black for
      reformatting, prior to adding pyproject.toml, because their extension is
      not .py.  I don't think they specifically need to be named .py.in, so I
      suggest renaming them to .py.  This will make it nicer to edit them, as
      editors will recognize them more easily as Python files.
      
      Perhaps this was needed before, when the testsuite didn't always put
      output files in the output directory.  Then, a different name for the
      source and destination file might have been desirable to avoid
      overwriting a file with itself (perhaps that wasn't well handled).  But
      in any case, it doesn't see to cause any problem now.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.python/py-framefilter-gdb.py.in: Rename to:
      	* gdb.python/py-framefilter-gdb.py: ... this.
      	* gdb.python/py-framefilter-invalidarg-gdb.py.in: Rename to:
      	* gdb.python/py-framefilter-invalidarg-gdb.py: ... this.
      
      Change-Id: I63bb94010bbbc33434ee1c91a386c91fc1ff80bc
      5277208d
    • Simon Marchi's avatar
      gdb: add pyproject.toml · 91e159e9
      Simon Marchi authored
      When running black to format Python files, files with extension .py.in
      are ignored, because they don't end in .py.  Add a pyproject.toml file
      to instruct black to pick up these files too.
      
      gdb/ChangeLog:
      
      	* py-project.toml: New.
      	* gdb-gdb.py.in: Re-format.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.python/py-framefilter-gdb.py.in: Re-format.
      	* gdb.python/py-framefilter-invalidarg-gdb.py.in: Re-format.
      
      Change-Id: I9b88faec3360ea24788f44c8b89fe0b2a5f4eb97
      91e159e9
    • Simon Marchi's avatar
      gdb: add cmd_list_element::is_command_class_help · 034dce7a
      Simon Marchi authored
      Same idea as the previous patches, but for whether a command is a
      "command class help" command.  I think this one is particularly useful,
      because it's not obvious when reading code what "c->func == NULL" means.
      
      Remove the cmd_func_p function, which does kind of the same thing as
      cmd_list_element::is_command_class_help (except it doesn't give a clue
      about the semantic of a NULL func value).
      
      gdb/ChangeLog:
      
      	* cli/cli-decode.h (cmd_list_element) <is_command_class_help>:
      	New, use it.
      	* command.h (cmd_func_p): Remove.
      	* cli/cli-decode.c (cmd_func_p): Remove.
      
      Change-Id: I521a3e1896dc93a5babe1493d18f5eb071e1b3b7
      034dce7a
    • Simon Marchi's avatar
      gdb: add cmd_list_element::is_prefix · 3d0b3564
      Simon Marchi authored
      Same idea as the previous patch, but for prefix instead of alias.
      
      gdb/ChangeLog:
      
      	* cli/cli-decode.h (cmd_list_element) <is_prefix>: New, use it.
      
      Change-Id: I76a9d2e82fc8d7429904424674d99ce6f9880e2b
      3d0b3564
    • Simon Marchi's avatar
      gdb: add cmd_list_element::is_alias · 1be99b11
      Simon Marchi authored
      Add the cmd_list_element::is_alias helper to check whether a command is
      an alias.  I find it easier to understand the intention in:
      
        if (c->is_alias ())
      
      than
      
        if (c->alias_target != nullptr)
      
      Change all the spots that are reading alias_target just to compare it to
      NULL/nullptr to use is_alias instead.
      
      gdb/ChangeLog:
      
      	* cli/cli-decode.h (cmd_list_element) <is_alias>: New, use it.
      
      Change-Id: I26ed56f99ee47fe884fdfedf87016501631693ce
      1be99b11
    • Simon Marchi's avatar
      gdb: rename cmd_list_element::cmd_pointer to target · 99858724
      Simon Marchi authored
      cmd_pointer is another field whose name I found really not clear.  Yes,
      it's a pointer to a command, the type tells me that.  But what's the
      relationship of that command to the current command?  This field
      contains, for an alias, the command that it aliases.  So I think that
      the name "alias_target" would be more appropriate.
      
      Also, rename "old" parameters to "target" in the functions that add
      aliases.
      
      gdb/ChangeLog:
      
      	* cli/cli-decode.h (cmd_list_element) <cmd_pointer>: Rename
      	to...
      	<alias_target>: ... this.
      	(add_alias_cmd): Rename old to target.
      	(add_info_alias): Rename old_name to target_name.
      	(add_com_alias): Likewise.
      
      Change-Id: I8db36c6dd799fae155f7acd3805f6d62d98befa9
      99858724
    • Simon Marchi's avatar
      gdb: rename cmd_list_element::prefixlist to subcommands · 14b42fc4
      Simon Marchi authored
      While browsing this code, I found the name "prefixlist" really
      confusing.  I kept reading it as "list of prefixes".  Which it isn't:
      it's a list of sub-commands, for a prefix command.  I think that
      renaming it to "subcommands" would make things clearer.
      
      gdb/ChangeLog:
      
      	* Rename "prefixlist" parameters to "subcommands" throughout.
      	* cli/cli-decode.h (cmd_list_element) <prefixlist>: Rename to...
      	<subcommands>: ... this.
      	* cli/cli-decode.c (lookup_cmd_for_prefixlist): Rename to...
      	(lookup_cmd_with_subcommands): ... this.
      
      Change-Id: I150da10d03052c2420aa5b0dee41f422e2a97928
      14b42fc4
    • Simon Marchi's avatar
      gdb: don't handle old == nullptr in add_alias_cmd · ecd0a6b3
      Simon Marchi authored
      I don't think this can ever happen, that we add an alias command and
      pass a nullptr old (target) command.  Remove the "if" handling this,
      replace with an assert.
      
      gdb/ChangeLog:
      
      	* cli/cli-decode.c (add_alias_cmd): Don't handle old == 0.
      
      Change-Id: Ibb39e8dc4e0c465fa42e6826215f30a0a0aef932
      ecd0a6b3
    • Simon Marchi's avatar
      gdb: move cmd_list_element::prefixname to cli/cli-decode.c · 413b49c2
      Simon Marchi authored
      I don't think this method really benefits from being implemented in the
      header file, especially because it's recursive, it can't be inlined.
      Move it to the source file, so it's no re-compiled by every CU
      including cli/cli-decode.h.
      
      I also noticed this method could be const, make it so.
      
      gdb/ChangeLog:
      
      	* cli/cli-decode.h (prefixname): Make const, move implementation
      	to cli/cli-decode.c.
      	* cli/cli-decode.c (cmd_list_element::prefixname): New.
      
      Change-Id: I1597cace98d9a4ba71f51f1f495e73cc07b5dcf3
      413b49c2
  3. May 17, 2021
    • Alex Coplan's avatar
      arm: Fix bugs with MVE vmov from two GPRs to vector lanes · e683cb41
      Alex Coplan authored
      The initial problem I wanted to fix here is that GAS was rejecting MVE
      instructions such as:
      
      vmov q3[2], q3[0], r2, r2
      
      with:
      
      Error: General purpose registers may not be the same -- `vmov q3[2],q3[0],r2,r2'
      
      which is incorrect; such instructions are valid. Note that for moves in
      the other direction, e.g.:
      
      vmov r2, r2, q3[2], q3[0]
      
      GAS is correct in rejecting this as it does not make sense to move both
      lanes into the same register (the Arm ARM says this is CONSTRAINED
      UNPREDICTABLE).
      
      After fixing this issue, I added assembly/disassembly tests for these
      vmovs. This revealed several disassembly issues, including incorrectly
      marking the moves into vector lanes as UNPREDICTABLE, and disassembling
      many of the vmovs as vector loads. These are now fixed.
      
      gas/ChangeLog:
      
      	* config/tc-arm.c (do_mve_mov): Only reject vmov if we're moving
      	into the same GPR twice.
      	* testsuite/gas/arm/mve-vmov-bad-2.l: Tweak error message.
      	* testsuite/gas/arm/mve-vmov-3.d: New test.
      	* testsuite/gas/arm/mve-vmov-3.s: New test.
      
      opcodes/ChangeLog:
      
      	* arm-dis.c (mve_opcodes): Fix disassembly of
      	MVE_VMOV2_GP_TO_VEC_LANE when idx == 1.
      	(is_mve_encoding_conflict): MVE vector loads should not match
      	when P = W = 0.
      	(is_mve_unpredictable): It's not unpredictable to use the same
      	source register twice (for MVE_VMOV2_GP_TO_VEC_LANE).
      e683cb41
    • Bhuvanendra Kumar N's avatar
      gdb/fortran: test case modified to suit the clang behavior. · 467f8eb2
      Bhuvanendra Kumar N authored
      As mentioned in the test case itself, depending on the fortran compiler
      used, class member names used in the print commands and also output of
      these print commands varies. Existing print commands and its output are
      suited for gfortran, hence they were failing with clang compiler and test
      case was modified accordingly for clang compiler.
      
      gdb/testsuite/ChangeLog:
              * gdb.base/class-allocatable-array.exp: Modified test for clang.
      467f8eb2
    • Mike Frysinger's avatar
      sim: fully merge sim_state_base into sim_state · f4fdd845
      Mike Frysinger authored
      Now that all ports have migrated to the new framework, drop support
      for the old sim_state_base layout.
      f4fdd845
    • Mike Frysinger's avatar
      sim: riscv: invert sim_state storage · 10c23a2c
      Mike Frysinger authored
      10c23a2c
    • Mike Frysinger's avatar
      sim: h8300: invert sim_state storage · 2ad10cb2
      Mike Frysinger authored
      2ad10cb2
    • Mike Frysinger's avatar
      sim: mips: invert sim_state storage · 8ea7241c
      Mike Frysinger authored
      8ea7241c
    • Mike Frysinger's avatar
      sim: avr: invert sim_state storage · 937af0fd
      Mike Frysinger authored
      937af0fd
    • Mike Frysinger's avatar
      e106fc35
    • Mike Frysinger's avatar
      sim: bfin: invert sim_state storage · 85d93de3
      Mike Frysinger authored
      85d93de3
    • Mike Frysinger's avatar
      sim: invert sim_state storage · 383861bd
      Mike Frysinger authored
      Currently all ports have to declare sim_state themselves in their
      sim-main.h and then embed the common sim_state_base & sim_cpu in it.
      This dynamic makes it impossible to share common object code among
      multiple ports because the core data structure is always different.
      
      Let's invert this relationship: common code declares sim_state, and
      if the port actually needs state on a per-instance basis, it can use
      the new arch_data field for it.  Most ports don't actually use it,
      so they don't need to declare anything at all.
      
      This is the first in a series of changes: it adds a define to select
      between the old & new layouts, then converts all the ports that don't
      need custom state over to the new layout.
      383861bd