[PATCH] libstdc++: Improve ostream output for std::stacktrace
Jonathan Wakely
jwakely@redhat.com
Wed Oct 15 21:09:20 GMT 2025
On Wed, 15 Oct 2025 at 22:04, Jonathan Wakely <jwakely@redhat.com> wrote:
>
> Instead of printing "<unknown>" in the ostream output, we could set that
> string in the stacktrace_entry::_Info object, so that description()
> returns that. Returning an empty string from that function seems simpler
> for users to handle and decide on their own behaviour, rather than
> having to parse "<unknown>".
>
> With this change locations that don't have a source file look like this:
>
> 18# __libc_start_call_main at [0x7fd6568f6574]
> 19# __libc_start_main@GLIBC_2.2.5 at [0x7fd6568f6627]
> 20# _start at [0x4006a4]
>
> Instead of:
>
> 18# __libc_start_call_main at :0
> 19# __libc_start_main@GLIBC_2.2.5 at :0
> 20# _start at :0
>
> The string representation of a default constructed stacktrace_entry is
> now "<unknown>" instead of an empty string.
We could also choose a different string for the default-constructed
stacktrace_entry, maybe "<none>" or "<invalid>".
That would distinguish a completely empty stacktrace_entry from a
non-empty one with an unknown function name.
More information about the Libstdc++
mailing list