1fdf08e4bSIan Rogers /* SPDX-License-Identifier: GPL-2.0 */ 2fdf08e4bSIan Rogers #ifndef __LIBUNWIND_ARCH_H 3fdf08e4bSIan Rogers #define __LIBUNWIND_ARCH_H 4fdf08e4bSIan Rogers 588b4275fSIan Rogers #include <stdbool.h> 688b4275fSIan Rogers #include <stdint.h> 788b4275fSIan Rogers #include <stdlib.h> 888b4275fSIan Rogers 988b4275fSIan Rogers struct machine; 102723e9f8SIan Rogers struct maps; 1188b4275fSIan Rogers struct perf_sample; 1288b4275fSIan Rogers struct thread; 1388b4275fSIan Rogers 1488b4275fSIan Rogers struct unwind_info { 1588b4275fSIan Rogers struct machine *machine; 1688b4275fSIan Rogers struct thread *thread; 1788b4275fSIan Rogers struct perf_sample *sample; 1888b4275fSIan Rogers void *cursor; 1988b4275fSIan Rogers uint64_t *ips; 2088b4275fSIan Rogers int cur_ip; 2188b4275fSIan Rogers int max_ips; 2288b4275fSIan Rogers unsigned int unw_word_t_size; 2388b4275fSIan Rogers uint16_t e_machine; 2488b4275fSIan Rogers bool best_effort; 2588b4275fSIan Rogers }; 2688b4275fSIan Rogers 2788b4275fSIan Rogers struct libarch_unwind__dyn_info { 2888b4275fSIan Rogers uint64_t start_ip; 2988b4275fSIan Rogers uint64_t end_ip; 3088b4275fSIan Rogers uint64_t segbase; 3188b4275fSIan Rogers uint64_t table_data; 3288b4275fSIan Rogers uint64_t table_len; 3388b4275fSIan Rogers }; 3488b4275fSIan Rogers struct libarch_unwind__proc_info; 352723e9f8SIan Rogers 36fdf08e4bSIan Rogers int __get_perf_regnum_for_unw_regnum_arm(int unw_regnum); 37fdf08e4bSIan Rogers int __get_perf_regnum_for_unw_regnum_arm64(int unw_regnum); 38fdf08e4bSIan Rogers int __get_perf_regnum_for_unw_regnum_loongarch(int unw_regnum); 39fdf08e4bSIan Rogers int __get_perf_regnum_for_unw_regnum_mips(int unw_regnum); 40fdf08e4bSIan Rogers int __get_perf_regnum_for_unw_regnum_ppc32(int unw_regnum); 41fdf08e4bSIan Rogers int __get_perf_regnum_for_unw_regnum_ppc64(int unw_regnum); 42*834c5571SIan Rogers int __get_perf_regnum_for_unw_regnum_riscv(int unw_regnum); 43fdf08e4bSIan Rogers int __get_perf_regnum_for_unw_regnum_s390(int unw_regnum); 44fdf08e4bSIan Rogers int __get_perf_regnum_for_unw_regnum_i386(int unw_regnum); 45fdf08e4bSIan Rogers int __get_perf_regnum_for_unw_regnum_x86_64(int unw_regnum); 46fdf08e4bSIan Rogers int get_perf_regnum_for_unw_regnum(unsigned int e_machine, int unw_regnum); 47fdf08e4bSIan Rogers 482723e9f8SIan Rogers void __libunwind_arch__flush_access_arm(struct maps *maps); 492723e9f8SIan Rogers void __libunwind_arch__flush_access_arm64(struct maps *maps); 502723e9f8SIan Rogers void __libunwind_arch__flush_access_loongarch(struct maps *maps); 512723e9f8SIan Rogers void __libunwind_arch__flush_access_mips(struct maps *maps); 522723e9f8SIan Rogers void __libunwind_arch__flush_access_ppc32(struct maps *maps); 532723e9f8SIan Rogers void __libunwind_arch__flush_access_ppc64(struct maps *maps); 54*834c5571SIan Rogers void __libunwind_arch__flush_access_riscv(struct maps *maps); 552723e9f8SIan Rogers void __libunwind_arch__flush_access_s390(struct maps *maps); 562723e9f8SIan Rogers void __libunwind_arch__flush_access_i386(struct maps *maps); 572723e9f8SIan Rogers void __libunwind_arch__flush_access_x86_64(struct maps *maps); 582723e9f8SIan Rogers void libunwind_arch__flush_access(struct maps *maps); 592723e9f8SIan Rogers 602723e9f8SIan Rogers void __libunwind_arch__finish_access_arm(struct maps *maps); 612723e9f8SIan Rogers void __libunwind_arch__finish_access_arm64(struct maps *maps); 622723e9f8SIan Rogers void __libunwind_arch__finish_access_loongarch(struct maps *maps); 632723e9f8SIan Rogers void __libunwind_arch__finish_access_mips(struct maps *maps); 642723e9f8SIan Rogers void __libunwind_arch__finish_access_ppc32(struct maps *maps); 652723e9f8SIan Rogers void __libunwind_arch__finish_access_ppc64(struct maps *maps); 66*834c5571SIan Rogers void __libunwind_arch__finish_access_riscv(struct maps *maps); 672723e9f8SIan Rogers void __libunwind_arch__finish_access_s390(struct maps *maps); 682723e9f8SIan Rogers void __libunwind_arch__finish_access_i386(struct maps *maps); 692723e9f8SIan Rogers void __libunwind_arch__finish_access_x86_64(struct maps *maps); 702723e9f8SIan Rogers void libunwind_arch__finish_access(struct maps *maps); 712723e9f8SIan Rogers 7288b4275fSIan Rogers void *__libunwind_arch__create_addr_space_arm(void); 7388b4275fSIan Rogers void *__libunwind_arch__create_addr_space_arm64(void); 7488b4275fSIan Rogers void *__libunwind_arch__create_addr_space_loongarch(void); 7588b4275fSIan Rogers void *__libunwind_arch__create_addr_space_mips(void); 7688b4275fSIan Rogers void *__libunwind_arch__create_addr_space_ppc32(void); 7788b4275fSIan Rogers void *__libunwind_arch__create_addr_space_ppc64(void); 78*834c5571SIan Rogers void *__libunwind_arch__create_addr_space_riscv(void); 7988b4275fSIan Rogers void *__libunwind_arch__create_addr_space_s390(void); 8088b4275fSIan Rogers void *__libunwind_arch__create_addr_space_i386(void); 8188b4275fSIan Rogers void *__libunwind_arch__create_addr_space_x86_64(void); 8288b4275fSIan Rogers void *libunwind_arch__create_addr_space(unsigned int e_machine); 8388b4275fSIan Rogers 8488b4275fSIan Rogers int __libunwind__find_proc_info(void *as, uint64_t ip, void *pi, int need_unwind_info, void *arg); 8588b4275fSIan Rogers int __libunwind__access_mem(void *as, uint64_t addr, void *valp_word, int __write, void *arg); 8688b4275fSIan Rogers int __libunwind__access_reg(void *as, int regnum, void *valp_word, int __write, void *arg); 8788b4275fSIan Rogers 8888b4275fSIan Rogers int __libunwind_arch__dwarf_search_unwind_table_arm(void *as, uint64_t ip, 8988b4275fSIan Rogers struct libarch_unwind__dyn_info *di, 9088b4275fSIan Rogers void *pi, 9188b4275fSIan Rogers int need_unwind_info, 9288b4275fSIan Rogers void *arg); 9388b4275fSIan Rogers int __libunwind_arch__dwarf_search_unwind_table_arm64(void *as, uint64_t ip, 9488b4275fSIan Rogers struct libarch_unwind__dyn_info *di, 9588b4275fSIan Rogers void *pi, 9688b4275fSIan Rogers int need_unwind_info, 9788b4275fSIan Rogers void *arg); 9888b4275fSIan Rogers int __libunwind_arch__dwarf_search_unwind_table_loongarch(void *as, uint64_t ip, 9988b4275fSIan Rogers struct libarch_unwind__dyn_info *di, 10088b4275fSIan Rogers void *pi, 10188b4275fSIan Rogers int need_unwind_info, 10288b4275fSIan Rogers void *arg); 10388b4275fSIan Rogers int __libunwind_arch__dwarf_search_unwind_table_mips(void *as, uint64_t ip, 10488b4275fSIan Rogers struct libarch_unwind__dyn_info *di, 10588b4275fSIan Rogers void *pi, 10688b4275fSIan Rogers int need_unwind_info, 10788b4275fSIan Rogers void *arg); 10888b4275fSIan Rogers int __libunwind_arch__dwarf_search_unwind_table_ppc32(void *as, uint64_t ip, 10988b4275fSIan Rogers struct libarch_unwind__dyn_info *di, 11088b4275fSIan Rogers void *pi, 11188b4275fSIan Rogers int need_unwind_info, 11288b4275fSIan Rogers void *arg); 11388b4275fSIan Rogers int __libunwind_arch__dwarf_search_unwind_table_ppc64(void *as, uint64_t ip, 11488b4275fSIan Rogers struct libarch_unwind__dyn_info *di, 11588b4275fSIan Rogers void *pi, 11688b4275fSIan Rogers int need_unwind_info, 11788b4275fSIan Rogers void *arg); 118*834c5571SIan Rogers int __libunwind_arch__dwarf_search_unwind_table_riscv(void *as, uint64_t ip, 119*834c5571SIan Rogers struct libarch_unwind__dyn_info *di, 120*834c5571SIan Rogers void *pi, 121*834c5571SIan Rogers int need_unwind_info, 122*834c5571SIan Rogers void *arg); 12388b4275fSIan Rogers int __libunwind_arch__dwarf_search_unwind_table_s390(void *as, uint64_t ip, 12488b4275fSIan Rogers struct libarch_unwind__dyn_info *di, 12588b4275fSIan Rogers void *pi, 12688b4275fSIan Rogers int need_unwind_info, 12788b4275fSIan Rogers void *arg); 12888b4275fSIan Rogers int __libunwind_arch__dwarf_search_unwind_table_i386(void *as, uint64_t ip, 12988b4275fSIan Rogers struct libarch_unwind__dyn_info *di, 13088b4275fSIan Rogers void *pi, 13188b4275fSIan Rogers int need_unwind_info, 13288b4275fSIan Rogers void *arg); 13388b4275fSIan Rogers int __libunwind_arch__dwarf_search_unwind_table_x86_64(void *as, uint64_t ip, 13488b4275fSIan Rogers struct libarch_unwind__dyn_info *di, 13588b4275fSIan Rogers void *pi, 13688b4275fSIan Rogers int need_unwind_info, 13788b4275fSIan Rogers void *arg); 13888b4275fSIan Rogers int libunwind_arch__dwarf_search_unwind_table(unsigned int e_machine, 13988b4275fSIan Rogers void *as, 14088b4275fSIan Rogers uint64_t ip, 14188b4275fSIan Rogers struct libarch_unwind__dyn_info *di, 14288b4275fSIan Rogers void *pi, 14388b4275fSIan Rogers int need_unwind_info, 14488b4275fSIan Rogers void *arg); 14588b4275fSIan Rogers 14688b4275fSIan Rogers int __libunwind_arch__dwarf_find_debug_frame_arm(int found, 14788b4275fSIan Rogers struct libarch_unwind__dyn_info *di_debug, 14888b4275fSIan Rogers uint64_t ip, 14988b4275fSIan Rogers uint64_t segbase, 15088b4275fSIan Rogers const char *obj_name, 15188b4275fSIan Rogers uint64_t start, 15288b4275fSIan Rogers uint64_t end); 15388b4275fSIan Rogers int __libunwind_arch__dwarf_find_debug_frame_arm64(int found, 15488b4275fSIan Rogers struct libarch_unwind__dyn_info *di_debug, 15588b4275fSIan Rogers uint64_t ip, 15688b4275fSIan Rogers uint64_t segbase, 15788b4275fSIan Rogers const char *obj_name, 15888b4275fSIan Rogers uint64_t start, 15988b4275fSIan Rogers uint64_t end); 16088b4275fSIan Rogers int __libunwind_arch__dwarf_find_debug_frame_loongarch(int found, 16188b4275fSIan Rogers struct libarch_unwind__dyn_info *di_debug, 16288b4275fSIan Rogers uint64_t ip, 16388b4275fSIan Rogers uint64_t segbase, 16488b4275fSIan Rogers const char *obj_name, 16588b4275fSIan Rogers uint64_t start, 16688b4275fSIan Rogers uint64_t end); 16788b4275fSIan Rogers int __libunwind_arch__dwarf_find_debug_frame_mips(int found, 16888b4275fSIan Rogers struct libarch_unwind__dyn_info *di_debug, 16988b4275fSIan Rogers uint64_t ip, 17088b4275fSIan Rogers uint64_t segbase, 17188b4275fSIan Rogers const char *obj_name, 17288b4275fSIan Rogers uint64_t start, 17388b4275fSIan Rogers uint64_t end); 17488b4275fSIan Rogers int __libunwind_arch__dwarf_find_debug_frame_ppc32(int found, 17588b4275fSIan Rogers struct libarch_unwind__dyn_info *di_debug, 17688b4275fSIan Rogers uint64_t ip, 17788b4275fSIan Rogers uint64_t segbase, 17888b4275fSIan Rogers const char *obj_name, 17988b4275fSIan Rogers uint64_t start, 18088b4275fSIan Rogers uint64_t end); 18188b4275fSIan Rogers int __libunwind_arch__dwarf_find_debug_frame_ppc64(int found, 18288b4275fSIan Rogers struct libarch_unwind__dyn_info *di_debug, 18388b4275fSIan Rogers uint64_t ip, 18488b4275fSIan Rogers uint64_t segbase, 18588b4275fSIan Rogers const char *obj_name, 18688b4275fSIan Rogers uint64_t start, 18788b4275fSIan Rogers uint64_t end); 188*834c5571SIan Rogers int __libunwind_arch__dwarf_find_debug_frame_riscv(int found, 189*834c5571SIan Rogers struct libarch_unwind__dyn_info *di_debug, 190*834c5571SIan Rogers uint64_t ip, 191*834c5571SIan Rogers uint64_t segbase, 192*834c5571SIan Rogers const char *obj_name, 193*834c5571SIan Rogers uint64_t start, 194*834c5571SIan Rogers uint64_t end); 19588b4275fSIan Rogers int __libunwind_arch__dwarf_find_debug_frame_s390(int found, 19688b4275fSIan Rogers struct libarch_unwind__dyn_info *di_debug, 19788b4275fSIan Rogers uint64_t ip, 19888b4275fSIan Rogers uint64_t segbase, 19988b4275fSIan Rogers const char *obj_name, 20088b4275fSIan Rogers uint64_t start, 20188b4275fSIan Rogers uint64_t end); 20288b4275fSIan Rogers int __libunwind_arch__dwarf_find_debug_frame_i386(int found, 20388b4275fSIan Rogers struct libarch_unwind__dyn_info *di_debug, 20488b4275fSIan Rogers uint64_t ip, 20588b4275fSIan Rogers uint64_t segbase, 20688b4275fSIan Rogers const char *obj_name, 20788b4275fSIan Rogers uint64_t start, 20888b4275fSIan Rogers uint64_t end); 20988b4275fSIan Rogers int __libunwind_arch__dwarf_find_debug_frame_x86_64(int found, 21088b4275fSIan Rogers struct libarch_unwind__dyn_info *di_debug, 21188b4275fSIan Rogers uint64_t ip, 21288b4275fSIan Rogers uint64_t segbase, 21388b4275fSIan Rogers const char *obj_name, 21488b4275fSIan Rogers uint64_t start, 21588b4275fSIan Rogers uint64_t end); 21688b4275fSIan Rogers int libunwind_arch__dwarf_find_debug_frame(unsigned int e_machine, 21788b4275fSIan Rogers int found, 21888b4275fSIan Rogers struct libarch_unwind__dyn_info *di_debug, 21988b4275fSIan Rogers uint64_t ip, 22088b4275fSIan Rogers uint64_t segbase, 22188b4275fSIan Rogers const char *obj_name, 22288b4275fSIan Rogers uint64_t start, 22388b4275fSIan Rogers uint64_t end); 22488b4275fSIan Rogers 22588b4275fSIan Rogers struct unwind_info *__libunwind_arch_unwind_info__new_arm(struct thread *thread, 22688b4275fSIan Rogers struct perf_sample *sample, 22788b4275fSIan Rogers int max_stack, 22888b4275fSIan Rogers bool best_effort, 22988b4275fSIan Rogers uint64_t first_ip); 23088b4275fSIan Rogers struct unwind_info *__libunwind_arch_unwind_info__new_arm64(struct thread *thread, 23188b4275fSIan Rogers struct perf_sample *sample, 23288b4275fSIan Rogers int max_stack, 23388b4275fSIan Rogers bool best_effort, 23488b4275fSIan Rogers uint64_t first_ip); 23588b4275fSIan Rogers struct unwind_info *__libunwind_arch_unwind_info__new_loongarch(struct thread *thread, 23688b4275fSIan Rogers struct perf_sample *sample, 23788b4275fSIan Rogers int max_stack, 23888b4275fSIan Rogers bool best_effort, 23988b4275fSIan Rogers uint64_t first_ip); 24088b4275fSIan Rogers struct unwind_info *__libunwind_arch_unwind_info__new_mips(struct thread *thread, 24188b4275fSIan Rogers struct perf_sample *sample, 24288b4275fSIan Rogers int max_stack, 24388b4275fSIan Rogers bool best_effort, 24488b4275fSIan Rogers uint64_t first_ip); 24588b4275fSIan Rogers struct unwind_info *__libunwind_arch_unwind_info__new_ppc32(struct thread *thread, 24688b4275fSIan Rogers struct perf_sample *sample, 24788b4275fSIan Rogers int max_stack, 24888b4275fSIan Rogers bool best_effort, 24988b4275fSIan Rogers uint64_t first_ip); 25088b4275fSIan Rogers struct unwind_info *__libunwind_arch_unwind_info__new_ppc64(struct thread *thread, 25188b4275fSIan Rogers struct perf_sample *sample, 25288b4275fSIan Rogers int max_stack, 25388b4275fSIan Rogers bool best_effort, 25488b4275fSIan Rogers uint64_t first_ip); 255*834c5571SIan Rogers struct unwind_info *__libunwind_arch_unwind_info__new_riscv(struct thread *thread, 256*834c5571SIan Rogers struct perf_sample *sample, 257*834c5571SIan Rogers int max_stack, 258*834c5571SIan Rogers bool best_effort, 259*834c5571SIan Rogers uint64_t first_ip); 26088b4275fSIan Rogers struct unwind_info *__libunwind_arch_unwind_info__new_s390(struct thread *thread, 26188b4275fSIan Rogers struct perf_sample *sample, 26288b4275fSIan Rogers int max_stack, 26388b4275fSIan Rogers bool best_effort, 26488b4275fSIan Rogers uint64_t first_ip); 26588b4275fSIan Rogers struct unwind_info *__libunwind_arch_unwind_info__new_i386(struct thread *thread, 26688b4275fSIan Rogers struct perf_sample *sample, 26788b4275fSIan Rogers int max_stack, 26888b4275fSIan Rogers bool best_effort, 26988b4275fSIan Rogers uint64_t first_ip); 27088b4275fSIan Rogers struct unwind_info *__libunwind_arch_unwind_info__new_x86_64(struct thread *thread, 27188b4275fSIan Rogers struct perf_sample *sample, 27288b4275fSIan Rogers int max_stack, 27388b4275fSIan Rogers bool best_effort, 27488b4275fSIan Rogers uint64_t first_ip); 27588b4275fSIan Rogers struct unwind_info *libunwind_arch_unwind_info__new(struct thread *thread, 27688b4275fSIan Rogers struct perf_sample *sample, 27788b4275fSIan Rogers int max_stack, 27888b4275fSIan Rogers bool best_effort, 27988b4275fSIan Rogers uint16_t e_machine, 28088b4275fSIan Rogers uint64_t first_ip); 28188b4275fSIan Rogers 28288b4275fSIan Rogers void libunwind_arch_unwind_info__delete(struct unwind_info *ui); 28388b4275fSIan Rogers 28488b4275fSIan Rogers int __libunwind_arch__unwind_step_arm(struct unwind_info *ui); 28588b4275fSIan Rogers int __libunwind_arch__unwind_step_arm64(struct unwind_info *ui); 28688b4275fSIan Rogers int __libunwind_arch__unwind_step_loongarch(struct unwind_info *ui); 28788b4275fSIan Rogers int __libunwind_arch__unwind_step_mips(struct unwind_info *ui); 28888b4275fSIan Rogers int __libunwind_arch__unwind_step_ppc32(struct unwind_info *ui); 28988b4275fSIan Rogers int __libunwind_arch__unwind_step_ppc64(struct unwind_info *ui); 290*834c5571SIan Rogers int __libunwind_arch__unwind_step_riscv(struct unwind_info *ui); 29188b4275fSIan Rogers int __libunwind_arch__unwind_step_s390(struct unwind_info *ui); 29288b4275fSIan Rogers int __libunwind_arch__unwind_step_i386(struct unwind_info *ui); 29388b4275fSIan Rogers int __libunwind_arch__unwind_step_x86_64(struct unwind_info *ui); 29488b4275fSIan Rogers int libunwind_arch__unwind_step(struct unwind_info *ui); 29588b4275fSIan Rogers 296fdf08e4bSIan Rogers #endif /* __LIBUNWIND_ARCH_H */ 297