• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/python
2# Copyright (C) 2018 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
16from os import sys, path
17
18sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
19import synth_common
20
21anon_member = 1
22swap_member = 2
23
24trace = synth_common.create_trace()
25
26trace.add_packet()
27trace.add_process(1, 0, 'init')
28trace.add_process(2, 1, 'system_server')
29trace.add_process(3, 1, 'lmk_victim:no_data:ignored')
30trace.add_process(4, 1, 'lmk_victim:no_ion')
31trace.add_process(5, 1, 'lmk_victim:with_ion')
32trace.add_process(6, 1, 'process')
33trace.add_process(7, 1, 'lmk_victim:with_process')
34trace.add_process(8, 1, 'app:ui', 10001)
35trace.add_process(9, 1, 'lmk_victim:with_app')
36
37trace.add_package_list(ts=1, name="app", uid=10001, version_code=123)
38trace.add_package_list(ts=1, name="shared_uid_app", uid=10001, version_code=345)
39
40trace.add_ftrace_packet(cpu=0)
41trace.add_kernel_lmk(ts=101, tid=3)
42
43trace.add_ftrace_packet(cpu=0)
44trace.add_oom_score_update(ts=201, oom_score_adj=0, pid=4)
45trace.add_kernel_lmk(ts=202, tid=4)
46
47trace.add_ftrace_packet(cpu=0)
48trace.add_ion_event(ts=301, tid=5, heap_name='system', len=1000)
49trace.add_oom_score_update(ts=302, oom_score_adj=100, pid=5)
50trace.add_kernel_lmk(ts=303, tid=5)
51
52trace.add_ftrace_packet(cpu=0)
53trace.add_oom_score_update(ts=401, oom_score_adj=0, pid=6)
54trace.add_oom_score_update(ts=402, oom_score_adj=200, pid=7)
55trace.add_rss_stat(ts=403, tid=6, member=anon_member, size=2000)
56trace.add_kernel_lmk(ts=404, tid=7)
57trace.add_process_free(ts=405, tid=6, comm='', prio=0)
58
59trace.add_ftrace_packet(cpu=0)
60trace.add_oom_score_update(ts=501, oom_score_adj=0, pid=8)
61trace.add_oom_score_update(ts=502, oom_score_adj=100, pid=9)
62trace.add_rss_stat(ts=503, tid=8, member=anon_member, size=2500)
63trace.add_rss_stat(ts=503, tid=8, member=swap_member, size=2500)
64trace.add_kernel_lmk(ts=504, tid=9)
65
66# Dummy trace event to ensure the trace does not end on an LMK.
67trace.add_ftrace_packet(cpu=0)
68trace.add_oom_score_update(ts=1001, oom_score_adj=-800, pid=2)
69
70print(trace.trace.SerializeToString())
71