[Lazarus] Memory leaks
Luca Olivetti
luca at wetron.es
Thu Nov 22 15:07:39 CET 2012
Al 22/11/12 14:48, En/na Antonio Fortuny ha escrit:
> Debug output is checked, but whatever the link configuration could be (automatic, stabs, Dwarf gives termination exceptions) with or without external dbg file, the only output I get from feaptrc is this:
Since I have the same problem and I use external dbg files, I wrote a quick'n'dirty python script that invokes gdb and adds the missing information.
You have to call it like this:
python gdbleak.py < heaptrace.log > new_heaptrace.log
-------------------------------------------------------------------
from subprocess import Popen,PIPE,STDOUT
import sys
class gdb:
def __init__(self, exe):
self._gdb=Popen(['gdb',exe],stdin=PIPE,stdout=PIPE,stderr=STDOUT)
def __del__(self):
self._gdb.terminate()
def read(self):
s=''
while s[-5:]!='(gdb)':
s=s+self._gdb.stdout.read(1)
return s.split('\r\n')[:-1]
def write(self,command):
#print command
self._gdb.stdin.write(command+'\r\n')
return self.read()
g=None
while True:
linea=sys.stdin.readline()
if not linea:
sys.exit()
linea=linea.rstrip()
printlinea=linea
if linea.startswith('Heap dump by heaptrc unit'):
progname=prevlinea.split()[0]
if g:
del g
g=gdb(progname)
g.read()
if linea.startswith(' $'):
if g and len(linea.split())==1:
r=' '.join(g.write('info line'+linea.replace('$','*0x')))
if r.startswith(' Line'):
kk=r.split('starts')
lineinfo=kk[0].strip().replace('"','').replace("Line","line")
funcname='unkn'
if len(kk)==2:
funcname=kk[1].split('<')[1].split('+')[0].split('>')[0]
printlinea="%s %s, %s" % (linea,funcname,lineinfo)
prevlinea=linea
print printlinea
More information about the Lazarus
mailing list