106f6ba60Sopenharmony_ci/* 206f6ba60Sopenharmony_ci * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. 306f6ba60Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 406f6ba60Sopenharmony_ci * you may not use this file except in compliance with the License. 506f6ba60Sopenharmony_ci * You may obtain a copy of the License at 606f6ba60Sopenharmony_ci * 706f6ba60Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 806f6ba60Sopenharmony_ci * 906f6ba60Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1006f6ba60Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1106f6ba60Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1206f6ba60Sopenharmony_ci * See the License for the specific language governing permissions and 1306f6ba60Sopenharmony_ci * limitations under the License. 1406f6ba60Sopenharmony_ci */ 1506f6ba60Sopenharmony_ci 1606f6ba60Sopenharmony_ci#ifndef HOOK_STANDALONE_H 1706f6ba60Sopenharmony_ci#define HOOK_STANDALONE_H 1806f6ba60Sopenharmony_ci 1906f6ba60Sopenharmony_ci#include <string> 2006f6ba60Sopenharmony_ci#include <sstream> 2106f6ba60Sopenharmony_ci#include <set> 2206f6ba60Sopenharmony_ci 2306f6ba60Sopenharmony_cistruct HookData { 2406f6ba60Sopenharmony_ci std::set<std::string> pids = {}; 2506f6ba60Sopenharmony_ci uint32_t smbSize {0}; 2606f6ba60Sopenharmony_ci uint64_t duration {0}; 2706f6ba60Sopenharmony_ci uint32_t filterSize {0}; 2806f6ba60Sopenharmony_ci uint32_t maxStackDepth {100}; 2906f6ba60Sopenharmony_ci uint32_t maxJsStackdepth = {0}; 3006f6ba60Sopenharmony_ci uint32_t statisticsInterval {0}; 3106f6ba60Sopenharmony_ci uint32_t sampleInterval {0}; 3206f6ba60Sopenharmony_ci int32_t jsStackReport {0}; 3306f6ba60Sopenharmony_ci uint32_t mallocFreeMatchingInterval {0}; 3406f6ba60Sopenharmony_ci std::string fileName {"/data/local/tmp/data.txt"}; 3506f6ba60Sopenharmony_ci std::string processName; 3606f6ba60Sopenharmony_ci std::string performanceFilename {"/data/local/tmp/performance.txt"}; 3706f6ba60Sopenharmony_ci std::string filterNapiName = {""}; 3806f6ba60Sopenharmony_ci bool mallocDisable {false}; 3906f6ba60Sopenharmony_ci bool mmapDisable {false}; 4006f6ba60Sopenharmony_ci bool freemsgstack {false}; 4106f6ba60Sopenharmony_ci bool munmapmsgstack {false}; 4206f6ba60Sopenharmony_ci bool fpUnwind {false}; 4306f6ba60Sopenharmony_ci bool offlineSymbolization {false}; 4406f6ba60Sopenharmony_ci bool callframeCompress {false}; 4506f6ba60Sopenharmony_ci bool stringCompressed {false}; 4606f6ba60Sopenharmony_ci bool rawString {false}; 4706f6ba60Sopenharmony_ci bool startupMode {false}; 4806f6ba60Sopenharmony_ci bool responseLibraryMode {false}; 4906f6ba60Sopenharmony_ci std::string ToString() const 5006f6ba60Sopenharmony_ci { 5106f6ba60Sopenharmony_ci std::stringstream ss; 5206f6ba60Sopenharmony_ci ss << "smbSize:" << smbSize << ", duration:" << duration 5306f6ba60Sopenharmony_ci << ", filterSize:" << filterSize << ", maxStackDepth:" << maxStackDepth 5406f6ba60Sopenharmony_ci << ", statisticsInterval:" << statisticsInterval << ", fileName:" << fileName 5506f6ba60Sopenharmony_ci << ", performanceFilename:" << performanceFilename << ", mallocDisable:" << mallocDisable 5606f6ba60Sopenharmony_ci << ", mmapDisable:" << mmapDisable << ", freemsgstack:" << freemsgstack 5706f6ba60Sopenharmony_ci << ", munmapmsgstack:" << munmapmsgstack << ", fpUnwind:" << fpUnwind 5806f6ba60Sopenharmony_ci << ", offlineSymbolization:" << offlineSymbolization << ", callframeCompress:" << callframeCompress 5906f6ba60Sopenharmony_ci << ", stringCompressed:" << stringCompressed << ", rawString:" << rawString <<", pids:"; 6006f6ba60Sopenharmony_ci for (std::string pid: pids) { 6106f6ba60Sopenharmony_ci ss << pid <<' '; 6206f6ba60Sopenharmony_ci } 6306f6ba60Sopenharmony_ci ss << ", processName:" << processName << ' ' <<",startupMode: " << startupMode 6406f6ba60Sopenharmony_ci << ", responseLibraryMode: " << responseLibraryMode << ", sampleInterval: " << sampleInterval 6506f6ba60Sopenharmony_ci << ", jsStackReport: " << jsStackReport << ", maxJsStackdepth: " << maxJsStackdepth 6606f6ba60Sopenharmony_ci <<", filterNapiName" << filterNapiName << "mallocFreeMatchingInterval: " << mallocFreeMatchingInterval; 6706f6ba60Sopenharmony_ci return ss.str(); 6806f6ba60Sopenharmony_ci } 6906f6ba60Sopenharmony_ci}; 7006f6ba60Sopenharmony_ci 7106f6ba60Sopenharmony_cinamespace OHOS::Developtools::Profiler::Hook { 7206f6ba60Sopenharmony_cibool StartHook(HookData& hookData); 7306f6ba60Sopenharmony_civoid EndHook(); 7406f6ba60Sopenharmony_ci} // namespace OHOS::Developtools::Profiler::Hook 7506f6ba60Sopenharmony_ci 7606f6ba60Sopenharmony_ci#endif // HOOK_STANDALONE_H