• 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(10, 1, "parent_process")
27trace.add_process(10335, 10, "child_process")
28trace.add_thread(15000, 10335, "worker thread")
29
30trace.add_ftrace_packet(1)
31
32# unskipped validation
33trace.add_atrace_begin(ts=100, tid=10335, pid=10335, buf="onMessageRefresh")
34trace.add_atrace_begin(
35    ts=200, tid=10335, pid=10335, buf="HwcPresentOrValidateDisplay 0")
36trace.add_atrace_end(ts=300, tid=10335, pid=10335)
37trace.add_atrace_begin(ts=400, tid=10335, pid=10335, buf="HwcPresentDisplay 0")
38trace.add_atrace_end(ts=500, tid=10335, pid=10335)
39trace.add_atrace_end(ts=600, tid=10335, pid=10335)
40
41# skipped validation
42trace.add_atrace_begin(ts=1_100, tid=10335, pid=10335, buf="composite 2")
43trace.add_atrace_begin(
44    ts=1_200, tid=10335, pid=10335, buf="HwcPresentOrValidateDisplay 0")
45trace.add_atrace_end(ts=1_300, tid=10335, pid=10335)
46trace.add_atrace_end(ts=1_400, tid=10335, pid=10335)
47
48# separated validation where HwcValidateDisplay is executed from worker thread
49trace.add_atrace_begin(ts=2_100, tid=10335, pid=10335, buf="composite 3")
50trace.add_atrace_begin(ts=2_200, tid=15000, pid=10335, buf="otherFunction")
51trace.add_atrace_begin(ts=2_300, tid=15000, pid=10335, buf="HwcValidateDisplay 1")
52trace.add_atrace_end(ts=2_400, tid=15000, pid=10335)
53trace.add_atrace_end(ts=2_500, tid=15000, pid=10335)
54trace.add_atrace_begin(ts=2_600, tid=10335, pid=10335, buf="HwcPresentDisplay 1")
55trace.add_atrace_end(ts=2_700, tid=10335, pid=10335)
56trace.add_atrace_end(ts=2_800, tid=10335, pid=10335)
57
58# skipped validation
59trace.add_atrace_begin(ts=3_100, tid=10335, pid=10335, buf="AnotherFunction")
60trace.add_atrace_begin(ts=3_200, tid=10335, pid=10335, buf="onMessageRefresh")
61trace.add_atrace_begin(
62    ts=3_300, tid=10335, pid=10335, buf="HwcPresentOrValidateDisplay 0")
63trace.add_atrace_end(ts=3_400, tid=10335, pid=10335)
64trace.add_atrace_end(ts=3_500, tid=10335, pid=10335)
65trace.add_atrace_end(ts=3_600, tid=10335, pid=10335)
66
67trace.add_atrace_begin(
68    ts=3_700, tid=15000, pid=10335, buf="HwcPresentOrValidateDisplay 1")
69trace.add_atrace_end(ts=3_800, tid=15000, pid=10335)
70
71# incomplete (ignored)
72trace.add_atrace_begin(
73    ts=4_200, tid=10335, pid=10335, buf="HwcValidateDisplay 1")
74trace.add_atrace_end(ts=4_300, tid=10335, pid=10335)
75
76sys.stdout.buffer.write(trace.trace.SerializeToString())