1 /* 2 * Copyright (C) 2020 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 17 #ifndef SRC_TRACED_PROBES_FTRACE_VENDOR_TRACEPOINTS_H_ 18 #define SRC_TRACED_PROBES_FTRACE_VENDOR_TRACEPOINTS_H_ 19 20 #include <map> 21 #include <string> 22 #include <vector> 23 24 #include "perfetto/base/status.h" 25 #include "src/traced/probes/ftrace/atrace_hal_wrapper.h" 26 #include "src/traced/probes/ftrace/ftrace_procfs.h" 27 #include "src/traced/probes/ftrace/proto_translation_table.h" 28 29 namespace perfetto { 30 namespace vendor_tracepoints { 31 32 // Path to the vendor categories file in Android (since Android 14). 33 constexpr const char* kCategoriesFile = 34 "/vendor/etc/atrace/atrace_categories.txt"; 35 36 // Returns a map from vendor category to events we should enable. Queries the 37 // atrace HAL. 38 std::map<std::string, std::vector<GroupAndName>> 39 DiscoverVendorTracepointsWithHal(AtraceHalWrapper* hal, FtraceProcfs* ftrace); 40 41 // Fills `*categories_map` with a map from vendor category to events we should 42 // enable. Queries the vendor categories file at 43 // `vendor_atrace_categories_path` (which should always be `kCategoriesFile` 44 // except in tests). 45 base::Status DiscoverVendorTracepointsWithFile( 46 const std::string& vendor_atrace_categories_path, 47 std::map<std::string, std::vector<GroupAndName>>* categories_map); 48 49 // Like `DiscoverVendorTracepointsWithFile`, but does not return events that are 50 // not accessible or do not actually exist on the tracing file system. 51 base::Status DiscoverAccessibleVendorTracepointsWithFile( 52 const std::string& vendor_atrace_categories_path, 53 std::map<std::string, std::vector<GroupAndName>>* categories_map, 54 FtraceProcfs* ftrace); 55 56 } // namespace vendor_tracepoints 57 } // namespace perfetto 58 59 #endif // SRC_TRACED_PROBES_FTRACE_VENDOR_TRACEPOINTS_H_ 60