buildroot/toolchain
Thomas De Schampheleire 5ac8c84693 toolchain/helpers.mk: gdbinit: set auto-load-safe-path before sysroot
The gdbinit supplied by Buildroot does two things:
A. specify the sysroot where gdb can find shared libraries
B. mark the sysroot as a 'safe path' for its auto-load feature, to make sure
  that pretty printers for libstdc++.so are added automatically (see commit
  6fb3216a80)

When debugging a core file, and the gdbinit file is specified via '-x'
rather than '-ix', then the order of these settings matters: If you first
set the sysroot, then gdb will immediately start finding the shared
libraries it needs for the core file, detect libstdc++ and its associated
libstdc++-gdb.py file, then give a big warning about safe paths:

  warning: File ".../i686-buildroot-linux-gnu/sysroot/lib/libstdc++.so.6.0.24-gdb.py"
          auto-loading has been declined by your `auto-load safe-path' set
          to "$debugdir:$datadir/auto-load".
  To enable execution of this file add
          add-auto-load-safe-path .../i686-buildroot-linux-gnu/sysroot/lib/libstdc++.so.6.0.24-gdb.py
  line to your configuration file "/home/me/.gdbinit".
  To completely disable this security protection add
          set auto-load safe-path /
  line to your configuration file "/home/me/.gdbinit".
  For more information about this security protection see the
  "Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
          info "(gdb)Auto-loading safe path"

and the pretty printing code is not loaded. This is because the second
line from the gdbinit file was not yet parsed at this point.

By changing the order (first configuring the safe path, then setting the
sysroot), this issue does not appear and everything is as expected.

Note that when '-ix' were used instead of '-x' to pass the gdbinit file to
gdb, then the order would not matter, because the entire gdbinit file would
be parsed before considering the core file.
However, even though the Buildroot manual now suggests '-ix', users may not
have noticed this change and continue to use '-x'.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
(cherry picked from commit f0e204d99b)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2021-10-04 22:24:07 +02:00
..
toolchain toolchain/toolchain: set TOOLCHAIN_INSTALL_STAGING only once 2019-10-27 14:56:52 +01:00
toolchain-buildroot package/glibc, toolchain/toolchain-buildroot: disable native RPC in glibc toolchains 2020-12-29 23:28:57 +01:00
toolchain-external toolchain/toolchain-external: fixup gdb pretty-printer loader for libstdcxx 2021-07-25 23:12:29 +02:00
Config.in toolchain: introduce BR2_TOOLCHAIN_HAS_GCC_BUG_83143 2021-09-13 19:25:03 +02:00
helpers.mk toolchain/helpers.mk: gdbinit: set auto-load-safe-path before sysroot 2021-10-04 22:24:07 +02:00
toolchain-wrapper.c toolchain/toolchain-wrapper: let recent GCC handle SOURCE_DATE_EPOCH 2020-06-27 17:19:53 +02:00
toolchain-wrapper.mk toolchain/toolchain-wrapper: disable -ftree-loop-distribute-patterns when building for microblaze with gcc >= 10 2020-10-25 10:48:58 +01:00
toolchain.mk toolchain: move glibc nsswitch.conf handling to a post-target hook 2018-10-21 01:50:35 +02:00