zoukankan      html  css  js  c++  java
  • 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:两年前遇到过同样的问题,今天有遇到就忘了当时是怎么解决的。还是记录一下吧。

  • 相关阅读:
    游戏类型
    cocos2d-x lua 一些语法
    lua中ipairs和pairs
    lua的一些语法
    误删jre怎么办
    右键android工程的包名选择Build Path后怎么还原
    播放Armature动画
    接入第三方sdk出现了一些问题总结
    gettimeofday() 获取系统时间,精确到微秒 这个似乎只能在linux 下用,不能在windows 下用
    windows timeGetTime() 函数 获取系统从开机到现在的毫秒时间值
  • 原文地址:https://www.cnblogs.com/htlee/p/6395179.html
Copyright © 2011-2022 走看看