get_test_data.h revision 8f680f60dc800bec880c5c35bfbc1ac36165e1f3
1569f64afd3db2b43003978765b833669f99477d2Yabin Cui/* 2569f64afd3db2b43003978765b833669f99477d2Yabin Cui * Copyright (C) 2015 The Android Open Source Project 3569f64afd3db2b43003978765b833669f99477d2Yabin Cui * 4569f64afd3db2b43003978765b833669f99477d2Yabin Cui * Licensed under the Apache License, Version 2.0 (the "License"); 5569f64afd3db2b43003978765b833669f99477d2Yabin Cui * you may not use this file except in compliance with the License. 6569f64afd3db2b43003978765b833669f99477d2Yabin Cui * You may obtain a copy of the License at 7569f64afd3db2b43003978765b833669f99477d2Yabin Cui * 8569f64afd3db2b43003978765b833669f99477d2Yabin Cui * http://www.apache.org/licenses/LICENSE-2.0 9569f64afd3db2b43003978765b833669f99477d2Yabin Cui * 10569f64afd3db2b43003978765b833669f99477d2Yabin Cui * Unless required by applicable law or agreed to in writing, software 11569f64afd3db2b43003978765b833669f99477d2Yabin Cui * distributed under the License is distributed on an "AS IS" BASIS, 12569f64afd3db2b43003978765b833669f99477d2Yabin Cui * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13569f64afd3db2b43003978765b833669f99477d2Yabin Cui * See the License for the specific language governing permissions and 14569f64afd3db2b43003978765b833669f99477d2Yabin Cui * limitations under the License. 15569f64afd3db2b43003978765b833669f99477d2Yabin Cui */ 16569f64afd3db2b43003978765b833669f99477d2Yabin Cui 17569f64afd3db2b43003978765b833669f99477d2Yabin Cui#ifndef SIMPLE_PERF_GET_TEST_DATA_H_ 18569f64afd3db2b43003978765b833669f99477d2Yabin Cui#define SIMPLE_PERF_GET_TEST_DATA_H_ 19569f64afd3db2b43003978765b833669f99477d2Yabin Cui 20569f64afd3db2b43003978765b833669f99477d2Yabin Cui#include <string> 21569f64afd3db2b43003978765b833669f99477d2Yabin Cui 22b1a885b014540a2f7798b5a35ea0f0ec150d93eeYabin Cui#include "build_id.h" 23b1a885b014540a2f7798b5a35ea0f0ec150d93eeYabin Cui 24569f64afd3db2b43003978765b833669f99477d2Yabin Cuistd::string GetTestData(const std::string& filename); 25b1a885b014540a2f7798b5a35ea0f0ec150d93eeYabin Cuiconst std::string& GetTestDataDir(); 26b1a885b014540a2f7798b5a35ea0f0ec150d93eeYabin Cui 27be7ec66eaa4f995bd9068637f7c7d5718173922cYabin Cuibool IsRoot(); 28be7ec66eaa4f995bd9068637f7c7d5718173922cYabin Cui 298f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// The source code of elf and elf_with_mini_debug_info is testdata/elf_file_source.cpp. 308f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cuistatic const std::string ELF_FILE = "elf"; 318f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cuistatic const std::string ELF_FILE_WITH_MINI_DEBUG_INFO = "elf_with_mini_debug_info"; 328f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// perf.data is generated by sampling on three processes running different 338f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// executables: elf, t1, t2 (all generated by elf_file_source.cpp, but with different 348f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// executable name). 356e51bef9aa101307523946df301ca90215d0ee82Yabin Cuistatic const std::string PERF_DATA = "perf.data"; 368f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// perf_g_fp.data is generated by sampling on one process running elf using --call-graph fp option. 376e51bef9aa101307523946df301ca90215d0ee82Yabin Cuistatic const std::string CALLGRAPH_FP_PERF_DATA = "perf_g_fp.data"; 388f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// perf_b.data is generated by sampling on one process running elf using -b option. 396e51bef9aa101307523946df301ca90215d0ee82Yabin Cuistatic const std::string BRANCH_PERF_DATA = "perf_b.data"; 408f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// perf_with_mini_debug_info.data is generated by sampling on one process running 418f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// elf_with_mini_debug_info. 4205400539d15c50a52a388daba2e831b86824cc8eYabin Cuistatic const std::string PERF_DATA_WITH_MINI_DEBUG_INFO = "perf_with_mini_debug_info.data"; 436e51bef9aa101307523946df301ca90215d0ee82Yabin Cui 448f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cuistatic BuildId elf_file_build_id("0b12a384a9f4a3f3659b7171ca615dbec3a81f71"); 456e51bef9aa101307523946df301ca90215d0ee82Yabin Cui 468f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui 478f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// To generate apk supporting execution on shared libraries in apk: 488f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// 1. Add android:extractNativeLibs=false in AndroidManifest.xml. 498f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// 2. Use `zip -0` to store native libraries in apk without compression. 508f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// 3. Use `zipalign -p 4096` to make native libraries in apk start at page boundaries. 518f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// 528f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// The logical in libhello-jni.so is as below: 538f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// volatile int GlobalVar; 548f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// 558f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// while (true) { 568f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// GlobalFunc() -> Func1() -> Func2() 578f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// } 588f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// And most time is spent in Func2(). 59b1a885b014540a2f7798b5a35ea0f0ec150d93eeYabin Cuistatic const std::string APK_FILE = "data/app/com.example.hellojni-1/base.apk"; 60b1a885b014540a2f7798b5a35ea0f0ec150d93eeYabin Cuistatic const std::string NATIVELIB_IN_APK = "lib/arm64-v8a/libhello-jni.so"; 618f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// has_embedded_native_libs_apk_perf.data is generated by sampling on one process running 628f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// APK_FILE using -g --no-unwind option. 63b1a885b014540a2f7798b5a35ea0f0ec150d93eeYabin Cuistatic const std::string NATIVELIB_IN_APK_PERF_DATA = "has_embedded_native_libs_apk_perf.data"; 648f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// The offset and size info are extracted from the generated apk file to run read_apk tests. 658f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cuiconstexpr size_t NATIVELIB_OFFSET_IN_APK = 0x639000; 668f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cuiconstexpr size_t NATIVELIB_SIZE_IN_APK = 0x1678; 67b1a885b014540a2f7798b5a35ea0f0ec150d93eeYabin Cui 688f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cuistatic BuildId native_lib_build_id("8ed5755a7fdc07586ca228b8ee21621bce2c7a97"); 69569f64afd3db2b43003978765b833669f99477d2Yabin Cui 70569f64afd3db2b43003978765b833669f99477d2Yabin Cui#endif // SIMPLE_PERF_GET_TEST_DATA_H_ 71