This is an archive of the discontinued LLVM Phabricator instance.

[Support][WIP] Add unit test for symbolized stack traces
Needs ReviewPublic

Authored by luismarques on Feb 8 2023, 2:23 PM.

Details

Reviewers
dblaikie
Summary

Stack trace symbolization is missing unit tests. This patch adds such a test.

The preprocessor condition gating the new test is the same as in LLVM's Signal.inc implementation. Some of the platforms that match that condition actually have broken stack traces and/or broken symbolization. The WIP is to investigate on what platforms symbolized traces actually work and to update the gating condition.

Diff Detail

Event Timeline

luismarques created this revision.Feb 8 2023, 2:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 8 2023, 2:24 PM
Herald added a subscriber: krytarowski. · View Herald Transcript
luismarques requested review of this revision.Feb 8 2023, 2:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 8 2023, 2:24 PM
dblaikie added inline comments.Feb 10 2023, 2:30 PM
llvm/unittests/Support/CrashRecoveryTest.cpp
118–120

Presumably the condition is more than the "can we do backtraces" condition - but can we do /symbolized/ backtraces, which means testing for whether this is built with debug info, but I'm not sure if we have a preprocessor define for that/way to detect that?

luismarques added inline comments.Feb 10 2023, 3:15 PM
llvm/unittests/Support/CrashRecoveryTest.cpp
118–120

You're right. I'm not aware of any standard preprocessor macro to detect exactly that condition, though maybe NDEBUG correlates with it well enough. I suppose we could define our own in LLVM's CMake files, based on the build options. Alternatively, we could make this translation unit always be built with debug info. Yet another option might be to do some kind of runtime inspection to detect debug info and skip the unit test if it's missing.

You're right. I'm not aware of any standard preprocessor macro to detect exactly that condition, though maybe NDEBUG correlates with it well enough.

I'd guess probably not - people enable assertions pretty regularly in LLVM, probably quite independently of debug info. But I might be wrong.

I suppose we could define our own in LLVM's CMake files, based on the build options. Alternatively, we could make this translation unit always be built with debug info.

Not sure if there's a tidy way to do that (always with debug info) - flags will vary by compiler/platform, and cmake abstracts that at the high level, not sure if it can be done at a lower/per-file level too.

Yet another option might be to do some kind of runtime inspection to detect debug info and skip the unit test if it's missing.

Yeah, though then the inspection probably has the same problems/complexities as the thing it's testing...