Bug 1904685 - Output the addresses in dmd.py, when present. r=pbone

With heap scan mode, the DMD log includes the address of every block.
This patch includes the addresses in the output, if they are present.
This is useful when no cycle collected objects are leaked.

Differential Revision: https://phabricator.services.mozilla.com/D214880
This commit is contained in:
Andrew McCreight 2024-06-26 23:25:15 +00:00
Родитель 6d4424d72c
Коммит 68868f579a
3 изменённых файлов: 15 добавлений и 0 удалений

Просмотреть файл

@ -71,6 +71,7 @@ class Record(object):
self.allocatedAtDesc = None
self.reportedAtDescs = []
self.usableSizes = collections.defaultdict(int)
self.addrs = []
def isZero(self, args):
return (
@ -504,6 +505,10 @@ def getDigestFromFile(args, inputFile):
traceTable, frameTable, allocatedAtTraceKey
)
# In heap scan mode, we record the address of every block.
if "addr" in block:
record.addrs.append(block["addr"])
if mode in ["live", "cumulative"]:
pass
elif mode == "dark-matter":
@ -674,6 +679,14 @@ def printDigest(args, digest):
number(record.numBlocks), plural(record.numBlocks), i, numRecords
)
)
if record.addrs:
if args.filter_stacks_for_testing:
# These addresses will vary, so for testing replace them with a fixed value.
baseAddrs = ["dadadada" for a in record.addrs]
else:
baseAddrs = sorted(record.addrs)
addrsString = ", ".join([f"0x{a}" for a in baseAddrs])
out(" block addresses: " + addrsString)
out(
" {:} bytes ({:} requested / {:} slop)".format(
number(record.usableSize),

Просмотреть файл

@ -10,6 +10,7 @@ Invocation {
Live {
1 block in heap block record 1 of 1
block addresses: 0xdadadada
32 bytes (24 requested / 8 slop)
100.00% of the heap (100.00% cumulative)
Allocated at {

Просмотреть файл

@ -10,6 +10,7 @@ Invocation {
Live {
1 block in heap block record 1 of 1
block addresses: 0xdadadada
48 bytes (48 requested / 0 slop)
100.00% of the heap (100.00% cumulative)
Allocated at {