Addressing the first point: what Valgrind's tracer does better than others is fetching more source code information and semantics. This can shown immediately with the following example:
``` #include <assert.h> #include <stdlib.h> inline void bar() { abort(); } template<typename T> inline void foo(T) { bar(); } int main() { foo(5); return 0; } ``` If compiled with -g, the debug output will display (1) C/C++ names down into the standard library (2) source code names and signatures (3) including template instantiations (4) file names (5) line numbers, among other things. I would be great to have a stack tracer like that. The prettiest alternatives without Valgrind go along the lines of https://eli.thegreenplace.net/2015/programmatic-access-to-the-call-stack-in-c/ using libunwind and cxxabi. This still is not as close to the source as Valgrind's output. Best, Martin On Mon, May 24, 2021 at 3:09 PM John Reiser <jrei...@bitwagon.com> wrote: > On 5/24/21, Martin Licht via Valgrind-users wrote: > > > I think the Valgrind stack tracer is pretty great and I would like to > use it as a substitute for `backtrace` in my C++ debug builds. > > It would help to give an explicit list of why valgrind's backtrace() is > "pretty great" > in contrast to GNU's. The comment > > https://urldefense.com/v3/__https://blog.mozilla.org/nnethercote/2011/01/11/using-valgrind-to-get-stack-traces/*comment-438__;Iw!!Mih3wA!UfTEqXmRbG-pQAMC4pm54vloAenaAZoBw-abVILaGfvzVPS2T4cKVx6_eFTqAPk$ > identifies one item: GNU backtrace() shows only global (non-static) > symbols. > What else? > > Also, a detailed list would make a good request for enhancement > at > https://urldefense.com/v3/__https://www.gnu.org/software/libc/bugs.html__;!!Mih3wA!UfTEqXmRbG-pQAMC4pm54vloAenaAZoBw-abVILaGfvzVPS2T4cKVx6_Yz5dunc$ > , > especially if accompanied by an actual test case > that shows how much better valgrind backtrace() is currently. > > -- > > > > _______________________________________________ > Valgrind-users mailing list > Valgrind-users@lists.sourceforge.net > > https://urldefense.com/v3/__https://lists.sourceforge.net/lists/listinfo/valgrind-users__;!!Mih3wA!UfTEqXmRbG-pQAMC4pm54vloAenaAZoBw-abVILaGfvzVPS2T4cKVx6_dyjVF6g$ >
_______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users