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

2021-05-26 Thread Martin Licht via Valgrind-users
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 
#include 

inline void bar()
{
abort();
}

template
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  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


[Valgrind-users] How to include the Valgrind stack traces in a stand-alone debug version?

2021-05-24 Thread Martin Licht via Valgrind-users
Hello,

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.

A blog post by Nicholas Nethercote (Using Valgrind to get stack traces)
describes a similar idea:
https://blog.mozilla.org/nnethercote/2011/01/11/using-valgrind-to-get-stack-traces/

However, while this is already fairly elegant, I am wondering whether this
can be done without invoking the program under valgrind.

If the Valgrind stack tracer were a simple #include that would be best.
Alternatively, a means of including any necessary valgrind framework into
the debug build would be helpful. I appreciate your feedback.

Regards,
Martin
___
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users