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 20 #include "dfx_socket_request.h" 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 /** 27 * @brief request file descriptor 28 * @param type type of resqust 29 * @return if succeed return file descriptor, otherwise return -1 30 */ 31 int32_t RequestFileDescriptor(int32_t type); 32 33 /** 34 * @brief request pipe file descriptor 35 * @param pid process id of request pipe 36 * @param pipeType type of request about pipe 37 * @param pipeFd pipeFd[0] to transfer call stack message and 38 * pipeFd[1] to transfer backtrace result 39 * @return if succeed return 0, otherwise return -1 40 */ 41 int32_t RequestPipeFd(int32_t pid, int32_t pipeType, int (&pipeFd)[2]); 42 43 /** 44 * @brief request delete file descriptor 45 * @param pid process id of request pipe 46 * @return if succeed return 0, otherwise return the error code 47 */ 48 int32_t RequestDelPipeFd(int32_t pid); 49 50 /** 51 * @brief request file descriptor 52 * @param request struct of request information 53 * @return if succeed return file descriptor, otherwise return -1 54 */ 55 int32_t RequestFileDescriptorEx(struct FaultLoggerdRequest* request); 56 57 /** 58 * @brief request dump stack about process 59 * @param pid process id 60 * @param tid thread id, if equal 0 means dump all the threads in a process. 61 * @param pipeReadFd if pass sdkdump, will get pipeReadFd[0] to read call stack message and 62 * pipeReadFd[1] to read backtrace result 63 * @param isJson if set true, will get json format result, else get string result 64 * @return if succeed return 0 , otherwise return the error code 65 */ 66 int32_t RequestSdkDump(int32_t pid, int32_t tid, int (&pipeReadFd)[2], 67 bool isjson = false, int timeout = 10000); // 10000 : dump timeout ms 68 69 /** 70 * @brief report sdk dump result to faultloggerd for stats collection 71 * @param request dump request result 72 * @return if succeed return 0 , otherwise return the error code 73 */ 74 int32_t ReportDumpStats(struct FaultLoggerdStatsRequest *request); 75 #ifdef __cplusplus 76 } 77 #endif 78 #endif 79