148f512ceSopenharmony_ci/* 248f512ceSopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 348f512ceSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 448f512ceSopenharmony_ci * you may not use this file except in compliance with the License. 548f512ceSopenharmony_ci * You may obtain a copy of the License at 648f512ceSopenharmony_ci * 748f512ceSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 848f512ceSopenharmony_ci * 948f512ceSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1048f512ceSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1148f512ceSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1248f512ceSopenharmony_ci * See the License for the specific language governing permissions and 1348f512ceSopenharmony_ci * limitations under the License. 1448f512ceSopenharmony_ci */ 1548f512ceSopenharmony_ci#ifndef HIPERF_LIBREPORT_H 1648f512ceSopenharmony_ci#define HIPERF_LIBREPORT_H 1748f512ceSopenharmony_ci 1848f512ceSopenharmony_ci#if defined(is_mingw) && is_mingw 1948f512ceSopenharmony_ci#define DLL_EXPORT __declspec(dllexport) 2048f512ceSopenharmony_ci#else 2148f512ceSopenharmony_ci#define DLL_EXPORT __attribute__((visibility("default"))) 2248f512ceSopenharmony_ci#endif 2348f512ceSopenharmony_ci 2448f512ceSopenharmony_ci#if is_ohos || is_double_framework 2548f512ceSopenharmony_ci// error: '__cdecl' calling convention is not supported for this target 2648f512ceSopenharmony_ci// [-Werror,-Wignored-attributes] 2748f512ceSopenharmony_ci#define CDECL 2848f512ceSopenharmony_ci#else 2948f512ceSopenharmony_ci#define CDECL __cdecl 3048f512ceSopenharmony_ci#endif 3148f512ceSopenharmony_ci 3248f512ceSopenharmony_ciextern "C" { 3348f512ceSopenharmony_ci/* 3448f512ceSopenharmony_ci demo usage in script/loadlib_test.py 3548f512ceSopenharmony_ci*/ 3648f512ceSopenharmony_ci 3748f512ceSopenharmony_ci// this is a loop back test 3848f512ceSopenharmony_ci// will return the const char with caller send to us 3948f512ceSopenharmony_ciDLL_EXPORT const char *CDECL EchoLoopBack(const char *); 4048f512ceSopenharmony_ci 4148f512ceSopenharmony_ci// set the hiperf in debug mode , it will print some detail log for debug 4248f512ceSopenharmony_ci// log will save in current dir 4348f512ceSopenharmony_ci// return 0 means suucessed 4448f512ceSopenharmony_ciDLL_EXPORT int CDECL SetDebug(bool enable); 4548f512ceSopenharmony_ci 4648f512ceSopenharmony_ci// same as "hiperf report", will create a report file with ascii code 4748f512ceSopenharmony_ci// parameter: 4848f512ceSopenharmony_ci// perfFile the perf.data file path 4948f512ceSopenharmony_ci// reportFile the output file path 5048f512ceSopenharmony_ci// reportOptions options pass to report 5148f512ceSopenharmony_ci// return 0 means suucessed 5248f512ceSopenharmony_ciDLL_EXPORT int CDECL Report(const char *perfFile, const char *reportFile, 5348f512ceSopenharmony_ci const char *reportOptions); 5448f512ceSopenharmony_ci 5548f512ceSopenharmony_ci// same as "hiperf report --json" 5648f512ceSopenharmony_ci// will output the report as json format 5748f512ceSopenharmony_ci// our html template will read this for UI show 5848f512ceSopenharmony_ci// parameter: 5948f512ceSopenharmony_ci// perfFile the perf.data file path 6048f512ceSopenharmony_ci// reportFile the output file path 6148f512ceSopenharmony_ci// return 0 means suucessed 6248f512ceSopenharmony_ciDLL_EXPORT int CDECL ReportJson(const char *perfFile, const char *reportFile); 6348f512ceSopenharmony_ci 6448f512ceSopenharmony_ci// same as "hiperf report --json --symbol-dir <dir>" 6548f512ceSopenharmony_ci// will output the report as json format and also unwind with --symbol-dir 6648f512ceSopenharmony_ci// our html template will read this for UI show 6748f512ceSopenharmony_ci// parameter: 6848f512ceSopenharmony_ci// perfFile the perf.data file path 6948f512ceSopenharmony_ci// reportFile the output file path 7048f512ceSopenharmony_ci// return 0 means suucessed 7148f512ceSopenharmony_ciDLL_EXPORT int CDECL ReportUnwindJson(const char *perfFile, const char *reportFile, 7248f512ceSopenharmony_ci const char *symbolsDir); 7348f512ceSopenharmony_ci 7448f512ceSopenharmony_ci// same as "hiperf report dump" 7548f512ceSopenharmony_ci// must be give the the perf.data file path 7648f512ceSopenharmony_ci// return 0 means suucessed 7748f512ceSopenharmony_ciDLL_EXPORT int CDECL Dump(const char *); 7848f512ceSopenharmony_ci 7948f512ceSopenharmony_ci// when give the perf.data file path 8048f512ceSopenharmony_ci// will return a const char with this format 8148f512ceSopenharmony_ci// [filepath,buildid],[filepath,buildid],[filepath,buildid],[filepath,buildid],.... 8248f512ceSopenharmony_ci// python use this for build id match 8348f512ceSopenharmony_ciDLL_EXPORT const char *CDECL ReportGetSymbolFiles(const char *perfFile); 8448f512ceSopenharmony_ci 8548f512ceSopenharmony_ci// when give the elf file path 8648f512ceSopenharmony_ci// will return the buildId in this elf 8748f512ceSopenharmony_ci// return "" when no buildId found 8848f512ceSopenharmony_ciDLL_EXPORT const char *CDECL ReportGetBuildId(const char *elfPath); 8948f512ceSopenharmony_ci 9048f512ceSopenharmony_ci// when give the elf file path 9148f512ceSopenharmony_ci// will return the arch in this elf 9248f512ceSopenharmony_ci// now support "arm","arm64","x86","x86_64" 9348f512ceSopenharmony_ci// return machine id(const char in ascii) when not support 9448f512ceSopenharmony_ci// return "unknown" when failed happend 9548f512ceSopenharmony_ciDLL_EXPORT const char *CDECL ReportGetElfArch(const char *elfPath); 9648f512ceSopenharmony_ci} 9748f512ceSopenharmony_ci#endif // HIPERF_LIBREPORT_H 98