Re: How to include the Valgrind stack traces in a stand-alone debug version?

Martin Licht via Valgrind-users <[email protected]>
Newsgroups gmane.comp.debugging.valgrind
Message-ID <CAJyWRm93XpkHHTcsmz=vjAbrSbDXobUs2cWo893gs6QaVKzd_Q@mail.gmail.com>
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 <[email protected]> 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
> [email protected]
>
> https://urldefense.com/v3/__https://lists.sourceforge.net/lists/listinfo/valgrind-users__;!!Mih3wA!UfTEqXmRbG-pQAMC4pm54vloAenaAZoBw-abVILaGfvzVPS2T4cKVx6_dyjVF6g$
>

_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.