-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FR]: std::stacktrace support #4336
Comments
I am willing to implement this feature myself. I prefer approach B. As an alternative, we could make |
I implemented approach B in #4337. |
If I recall correctly there are two uses of stack tracing in GoogleTest. One of them is to print a stack trace when an expectation fails. The other is to print a stack trace when your test crashes (via the environment variable
We have an async signal safe implementation of stack tracing that also has line numbers, but we haven't open sourced it yet. I should also note that the async signal safe implementations are quite slow compared to alternatives, but that is the price we pay. I'm sure it is possible to use an implementation based on All this is to say I'm sorry because big changes are quite difficult to make for an outsider since Google-internal systems need to be prioritized. |
I did not know about the However, I don't think that feature is relevant to this issue. The current If |
Ah, I am misremembering a bit here. |
Does the feature exist in the most recent commit?
no
Why do we need this feature?
I want to get pretty stack traces in my tests without depending on Abseil.
In addition, Microsoft STL's implementation of std::stacktrace provides more information than Abseil, such as file and line numbers.
I think this feature would be generally useful, thus I think this feature should be built into googletest instead of users leveraging the (currently broken #1020)
OsStackTraceGetterInterface
extension point.Describe the proposal.
Approach A:
Change the existing
OsStackTraceGetter
class to use std::stacktrace if available, falling back to Absel or a no-op implementation if std::stacktrace unavailable.Problem with approach A:
This would involve adding
#if
s in header files which might lead to ODR problems.Approach B:
OsStackTraceGetter
into two classes:AbslStackTraceGetter
(which uses Abseil; conditionally defined) andNoopStackTraceGetter
(always defined).StdStackTraceGetter
(which uses std::stacktrace; conditionally defined).UnitTestImpl::os_stack_trace_getter
choosStdStackTraceGetter
if available, falling back toAbslStackTraceGetter
orNoopStackTraceGetter
if std::stacktrace is unavailable.(This seems to be how
OsStackTraceGetterInterface
was meant to be used.)Is the feature specific to an operating system, compiler, or build system version?
Currently, std::stacktrace is available on recent MSVC versions for Windows. It might be available with effort on GCC/libstdc++. libc++ does not have an implementation.
Boost has a somewhat-portable implementation which looks similar to std::stacktrace. I don't propose using Boost's version.
The text was updated successfully, but these errors were encountered: