1#!/usr/bin/python 2#!/usr/bin/python 3# Copyright (C) 2019 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17# This synthetic trace tests handling of the mm_id field in the rss_stat 18# event when mm_structs are reused on process death. 19 20from os import sys, path 21 22sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) 23import synth_common 24 25trace = synth_common.create_trace() 26 27trace.add_packet(ts=1) 28trace.add_process(10, 1, "parent_process") 29trace.add_process(11, 1, "other_process") 30 31trace.add_ftrace_packet(1) 32 33# Emit an event on an irrelevant thread. 34trace.add_rss_stat(90, tid=11, member=0, size=20, mm_id=0x5678, curr=1) 35 36# Emit an event for the process. 37trace.add_rss_stat(100, tid=10, member=0, size=100, mm_id=0x1234, curr=1) 38 39# Now kill the process. 40trace.add_process_free(ts=101, tid=10, comm="parent_process", prio=0) 41 42# Emit an event on another thread which reuses the struct after free. 43trace.add_rss_stat(103, tid=11, member=0, size=10, mm_id=0x1234, curr=0) 44 45print(trace.trace.SerializeToString()) 46