1800b99b8Sopenharmony_ci/* 2800b99b8Sopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3800b99b8Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4800b99b8Sopenharmony_ci * you may not use this file except in compliance with the License. 5800b99b8Sopenharmony_ci * You may obtain a copy of the License at 6800b99b8Sopenharmony_ci * 7800b99b8Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8800b99b8Sopenharmony_ci * 9800b99b8Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10800b99b8Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11800b99b8Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12800b99b8Sopenharmony_ci * See the License for the specific language governing permissions and 13800b99b8Sopenharmony_ci * limitations under the License. 14800b99b8Sopenharmony_ci */ 15800b99b8Sopenharmony_ci#ifndef DFX_FAULTLOGGERD_CLIENT_H 16800b99b8Sopenharmony_ci#define DFX_FAULTLOGGERD_CLIENT_H 17800b99b8Sopenharmony_ci 18800b99b8Sopenharmony_ci#include <inttypes.h> 19800b99b8Sopenharmony_ci#include "dfx_socket_request.h" 20800b99b8Sopenharmony_ci 21800b99b8Sopenharmony_ci#ifdef __cplusplus 22800b99b8Sopenharmony_ciextern "C" { 23800b99b8Sopenharmony_ci#endif 24800b99b8Sopenharmony_ci 25800b99b8Sopenharmony_ci/** 26800b99b8Sopenharmony_ci * @brief Check connection status of client 27800b99b8Sopenharmony_ci * 28800b99b8Sopenharmony_ci * @return if available return true, otherwise return false 29800b99b8Sopenharmony_ci*/ 30800b99b8Sopenharmony_cibool CheckConnectStatus(); 31800b99b8Sopenharmony_ci/** 32800b99b8Sopenharmony_ci * @brief request file descriptor 33800b99b8Sopenharmony_ci * @param type type of resqust 34800b99b8Sopenharmony_ci * @return if succeed return file descriptor, otherwise return -1 35800b99b8Sopenharmony_ci*/ 36800b99b8Sopenharmony_ciint32_t RequestFileDescriptor(int32_t type); 37800b99b8Sopenharmony_ci 38800b99b8Sopenharmony_ci/** 39800b99b8Sopenharmony_ci * @brief request log file descriptor 40800b99b8Sopenharmony_ci * @param request struct of request information 41800b99b8Sopenharmony_ci * @return if succeed return file descriptor, otherwise return -1 42800b99b8Sopenharmony_ci*/ 43800b99b8Sopenharmony_ciint32_t RequestLogFileDescriptor(struct FaultLoggerdRequest *request); 44800b99b8Sopenharmony_ci 45800b99b8Sopenharmony_ci/** 46800b99b8Sopenharmony_ci * @brief request pipe file descriptor 47800b99b8Sopenharmony_ci * @param pid process id of request pipe 48800b99b8Sopenharmony_ci * @param pipeType type of request about pipe 49800b99b8Sopenharmony_ci * @return if succeed return file descriptor, otherwise return -1 50800b99b8Sopenharmony_ci*/ 51800b99b8Sopenharmony_ciint32_t RequestPipeFd(int32_t pid, int32_t pipeType); 52800b99b8Sopenharmony_ci 53800b99b8Sopenharmony_ci/** 54800b99b8Sopenharmony_ci * @brief request delete file descriptor 55800b99b8Sopenharmony_ci * @param pid process id of request pipe 56800b99b8Sopenharmony_ci * @return if succeed return 0, otherwise return -1 57800b99b8Sopenharmony_ci*/ 58800b99b8Sopenharmony_ciint32_t RequestDelPipeFd(int32_t pid); 59800b99b8Sopenharmony_ci 60800b99b8Sopenharmony_ci/** 61800b99b8Sopenharmony_ci * @brief request file descriptor 62800b99b8Sopenharmony_ci * @param request struct of request information 63800b99b8Sopenharmony_ci * @return if succeed return file descriptor, otherwise return -1 64800b99b8Sopenharmony_ci*/ 65800b99b8Sopenharmony_ciint RequestFileDescriptorEx(const struct FaultLoggerdRequest *request); 66800b99b8Sopenharmony_ci 67800b99b8Sopenharmony_ci/** 68800b99b8Sopenharmony_ci * @brief request checking permission of process 69800b99b8Sopenharmony_ci * @param pid process id 70800b99b8Sopenharmony_ci * @return if pass return true , otherwise return false 71800b99b8Sopenharmony_ci*/ 72800b99b8Sopenharmony_cibool RequestCheckPermission(int32_t pid); 73800b99b8Sopenharmony_ci/** 74800b99b8Sopenharmony_ci * @brief request printing message to hilog 75800b99b8Sopenharmony_ci * @param msg message 76800b99b8Sopenharmony_ci * @param length length of message 77800b99b8Sopenharmony_ci * @return if succeed return 0 , otherwise return -1 78800b99b8Sopenharmony_ci*/ 79800b99b8Sopenharmony_ciint RequestPrintTHilog(const char *msg, int length); 80800b99b8Sopenharmony_ci 81800b99b8Sopenharmony_ci/** 82800b99b8Sopenharmony_ci * @brief request dump stack about process 83800b99b8Sopenharmony_ci * @param pid process id 84800b99b8Sopenharmony_ci * @param tid thread id, if equal 0 means dump all the threads in a process. 85800b99b8Sopenharmony_ci * @return if succeed return 0 , otherwise return -1 86800b99b8Sopenharmony_ci*/ 87800b99b8Sopenharmony_ciint RequestSdkDump(int32_t pid, int32_t tid, int timeout = 10000); // 10000 : dump timeout ms 88800b99b8Sopenharmony_ci 89800b99b8Sopenharmony_ci/** 90800b99b8Sopenharmony_ci * @brief request dump stack about process 91800b99b8Sopenharmony_ci * @param pid process id 92800b99b8Sopenharmony_ci * @param tid thread id, if equal 0 means dump all the threads in a process. 93800b99b8Sopenharmony_ci * @return if succeed return 0 , otherwise return -1 94800b99b8Sopenharmony_ci*/ 95800b99b8Sopenharmony_ciint RequestSdkDumpJson(int32_t pid, int32_t tid, bool isJson, int timeout); 96800b99b8Sopenharmony_ci 97800b99b8Sopenharmony_ci/** 98800b99b8Sopenharmony_ci * @brief report sdk dump result to faultloggerd for stats collection 99800b99b8Sopenharmony_ci * @param request dump request result 100800b99b8Sopenharmony_ci*/ 101800b99b8Sopenharmony_ciint ReportDumpStats(const struct FaultLoggerdStatsRequest *request); 102800b99b8Sopenharmony_ci#ifdef __cplusplus 103800b99b8Sopenharmony_ci} 104800b99b8Sopenharmony_ci#endif 105800b99b8Sopenharmony_ci#endif 106