[Lazarus] Memory leaks
Luca Olivetti
luca at wetron.es
Thu Nov 22 16:20:48 CET 2012
Al 22/11/12 15:40, En/na Antonio Fortuny ha escrit:
> Hi Luca.
>
> Sorry but I don't know (yet) Python.
>
> I've downloaded and installed Pyton 2.7.3 and it runs so far.
> When submitting ly file I get an error on every line:
> D:\Compiled\Lazarus\i386-win32>"c:\Program Files\Python\python.exe" < leonidas.mlk > leonidas.ht
For your convenience I attached the script instead of puttin it inline.
Save it somewhere, make sure the correct gdb is in your PATH, then call it like this
"c:\Program Files\Python\python.exe" c:\wherever\you\saved\it\gdbleak.py < leonidas.mlk > leonidas.ht
Bye
--
Luca
-------------- next part --------------
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