A few misc comments:
In general, +1.
It might be nice to move the stack trace code into a separate function (not static to elog.c) - I have often found it useful to attach backtraces to objects so I can debug complex allocation/deallocation problems.
The major expense in capturing a stack trace is in the symbolization of the stack addresses, not the stack walk itself. You typically want to symbolize the addresses at the time you generate the trace, but that's not always the case. For example, if you want to record the stack trace of every call to AllocSetAlloc() (and attach the trace to the AllocChunk) performance gets unbearable if you symbolize every trace. So a flag that specifies whether to symbolize would be nice too.
If you don't symbolize, you need a way to capture the address range of each dynamically loaded shared object (so that you can later symbolize using something like addr2line).
(The above suggestions relate to server debugging, not application debugging).
End of wish list...
-- Korry