dmalloc日志未格式化堆栈地址

时间:2015-12-23 10:06:01

标签: c dmalloc

使用conf.h文件中的以下设置构建dmalloc lib

#define HAVE_VPRINTF 0
#define HAVE_SNPRINTF 0
#define HAVE_VSNPRINTF 0

并在链接后运行我的代码,日志文件内容将无格式的地址信息添加到函数名和行号。

Unformatted log o/p is given below.

        Venkatesh:~/Dmalloc/dmalloc-5.5.2$ cat logfile
        %ld: %lu: Dmalloc version '%s' from '%s'
        %ld: %lu: flags = %#x, logfile '%s'
        %ld: %lu: interval = %lu, addr = %#lx, seen # = %ld, limit = %ld
        %ld: %lu: starting time = %s
        %ld: %lu: process pid = %ld
        %ld: %lu:   error details: %s
        %ld: %lu:   pointer '%#lx' from '%s' prev access '%s'
        %ld: %lu:   dump of proper fence-top bytes: '%.*s'
        %ld: %lu:   dump of '%#lx'%+d: '%.*s'
        %ld: %lu:   next pointer '%#lx' (size %u) may have run under from '%s'
        %ld: %lu: ERROR: %s: %s (err %d)


If I define HAVE_VSNPRINTF to 1, then I log file has only dmalloc log header, no information about errors as given below.

        Venkatesh:~/Dmalloc/dmalloc-5.5.2$ cat logfile
        1450864250: 5: Dmalloc version '5.5.2' from 'http://dmalloc.com/'
        1450864250: 11: flags = 0x4f4e503, logfile 'logfile'
        1450864250: 17: interval = 100, addr = 0, seen # = 0, limit = 0
        1450864250: 25: starting time = 1450864250
        1450864250: 31: process pid = 10270

我的测试代码如下。

    #include <stdio.h>
    #include <stdlib.h>

    #ifdef DMALLOC
    #include "dmalloc.h"
    #endif

    int main ()
    {
            char *p;
            p = malloc (50);
            p[51] = 'c'; //Writing character beyond allocated range
            return 0;
    }

我使用的Dmalloc optins是:         DMALLOC_OPTIONS =调试= 0x4f4ed03除= 100,日志=日志文件

0 个答案:

没有答案