1 /* 2 * Copyright (c) 2024 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_ASYNC_STACK_H 16 #define DFX_ASYNC_STACK_H 17 18 #include <inttypes.h> 19 #include <unistd.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 // return stackId 26 uint64_t CollectAsyncStack(void); 27 28 // set stack id to TLS 29 void SetStackId(uint64_t stackId); 30 31 // get stack id from TLS 32 uint64_t GetStackId(void); 33 34 /** 35 * @brief get submitter stack in local case 36 * 37 * @param stackTrace stackTrace of submitter 38 * @param bufferSize buffer size of stackTrace 39 * @return if succeed return 0, otherwise return -1 40 */ 41 int DfxGetSubmitterStackLocal(char* stackTrace, size_t bufferSize); 42 43 #ifdef __cplusplus 44 } 45 #endif 46 #endif