1. May 15, 2021
    • GDB Administrator's avatar
      Automatic date update in version.in · fcf102ba
      GDB Administrator authored
      fcf102ba
    • Fangrui Song's avatar
      gold: Add -Bno-symbolic · 823241a2
      Fangrui Song authored
      gold/
          PR 27834
          * options.h (General_options): Make -Bsymbolic and
          -Bsymbolic-functions special and adjust the help messages. Add
          enum Bsymbolic_kind and -Bno-symbolic.
          * options.cc (General_options): Define parse_Bno_symbolic,
          parse_Bsymbolic_functions, and parse_Bsymbolic.
      823241a2
  2. May 14, 2021
    • Bernd Edlinger's avatar
      testsuite: Cleanup some temp dirs with gdb-index files · f8eec398
      Bernd Edlinger authored
      After the gdb test-suite runs there are some files
      left in /tmp/tmp*/*.gdb-index, remove those files
      and the directory at the end of the test case.
      
      gdb/testsuite:
      2021-05-14  Bernd Edlinger  <bernd.edlinger@hotmail.de>
      
      	* gdb.base/index-cache.exp: Cleanup $cache_dir/*.gdb-index and
      	remove the directory.
      	* gdb.dwarf2/per-bfd-sharing.exp: Likewise.
      f8eec398
    • Tankut Baris Aktemur's avatar
      gdb/python: add a 'connection_num' attribute to Inferior objects · 55789354
      Tankut Baris Aktemur authored
      Define a 'connection_num' attribute for Inferior objects.  The
      read-only attribute is the ID of the connection of an inferior, as
      printed by "info inferiors".  In GDB's internal terminology, that's
      the process stratum target of the inferior.  If the inferior has no
      target connection, the attribute is None.
      
      gdb/ChangeLog:
      2021-05-14  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
      
      	* python/py-inferior.c (infpy_get_connection_num): New function.
      	(inferior_object_getset): Add a new element for 'connection_num'.
      	* NEWS: Mention the 'connection_num' attribute of Inferior objects.
      
      gdb/doc/ChangeLog:
      2021-05-14  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
      
      	* python.texi (Inferiors In Python): Mention the 'connection_num'
      	attribute.
      
      gdb/testsuite/ChangeLog:
      2021-05-14  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
      
      	* gdb.python/py-inferior.exp: Add test cases for 'connection_num'.
      55789354
    • Andrew Burgess's avatar
      gdb: some int to bool conversion in remote.c · 2f63ec5c
      Andrew Burgess authored
      Convert a couple of local variables from int to bool.  There should be
      no user visible changes after this commit.
      
      gdb/ChangeLog:
      
      	* remote.c (check_pending_events_prevent_wildcard_vcont): Change
      	argument type, update and re-wrap, header comment.
      	(remote_target::commit_resumed): Convert any_process_wildcard and
      	may_global_wildcard_vcont from int to bool.
      2f63ec5c
    • Nelson Chu's avatar
      RISC-V: Check the overflow for %pcrel_lo addend more strictly. · 75f03fa7
      Nelson Chu authored
      The %pcrel_lo addend may causes the overflow, and need more than one
      %pcrel_hi values.  But there may be only one auipc, shared by those
      %pcrel_lo with addends.  However, the existing check method in the
      riscv_resolve_pcrel_lo_relocs, may not be able to work for some
      special/corner cases.
      
      Consider the testcases pcrel-lo-addend-2b.  Before applying this patch,
      I can compile it successfully.  But in fact the addend cause the value
      of %pcrel_hi to be different.  This patch try to check the value of
      %pcrel_hi directly, to make sure it won't be changed.  Otherwise, linker
      will report the following errors,
      
      (.text+0xa): dangerous relocation: %pcrel_lo overflow with an addend,
      the value of %pcrel_hi is 0x1000 without any addend, but may be 0x2000
      after adding the %pcrel_lo addend
      
      The toolchain regressions, rv64gc-linux/rv64gc-elf/rv32gc-linux/rv32i-elf,
      pass expectedly and looks fine.
      
      bfd/
          * elfnn-riscv.c (riscv_resolve_pcrel_lo_relocs): Check...
      75f03fa7
    • Kent Cheung's avatar
      gdb: fix pretty printing max depth behaviour · ecf25064
      Kent Cheung authored
      The 'print max-depth' feature incorrectly causes GDB to skip printing
      the string representation of pretty printed variables if the variable
      is stored at a nested depth corresponding to the set max-depth value.
      This change ensures that it is always printed before checking whether
      the maximum print depth has been reached.
      
      Regression tested with GCC 7.3.0 on x86_64, ppc64le, aarch64.
      
      gdb/ChangeLog:
      
      	* cp-valprint.c (cp_print_value): Replaced duplicate code.
      	* guile/scm-pretty-print.c (ppscm_print_children): Check max_depth
      	just before printing child values.
      	(gdbscm_apply_val_pretty_printer): Don't check max_depth before
      	printing string representation.
      	* python/py-prettyprint.c (print_children): Check max_depth just
      	before printing child values.
      	(gdbpy_apply_val_pretty_printer): Don't check max_depth before
      	printing string representation.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.python/py-format-string.c: Added a variable to test.
      	* gdb.python/py-format-string.exp: Check string representation is
      	printed at appropriate max_depth settings.
      	* gdb.python/py-nested-maps.exp: Likewise.
      	* gdb.guile/scm-pretty-print.exp: Add additional tests.
      ecf25064
    • Mike Frysinger's avatar
      sim: callback: inline PTR define · 64654371
      Mike Frysinger authored
      We require C11 now, so no need for these pre-ANSI C hacks.
      PTR is simply void*, so use that directly.
      64654371
    • Mike Frysinger's avatar
      sim: callback: use ATTRIBUTE_NORETURN · 7fb6dc36
      Mike Frysinger authored
      This define is handled by ansidecl.h, so no need to duplicate effort.
      7fb6dc36
    • Mike Frysinger's avatar
      sim: callback: always include necessary headers · 2e4885ee
      Mike Frysinger authored
      We use types from these headers, so always include them.
      2e4885ee
    • Mike Frysinger's avatar
      sim: create header namespace · df68e12b
      Mike Frysinger authored
      The gdb/callback.h & gdb/remote-sim.h headers have nothing to do with
      gdb and are really definitions for the libsim API under the sim/ tree.
      While gdb uses those headers as a client, it's not specific to it.  So
      create a new sim/ namespace and move the headers there.
      df68e12b
    • Mike Frysinger's avatar
      gdb: lm32: drop unused sim headers · 183aaaf7
      Mike Frysinger authored
      Looks like these were copied & pasted as nothing from them are used.
      183aaaf7
    • GDB Administrator's avatar
      Automatic date update in version.in · e218e274
      GDB Administrator authored
      e218e274
    • Simon Marchi's avatar
      gdb: maybe unpush target from old inferior in inf_child_target::follow_exec · 737358ba
      Simon Marchi authored
      I realized that with "follow-exec-mode == new", the process target
      stayed pushed in the original inferior.  This can cause a small
      incoherence:
      
          $ ./gdb -q -nx --data-directory=data-directory -ex "set follow-exec-mode new" --args execer args-for-execer
          Reading symbols from execer...
          (gdb) r
          Starting program: /home/smarchi/build/binutils-gdb/gdb/execer args-for-execer
          I am execer and my argv[1] is: args-for-execer
          process 3562426 is executing new program: /home/smarchi/build/binutils-gdb/gdb/execee
          [New inferior 2]
          [New process 3562426]
          I am execee and my argv[1] is: arg-for-execee
          [Inferior 2 (process 3562426) exited normally]
          (gdb) info inferiors
            Num  Description       Connection           Executable
            1    <null>            1 (native)           /home/smarchi/build/binutils-gdb/gdb/execer
          * 2    <null>                                 /home/smarchi/build/binutils-gdb/gdb/execee
          (gdb) maintenance print target-stack
          The current target stack is:
            - exec (Local exec file)
            - None (None)
          (gdb) inferior 1
          [Switching to inferior 1 [<null>] (/home/smarchi/build/binutils-gdb/gdb/execer)]
          (gdb) maintenance print target-stack
          The current target stack is:
            - native (Native process)
            - exec (Local exec file)
            - None (None)
      
      On exec, when execution continues into inferior 2, the native target
      isn't unpushed from inferior 1.  When inferior 2's execution finishes
      normally, inf_child_target::mourn_inferior unpushes the native target,
      because the native target has been implicitly opened.
      
      I think that if the native target was implicitly opened, it should be
      unpushed from inferior 1, just like it is unpushed from an inferior
      whose execution terminate.  This patch implements that.
      
      gdb/ChangeLog:
      
      	* inf-child.h (inf_child_target) <follow_exec>: New.
      	* inf-child.c (inf_child_target::follow_exec): New.
      
      Change-Id: I782cc08d73d93a990f4e53611107f68b2cb58af1
      737358ba
    • Simon Marchi's avatar
      gdb: on exec, delegate pushing / unpushing target and adding thread to target_ops::follow_exec · 294c36eb
      Simon Marchi authored
      On "exec", some targets need to unpush themselves from the inferior,
      and do some bookkeeping, like forgetting the data associated to the
      exec'ing inferior.
      
      One such example is the thread-db target.  It does so in
      a special case in thread_db_target::wait, just before returning the
      TARGET_WAITKIND_EXECD event to its caller.
      
      We have another such case in the context of rocm-gdb [1], where the
      "rocm" target is pushed on top of the linux-nat target.  When an exec
      happens, we want to unpush the rocm target from the exec'ing inferior to
      close some file descriptors that refer to the pre-exec address space and
      forget about that inferior.  We then want to push the target on the
      inferior in which execution continues, to open the file descriptors for
      the post-exec address space.
      
      I think that a good way to address this cleanly is to do all this in the
      target_ops::follow_exec implementations.  Make the
      process_stratum_target::follow_exec implementation have the default
      behavior of pushing itself to the new inferior's target stack (if
      execution continues in a new inferior) and add the initial thread.
      
      remote_target::follow_exec is an example of process target that wants to
      do a bit more than the default behavior.  So it calls
      process_stratum_target::follow_exec first and does the extra work
      second.
      
      linux-thread-db (a non-process target) implements follow_exec to do some
      bookeeping (forget about that process' data), before handing down the
      event down to the process target (which hits
      process_stratum_target::follow_exec).
      
      gdb/ChangeLog:
      
      	* target.h (struct target_ops) <follow_exec>: Add ptid_t
      	parameter.
      	(target_follow_exec): Likewise.
      	* target.c (target_follow_exec): Add ptid_t parameter.
      	* infrun.c (follow_exec): Adjust call to target_follow_exec,
      	don't push target nor create thread.
      	* linux-thread-db.c (class thread_db_target) <follow_exec>: New.
      	(thread_db_target::wait): Just return on TARGET_WAITKIND_EXECD.
      	(thread_db_target::follow_exec): New.
      	* remote.c (class remote_target) <follow_exec>: Add ptid_t parameter.
      	(remote_target::follow_exec): Call
      	process_stratum_target::follow_exec.
      	* target-delegates.c: Re-generate.
      
      Change-Id: I3f96d0ba3ea0dde6540b7e1b4d5cdb01635088c8
      294c36eb
    • Simon Marchi's avatar
      gdb: call target_follow_exec when "set follow-exec-mode" is "same" · 2af87c85
      Simon Marchi authored
      target_follow_exec is currently only called in the "follow-exec-mode ==
      new" branch of follow_exec, not the "follow-exec-mode == same" branch.
      I think it would make sense to call it regardless of the mode to let
      targets do some necessary handling.
      
      This is needed in the context of rocm-gdb [1], where a target is pushed
      on top of the linux-nat target.  On exec, it needs to do some
      bookkeeping, close some file descriptors / handles that were related to
      the process pre-exec and open some new ones for the process post-exec.
      
      However, by looking at the only in-tree implementation of
      target_ops::follow_exec, remote_target::follow_exec, I found that it
      would be useful for the extended-remote target too, to align its
      behavior with native debugging (although I think that behavior is not
      very user-friendly, see PR 27745 [2]).
      
      Using two programs, one (let's call it "execer") that execs the other
      (let's call it "execee"), with native:
      
          $ ./gdb -q -nx --data-directory=data-directory ./execer
          Reading symbols from ./execer...
          (gdb) r
          Starting program: /home/simark/build/binutils-gdb/gdb/execer
          I am execer
          process 1495622 is executing new program: /home/simark/build/binutils-gdb/gdb/execee
          I am execee
          [Inferior 1 (process 1495622) exited normally]
          (gdb) r
          Starting program: /home/simark/build/binutils-gdb/gdb/execee
          I am execee
          [Inferior 1 (process 1495626) exited normally]
      
      And now with gdbserver (some irrelevant output lines removed for brevity):
      
          $ ./gdbserver --once --multi :1234
          ...
      
          $ ./gdb -q -nx --data-directory=data-directory ./execer -ex "set remote exec-file /home/simark/build/binutils-gdb/gdb/execer" -ex "tar ext :1234"
          Reading symbols from ./execer...
          Remote debugging using :1234
          (gdb) r
          Starting program: /home/simark/build/binutils-gdb/gdb/execer
          process 1495724 is executing new program: /home/simark/build/binutils-gdb/gdb/execee
          [Inferior 1 (process 1495724) exited normally]
          (gdb) r
          `target:/home/simark/build/binutils-gdb/gdb/execee' has disappeared; keeping its symbols.
          Starting program: target:/home/simark/build/binutils-gdb/gdb/execee
          warning: Build ID mismatch between current exec-file target:/home/simark/build/binutils-gdb/gdb/execee
          and automatically determined exec-file target:/home/simark/build/binutils-gdb/gdb/execer
          exec-file-mismatch handling is currently "ask"
          Reading /home/simark/build/binutils-gdb/gdb/execer from remote target...
          Load new symbol table from "target:/home/simark/build/binutils-gdb/gdb/execer"? (y or n)
      
      When handling the exec, GDB updates the exec-file of the inferior to be
      the execee.  This means that a subsequent "run" will run the execee, not
      the original executable (execer).
      
      remote_target::follow_exec is meant to update the "remote exec-file",
      which is the file on the remote system that will be executed if you
      "run" the inferior, to the execee as well.  However, this is not called
      when follow-exec-mode is same, because target_follow_exec is not called
      in this branch.  As a result, GDB thinks the inferior is executing
      execee but the remote side is really executing execer, hence the
      mismatch message.
      
      By calling target_follow_exec in the "same" branch of the follow_exec
      function, we ensure that everybody agrees, and we get the same behavior
      with the extended-remote target as we get with the native target, the
      execee is executed on the second run:
      
          $ ./gdbserver --once --multi :1234
          ...
      
          $ ./gdb -q -nx --data-directory=data-directory ./execer -ex "set remote exec-file /home/simark/build/binutils-gdb/gdb/execer" -ex "tar ext :1234"
          Reading symbols from ./execer...
          Remote debugging using :1234
          (gdb) r
          Starting program: /home/simark/build/binutils-gdb/gdb/execer
          process 1501445 is executing new program: /home/simark/build/binutils-gdb/gdb/execee
          [Inferior 1 (process 1501445) exited normally]
          (gdb) r
          `target:/home/simark/build/binutils-gdb/gdb/execee' has disappeared; keeping its symbols.
          Starting program: target:/home/simark/build/binutils-gdb/gdb/execee
          [Inferior 1 (process 1501447) exited normally]
          (gdb)
      
      This scenario is tested in gdb.base/foll-exec-mode.exp, and in fact this
      patch fixes the test for me when using
      --target_board=native-extended-gdbserver.
      
      gdb/ChangeLog:
      
      	* infrun.c (follow_exec): Call target_follow_fork when
      	follow-exec-mode is same.
      	* target.h (target_follow_fork): Improve doc.
      
      [1] https://github.com/ROCm-Developer-Tools/ROCgdb
      [2] https://sourceware.org/bugzilla/show_bug.cgi?id=27745
      
      Change-Id: I4ee84a875e39bf3f8eaf3e6789a4bfe23a2a430e
      2af87c85
    • Andrew Burgess's avatar
      gdb/testsuite: fix dates in last 3 ChangeLog entries · bab9eb49
      Andrew Burgess authored
      Incorrect dates in last 3 ChangeLog entries for gdb/testsuite/ChangeLog.
      bab9eb49
    • Andrew Burgess's avatar
      gdb/testsuite: resolve remaining duplicate tests in gdb.guile/ · 4a0a0bd2
      Andrew Burgess authored
      The remaining duplicates are resolved by adding a with_test_prefix and
      reindenting a proc.  I also added a couple of additional test names to
      some of the tests.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.guile/scm-pretty-print.exp (run_lang_tests): Give some tests
      	unique names, also wrap proc body in with_test_prefix.
      4a0a0bd2
    • Andrew Burgess's avatar
      gdb/testsuite: resolve duplicate test names in gdb.guile/*.exp · 62f2f198
      Andrew Burgess authored
      This commit resolves almost all of the remaining duplicate test names
      in gdb.guile/*.exp.  This is done by either:
      
       - Making use of with_test_prefix,
       - Giving tests a unique name,
       - Extending the existing name to make it unique,
       - Not printing PASS lines for simple setup commands (e.g. loading
         support modules, or adjusting GDB internal settings not relating to
         guile).
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.guile/scm-frame-args.exp: Add with_test_prefix to resolve
      	duplicate test names.
      	* gdb.guile/scm-parameter.exp: Provide test names to avoid
      	duplicate names based on the command being run.
      	* gdb.guile/scm-symbol.exp: Extend test name to make it unique.
      	* gdb.guile/scm-type.exp (restart_gdb): Don't print PASS line when
      	loading a support module.
      	(test_equality): Update test name to match the actual test, making
      	the name unique in the process.
      	* gdb.guile/scm-value.exp (test_value_in_inferior): Add test names
      	to resolve duplicate tests.
      	(test_inferior_function_call): Likewise.
      	(test_subscript_regression): Likewise.
      62f2f198
    • Andrew Burgess's avatar
      gdb/testsuite: remove some duplicate test names from guile tests · 5c6f801d
      Andrew Burgess authored
      The guile support library has some "tests" that are actually being
      used to setup GDB ready for the real guile tests, e.g. we load some
      support modules, and define some helper functions.
      
      As this setup is done every time we call gdb_guile_runto_main, which
      could be called multiple times in a single test script, this can lead
      to duplicate PASS lines.
      
      As this setup is all pretty basic, and isn't the actual focus of the
      real tests, then in this commit I pass an empty test name through to
      the gdb_test_no_output calls, the result of this is that the PASS
      lines are no longer printed.  This removes some duplicate tests from
      the gdb.guile/*.exp set of tests.
      
      gdb/testsuite/ChangeLog:
      
      	* lib/guile.exp (gdb_scm_load_file): Use empty test name to
      	silence PASS lines.
      	(gdb_install_guile_module): Likewise.
      5c6f801d
  3. May 13, 2021
    • Simon Marchi's avatar
      gdb: remove cmd_list_element::pre_show_hook · 0b2256f7
      Simon Marchi authored
      This is unused, remove it.
      
      gdb/ChangeLog:
      
      	* cli/cli-decode.h (struct cmd_list_element) <pre_show_hook>:
      	Remove.
      	* cli/cli-setshow.c (do_show_command): Adjust.
      
      Change-Id: Ib9cd79d842550392b062309e1e5c079ad5d7571a
      0b2256f7
    • Nick Clifton's avatar
      revert previous delta · 0522d016
      Nick Clifton authored
      0522d016
    • Nick Clifton's avatar
      Fix an infinite loop in the DWARF decoder when parsing a corrupt string table. · c4375dd7
      Nick Clifton authored
      	PR 27861
      	* dwarf.c (display_debug_str_offsets): Warn if the length field is
      	larger than the amount of data remaining in the section.
      c4375dd7
    • Alan Modra's avatar
      PR27861, Infinite loop in dwarf.c:7507-7526 · b96a1bcb
      Alan Modra authored
      	PR 27861
      	* dwarf.c (display_debug_str_offsets): Sanity check dwarf5
      	header length.
      b96a1bcb
    • Alan Modra's avatar
      PR27860, Segmentation fault on readelf -w · d21f875d
      Alan Modra authored
      Well it didn't take long for the SAFE_BYTE_GET assert to trigger.
      
      	PR 27860
      	* dwarf.c (display_debug_frames): Sanity check cie_off before
      	attempting to read cie.
      d21f875d
    • Luis Machado's avatar
      [AArch64] Fix off-by-one when calculating tag granules. · 0746f49b
      Luis Machado authored
      When we want to fetch tags from a memory range, the last address in that
      range is not included.
      
      There is a off-by-one error in aarch64_mte_get_tag_granules, which this
      patch fixes.
      
      gdb/ChangeLog:
      
      2021-05-13  Luis Machado  <luis.machado@linaro.org>
      
      	* arch/aarch64-mte-linux.c (aarch64_mte_get_tag_granules): Don't
      	include the last address in the range.
      0746f49b
    • Nelson Chu's avatar
      RISC-V: Record implicit subsets in a table, to avoid repeated codes. · 7671eff8
      Nelson Chu authored
      Add a new table, riscv_implicit_subsets, to record all implicit information.
      So that we add all implicit subsets according to the table, to avoid too
      many repeated codes in the riscv_parse_add_implicit_subsets.  Besides, the
      check_func is used to check whether we should add this implicit subset.
      For example, check_implicit_for_i checks the version of i, and we only add
      zicsr and zifencei implicitly only when the version less than 2.1.
      
      bfd/
          * elfxx-riscv.c (check_implicit_always): The check_func, always add
          the implicit subset without checking.
          (check_implicit_for_i): The check_func for i, only add zicsr and
          zifencei when the version of i less than 2.1.
          (struct riscv_implicit_subset): Record the subsets and their
          corresponding implicit subsets.
          (riscv_implicit_subsets): Table records all implicit informations.
          (riscv_parse_add_implicit_subsets): Updated and add implicit subsets
          according to riscv_implicit_subsets.  Remove the redundant codes.
      7671eff8
    • Fangrui Song's avatar
      ld: Add -Bno-symbolic · cf893b0e
      Fangrui Song authored
      	PR 27834
      	* ldlex.h (enum option_values): Add OPTION_NO_SYMBOLIC.
      	* lexsup.c (ld_options): Add -Bno-symbolic.
      	(parse_args): Handle -Bno-symbolic.
      	* ld.texi: Document -Bno-symbolic.
      	* NEWS: Mention -Bno-symbolic.
      	* testsuite/ld-elf/shared.exp: Add a test.
      cf893b0e
    • Alan Modra's avatar
      PR27858, global-buffer-overflow · 4863cddb
      Alan Modra authored
      	PR 27858
      	* elf32-sh.c (sh_elf_info_to_howto): Correct check for last valid
      	reloc howto.
      4863cddb
    • GDB Administrator's avatar
      Automatic date update in version.in · 3e5fac07
      GDB Administrator authored
      3e5fac07
    • Simon Marchi's avatar
      gdb: make gdbpy_parse_command_name return a unique_xmalloc_ptr · 4b8cb9dd
      Simon Marchi authored
      This avoids some manual memory management.
      
      cmdpy_init correctly transfers ownership of the name to the
      cmd_list_element, as it sets the name_allocated flag.  However,
      cmdpy_init (and add_setshow_generic) doesn't, it looks like the name is
      just leaked.  This is a bit tricky, because it actually creates two
      commands (one set and one show), it would take a bit of refactoring of
      the command code to give each their own allocated copy.  For now, just
      keep doing what the current code does but in a more explicit fashion,
      with an explicit release.
      
      gdb/ChangeLog:
      
      	* python/python-internal.h (gdbpy_parse_command_name): Return
      	gdb::unique_xmalloc_ptr.
      	* python/py-cmd.c (gdbpy_parse_command_name): Likewise.
      	(cmdpy_init): Adjust.
      	* python/py-param.c (parmpy_init): Adjust.
      	(add_setshow_generic): Take gdb::unique_xmalloc_ptr, release it
      	when done.
      
      Change-Id: Iae5bc21fe2b22f12d5f954057b0aca7ca4cd3f0d
      4b8cb9dd
  4. May 12, 2021
    • Tom de Vries's avatar
      Revert "[gdb/symtab] Fix infinite recursion in dwarf2_cu::get_builder()" · 3db19b2d
      Tom de Vries authored
      This reverts commit 4cf88725.
      
      It causes the following regression:
      ...
      $ cat shadow.cc
      namespace A {}
      
      int
      main()
      {
        using namespace A;
        return 0;
      }
      $ g++-10 -g shadow.cc -flto -o shadow
      $ ./gdb -q -batch ./shadow  -ex "b main"
      Aborted (core dumped)
      ...
      3db19b2d
    • Alan Modra's avatar
      Ensure data pointer kept within bounds · a7077ce7
      Alan Modra authored
      	* dwarf.c (process_extended_line_op): Don't bump data pointer past
      	end when strnlen doesn't find string terminator.
      	(decode_location_expression): Remove dead code.
      	(skip_attr_bytes): Remove const from end param.  Ensure data
      	pointer doesn't pass end.
      	(get_type_signedness): Remove const from end param.
      	(read_and_display_attr_value): Ensure data pointer doesn't pass end.
      	(display_debug_lines_raw, display_debug_lines_decoded): Likewise.
      	(display_debug_pubnames_worker): Likewise.
      	(display_debug_pubnames_worker): Use SAFE_BYTE_GET_AND INC rather
      	than blindly incrementing data pointer.
      	(display_debug_addr, display_debug_str_offsets): Likewise.  Don't
      	compare pointers, compare lengths.
      a7077ce7
    • Alan Modra's avatar
      SAFE_BYTE_GET · 6d1ad6f7
      Alan Modra authored
      This rearranges SAFE_BYTE_GET* macros, eliminating some duplication,
      and making sure that the _INC variants never increment their PTR arg
      past END.  I've added an assertion that should show us places where we
      use them improperly with user derived PTR args, which I'm sure the
      fuzzers will find for us.
      
      	* dwarf.c (SAFE_BYTE_GET_INTERNAL): Define.
      	(SAFE_BYTE_GET, SAFE_BYTE_GET_AND_INC): Define using the above.
      	(SAFE_SIGNED_BYTE_GET, SAFE_SIGNED_BYTE_GET_AND_INC): Likewise.
      	(display_discr_list): Use SAFE_BYTE_GET_AND_INC rather than
      	SAFE_BYTE_GET followed by increment.
      	(process_debug_info): Likewise, and test bytes remaining before
      	incrementing section_begin rather than using pointer comparison.
      	(display_debug_names): Pass lvalue as SAFE_BYTE_GET PTR.
      	(process_cu_tu_index): Likewise for SAFE_BYTE_GET_AND_INC.
      6d1ad6f7
    • Alan Modra's avatar
      SAFE_BYTE_GET64 · af2ddf69
      Alan Modra authored
      Functions dealing with lack of a 64-bit integer type can disappear now
      that we require C99.  Printing using dwarf_vmatoa is better too.
      
      binutils/
      	* dwarf.c (dwarf_vmatoa64, SAFE_BYTE_GET64, add64): Delete.
      	(skip_attr_bytes): Replace use of SAFE_BYTE_GET64 with
      	SAFE_BYTE_GET_AND_INC.
      	(read_and_display_attr_value): Likewise.  Print using dwarf_vmatoa.
      	(process_debug_info, process_cu_tu_index): Likewise.
      	* elfcomm.c (byte_put, byte_put_little_endian, byte_put_big_endian),
      	(byte_get, byte_get_little_endian, byte_get_big_endian),
      	(byte_get_signed): Make size param unsigned.  Remove code dealing
      	with 4-byte elf_vma.
      	(byte_get_64): Delete.
      	* elfcomm.h  (byte_put, byte_put_little_endian, byte_put_big_endian),
      	(byte_get, byte_get_little_endian, byte_get_big_endian),
      	(byte_get_signed): Update prototypes.
      	(byte_get_64): Delete.
      gas/
      	* testsuite/gas/elf/dwarf-5-file0.d: Update.
      	* testsuite/gas/i386/dwarf5-line-1.d: Update.
      af2ddf69
    • Alan Modra's avatar
      PR27836, readelf -w pointer comparison UB · 0d872fca
      Alan Modra authored
      	PR 27836
      	* dwarf.c (display_debug_frames): Don't compare pointers derived
      	from user input.  Test offset against bounds instead.
      0d872fca
    • George Barrett's avatar
      Guile: add value-const-value · ee35ce82
      George Barrett authored
      The Guile API doesn't currently have an equivalent to the Python API's
      gdb.Value.const_value(). This commit adds a procedure with equivalent
      semantics to the Guile API.
      
      gdb/ChangeLog:
      
      	* NEWS (Guile API): Note the addition of the new procedure.
      	* guile/scm-value.c (gdbscm_value_const_value): Add
      	implementation of value-const-value procedure.
      	(value_functions): Add value-const-value procedure.
      
      gdb/doc/ChangeLog:
      
      	* guile.texi (Values From Inferior In Guile): Add documentation
      	for value-const-value.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.guile/scm-value.exp (test_value_in_inferior): Add test for
      	value-const-value.
      ee35ce82
    • George Barrett's avatar
      Guile: add value-{rvalue-,}reference-value · 9d4fc61d
      George Barrett authored
      The Guile API doesn't currently have an equivalent to the Python API's
      Value.reference_value() or Value.rvalue_reference_value(). This commit
      adds a procedure with equivalent semantics to the Guile API.
      
      gdb/ChangeLog:
      
      	* NEWS (Guile API): Note the addition of new procedures.
      	* guile/scm-value.c (gdbscm_reference_value): Add helper function
      	for reference value creation.
      	(gdbscm_value_reference_value): Add implementation of
      	value-reference-value procedure.
      	(gdbscm_value_rvalue_reference_value): Add implementation of
      	value-rvalue-reference-value procedure.
      	(value_functions): Add value-reference-value procedure.  Add
      	value-rvalue-reference-value procedure.
      
      gdb/doc/ChangeLog:
      
      	* guile.texi (Values From Inferior In Guile): Add documentation
      	for value-reference-value.  Add documentation for
      	value-rvalue-reference-value.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.guile/scm-value.exp (test_value_in_inferior): Add test for
      	value-reference-value.  Add test for value-rvalue-reference-value.
      9d4fc61d
    • George Barrett's avatar
      Guile: improved rvalue reference support · 97cef6b7
      George Barrett authored
      Adds a couple of missing bits to the Guile API to make C++11 rvalue
      reference values and types usable from Guile scripts.
      
      gdb/ChangeLog:
      
      	* guile/scm-type.c (type_integer_constants): Add binding for
      	TYPE_CODE_RVALUE_REF.
      	* guile/scm-value.c (gdbscm_value_referenced_value): Handle
      	dereferencing of rvalue references.
      	* NEWS (Guile API): Note improvements in rvalue reference support.
      
      gdb/doc/ChangeLog:
      
      	* guile.texi (Types In Guile): Add documentation for
      	TYPE_CODE_RVALUE_REF.
      97cef6b7
    • Richard Earnshaw's avatar
      arm: fix fallout from recent thumb2 detection patch · 84139c58
      Richard Earnshaw authored
      The recent change to correct the detection of thumb2 object files
      resulted in a ld test for veneering starting to fail.  The problem was
      the test itself, which was incorrectly expecting thumb1 type far-call
      veneers instead of the thumb2 flavour.  We already have a dump file of
      the expected form, so the fix is to change the expected output
      accordingly.
      
      ld/
      
      	* testsuite/ld-arm/arm-elf.exp (farcall test for v8-m.mainline):
      	Correct expected output.
      84139c58