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