if acid mentions function names in the 'reports' of allocated or free blocks, remember them such that leak can show them: % leak 399373 block 0x0001cc20 0x00000040 0x0000a7ef 0x00000000 fmtstrinit+0x38 0x0 block 0x0001e4a8 0x000000a0 0x0000102f 0x00000000 emalloc+0xf 0x0 % (if this is too expensive memory-wise, would a string 'allocater' that stores each unique string only once help?) Axel. Reference: /n/sources/patch/applied/acidleak-keep-fnnames Date: Wed Nov 22 14:20:54 CET 2006 Signed-off-by: Axel.Belinfante@cs.utwente.nl --- /sys/src/cmd/aux/acidleak.c Wed Nov 22 14:10:20 2006 +++ /sys/src/cmd/aux/acidleak.c Wed Nov 22 14:10:18 2006 @@ -23,6 +23,17 @@ return v; } +char* +estrdup(char* s) +{ + char *r; + + r = strdup(s); + if(r == nil) + sysfatal("strdup fails\n"); + return r; +} + typedef struct Block Block; typedef struct Data Data; struct Block { @@ -30,6 +41,8 @@ ulong size; ulong w0; ulong w1; + char *s0; + char *s1; int mark; int free; Data *d; @@ -202,6 +215,13 @@ block[nblock].size = strtoul(f[2], nil, 0); block[nblock].w0 = strtoul(f[3], nil, 0); block[nblock].w1 = strtoul(f[4], nil, 0); + if (nf >= 7) { + block[nblock].s0 = estrdup(f[5]); + block[nblock].s1 = estrdup(f[6]); + } else { + block[nblock].s0 = ""; + block[nblock].s1 = ""; + } block[nblock].mark = 0; block[nblock].d = 0; block[nblock].free = strcmp(f[0], "free") == 0; @@ -296,7 +316,7 @@ eb = block+nblock; for(b=block; bmark == 0 && !b->free) - Bprint(&bio, "block 0x%.8lux 0x%.8lux 0x%.8lux 0x%.8lux\n", b->addr, b->size, b->w0, b->w1); + Bprint(&bio, "block 0x%.8lux 0x%.8lux 0x%.8lux 0x%.8lux %s %s\n", b->addr, b->size, b->w0, b->w1, b->s0, b->s1); } Bterm(&bio); }