• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <stdint.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #include "libunwind_i.h"
26 #include "map_info.h"
27 
28 // set unwind context without modifing target memory
29 extern void unw_set_context(unw_cursor_t * cursor, uintptr_t regs[], int reg_sz);
30 // update adjust pc
31 extern void unw_set_adjust_pc(struct unw_cursor *cursor, uint64_t pc);
32 // Get relative pc from cursor or calculate it
33 extern unw_word_t unw_get_rel_pc (unw_cursor_t *);
34 // We may want to get previous executed address, thus previous instruction size is needed
35 // target dependent
36 extern unw_word_t unw_get_previous_instr_sz(unw_cursor_t *);
37 // Get current associated map
38 extern struct map_info* unw_get_map (unw_cursor_t *);
39 // Get map info list of current unwind target
40 extern struct map_info* unw_get_maps (unw_cursor_t *);
41 // Get build id from cached map info
42 extern bool unw_get_build_id(struct map_info* map, uint8_t** build_id_ptr, size_t* length);
43 // Get ark js heap crash info
44 extern int unw_get_ark_js_heap_crash_info(int pid, uintptr_t* x20, uintptr_t* fp, int out_js_info, char* buf, size_t buf_sz);
45 // Loop the symbol table to find matched symbol
46 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);
47 // Set unwind process id, for caching maps
48 extern void unw_set_target_pid(unw_addr_space_t as, int pid);
49 
50 // Create caching maps for local uinwinding
51 extern void unw_init_local_address_space(unw_addr_space_t* as);
52 // Destory caching maps for local uinwinding
53 extern void unw_destroy_local_address_space(unw_addr_space_t as);
54 // Init cursor with other address space
55 extern int unw_init_local_with_as(unw_addr_space_t as, unw_cursor_t *cursor, unw_context_t *uc);
56 // Loop the symbol table to find matched symbol, only for local uinwinding
57 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);
58 // Get library name associated to specific map
59 extern int unw_get_library_name_by_map (struct map_info* map, char *buf, int buf_sz);
60 
61 #ifdef __cplusplus
62 }
63 #endif
64 #endif
65