143 lines · c
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//8// Extensions to libunwind API.9//10//===----------------------------------------------------------------------===//11 12#ifndef __LIBUNWIND_EXT__13#define __LIBUNWIND_EXT__14 15#include "config.h"16#include <libunwind.h>17#include <unwind.h>18 19#define UNW_STEP_SUCCESS 120#define UNW_STEP_END 021 22#ifdef __cplusplus23extern "C" {24#endif25 26extern int __unw_getcontext(unw_context_t *);27extern int __unw_init_local(unw_cursor_t *, unw_context_t *);28extern int __unw_step(unw_cursor_t *);29extern int __unw_get_reg(unw_cursor_t *, unw_regnum_t, unw_word_t *);30extern int __unw_get_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t *);31extern int __unw_set_reg(unw_cursor_t *, unw_regnum_t, unw_word_t);32extern int __unw_set_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t);33_LIBUNWIND_TRACE_NO_INLINE34 extern int __unw_resume_with_frames_walked(unw_cursor_t *, unsigned);35// `__unw_resume` is a legacy function. Use `__unw_resume_with_frames_walked` instead.36_LIBUNWIND_TRACE_NO_INLINE37 extern int __unw_resume(unw_cursor_t *);38 39#ifdef __arm__40/* Save VFP registers in FSTMX format (instead of FSTMD). */41extern void __unw_save_vfp_as_X(unw_cursor_t *);42#endif43 44extern const char *__unw_regname(unw_cursor_t *, unw_regnum_t);45extern int __unw_get_proc_info(unw_cursor_t *, unw_proc_info_t *);46extern int __unw_is_fpreg(unw_cursor_t *, unw_regnum_t);47extern int __unw_is_signal_frame(unw_cursor_t *);48extern int __unw_get_proc_name(unw_cursor_t *, char *, size_t, unw_word_t *);49extern const char *__unw_strerror(int);50 51#if defined(_AIX)52extern uintptr_t __unw_get_data_rel_base(unw_cursor_t *);53#endif54 55// SPI56extern void __unw_iterate_dwarf_unwind_cache(void (*func)(57 unw_word_t ip_start, unw_word_t ip_end, unw_word_t fde, unw_word_t mh));58 59// IPI60extern void __unw_add_dynamic_fde(unw_word_t fde);61extern void __unw_remove_dynamic_fde(unw_word_t fde);62 63extern void __unw_add_dynamic_eh_frame_section(unw_word_t eh_frame_start);64extern void __unw_remove_dynamic_eh_frame_section(unw_word_t eh_frame_start);65 66#ifdef __APPLE__67 68// Holds a description of the object-format-header (if any) and unwind info69// sections for a given address:70//71// * dso_base should point to a header for the JIT'd object containing the72// given address. The header's type should match the format type that73// libunwind was compiled for (so a mach_header or mach_header_64 on Darwin).74// A value of zero indicates that no such header exists.75//76// * dwarf_section and dwarf_section_length hold the address range of a DWARF77// eh-frame section associated with the given address, if any. If the78// dwarf_section_length field is zero it indicates that no such section79// exists (and in this case dwarf_section should also be set to zero).80//81// * compact_unwind_section and compact_unwind_section_length hold the address82// range of a compact-unwind info section associated with the given address,83// if any. If the compact_unwind_section_length field is zero it indicates84// that no such section exists (and in this case compact_unwind_section85// should also be set to zero).86//87// See the unw_find_dynamic_unwind_sections type below for more details.88struct unw_dynamic_unwind_sections {89 unw_word_t dso_base;90 unw_word_t dwarf_section;91 size_t dwarf_section_length;92 unw_word_t compact_unwind_section;93 size_t compact_unwind_section_length;94};95 96// Typedef for unwind-info lookup callbacks. Functions of this type can be97// registered and deregistered using __unw_add_find_dynamic_unwind_sections98// and __unw_remove_find_dynamic_unwind_sections respectively.99//100// An unwind-info lookup callback should return 1 to indicate that it found101// unwind-info for the given address, or 0 to indicate that it did not find102// unwind-info for the given address. If found, the callback should populate103// some or all of the fields of the info argument (which is guaranteed to be104// non-null with all fields zero-initialized):105typedef int (*unw_find_dynamic_unwind_sections)(106 unw_word_t addr, struct unw_dynamic_unwind_sections *info);107 108// Register a dynamic unwind-info lookup callback. If libunwind does not find109// unwind info for a given frame in the executable program or normal dynamic110// shared objects then it will call all registered dynamic lookup functions111// in registration order until either one of them returns true, or the end112// of the list is reached. This lookup will happen before libunwind searches113// any eh-frames registered via __register_frame or114// __unw_add_dynamic_eh_frame_section.115//116// Returns UNW_ESUCCESS for successful registrations. If the given callback117// has already been registered then UNW_EINVAL will be returned. If all118// available callback entries are in use then UNW_ENOMEM will be returned.119extern int __unw_add_find_dynamic_unwind_sections(120 unw_find_dynamic_unwind_sections find_dynamic_unwind_sections);121 122// Deregister a dynacim unwind-info lookup callback.123//124// Returns UNW_ESUCCESS for successful deregistrations. If the given callback125// has already been registered then UNW_EINVAL will be returned.126extern int __unw_remove_find_dynamic_unwind_sections(127 unw_find_dynamic_unwind_sections find_dynamic_unwind_sections);128 129#endif130 131#if defined(_LIBUNWIND_ARM_EHABI)132extern const uint32_t* decode_eht_entry(const uint32_t*, size_t*, size_t*);133extern _Unwind_Reason_Code _Unwind_VRS_Interpret(_Unwind_Context *context,134 const uint32_t *data,135 size_t offset, size_t len);136#endif137 138#ifdef __cplusplus139}140#endif141 142#endif // __LIBUNWIND_EXT__143