1#!/bin/bash
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
16for f in $(cat $1 | grep u:object_r:debugfs_tracing:s0 | grep tracing/events | awk '{ print $3 }' | xargs -n1 basename);do
17  if [ -f "protos/perfetto/trace/ftrace/$f.proto" ]; then
18    echo "'protos/perfetto/trace/ftrace/$f.proto',";
19  else
20    for x in $(find src/traced/probes/ftrace/test/data/*/events -wholename '*/'"$f"'/format' -or -wholename '*/'"$f"'/*/format'); do
21      event=$(echo $x | awk -F / '{print $(NF - 1)}')
22      n="protos/perfetto/trace/ftrace/$event.proto";
23      if [ -f $n ]; then
24        echo "'$n',"
25      else
26          echo "# MISSING $event"
27      fi
28    done
29  fi
30done | sort
31