我使用 pin 来分析我的简单程序。
它有 4 个 malloc 函数,但是,当我将 pin 与名为 malloctrace 的 pintool 一起使用时,它会显示超过 4 个 malloc。
这些 malloc 函数是什么?
我的操作系统是 Ubuntu 12.04 64 位。以下项目是我制作的代码和 pintool 的结果。
#include <stdio.h>
#define SIZE 100
int main()
{
int *test1 = (int*)malloc(SIZE* sizeof(int));
int *test2 = (int*)malloc(SIZE* sizeof(int));
int i, j;
int *test3 = (int*)malloc(16*sizeof(int));
int *test4 = (char*)malloc(SIZE* sizeof(int));
test1[0] = 2;
test1[2] = 3;
test2[0] = 5;
printf("test1's addr : %p , test1's val = %d \n", test1, test1[0]);
printf("test1's addr : %p , test1's val = %d \n", &test1[1], test1[1]);
printf("test2's addr : %p , test2's val = %d \n", &test1[9], test1[9]);
return 0;
}
name size start_addr malloc_IP access_cnt
malloc 0x589 0 0x7ffff7de557e 0
malloc 0x489 0 0x7ffff7de557e 0
malloc 0xf 0 0x7ffff7ddd29e 0
malloc 0x4b 0 0x7ffff7df01b2 0
malloc 0x28 0 0x7ffff7de1fe7 0
malloc 0x14a0 0 0x7ffff7de202c 0
malloc 0x28 0 0x7ffff7de22ad 0
malloc 0x48 0 0x7ffff7ddf9d3 0
malloc 0x5c 0 0x7ffff7ddf9d3 0
malloc 0x5c 0 0x7ffff7ddf9d3 0
malloc 0x39 0 0x7ffff7ddf9d3 0
malloc 0x20 0 0x7ffff7de294e 0
malloc 0x492 0 0x7ffff7de557e 0
malloc 0x20 0 0x7ffff7de57ed 0
malloc 0x28 0 0x7ffff7de776f 0
malloc 0x38 0 0x7ffff7de7900 0
malloc 0x48 0 0x7ffff7deab5a 0
malloc 0x48 0 0x7ffff7deab5a 0
malloc 0x228 0 0x7ffff7deab5a 0
malloc 0x90 0 0x7ffff7deab5a 0
malloc 0x410 0 0x7ffff7ddaf22 0
malloc 0x110 0 0x7ffff7debd52 0
malloc 0x190 0 0x4013d2 0
malloc 0x190 0x603010 0x4013d2 0
malloc 0x190 0x6031b0 0x4013e0 0
malloc 0x40 0x603350 0x4013ee 0
malloc 0x190 0x6033a0 0x4013fc 0
free 0 0 0x401688 0
free 0 0 0x401688 0
free 0 0 0x401688 0
free 0 0 0x401688 0
free 0 0 0x4016b0 0
free 0 0 0x4016b0 0
free 0 0 0x4016d7 0
free 0 0 0x4016d7 0
free 0 0 0x4016d7 0
free 0 0 0x4016d7 0
free 1 0 0x4016e8 0
free 0 0 0x4016e8 0
free 0 0 0x401718 0
free 0 0 0x401718 0