5 """Set the callback IDs for the Citizen; if both is true, set both new and delete to the same value
7 You probably want to chant the following to gdb:
8 break defaultNewCallback
9 break defaultDeleteCallback
11 You might want to put this in your .gdbinit file.
13 You can retrieve a citizen's signature from python with obj.repr()
18 if delete
and new != delete:
19 raise RuntimeError,
"You may not specify new, delete, and both"
25 dafBase.Citizen.setNewCallbackId(new)
27 dafBase.Citizen.setDeleteCallbackId(delete)
29 def mortal(memId0=0, nleakPrintMax=20, first=True, showTypes=None):
30 """Print leaked memory blocks
31 @param memId0 Only consider blocks allocated after this memId
32 @param nleakPrintMax Maximum number of leaks to print; <= 0 means unlimited
33 @param first Print the first nleakPrintMax blocks; if False print the last blocks.
34 @param showTypes Only print objects matching this regex (if starts with !, print objects that don't match)
36 If you want finer control than nleakPrintMax/first provide, use
37 dafBase.Citizen.census() to get the entire list
39 You can get the next memId to be allocated with mortal("set"), e.g.
40 memId0 = mortal("set")
46 return dafBase.Citizen.getNextMemId()
48 nleak = dafBase.Citizen.census(0, memId0)
50 print "%d Objects leaked" % dafBase.Citizen.census(0, memId0)
52 census = dafBase.Citizen.census()
53 census = [census[i].repr()
for i
in range(len(census))]
55 if showTypes[0] ==
'!':
57 showTypes = showTypes[1:]
61 _census, census = census, []
63 memId, addr, dtype = c.split()
64 memId = int(memId[:-1])
67 (
not invert
and re.search(showTypes, dtype))
or \
68 (invert
and not re.search(showTypes, dtype)):
72 print "%d leaked objects match" % nleak
74 if nleakPrintMax <= 0
or nleak <= nleakPrintMax:
76 memId, addr, type = c.split()
77 memId = int(memId[:-1])
82 for i
in range(nleakPrintMax - 1, -1, -1):