1 /* 2 * Copyright (c) 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 FFRT_API_C_FFRT_DUMP_H 16 #define FFRT_API_C_FFRT_DUMP_H 17 #include <stdint.h> 18 #include "type_def_ext.h" 19 20 #define MAX_TASK_NAME_LENGTH (64) 21 #define TASK_STAT_LENGTH (88) 22 23 typedef enum { 24 DUMP_INFO_ALL = 0, 25 DUMP_TASK_STATISTIC_INFO, 26 DUMP_START_STAT, 27 DUMP_STOP_STAT 28 } ffrt_dump_cmd_t; 29 30 typedef struct ffrt_stat { 31 char taskName[MAX_TASK_NAME_LENGTH]; 32 uint64_t funcPtr; 33 uint64_t startTime; 34 uint64_t endTime; 35 } ffrt_stat; 36 37 typedef void(*ffrt_task_timeout_cb)(uint64_t gid, const char *msg, uint32_t size); 38 39 /** 40 * @brief dump ffrt信息,包括task、queue、worker相关信息. 41 * 42 * @param cmd 命令类型: 43 * DUMP_INFO_ALL:表示输出所有信息 44 * DUMP_TASK_STATISTIC_INFO:输出任务统计信息 45 * @param buf 指向需要写入的buffer 46 * @param len buffer大小 47 * @return 写入buffer的字符数,不包含字符串的结尾符号\0 48 * 负数:表示操作未成功 49 * 0 : 未写入buffer 50 * 正数:成功写入buffer的字符数 51 * @约束: 52 * 1.buffer大小不足,ffrt记录信息不全(buffer用完则不再写入) 53 * @规格: 54 * 1.调用时机:业务、交互命令任意时机均可以调用 55 * 2.影响:该功能执行过程中、执行过后均不影响系统、业务功能 56 */ 57 FFRT_C_API int ffrt_dump(ffrt_dump_cmd_t cmd, char *buf, uint32_t len); 58 FFRT_C_API ffrt_task_timeout_cb ffrt_task_timeout_get_cb(void); 59 FFRT_C_API void ffrt_task_timeout_set_cb(ffrt_task_timeout_cb cb); 60 FFRT_C_API uint32_t ffrt_task_timeout_get_threshold(void); 61 FFRT_C_API void ffrt_task_timeout_set_threshold(uint32_t threshold_ms); 62 #endif /* FFRT_API_C_FFRT_DUMP_H */