Add support for PERF_RECORD_MMAP2 record type

Newer perf.data contains both MMAP and MMAP2 record type,
but MMAP2 record type is not supported in previous ll_prof,
MMAP2 record information will be lost.

BUG=v8:4569
LOG=n

Review URL: https://codereview.chromium.org/1469153004

Cr-Commit-Position: refs/heads/master@{#32319}
This commit is contained in:
jie.pan 2015-11-26 01:31:15 -08:00 committed by Commit bot
parent 45c52ddfdd
commit f9bc310e44

View File

@ -568,7 +568,7 @@ PERF_EVENT_HEADER_DESC = Descriptor([
])
# Reference: kernel/events/core.c
# Reference: kernel/tools/perf/util/event.h
PERF_MMAP_EVENT_BODY_DESC = Descriptor([
("pid", "u32"),
("tid", "u32"),
@ -577,6 +577,20 @@ PERF_MMAP_EVENT_BODY_DESC = Descriptor([
("pgoff", "u64")
])
# Reference: kernel/tools/perf/util/event.h
PERF_MMAP2_EVENT_BODY_DESC = Descriptor([
("pid", "u32"),
("tid", "u32"),
("addr", "u64"),
("len", "u64"),
("pgoff", "u64"),
("maj", "u32"),
("min", "u32"),
("ino", "u64"),
("ino_generation", "u64"),
("prot", "u32"),
("flags","u32")
])
# perf_event_attr.sample_type bits control the set of
# perf_sample_event fields.
@ -616,6 +630,7 @@ PERF_SAMPLE_EVENT_IP_FORMAT = "u64"
PERF_RECORD_MMAP = 1
PERF_RECORD_MMAP2 = 10
PERF_RECORD_SAMPLE = 9
@ -664,6 +679,15 @@ class TraceReader(object):
mmap_info.filename = HOST_ROOT + filename[:filename.find(chr(0))]
return mmap_info
def ReadMmap2(self, header, offset):
mmap_info = PERF_MMAP2_EVENT_BODY_DESC.Read(self.trace,
offset + self.header_size)
# Read null-terminated filename.
filename = self.trace[offset + self.header_size + ctypes.sizeof(mmap_info):
offset + header.size]
mmap_info.filename = HOST_ROOT + filename[:filename.find(chr(0))]
return mmap_info
def ReadSample(self, header, offset):
sample = self.sample_event_body_desc.Read(self.trace,
offset + self.header_size)
@ -973,6 +997,14 @@ if __name__ == "__main__":
else:
library_repo.Load(mmap_info, code_map, options)
mmap_time += time.time() - start
elif header.type == PERF_RECORD_MMAP2:
start = time.time()
mmap_info = trace_reader.ReadMmap2(header, offset)
if mmap_info.filename == HOST_ROOT + V8_GC_FAKE_MMAP:
log_reader.ReadUpToGC()
else:
library_repo.Load(mmap_info, code_map, options)
mmap_time += time.time() - start
elif header.type == PERF_RECORD_SAMPLE:
ticks += 1
start = time.time()