• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# Copyright (C) 2021 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16# This synthetic trace tests handling of the mm_id field in the rss_stat
17# event when mm_structs are reused on process death.
18
19from os import sys, path
20
21import synth_common
22
23trace = synth_common.create_trace()
24
25trace.add_packet(ts=1)
26trace.add_process(
27    pid=10, ppid=1, cmdline='/system/bin/surfaceflinger', uid=None)
28trace.add_thread(tid=10, tgid=10, cmdline='', name='Main thread')
29trace.add_thread(tid=33, tgid=10, cmdline='', name='GPU completion')
30trace.add_ftrace_packet(1)
31
32trace.add_atrace_begin(
33    ts=1_000_000, tid=33, pid=10, buf='waiting for GPU completion 4')
34trace.add_atrace_end(ts=2_000_000, tid=33, pid=10)
35
36trace.add_atrace_begin(
37    ts=3_000_000, tid=10, pid=10, buf='Trace GPU completion fence 5')
38trace.add_atrace_begin(
39    ts=3_000_000, tid=33, pid=10, buf='waiting for GPU completion 5')
40trace.add_atrace_end(ts=3_000_500, tid=10, pid=10)
41trace.add_atrace_end(ts=6_000_000, tid=33, pid=10)
42
43trace.add_atrace_begin(
44    ts=7_000_000, tid=10, pid=10, buf='Trace GPU completion fence 6')
45trace.add_atrace_begin(
46    ts=7_000_000, tid=33, pid=10, buf='waiting for GPU completion 6')
47trace.add_atrace_end(ts=7_000_500, tid=10, pid=10)
48trace.add_atrace_begin(
49    ts=10_000_000, tid=10, pid=10, buf='Trace GPU completion fence 7')
50trace.add_atrace_end(ts=10_000_500, tid=10, pid=10)
51trace.add_atrace_end(ts=12_000_000, tid=33, pid=10)
52trace.add_atrace_begin(
53    ts=12_000_000, tid=33, pid=10, buf='waiting for GPU completion 7')
54trace.add_atrace_end(ts=14_000_000, tid=33, pid=10)
55
56trace.add_atrace_begin(
57    ts=15_000_000, tid=10, pid=10, buf='Trace GPU completion fence 8')
58trace.add_atrace_end(ts=15_000_500, tid=10, pid=10)
59
60sys.stdout.buffer.write(trace.trace.SerializeToString())
61