If you don't care about exotica like async or signal safety, and just need to see the callstack from arbitray points, this can do the job without C++23:
Ime the execinfo.h backtraces are unfortunately not that useful in practice, due to being unable to resolve symbol names of static functions. But FWIW, you can use it for async signals with the _fd variant.