A handy script for generating a talloc report for a running process

Rusty Russell rusty at rustcorp.com.au
Sun Jan 30 22:35:39 MST 2011


On Wed, 26 Jan 2011 05:46:40 pm Carl Worth wrote:
> I was lucky enough to sit next to Andrew at dinner last night and he
> gave me some tips on using talloc's reporting facilities for debugging
> memory leaks.
> 
> One of the tips he had was using a script that uses a gdb script to
> generate a talloc report for a current process.
> 
> I've included below the script that he helped me write. I think it would
> make sense to bundle something like this with talloc itself. Some notes:
> 
> 1. I've attached a copyright message for Andrew since at most I just
>    copied from a file he wrote originally. I also attached the standard
>    license blurb from talloc. Andrew, let me know if any of that should
>    change.
> 
> 2. It would be preferable for the script to generate output on stdout
>    rather than printing to a file in /tmp/ and forcing a leak of a file
>    descriptor. If someone could improve that, that would be great.

You want to do this, I think:

	p fopen ("$LOGFILE", "w")
	p $1 ? talloc_report_full (0, $1) : 0
	p $1 ? fclose($1) : 0

I'm not sure if this still crashes if null tracking isn't on...

> I hope this is useful,

Very useful!

Thanks,
Rusty.


More information about the samba-technical mailing list