Path: blob/main/contrib/llvm-project/libunwind/src/libunwind_ext.h
35148 views
//===----------------------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//7// Extensions to libunwind API.8//9//===----------------------------------------------------------------------===//1011#ifndef __LIBUNWIND_EXT__12#define __LIBUNWIND_EXT__1314#include "config.h"15#include <libunwind.h>16#include <unwind.h>1718#define UNW_STEP_SUCCESS 119#define UNW_STEP_END 02021#ifdef __cplusplus22extern "C" {23#endif2425extern int __unw_getcontext(unw_context_t *);26extern int __unw_init_local(unw_cursor_t *, unw_context_t *);27extern int __unw_step(unw_cursor_t *);28extern int __unw_get_reg(unw_cursor_t *, unw_regnum_t, unw_word_t *);29extern int __unw_get_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t *);30extern int __unw_set_reg(unw_cursor_t *, unw_regnum_t, unw_word_t);31extern int __unw_set_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t);32extern int __unw_resume(unw_cursor_t *);3334#ifdef __arm__35/* Save VFP registers in FSTMX format (instead of FSTMD). */36extern void __unw_save_vfp_as_X(unw_cursor_t *);37#endif3839extern const char *__unw_regname(unw_cursor_t *, unw_regnum_t);40extern int __unw_get_proc_info(unw_cursor_t *, unw_proc_info_t *);41extern int __unw_is_fpreg(unw_cursor_t *, unw_regnum_t);42extern int __unw_is_signal_frame(unw_cursor_t *);43extern int __unw_get_proc_name(unw_cursor_t *, char *, size_t, unw_word_t *);4445#if defined(_AIX)46extern uintptr_t __unw_get_data_rel_base(unw_cursor_t *);47#endif4849// SPI50extern void __unw_iterate_dwarf_unwind_cache(void (*func)(51unw_word_t ip_start, unw_word_t ip_end, unw_word_t fde, unw_word_t mh));5253// IPI54extern void __unw_add_dynamic_fde(unw_word_t fde);55extern void __unw_remove_dynamic_fde(unw_word_t fde);5657extern void __unw_add_dynamic_eh_frame_section(unw_word_t eh_frame_start);58extern void __unw_remove_dynamic_eh_frame_section(unw_word_t eh_frame_start);5960#ifdef __APPLE__6162// Holds a description of the object-format-header (if any) and unwind info63// sections for a given address:64//65// * dso_base should point to a header for the JIT'd object containing the66// given address. The header's type should match the format type that67// libunwind was compiled for (so a mach_header or mach_header_64 on Darwin).68// A value of zero indicates that no such header exists.69//70// * dwarf_section and dwarf_section_length hold the address range of a DWARF71// eh-frame section associated with the given address, if any. If the72// dwarf_section_length field is zero it indicates that no such section73// exists (and in this case dwarf_section should also be set to zero).74//75// * compact_unwind_section and compact_unwind_section_length hold the address76// range of a compact-unwind info section associated with the given address,77// if any. If the compact_unwind_section_length field is zero it indicates78// that no such section exists (and in this case compact_unwind_section79// should also be set to zero).80//81// See the unw_find_dynamic_unwind_sections type below for more details.82struct unw_dynamic_unwind_sections {83unw_word_t dso_base;84unw_word_t dwarf_section;85size_t dwarf_section_length;86unw_word_t compact_unwind_section;87size_t compact_unwind_section_length;88};8990// Typedef for unwind-info lookup callbacks. Functions of this type can be91// registered and deregistered using __unw_add_find_dynamic_unwind_sections92// and __unw_remove_find_dynamic_unwind_sections respectively.93//94// An unwind-info lookup callback should return 1 to indicate that it found95// unwind-info for the given address, or 0 to indicate that it did not find96// unwind-info for the given address. If found, the callback should populate97// some or all of the fields of the info argument (which is guaranteed to be98// non-null with all fields zero-initialized):99typedef int (*unw_find_dynamic_unwind_sections)(100unw_word_t addr, struct unw_dynamic_unwind_sections *info);101102// Register a dynamic unwind-info lookup callback. If libunwind does not find103// unwind info for a given frame in the executable program or normal dynamic104// shared objects then it will call all registered dynamic lookup functions105// in registration order until either one of them returns true, or the end106// of the list is reached. This lookup will happen before libunwind searches107// any eh-frames registered via __register_frame or108// __unw_add_dynamic_eh_frame_section.109//110// Returns UNW_ESUCCESS for successful registrations. If the given callback111// has already been registered then UNW_EINVAL will be returned. If all112// available callback entries are in use then UNW_ENOMEM will be returned.113extern int __unw_add_find_dynamic_unwind_sections(114unw_find_dynamic_unwind_sections find_dynamic_unwind_sections);115116// Deregister a dynacim unwind-info lookup callback.117//118// Returns UNW_ESUCCESS for successful deregistrations. If the given callback119// has already been registered then UNW_EINVAL will be returned.120extern int __unw_remove_find_dynamic_unwind_sections(121unw_find_dynamic_unwind_sections find_dynamic_unwind_sections);122123#endif124125#if defined(_LIBUNWIND_ARM_EHABI)126extern const uint32_t* decode_eht_entry(const uint32_t*, size_t*, size_t*);127extern _Unwind_Reason_Code _Unwind_VRS_Interpret(_Unwind_Context *context,128const uint32_t *data,129size_t offset, size_t len);130#endif131132#ifdef __cplusplus133}134#endif135136#endif // __LIBUNWIND_EXT__137138139