1/* 2 * Copyright (c) 2021-2023 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 DFX_FAULTLOGGERD_CLIENT_H 16#define DFX_FAULTLOGGERD_CLIENT_H 17 18#include <inttypes.h> 19#include "dfx_socket_request.h" 20 21#ifdef __cplusplus 22extern "C" { 23#endif 24 25/** 26 * @brief Check connection status of client 27 * 28 * @return if available return true, otherwise return false 29*/ 30bool CheckConnectStatus(); 31/** 32 * @brief request file descriptor 33 * @param type type of resqust 34 * @return if succeed return file descriptor, otherwise return -1 35*/ 36int32_t RequestFileDescriptor(int32_t type); 37 38/** 39 * @brief request log file descriptor 40 * @param request struct of request information 41 * @return if succeed return file descriptor, otherwise return -1 42*/ 43int32_t RequestLogFileDescriptor(struct FaultLoggerdRequest *request); 44 45/** 46 * @brief request pipe file descriptor 47 * @param pid process id of request pipe 48 * @param pipeType type of request about pipe 49 * @return if succeed return file descriptor, otherwise return -1 50*/ 51int32_t RequestPipeFd(int32_t pid, int32_t pipeType); 52 53/** 54 * @brief request delete file descriptor 55 * @param pid process id of request pipe 56 * @return if succeed return 0, otherwise return -1 57*/ 58int32_t RequestDelPipeFd(int32_t pid); 59 60/** 61 * @brief request file descriptor 62 * @param request struct of request information 63 * @return if succeed return file descriptor, otherwise return -1 64*/ 65int RequestFileDescriptorEx(const struct FaultLoggerdRequest *request); 66 67/** 68 * @brief request checking permission of process 69 * @param pid process id 70 * @return if pass return true , otherwise return false 71*/ 72bool RequestCheckPermission(int32_t pid); 73/** 74 * @brief request printing message to hilog 75 * @param msg message 76 * @param length length of message 77 * @return if succeed return 0 , otherwise return -1 78*/ 79int RequestPrintTHilog(const char *msg, int length); 80 81/** 82 * @brief request dump stack about process 83 * @param pid process id 84 * @param tid thread id, if equal 0 means dump all the threads in a process. 85 * @return if succeed return 0 , otherwise return -1 86*/ 87int RequestSdkDump(int32_t pid, int32_t tid, int timeout = 10000); // 10000 : dump timeout ms 88 89/** 90 * @brief request dump stack about process 91 * @param pid process id 92 * @param tid thread id, if equal 0 means dump all the threads in a process. 93 * @return if succeed return 0 , otherwise return -1 94*/ 95int RequestSdkDumpJson(int32_t pid, int32_t tid, bool isJson, int timeout); 96 97/** 98 * @brief report sdk dump result to faultloggerd for stats collection 99 * @param request dump request result 100*/ 101int ReportDumpStats(const struct FaultLoggerdStatsRequest *request); 102#ifdef __cplusplus 103} 104#endif 105#endif 106