1 /* 2 * Copyright (c) 2022 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 16 #ifndef LIBUNWIND_I_OHOS_H 17 #define LIBUNWIND_I_OHOS_H 18 #include <inttypes.h> 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 #include "libunwind_i.h" 25 #include "map_info.h" 26 27 // Unwind using specific method 28 // target dependent 29 extern int uwn_step(unw_cursor_t *, int method); 30 // Get relative pc from cursor or calculate it 31 extern unw_word_t unw_get_rel_pc (unw_cursor_t *); 32 // We may want to get previous executed address, thus previous instruction size is needed 33 // target dependent 34 extern unw_word_t unw_get_previous_instr_sz(unw_cursor_t *); 35 // Get current associated map 36 extern struct map_info* unw_get_map (unw_cursor_t *); 37 // Get map info list of current unwind target 38 extern struct map_info* unw_get_maps (unw_cursor_t *); 39 // Loop the symbol table to find matched symbol 40 extern int unw_get_symbol_info(struct unw_cursor *cursor, uint64_t pc, int buf_sz, char *buf, uint64_t *sym_start, uint64_t *sym_end); 41 // Set unwind process id, for caching maps 42 extern void unw_set_target_pid(unw_addr_space_t as, int pid); 43 44 // Create caching maps for local uinwinding 45 extern void unw_init_local_address_space(unw_addr_space_t* as); 46 // Destory caching maps for local uinwinding 47 extern void unw_destroy_local_address_space(unw_addr_space_t as); 48 // Init cursor with other address space 49 extern int unw_init_local_with_as(unw_addr_space_t as, unw_cursor_t *cursor, unw_context_t *uc); 50 // Loop the symbol table to find matched symbol, only for local uinwinding 51 extern int unw_get_symbol_info_by_pc(unw_addr_space_t as, uint64_t pc, int buf_sz, char *buf, uint64_t *sym_start, uint64_t *sym_end); 52 53 #ifdef __cplusplus 54 } 55 #endif 56 #endif 57