如何告诉 valgrind 在堆栈帧前面加上二进制名称(可执行文件、共享库)?

How to tell valgrind to prepend the stack frames with the binary names (executable, shared lib)?

我得到:

==830==    at 0x4CD40DC: DebugSyslogHandlerFunc(DebugContext const&) (DebugSyslogHandler.cpp:202)
==830==    by 0x6A2F3: AssertHandler::~AssertHandler() (Debug.hpp:1219)
==830==    by 0x77F03: CircularQueue::capoffData(int) (CircularQueue.hpp:1216)

我要:

==830==    at 0x4CD40DC: /usr/local/lib/shared_lib1.so.0: DebugSyslogHandlerFunc(DebugContext const&) (DebugSyslogHandler.cpp:202)
==830==    by 0x6A2F3: /usr/local/lib/shared_lib2.so.0: AssertHandler::~AssertHandler() (Debug.hpp:1219)
==830==    by 0x77F03: /usr/local/bin/my_exe: CircularQueue::capoffData(int) (CircularQueue.hpp:1216)

(每个地址后都有二进制路径和名称)。
我找不到类似的东西。

如何告诉 valgrind 在堆栈帧前面加上二进制名称(可执行文件、共享库)?

无法指示valgrind 始终输出对象名称。 如果 valgrind 找到源位置,则它不会输出对象名称。

然而,始终输出对象名称的更改是微不足道的:

在 debuginfo.c 中添加以下标记的行(未经测试)应该可以工作

  if (know_srcloc) {
     if (know_objname) {   // Add from here
       APPEND(" (in ");    //
       APPEND(buf_obj);    //
       APPEND(")");        //
     }                     // Till here
     APPEND(" (");