1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 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#ifndef HIPERF_LIBREPORT_H 16#define HIPERF_LIBREPORT_H 17 18#if defined(is_mingw) && is_mingw 19#define DLL_EXPORT __declspec(dllexport) 20#else 21#define DLL_EXPORT __attribute__((visibility("default"))) 22#endif 23 24#if is_ohos || is_double_framework 25// error: '__cdecl' calling convention is not supported for this target 26// [-Werror,-Wignored-attributes] 27#define CDECL 28#else 29#define CDECL __cdecl 30#endif 31 32extern "C" { 33/* 34 demo usage in script/loadlib_test.py 35*/ 36 37// this is a loop back test 38// will return the const char with caller send to us 39DLL_EXPORT const char *CDECL EchoLoopBack(const char *); 40 41// set the hiperf in debug mode , it will print some detail log for debug 42// log will save in current dir 43// return 0 means suucessed 44DLL_EXPORT int CDECL SetDebug(bool enable); 45 46// same as "hiperf report", will create a report file with ascii code 47// parameter: 48// perfFile the perf.data file path 49// reportFile the output file path 50// reportOptions options pass to report 51// return 0 means suucessed 52DLL_EXPORT int CDECL Report(const char *perfFile, const char *reportFile, 53 const char *reportOptions); 54 55// same as "hiperf report --json" 56// will output the report as json format 57// our html template will read this for UI show 58// parameter: 59// perfFile the perf.data file path 60// reportFile the output file path 61// return 0 means suucessed 62DLL_EXPORT int CDECL ReportJson(const char *perfFile, const char *reportFile); 63 64// same as "hiperf report --json --symbol-dir <dir>" 65// will output the report as json format and also unwind with --symbol-dir 66// our html template will read this for UI show 67// parameter: 68// perfFile the perf.data file path 69// reportFile the output file path 70// return 0 means suucessed 71DLL_EXPORT int CDECL ReportUnwindJson(const char *perfFile, const char *reportFile, 72 const char *symbolsDir); 73 74// same as "hiperf report dump" 75// must be give the the perf.data file path 76// return 0 means suucessed 77DLL_EXPORT int CDECL Dump(const char *); 78 79// when give the perf.data file path 80// will return a const char with this format 81// [filepath,buildid],[filepath,buildid],[filepath,buildid],[filepath,buildid],.... 82// python use this for build id match 83DLL_EXPORT const char *CDECL ReportGetSymbolFiles(const char *perfFile); 84 85// when give the elf file path 86// will return the buildId in this elf 87// return "" when no buildId found 88DLL_EXPORT const char *CDECL ReportGetBuildId(const char *elfPath); 89 90// when give the elf file path 91// will return the arch in this elf 92// now support "arm","arm64","x86","x86_64" 93// return machine id(const char in ascii) when not support 94// return "unknown" when failed happend 95DLL_EXPORT const char *CDECL ReportGetElfArch(const char *elfPath); 96} 97#endif // HIPERF_LIBREPORT_H 98