• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/python
2# Copyright (C) 2019 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
21sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
22import synth_common
23
24trace = synth_common.create_trace()
25
26trace.add_packet(ts=1)
27trace.add_process(10, 1, "parent_process")
28
29trace.add_ftrace_packet(1)
30
31# Emit an event for the process.
32trace.add_rss_stat(100, tid=10, member=0, size=100, mm_id=0x1234, curr=1)
33
34# Now kill the process.
35trace.add_process_free(ts=101, tid=10, comm="parent_process", prio=0)
36
37# Create a new thread which reuses the pid and mm struct.
38trace.add_newtask(102, tid=1, new_tid=10, new_comm="new_process", flags=0)
39
40# Emit an event for the new thread.
41trace.add_rss_stat(103, tid=10, member=0, size=10, mm_id=0x1234, curr=1)
42
43print(trace.trace.SerializeToString())
44