From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: "François Dumont" <frs.dumont@gmail.com>
Cc: "libstdc++" <libstdc++@gcc.gnu.org>
Subject: Re: WIP _GLIBCXX_DEBUG backtrace
Date: Mon, 4 Jul 2022 20:52:05 +0100 [thread overview]
Message-ID: <CAH6eHdTLbqY0S-zAoqXTH_Q9bUaOCR+x9_+AreHTfDyuGdT9KQ@mail.gmail.com> (raw)
In-Reply-To: <c4b13ad8-e5d7-0a5a-8b4a-f481c2c498b7@gmail.com>
On Mon, 4 Jul 2022, 18:21 François Dumont via Libstdc++, <
libstdc++@gcc.gnu.org> wrote:
> Hi
>
> Here is the patch to add backtrace to _GLIBCXX_DEBUG mode. It is using
> the recently introduced _GLIBCXX_HAS_STACKTRACE.
>
> It is only WIP because for the moment I had to add:
>
> // { dg-options "-lstdc++_libbacktrace" }
>
> to avoid unresolved symbols.
>
> How should I handle this ?
>
> 1. Ask the user to define _GLIBCXX_DEBUG_STACKTRACE to get the backtrace
> and so also require to add this linker option.
>
For now, I think this is the best option. Even when the symbols are in the
library I think the backtraces should be optional. Controlled by a
compile-time macro and/or an environment variable.
> 2. Is it possible to add something in formatter.h to automagically link
> libstdc++_libbacktrace ?
>
Not possible, GCC and Unix linkers don't support doing that.
> 3. Add symbols to libstdc++.so ?
>
The symbols from libstdc++_libbacktrace.a will move to the .so at some
point, once the C++23 std::stacktrace implementation is stable. I don't
know if that will happen for GCC 13 though, it might be GCC 14.
> Output sample:
>
>
> /home/fdt/dev/gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/include/debug/vector:264:
> In function:
> void std::debug::vector<_Tp, _Allocator>::assign(_InputIterator,
> _InputIterator) [with _InputIterator = const int*;
> <template-parameter-2-2> = void; _Tp = int; _Allocator =
> std::allocator<int>]
>
> Backtrace:
> 0x40284a void std::debug::vector<int, std::allocator<int>
> >::assign<int const*, void>(int const*, int const*)
>
> /home/fdt/dev/gcc/build/x86_64-pc-linux-gnu/libstdc++-v3/include/debug/vector:264
> 0x402bed void gnu_test::check_assign1<std::debug::vector<int,
> std::allocator<int> > >()
> /home/fdt/dev/gcc/git/libstdc++-v3/testsuite/util/debug/checks.h:111
> 0x40246c test01()
>
> /home/fdt/dev/gcc/git/libstdc++-v3/testsuite/23_containers/vector/debug/assign4_neg.cc:26
> 0x40246c main
>
> /home/fdt/dev/gcc/git/libstdc++-v3/testsuite/23_containers/vector/debug/assign4_neg.cc:31
>
> Error: function requires a valid iterator range [first, last).
>
> Objects involved in the operation:
> iterator "first" @ 0x7ffe09e62fd8 {
> type = int const* (constant iterator);
> }
> iterator "last" @ 0x7ffe09e62fd0 {
> type = int const* (constant iterator);
> }
> XFAIL: 23_containers/vector/debug/assign4_neg.cc execution test
>
> François
>
>
prev parent reply other threads:[~2022-07-04 19:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-04 17:20 François Dumont
2022-07-04 19:52 ` Jonathan Wakely [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAH6eHdTLbqY0S-zAoqXTH_Q9bUaOCR+x9_+AreHTfDyuGdT9KQ@mail.gmail.com \
--to=jwakely.gcc@gmail.com \
--cc=frs.dumont@gmail.com \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).