1. May 18, 2021
    • 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
  2. 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
    • Mike Frysinger's avatar
      sim: install library header files · 92bc001e
      Mike Frysinger authored
      We install libsim.a for people to link against, but haven't been
      installing the header files to for its API.  Export them!
      92bc001e
    • Mike Frysinger's avatar
      sim: switch config.h usage to defs.h · 6df01ab8
      Mike Frysinger authored
      The defs.h header will take care of including the various config.h
      headers.  For now, it's just config.h, but we'll add more when we
      integrate gnulib in.
      
      This header should be used instead of config.h, and should be the
      first include in every .c file.  We won't rely on the old behavior
      where we expected files to include the port's sim-main.h which then
      includes the common sim-basics.h which then includes config.h.  We
      have a ton of code that includes things before sim-main.h, and it
      sometimes needs to be that way.  Creating a dedicated header avoids
      the ordering mess and implicit inclusion that shows up otherwise.
      6df01ab8
    • GDB Administrator's avatar
      Automatic date update in version.in · 681eb80f
      GDB Administrator authored
      681eb80f
    • Weimin Pan's avatar
      CTF: handle forward reference type · ea11a98d
      Weimin Pan authored
      The problems can be illustrated, with any program, below:
      
      (gdb) print main
      $1 = {main} 0x0
      
      The return type was incorrectly set in read_func_kind_type, with
      the name of the function, which leads c_type_print_base_1 to print
      it. In addition, the address of a new function needs to be set with
      that info in its minimal symtab entry, when the new function is added.
      
      After the fix:
      
      (gdb) print main
      $1 = {int ()} 0x4004b7 <main>
      
      A new test, gdb.ctf/funcreturn.exp, is added to the testsuite.
      
      gdb/ChangeLog:
              * ctfread.c (new_symbol): Set function address.
              (read_func_kind_type): Remove incorrect type name setting.
              Don't copy name returned from ctf_type_ame_raw throughout file.
      
      gdb/testsuite/ChangeLog:
              * gdb.ctf/funcreturn.exp: New file.
              * gdb.ctf/whatis.c: Copy from gdb.base.
      ea11a98d
  3. May 16, 2021
  4. May 15, 2021
    • Mike Frysinger's avatar
      sim: ppc: clean up various warnings · be2bc30f
      Mike Frysinger authored
      A random grab bag of minor fixes to enable -Werror for this port.
      
      Cast address vars to long when the format was using %l.
      Use %zu with sizeof operations.
      Add const to a bunch of strings.
      Trim unused variables.
      Fix sizeof call to calculate target storage and not the pointer itself.
      be2bc30f
    • Mike Frysinger's avatar
      sim: switch to libiberty environ.h · c5a2e012
      Mike Frysinger authored
      Drop our compat code and assume environ exists to simplify.
      c5a2e012
    • Alan Modra's avatar
      process_cu_tu_index · b9c0d703
      Alan Modra authored
      	* dwarf.c (process_cu_tu_index): Avoid pointer UB.  Use _mul_overflow.
      	Delete dead code.
      b9c0d703
    • Alan Modra's avatar
      display_gdb_index · bb19bf12
      Alan Modra authored
      	* dwarf.c (display_gdb_index): Avoid pointer UB and overflow in
      	length calculations.
      bb19bf12
    • Alan Modra's avatar
      display_debug_names · d7870f63
      Alan Modra authored
      	* dwarf.c (display_debug_names): Complain when header length is
      	too small.  Avoid pointer UB.  Sanity check augmentation string,
      	CU table, TU table and foreign TU table sizes.
      d7870f63
    • Alan Modra's avatar
      display_debug_frames · 5897a389
      Alan Modra authored
      	* dwarf.c (display_debug_frames): Delete initial_length_size.
      	Avoid pointer UB.  Constrain data reads to length given in header.
      	Sanity check cie header length.  Only skip up to next FDE on
      	finding augmentation data too long.
      5897a389
    • Alan Modra's avatar
      read_cie · c93c4a85
      Alan Modra authored
      	* dwarf.c (read_cie): Add more sanity checks to ensure data
      	pointer is not bumped past end.
      c93c4a85
    • Alan Modra's avatar
      display_debug_ranges · b4951546
      Alan Modra authored
      	* dwarf.c (display_debug_ranges): Delete initial_length_size.
      	Correct fallback size calculated on finding a reloc.  Constrain
      	data reads to length given in header.  Avoid pointer UB.
      b4951546
    • Alan Modra's avatar
      display_debug_rnglists_list · 669f463d
      Alan Modra authored
      	* dwarf.c (display_debug_rnglists_list): Avoid pointer UB.
      669f463d
    • Alan Modra's avatar
      display_debug_str_offsets · 5250d2f0
      Alan Modra authored
      	* dwarf.c (display_debug_str_offsets): Constrain reads to length
      	given in header.
      5250d2f0
    • Alan Modra's avatar
      display_debug_aranges · 6ca07350
      Alan Modra authored
      	* dwarf.c (display_debug_aranges): Delete initial_length_size.
      	Use end_ranges to constrain data reads to header length.  Avoid
      	pointer UB.
      6ca07350
    • Alan Modra's avatar
      display_loc_list · 78480097
      Alan Modra authored
      	* dwarf.c (display_loc_list): Avoid pointer UB.  Correct check
      	before reading uleb length.  Warn on excess length.
      78480097
    • Alan Modra's avatar
      display_debug_macro · b0d461ec
      Alan Modra authored
      	* dwarf.c (display_debug_macro): Print strings that might not
      	be zero terminated with %*s.  Don't bump curr if unterminated.
      b0d461ec
    • Alan Modra's avatar
      get_line_filename_and_dirname · 46d1214d
      Alan Modra authored
      	* dwarf.c (get_line_filename_and_dirname): Delete initial_length_size.
      	Simplify length sanity check, and check for too small lengths.
      	Constrain data reads to header length.  Avoid pointer UB.
      46d1214d
    • Alan Modra's avatar
      display_debug_macinfo · c03df922
      Alan Modra authored
      The existing code went to the bother of using strnlen for scanning but
      went wild when printing, and possibly incremented curr past end.
      
      	* dwarf.c (display_debug_macinfo): Print strings that might not
      	be zero terminated with %*s.  Don't bump curr if unterminated.
      c03df922
    • Alan Modra's avatar
      display_debug_pubnames_worker · 35b2c89e
      Alan Modra authored
      	* dwarf.c (display_debug_pubnames_worker): Delete initial_length_size.
      	Simplify length check.  Constrain reads to length given by header.
      35b2c89e
    • Alan Modra's avatar
      display_debug_lines_decoded · 56051e28
      Alan Modra authored
      The directory_table strnlen used the negative of the proper size.  After
      fixing that I realised we don't need strnlen here.
      
      	* dwarf.c (display_debug_lines_decoded): Don't use strnlen when
      	we have already checked for NUL termination.
      56051e28