1. Apr 29, 2021
    • Andrew Burgess's avatar
      gdb/NEWS: Fix typo and stray full stop · 8eb82ba1
      Andrew Burgess authored
      Some errors introduced in commit:
      
        commit edeaceda
        Date:   Thu Aug 27 16:53:13 2020 +0100
      
            gdb: startup commands to control Python extension language
      
      gdb/ChangeLog:
      
      	* NEWS: Fix typo and stray full stop.
      8eb82ba1
    • GDB Administrator's avatar
      Automatic date update in version.in · ae95c78d
      GDB Administrator authored
      ae95c78d
    • Tom Tromey's avatar
      Fix Ada overloading with 'null' · db2534b7
      Tom Tromey authored
      Currently, the Ada expression parser treats 'null' as an integer 0.
      However, this causes overloading to fail in certain cases.
      
      This patch changes the Ada expression parser to use a special type for
      'null'.  I chose pointer-to-int0, because I think that's not likely to
      be needed for any other Ada expression.  Note this works because a
      "mod 1" type has an underlying non-zero byte size; the test includes a
      check for this.
      
      The output is changed so that "print null", by default, shows "null".
      And, ada_type_match is changed both to recognize the special null type
      and to remove a bit of weird code related to how pointers are treated
      for overload type matching.
      
      Tested on x86-64 Fedora 32.  Because this only touches Ada, and Joel
      already approved it internally at AdaCore, I am checking it in.
      
      gdb/ChangeLog
      2021-04-28  Tom Tromey  <tromey@adacore.com>
      
      	* ada-exp.y (primary): Use new type for null pointer.
      	* ada-lang.c (ada_type_match): Remove "may_deref"
      	parameter.  Handle nul...
      db2534b7
  2. Apr 28, 2021
    • Andrew Burgess's avatar
      gdb/doc: use @env to reference environment variables · e43c3e2a
      Andrew Burgess authored
      Clean up a few places where we are not using @env{...} to reference
      environment variables.
      
      gdb/doc/ChangeLog:
      
      	* gdb.texinfo (Initialization Files): Use @env when referencing
      	environment variables.
      	(Shell Commands): Likewise.
      	(Starting): Likewise.
      	(Arguments): Likewise.
      	(Environment): Likewise.
      	(Edit): Likewise.
      	(Compiling and Injecting Code): Likewise.
      	(Files): Likewise.
      	(Command History): Likewise.
      	(Screen Size): Likewise.
      	(Emacs): Likewise.
      e43c3e2a
    • Nick Clifton's avatar
      Stop the BFD library from treating annobin symbols as potential function symbols. · 24aebc79
      Nick Clifton authored
      bfd	* elf.c (_bfd_elf_maybe_function_sym): Do not accept annobin
      	symbols as potential function symbols.
      	* elfnn-aarch64.c (elfNN_aarch64_maybe_function_sym): Likewise.
      	* elf64-ppc.c (ppc64_elf_maybe_function_sym): Likewise.
      	* elf32-arm.c (elf32_arm_maybe_function_sym): Likewise.
      
      ld	* testsuite/ld-elf/anno-sym.s: New test source file.
      	* testsuite/ld-elf/anno-sym.d: New test driver.
      	* testsuite/ld-elf/anno-sym.l: New test error output.
      24aebc79
    • Andrew Burgess's avatar
      gdb: startup commands to control Python extension language · edeaceda
      Andrew Burgess authored
      Add two new commands to GDB that can be placed into the early
      initialization to control how Python starts up.  The new options are:
      
        set python ignore-environment on|off
        set python dont-write-bytecode auto|on|off
      
        show python ignore-environment
        show python dont-write-bytecode
      
      These can be used from GDB's startup file to control how the Python
      extension language behaves.  These options are equivalent to the -E
      and -B flags to python respectively, their descriptions from the
      Python man page:
      
        -E     Ignore environment variables like PYTHONPATH and PYTHONHOME
               that modify the  behavior  of  the  interpreter.
      
        -B     Don't write .pyc files on import.
      
      gdb/ChangeLog:
      
      	* NEWS: Mention new commands.
      	* python/python.c (python_ignore_environment): New static global.
      	(show_python_ignore_environment): New function.
      	(set_python_ignore_environment): New function.
      	(python_dont_write_bytecode): New static global.
      	(show_python_dont_write_bytecode): New function.
      	(set_python_dont_write_bytecode): New function.
      	(_initialize_python): Register new commands.
      
      gdb/doc/ChangeLog:
      
      	* python.texinfo (Python Commands): Mention new commands.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.python/py-startup-opt.exp: New file.
      edeaceda
    • Andrew Burgess's avatar
      gdb: extension languages finish_initialization to initialize · 041ca48e
      Andrew Burgess authored
      Now that both Python and Guile are fully initialized from their
      respective finish_initialization methods, the "finish" in the method
      name doesn't really make sense; initialization starts _and_ finishes
      with that method.
      
      As such, this commit renames finish_initialization to just initialize.
      
      There should be no user visible changes after this commit.
      
      gdb/ChangeLog:
      
      	* extension-priv.h (struct extension_language_ops): Rename
      	'finish_initialization' to 'initialize'.
      	* extension.c (finish_ext_lang_initialization): Renamed to...
      	(ext_lang_initialization): ...this, update comment, and updated
      	the calls to reflect the change in struct extension_language_ops.
      	* extension.h (finish_ext_lang_initialization): Renamed to...
      	(ext_lang_initialization): ...this.
      	* guile/guile.c (gdbscm_finish_initialization): Renamed to...
      	(gdbscm_initialize): ...this, update comment at definition.
      	(guile_extension_ops): Update.
      	* main.c (captured_main_1): Update call to
      	finish_ext_lang_initialization.
      	* python/python.c (gdbpy_finish_initialization): Rename to...
      	(gdbpy_initialize): ...this, update comment at definition, and
      	update call to do_finish_initialization.
      	(python_extension_ops): Update.
      	(do_finish_initialization): Rename to...
      	(do_initialize): ...this, and update comment.
      041ca48e
    • Andrew Burgess's avatar
      gdb: initialise extension languages after processing early startup files · 1178f01a
      Andrew Burgess authored
      Now (thanks to the last few commits) all extension languages are
      fully initialised in their finish_initialization method, this commit
      delays the call to this method until after the early initialization
      files have been processed.
      
      Right now there's no benefit from doing this, but in a later commit I
      plan to add new options for Python that will control how Python is
      initialized.
      
      With this commit in place, my next commits will allow the user to add
      options to their early initialization file and alter how Python starts
      up.
      
      There should be no user visible changes after this commit.
      
      gdb/ChangeLog:
      
      	* main.c (captured_main_1): Add a call to
      	finish_ext_lang_initialization.
      	* top.c (gdb_init): Remove call to finish_ext_lang_initialization.
      1178f01a
    • Andrew Burgess's avatar
      gdb delay guile initialization until gdbscm_finish_initialization · 880ae75a
      Andrew Burgess authored
      Like with the previous commit, this commit delays the initialisation
      of the guile extension language until gdbscm_finish_initialization.
      
      This is mostly about splitting the existing gdbscm_initialize_*
      functions in two, all the calls to register_objfile_data_with_cleanup,
      gdbarch_data_register_post_init, etc are moved into new _initialize_*
      functions, but everything else is left in the gdbscm_initialize_*
      functions.
      
      Then the call to code previously in _initialize_guile is moved into
      gdbscm_finish_initialization.
      
      There should be no user visible changes after this commit.
      
      gdb/ChangeLog:
      
      	* guile/guile.c (gdbscm_set_backtrace): Add declaration.
      	(gdbscm_finish_initialization): Add code moved from
      	_initialize_guile.
      	(_initialize_guile): Move code to gdbscm_finish_initialization.
      	* guile/scm-arch.c (gdbscm_initialize_arches): Move some code into
      	_initialize_scm_arch.
      	(_initialize_scm_arch): New function.
      	* guile/scm-block.c (gdbscm_initialize_blocks): Move some code
      	into _initialize_scm_block.
      	(_initialize_scm_block): New function.
      	* guile/scm-frame.c (gdbscm_initialize_frames): Move some code
      	into _initialize_scm_frame.
      	(_initialize_scm_frame): New function.
      	* guile/scm-objfile.c (gdbscm_initialize_objfiles): Move some code
      	into _initialize_scm_objfile.
      	(_initialize_scm_objfile): New function.
      	* guile/scm-progspace.c (gdbscm_initialize_pspaces): Move some
      	code into _initialize_scm_progspace.
      	(_initialize_scm_progspace): New function.
      	* guile/scm-symbol.c (gdbscm_initialize_symbols): Move some code
      	into _initialize_scm_symbol.
      	(_initialize_scm_symbol): New function.
      	* guile/scm-symtab.c (gdbscm_initialize_symtabs): Move some code
      	into _initialize_scm_symtab.
      	(_initialize_scm_symtab): New function.
      	* guile/scm-type.c (gdbscm_initialize_types): Move some code into
      	_initialize_scm_type.
      	(_initialize_scm_type): New function.
      880ae75a
    • Andrew Burgess's avatar
      gdb: delay python initialisation until gdbpy_finish_initialization · 8e3685bf
      Andrew Burgess authored
      Delay Python initialisation until gdbpy_finish_initialization.
      
      This is mostly about splitting the existing gdbpy_initialize_*
      functions in two, all the calls to register_objfile_data_with_cleanup,
      gdbarch_data_register_post_init, etc are moved into new _initialize_*
      functions, but everything else is left in the gdbpy_initialize_*
      functions.
      
      Then the call to do_start_initialization (in python/python.c) is moved
      from the _initialize_python function into gdbpy_finish_initialization.
      
      There should be no user visible changes after this commit.
      
      gdb/ChangeLog:
      
      	* python/py-arch.c (_initialize_py_arch): New function.
      	(gdbpy_initialize_arch): Move code to _initialize_py_arch.
      	* python/py-block.c (_initialize_py_block): New function.
      	(gdbpy_initialize_blocks): Move code to _initialize_py_block.
      	* python/py-inferior.c (_initialize_py_inferior): New function.
      	(gdbpy_initialize_inferior): Move code to _initialize_py_inferior.
      	* python/py-objfile.c (_initialize_py_objfile): New function.
      	(gdbpy_initialize_objfile): Move code to _initialize_py_objfile.
      	* python/py-progspace.c (_initialize_py_progspace): New function.
      	(gdbpy_initialize_pspace): Move code to _initialize_py_progspace.
      	* python/py-registers.c (_initialize_py_registers): New function.
      	(gdbpy_initialize_registers): Move code to
      	_initialize_py_registers.
      	* python/py-symbol.c (_initialize_py_symbol): New function.
      	(gdbpy_initialize_symbols): Move code to _initialize_py_symbol.
      	* python/py-symtab.c (_initialize_py_symtab): New function.
      	(gdbpy_initialize_symtabs): Move code to _initialize_py_symtab.
      	* python/py-type.c (_initialize_py_type): New function.
      	(gdbpy_initialize_types): Move code to _initialize_py_type.
      	* python/py-unwind.c (_initialize_py_unwind): New function.
      	(gdbpy_initialize_unwind): Move code to _initialize_py_unwind.
      	* python/python.c (_initialize_python): Move call to
      	do_start_initialization to gdbpy_finish_initialization.
      	(gdbpy_finish_initialization): Add call to
      	do_start_initialization.
      8e3685bf
    • Andrew Burgess's avatar
      gdb: ensure SIGINT is set to SIG_DFL during initialisation · 913832e9
      Andrew Burgess authored
      In order for our SIGINT handling to work correctly with Python we
      require that SIGINT be set to SIG_DFL during Python's initialisation.
      
      Currently this is the case, but, in a later commit I plan to delay the
      initialisation of Python until after the point where GDB's own SIGINT
      handler has been installed.
      
      The consequence of this is that our SIGINT handling would become
      broken.
      
      In this commit I propose adding an RAII class that will ensure SIGINT
      is set to SIG_DFL during the call to each extension languages
      finish_initialization method.
      
      At this point this change should have not effect.
      
      gdb/ChangeLog:
      
      	* extension.c (struct scoped_default_signal): New struct.
      	(scoped_default_sigint): New typedef.
      	(finish_ext_lang_initialization): Make use of
      	scoped_default_sigint.
      913832e9
    • Andrew Burgess's avatar
      gdb: remove unused argument from gdb_init · a3b5ef3e
      Andrew Burgess authored
      The argument to gdb_init is not used, remove it.
      
      There should be no user visible changes after this commit.
      
      gdb/ChangeLog:
      
      	* main.c (captured_main_1): Don't pass argument to gdb_init.
      	* top.c (gdb_init): Remove unused argument, and add header
      	comment.
      	* top.h (gdb_init): Remove argument.
      a3b5ef3e
    • Jan Beulich's avatar
      x86: honor signedness of PC-relative relocations · eb19308f
      Jan Beulich authored
      PR gas/27763
      
      While the comment in output_jump() was basically correct prior to the
      introduction of 64-bit mode, both that and the not-JMP-like behavior of
      XBEGIN require adjustments: Branches with 32-bit displacement do not
      wrap at 4G in 64-bit mode, and XBEGIN with 16-bit operand size doesn't
      wrap at 64k. Similarly %rip-relative addressing doesn't wrap at 4G.
      
      The new testcase points out that for PE/COFF object_64bit didn't get
      set so far, preventing in particular the check at the end of
      md_convert_frag() to take effect.
      
      For Mach-O the new testcase fails (bogusly), in that only the first two
      of the expected errors get raised. Since for Mach-O many testcases
      already fail, and since an x86_64-darwin target can't even be configured
      for, I didn't think I need to bother.
      
      Note that there are further issues in this area, in particular for
      branches with operand size overrides. Such branches, which truncate
      %rip / %eip, can't be correctly expressed with ordinary PC-relative
      relocations. It's not really clear what to do with them - perhaps the
      best we can do is to carry through all associated relocations, leaving
      it to the linker (or even loader) to decide (once the final address
      layout is known). Same perhaps goes for relocations associated with
      32-bit addressing in 64-bit mode.
      eb19308f
    • GDB Administrator's avatar
      Automatic date update in version.in · 6c356992
      GDB Administrator authored
      6c356992
    • Luis Machado's avatar
      Fix timeout with maint print objfiles · b9f90c72
      Luis Machado authored
      I'm seeing timeouts from gdb.rust/traits.exp when we attempt to print
      things with "maint print objfiles".
      
      This happens for two reasons:
      
      1 - GDB does not explicitly split each entry into its own line, but rather
          relies on the terminal's width to insert line breaks.
      
      2 - When running the GDB testsuite, such width may be unlimited, which will
          prevent GDB from inserting any line breaks.
      
      As a result, the output may be too lengthy and will come in big lines.  Tweak
      the support library to match the patterns line-by-line, which gives us more
      time to match things. Also fix GDB's output to print one entry per line,
      regardless of the terminal width.
      
      A similar approach was used in another testcase using the same command (commit
      eaeaf44c). With the new line breaks, we don't
      need a particular pattern, so clean up that test as well.
      
      gdb/ChangeLog:
      
      2021-04-27  Luis Machado  <luis.machado@linaro.org>
      
      	* psymtab.c (psymbol_functions::dump): Output newline.
      	* symmisc.c (dump_objfile): Likewise.
      
      gdb/testsuite/ChangeLog:
      
      2021-04-27  Luis Machado  <luis.machado@linaro.org>
      
      	* gdb.base/maint.exp: Drop a pattern that is not needed.
      	* lib/gdb.exp (readnow): Match line-by-line.
      b9f90c72
    • Luis Machado's avatar
      Fix timeout for gdb.xml/tdesc-reload.exp · 4b62a30d
      Luis Machado authored
      For aarch64, the "info all-registers" output is very verbose.  If you run
      this test using read1, it will timeout before the command output is done being
      read.
      
      Read line-by-line so we don't run into timeouts.
      
      gdb/testsuite/ChangeLog:
      
      2021-04-27  Luis Machado  <luis.machado@linaro.org>
      
      	* gdb.xml/tdesc-reload.exp: Pass -lbl.
      4b62a30d
  3. Apr 27, 2021
    • Michael Weghorn's avatar
      gdb: do autoload before notifying Python side in new_objfile event · 2c473def
      Michael Weghorn authored
      Without any explicit dependencies specified, the observers attached
      to the 'gdb::observers::new_objfile' observable are always notified
      in the order in which they have been attached.
      
      The new_objfile observer callback to auto-load scripts is attached in
      '_initialize_auto_load'.
      The new_objfile observer callback that propagates the new_objfile event
      to the Python side is attached in 'gdbpy_initialize_inferior', which is
      called via '_initialize_python'.
      With '_initialize_python' happening before '_initialize_auto_load',
      the consequence was that the new_objfile event was emitted on the Python
      side before autoloaded scripts had been executed when a new objfile was
      loaded.
      As a result, trying to access the objfile's pretty printers (defined in
      the autoloaded script) from a handler for the Python-side
      'new_objfile' event would fail. Those would only be initialized later on
      (when the 'auto_load_new_objfile' callback was called).
      
      To make sure that the objfile passed to the Python event handler
      is properly initialized (including its 'pretty_printers' member),
      make sure that the 'auto_load_new_objfile' observer is notified
      before the 'python_new_objfile' one that propagates the event
      to the Python side.
      
      To do this, make use of the mechanism to explicitly specify
      dependencies between observers (introduced in a preparatory commit).
      
      Add a corresponding testcase that involves a test library with an autoloaded
      Python script and a handler for the Python 'new_objfile' event.
      
      (The real world use case where I came across this issue was in an attempt
      to extend handling for GDB pretty printers for dynamically loaded
      objfiles in the Qt Creator IDE, s. [1] and [2] for more background.)
      
      [1] https://bugreports.qt.io/browse/QTCREATORBUG-25339
      [2] https://codereview.qt-project.org/c/qt-creator/qt-creator/+/333857/1
      
      Tested on x86_64-linux (Debian testing).
      
      gdb/ChangeLog:
      
      	* gdb/auto-load.c (_initialize_auto_load): 'Specify token
      	when attaching the 'auto_load_new_objfile' observer, so
      	other observers can specify it as a dependency.
      	* gdb/auto-load.h (struct token): Declare
      	'auto_load_new_objfile_observer_token' as token to be used
      	for the 'auto_load_new_objfile' observer.
      	* gdb/python/py-inferior.c (gdbpy_initialize_inferior): Make
      	'python_new_objfile' observer depend on 'auto_load_new_objfile'
      	observer, so it gets notified after the latter.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.python/libpy-autoloaded-pretty-printers-in-newobjfile-event.so-gdb.py: New test.
      	* gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-lib.cc: New test.
      	* gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-lib.h: New test.
      	* gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event-main.cc: New test.
      	* gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.exp: New test.
      	* gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.py: New test.
      
      Change-Id: I8275b3f4c3bec32e56dd7892f9a59d89544edf89
      2c473def
    • Michael Weghorn's avatar
      gdbsupport: allow to specify dependencies between observers · 9a6e099f
      Michael Weghorn authored
      Previously, the observers attached to an observable were always notified
      in the order in which they had been attached.  That order is not easily
      controlled, because observers are typically attached in _initialize_*
      functions, which are called in an undefined order.
      
      However, an observer may require that another observer attached only
      later is called before itself is.
      
      Therefore, extend the 'observable' class to allow explicitly specifying
      dependencies when attaching observers, by adding the possibility to
      specify tokens for observers that it depends on.
      
      To make sure dependencies are notified before observers depending on
      them, the vector holding the observers is sorted in a way that
      dependencies come before observers depending on them.  The current
      implementation for sorting uses the depth-first search algorithm for
      topological sorting as described at [1].
      
      Extend the observable unit tests to cover this case as well.  Check that
      this works for a few different orders in which the observers are
      attached.
      
      This newly introduced mechanism to explicitly specify dependencies will
      be used in a follow-up commit.
      
      [1] https://en.wikipedia.org/wiki/Topological_sorting#Depth-first_search
      
      Tested on x86_64-linux (Debian testing).
      
      gdb/ChangeLog:
      
      	* unittests/observable-selftests.c (dependency_test_counters):
      	New.
      	(observer_token0, observer_token1, observer_token2,
      	observer_token3, observer_token4, observer_token5): New.
      	(struct dependency_observer_data): New struct.
      	(observer_dependency_test_callback): New function.
      	(test_observers): New.
      	(run_dependency_test): New function.
      	(test_dependency): New.
      	(_initialize_observer_selftest): Register dependency test.
      
      gdbsupport/ChangeLog:
      
      	* observable.h (class observable): Extend to allow specifying
      	dependencies between observers, keep vector holding observers
      	sorted so that dependencies are notified before observers
      	depending on them.
      
      Change-Id: I5399def1eeb69ca99e28c9f1fdf321d78b530bdb
      9a6e099f
    • H.J. Lu's avatar
      x86: Add () to silence GCC 5 · 60cfa10c
      H.J. Lu authored
      Add () to !i.prefix[ADDR_PREFIX] to silence GCC 5:
      
      gas/config/tc-i386.c:4152:31: error: logical not is only applied to the left hand side of comparison [-Werror=logical-not-parentheses]
           && !i.prefix[ADDR_PREFIX] != (flag_code == CODE_32BIT))
                                     ^
      
      	* config/tc-i386.c (optimize_encoding): Add () to silence GCC 5.
      60cfa10c
    • Nick Clifton's avatar
      Reject debuglink sections with no associated filename. · 3d64c987
      Nick Clifton authored
      	PR 27779
      	* dwarf.c (parse_gnu_debuglink): Reject empty names.
      	(parse_gnu_debugaltlink): Likewise.
      3d64c987
    • Mike Frysinger's avatar
      sim: riscv: switch MIN/MAX to common min/max · 2045d9d1
      Mike Frysinger authored
      The common sim-basics.h defines min/max already, so use them.
      2045d9d1
    • Mike Frysinger's avatar
      sim: nltvals: unify common syscall tables · bd0918c9
      Mike Frysinger authored
      Since libgloss provides a default syscall table for arches, use that
      to provide the default syscall table for ports.  Only the exceptions
      need to be enumerated now with the common logic as the default.
      bd0918c9
    • Mike Frysinger's avatar
      sim: enable hardware support by default · 66d055c7
      Mike Frysinger authored
      Force this on for all ports.  We have a few common models that can
      be used, so make them generally available.  If the port doesn't use
      any hardware (the default), then behavior is unchanged.
      66d055c7
    • Mike Frysinger's avatar
      bfd: add stdlib.h when using abort · 3955e346
      Mike Frysinger authored
      Since this file calls abort() now, we need to include stdlib.h for
      its prototype.
      3955e346
    • GDB Administrator's avatar
      Automatic date update in version.in · 674c5857
      GDB Administrator authored
      674c5857
    • Nick Clifton's avatar
      Fix a bug in the ARM emulator which would not allow 4 byte alignment for double word stores. · f6b9562f
      Nick Clifton authored
      	PR 22790
      	* armemu.c (Handle_Store_Double): Allow 4 byte alignment when
      	running in v6 mode.
      f6b9562f
  4. Apr 26, 2021
    • Tom Tromey's avatar
      Add test case for gdb 10 crash · e8b6c1da
      Tom Tromey authored
      PR gdb/27743 points out a gdb crash when expanding partial symtabs,
      where one of the compilation units uses DW_TAG_imported_unit.
      
      This crash happens for gdb 10, but not git trunk.  This patch pulls
      over the new test case only.
      
      gdb/testsuite/ChangeLog
      2021-04-26  Tom Tromey  <tromey@adacore.com>
      
      	PR gdb/27743:
      	* gdb.dwarf2/imported-unit-bp.exp: New file.
      	* gdb.dwarf2/imported-unit-bp-main.c: New file.
      	* gdb.dwarf2/imported-unit-bp-alt.c: New file.
      e8b6c1da
    • Simon Marchi's avatar
      gdb: check result of gdb_fopen_cloexec in dump_binary_file · bea3329b
      Simon Marchi authored
      Bug 27773 shows that passing a filename in a non-existent directory to
      the "dump binary" command leads to a gdb crash.  This is because the
      gdb_fopen_cloexec in dump_binary_file fails (returns nullptr) and the
      return value is not checked.  Fix that by erroring out if
      gdb_fopen_cloexec fails.
      
      gdb/ChangeLog:
      
      	PR gdb/27773
      	* cli/cli-dump.c (dump_binary_file): Check result of
      	gdb_fopen_cloexec.
      
      gdb/testsuite/ChangeLog:
      
      	PR gdb/27773
      	* gdb.base/dump.exp: Test dump to non-existent dir.
      
      Change-Id: Iea89a3bf9e6b9dcc31142faa5ae17bc855759328
      bea3329b
    • Luis Machado's avatar
      Fix gdb.arch/aarch64-dbreg-contents.exp FAIL · 21f91785
      Luis Machado authored
      The test checks for a particular ARCH level, but it needs to check for
      ARCH levels from a minimum and upwards.
      
      gdb/testsuite/ChangeLog:
      
      2021-04-26  Luis Machado  <luis.machado@linaro.org>
      
      	* gdb.arch/aarch64-dbreg-contents.c (set_watchpoint): Fix arch level
      	comparison.
      21f91785
    • Jan Beulich's avatar
      x86: correct overflow checking for 16-bit PC-relative relocs · a7664973
      Jan Beulich authored
      The only insn requiring a truly 16-bit PC-relative relocation outside of
      16-bit mode is XBEGIN (with an operand size override). For it, the
      relocation generated should behave similar to 8- and (for 64-bit) 32-bit
      PC-relatives ones, i.e. be checked for a signed value to fit the field.
      This same mode is also correct for 16-bit code. Outside of 16-bit code,
      branches with operand size overrides act in a truly PC-relative way only
      when living in the low 32k of address space, as they truncate rIP to 16
      bits. This can't be expressed by a PC-relative relocation.
      
      Putting in place a new testcase, I'd like to note that the two existing
      ones (pcrel16 and pcrel16abs) appear to be pretty pointless: They don't
      expect any error despite supposedly checking for overflow, and in fact
      there can't possibly be any error for the
      - former since gas doesn't emit any relocation in the first place there,
      - latter because the way the relocation gets expressed by gas doesn't
        allow the linker to notice the overflow; it should be detected by gas
        if at all, but see above (an error would be reported here for x86-64
        afaict, but this test doesn't get re-used there).
      a7664973
    • Jan Beulich's avatar
      x86: add IS_ELF to check whether to resolve @size reloc · 8fb88245
      Jan Beulich authored
      This may not be strictly needed, as BFD_RELOC_SIZE* shouldn't appear
      from elsewhere for non-ELF, but let's be on the safe side.
      8fb88245
    • Jan Beulich's avatar
      x86: limit 32-bit @size overflow checks to 64-bit objects · d965814f
      Jan Beulich authored
      For 32-bit objects the behavior should not be dependent upon the build
      being a BFD64 one.
      d965814f
    • Jan Beulich's avatar
      x86: optimize LEA · fe134c65
      Jan Beulich authored
      Over the years I've seen a number of instances where people used
      
          lea     (%reg1), %reg2
      
      or
      
          lea     symbol, %reg
      
      despite the same thing being expressable via MOV. Since additionally
      LEA often has restrictions towards the ports it can be issued to, while
      MOV typically gets dealt with simply by register renaming, transform to
      MOV when possible (without growing opcode size and without altering
      involved relocation types).
      
      Note that for Mach-O the new 64-bit testcases would fail (for
      BFD_RELOC_X86_64_32S not having a representation), and hence get skipped
      there.
      fe134c65
    • Jan Beulich's avatar
      x86-64: have value properly checked when resolving fixup · b8188555
      Jan Beulich authored
      Constants not known at the time an individual insn gets assembled and
      going into a sign-extended field still shouldn't be silently truncated
      at the time the respective fixup gets resolved.
      b8188555
    • Sergei Trofimovich's avatar
      gdb: fix sparc build failure of linux-nat · c290cb01
      Sergei Trofimovich authored
      On sparc build failed as:
      
      ```
      gdb/sparc-linux-nat.c: In member function
        'virtual void sparc_linux_nat_target::fetch_registers(regcache*, int)':
      gdb/sparc-linux-nat.c:36:37:
        error: cannot convert 'regcache*' to 'process_stratum_target*'
         36 |   { sparc_fetch_inferior_registers (regcache, regnum); }
            |                                     ^~~~~~~~
            |                                     |
            |                                     regcache*
      ```
      
      The fix adopts gdb/sparc-nat.h API change in d1e93af6
      ("gdb: set current thread in sparc_{fetch,collect}_inferior_registers").
      
      gdb/ChangeLog:
      
      	* sparc-linux-nat.c (sparc_linux_nat_target): fix sparc build
      	by passing `process_stratum_target*` parameter.
      c290cb01
    • GDB Administrator's avatar
      Automatic date update in version.in · 6476ec74
      GDB Administrator authored
      6476ec74
    • Lancelot SIX's avatar
      [PR gdb/22640] ptype: add option to use hexadecimal notation · fbb46296
      Lancelot SIX authored
      This commit adds a flag to the ptype command in order to print the
      offsets and sizes of struct members using the hexadecimal notation.  The
      'x' flag ensures use of the hexadecimal notation while the 'd' flag
      ensures use of the decimal notation.  The default is to use decimal
      notation.
      
      Before this patch, gdb only uses decimal notation, as pointed out in PR
      gdb/22640.
      
      Here is an example of this new behavior with hex output turned on:
      
          (gdb) ptype /ox struct type_print_options
          /* offset      |    size */  type = struct type_print_options {
          /* 0x0000: 0x0 |  0x0004 */    unsigned int raw : 1;
          /* 0x0000: 0x1 |  0x0004 */    unsigned int print_methods : 1;
          /* 0x0000: 0x2 |  0x0004 */    unsigned int print_typedefs : 1;
          /* 0x0000: 0x3 |  0x0004 */    unsigned int print_offsets : 1;
          /* 0x0000: 0x4 |  0x0004 */    unsigned int print_in_hex : 1;
          /* XXX  3-bit hole       */
          /* XXX  3-byte hole      */
          /* 0x0004      |  0x0004 */    int print_nested_type_limit;
          /* 0x0008      |  0x0008 */    typedef_hash_table *local_typedefs;
          /* 0x0010      |  0x0008 */    typedef_hash_table *global_typedefs;
          /* 0x0018      |  0x0008 */    ext_lang_type_printers *global_printers;
      
                                         /* total size (bytes):   32 */
                                       }
      
      This patch also adds the 'set print type hex' and 'show print type hex'
      commands in order to set and inspect the default behavior regarding the
      use of decimal or hexadecimal notation when printing struct sizes and
      offsets.
      
      Tested using on x86_64.
      
      gdb/ChangeLog:
      
      	PR gdb/22640
      	* typeprint.h (struct type_print_options): Add print_in_hex
      	flag.
      	(struct print_offset_data): Add print_in_hex flag, add a
      	constructor accepting a type_print_options* argument.
      	* typeprint.c (type_print_raw_options, default_ptype_flags): Set
      	default value for print_in_hex.
      	(print_offset_data::indentation): Allow more horizontal space.
      	(print_offset_data::print_offset_data): Add ctor.
      	(print_offset_data::maybe_print_hole, print_offset_data::update):
      	Handle the print_in_hex flag.
      	(whatis_exp): Handle 'x' and 'd' flags.
      	(print_offsets_and_sizes_in_hex): Declare.
      	(set_print_offsets_and_sizes_in_hex): Create.
      	(show_print_offsets_and_sizes_in_hex): Create.
      	(_initialize_typeprint): Update help message for the ptype
      	command, register the 'set print type hex' and 'show print type
      	hex' commands.
      	* c-typeprint.c (c_print_type, c_type_print_base_struct_union)
      	(c_type_print_base): Construct the print_offset_data
      	object using the type_print_optons parameter.
      	* rust-lang.c (rust_language::print_type): Construct the
      	print_offset_data object using the type_print_optons parameter.
      	* NEWS: Mention the new flags of the ptype command.
      
      gdb/doc/ChangeLog:
      
      	PR gdb/22640
      	* gdb.texinfo (Symbols): Describe the 'x' and 'd' flags of the
      	ptype command, describe 'set print type hex' and 'show print
      	type hex' commands.  Update 'ptype/o' examples.
      
      gdb/testsuite/ChangeLog:
      
      	PR gdb/22640
      	* gdb.base/ptype-offsets.exp: Add tests to verify the behavior
      	of 'ptype/ox' and 'ptype/od'. Check that 'set print type hex'
      	changes the default behavior of 'ptype/o'.  Update to take into
      	account new horizontal layout.
      	* gdb.rust/simple.exp: Update ptype test to check new horizontal
      	layout.
      	* gdb.rust/union.exp: Same.
      fbb46296
    • Lancelot SIX's avatar
      gdb/typeprint.h: reorder struct declaration · 18bbba46
      Lancelot SIX authored
      Move the declaration of struct type_print_raw_options before struct
      print_offset_data to ease upcoming changes.  This is a helper commit
      intended to make it easier to build a print_offset_data object from
      configurations given by a type_print_raw_options.
      
      gdb/ChangeLog:
      
      	* typeprint.h (struct type_print_options): Move before
      	  print_offset_data.
      18bbba46
  5. Apr 25, 2021
    • Tom Tromey's avatar
      Add engv32.h to SIM_EXTRA_DEPS in sim/cris · b22138f3
      Tom Tromey authored
      A rebuild showed that an earlier change of mine missed a built header
      file -- cris/engv32.h.  This patch fixes the problem.
      
      sim/cris/ChangeLog
      2021-04-25  Tom Tromey  <tom@tromey.com>
      
      	* Makefile.in (SIM_EXTRA_DEPS): Add engv32.h.
      b22138f3
    • Tom Tromey's avatar
      Use htab_t in sim-options.c · 4478c331
      Tom Tromey authored
      This changes sim-options.c to use the libiberty hash table, rather
      than its own custom hash table.
      
      sim/common/ChangeLog
      2021-04-25  Tom Tromey  <tom@tromey.com>
      
      	* sim-options.c (compare_strings): New function.
      	(ARG_HASH_SIZE, ARG_HASH): Remove.
      	(dup_arg_p): Use htab_t.
      	(sim_parse_args): Remove assert.
      4478c331