1 /* 2 * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef HOOK_STANDALONE_H 17 #define HOOK_STANDALONE_H 18 19 #include <string> 20 #include <sstream> 21 #include <set> 22 23 struct HookData { 24 std::set<std::string> pids = {}; 25 uint32_t smbSize {0}; 26 uint64_t duration {0}; 27 uint32_t filterSize {0}; 28 uint32_t maxStackDepth {100}; 29 uint32_t statisticsInterval {0}; 30 uint32_t sampleInterval {0}; 31 std::string fileName {"/data/local/tmp/data.txt"}; 32 std::string processName; 33 std::string performanceFilename {"/data/local/tmp/performance.txt"}; 34 bool mallocDisable {false}; 35 bool mmapDisable {false}; 36 bool freemsgstack {false}; 37 bool munmapmsgstack {false}; 38 bool fpUnwind {false}; 39 bool offlineSymbolization {false}; 40 bool callframeCompress {false}; 41 bool stringCompressed {false}; 42 bool rawString {false}; 43 bool startupMode {false}; 44 bool responseLibraryMode {false}; ToStringHookData45 std::string ToString() const 46 { 47 std::stringstream ss; 48 ss << "smbSize:" << smbSize << ", duration:" << duration 49 << ", filterSize:" << filterSize << ", maxStackDepth:" << maxStackDepth 50 << ", statisticsInterval:" << statisticsInterval << ", fileName:" << fileName 51 << ", performanceFilename:" << performanceFilename << ", mallocDisable:" << mallocDisable 52 << ", mmapDisable:" << mmapDisable << ", freemsgstack:" << freemsgstack 53 << ", munmapmsgstack:" << munmapmsgstack << ", fpUnwind:" << fpUnwind 54 << ", offlineSymbolization:" << offlineSymbolization << ", callframeCompress:" << callframeCompress 55 << ", stringCompressed:" << stringCompressed << ", rawString:" << rawString <<", pids:"; 56 for (std::string pid: pids) { 57 ss << pid <<' '; 58 } 59 ss << ", processName:" << processName << ' ' <<",startupMode: " << startupMode 60 << ", responseLibraryMode: " << responseLibraryMode << ", sampleInterval: " << sampleInterval; 61 return ss.str(); 62 } 63 }; 64 65 namespace OHOS::Developtools::Profiler::Hook { 66 bool StartHook(HookData& hookData); 67 } // namespace OHOS::Developtools::Profiler::Hook 68 69 #endif // HOOK_STANDALONE_H