• valgrind跟踪调试动态库*.so


    遇到问题:

    在使用valgrind跟踪调试动态库时,遇到如下问题,不知道问题发生在代码哪里:

    ==11728== 1 errors in context 5 of 31:

    ==11728== Source and destination overlap in memcpy(0x4f35880, 0x4f35880, 163840)
    ==11728== at 0x4A08A9E: memcpy (mc_replace_strmem.c:878)
    ==11728== by 0x5885956: ???
    ==11728== by 0x5887CDC: ???
    ==11728== by 0x588DBEE: ???
    ==11728== by 0x5249391: ???
    ==11728== by 0x503E2D2: ???
    ==11728== by 0x405F5B: main (main.c:168)

    一、在官方帮助中有:

    If they're not long enough, use --num-callers to make them longer.

    If they're not detailed enough, make sure you are compiling with -g to add debug information. And don't strip symbol tables (programs should be unstripped unless you run 'strip' on them; some libraries ship stripped).

    Also, for leak reports involving shared objects, if the shared object is unloaded before the program terminates, Valgrind will discard the debug information and the error message will be full of ??? entries. The workaround here is to avoid calling dlclose on these shared objects.

    从字面上看,主程序不要关闭(或卸载)动态库,但怎么才算不不关闭动态库呢?

    看了半个下午,才搞懂这个是什么意思:

    正常情况下,我们在程序中打开动态库后,在程序结束后,都要关闭动态库。这样的话,就无法找到符号表。

    二、解决方案:

    把关闭动态库的代码注释掉即可。

    例如在glib中:

    //g_module_close(mode_dispatch);

    ps:两年前遇到过同样的问题,今天有遇到就忘了当时是怎么解决的。还是记录一下吧。

  • 相关阅读:
    Vue 路由的编程式导航与history模式
    Vue 路由配置、动态路由
    Vue 组件传值
    Vue 组件以及生命周期函数
    Vue 封装js
    记一次proc_open没有开启心得感悟
    面向内容的标记语言--markdonw
    浅谈索引
    mysql主从配置
    centos7下操作防火墙
  • 原文地址:https://www.cnblogs.com/htlee/p/6395179.html
Copyright © 2020-2023  润新知