Blame sysdeps/generic/unwind.h

Packit 6c4009
/* Exception handling and frame unwind runtime interface routines.
Packit 6c4009
   Copyright (C) 2001-2018 Free Software Foundation, Inc.
Packit 6c4009
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
/* This is derived from the C++ ABI for IA-64.  Where we diverge
Packit 6c4009
   for cross-architecture compatibility are noted with "@@@".  */
Packit 6c4009
Packit 6c4009
#ifndef _UNWIND_H
Packit 6c4009
#define _UNWIND_H	1
Packit 6c4009
Packit 6c4009
#ifdef __cplusplus
Packit 6c4009
extern "C" {
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* Level 1: Base ABI  */
Packit 6c4009
Packit 6c4009
/* @@@ The IA-64 ABI uses uint64 throughout.  Most places this is
Packit 6c4009
   inefficient for 32-bit and smaller machines.  */
Packit 6c4009
typedef unsigned _Unwind_Word __attribute__((__mode__(__unwind_word__)));
Packit 6c4009
typedef signed _Unwind_Sword __attribute__((__mode__(__unwind_word__)));
Packit 6c4009
#if defined(__ia64__) && defined(__hpux__)
Packit 6c4009
typedef unsigned _Unwind_Ptr __attribute__((__mode__(__word__)));
Packit 6c4009
#else
Packit 6c4009
typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
Packit 6c4009
#endif
Packit 6c4009
typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__)));
Packit 6c4009
Packit 6c4009
/* @@@ The IA-64 ABI uses a 64-bit word to identify the producer and
Packit 6c4009
   consumer of an exception.  We'll go along with this for now even on
Packit 6c4009
   32-bit machines.  We'll need to provide some other option for
Packit 6c4009
   16-bit machines and for machines with > 8 bits per byte.  */
Packit 6c4009
typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__)));
Packit 6c4009
Packit 6c4009
/* The unwind interface uses reason codes in several contexts to
Packit 6c4009
   identify the reasons for failures or other actions.  */
Packit 6c4009
typedef enum
Packit 6c4009
{
Packit 6c4009
  _URC_NO_REASON = 0,
Packit 6c4009
  _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
Packit 6c4009
  _URC_FATAL_PHASE2_ERROR = 2,
Packit 6c4009
  _URC_FATAL_PHASE1_ERROR = 3,
Packit 6c4009
  _URC_NORMAL_STOP = 4,
Packit 6c4009
  _URC_END_OF_STACK = 5,
Packit 6c4009
  _URC_HANDLER_FOUND = 6,
Packit 6c4009
  _URC_INSTALL_CONTEXT = 7,
Packit 6c4009
  _URC_CONTINUE_UNWIND = 8
Packit 6c4009
} _Unwind_Reason_Code;
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* The unwind interface uses a pointer to an exception header object
Packit 6c4009
   as its representation of an exception being thrown. In general, the
Packit 6c4009
   full representation of an exception object is language- and
Packit 6c4009
   implementation-specific, but it will be prefixed by a header
Packit 6c4009
   understood by the unwind interface.  */
Packit 6c4009
Packit 6c4009
struct _Unwind_Exception;
Packit 6c4009
Packit 6c4009
typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code,
Packit 6c4009
					      struct _Unwind_Exception *);
Packit 6c4009
Packit 6c4009
struct _Unwind_Exception
Packit 6c4009
{
Packit 6c4009
  _Unwind_Exception_Class exception_class;
Packit 6c4009
  _Unwind_Exception_Cleanup_Fn exception_cleanup;
Packit 6c4009
  _Unwind_Word private_1;
Packit 6c4009
  _Unwind_Word private_2;
Packit 6c4009
Packit 6c4009
  /* @@@ The IA-64 ABI says that this structure must be double-word aligned.
Packit 6c4009
     Taking that literally does not make much sense generically.  Instead we
Packit 6c4009
     provide the maximum alignment required by any type for the machine.  */
Packit 6c4009
} __attribute__((__aligned__));
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* The ACTIONS argument to the personality routine is a bitwise OR of one
Packit 6c4009
   or more of the following constants.  */
Packit 6c4009
typedef int _Unwind_Action;
Packit 6c4009
Packit 6c4009
#define _UA_SEARCH_PHASE	1
Packit 6c4009
#define _UA_CLEANUP_PHASE	2
Packit 6c4009
#define _UA_HANDLER_FRAME	4
Packit 6c4009
#define _UA_FORCE_UNWIND	8
Packit 6c4009
#define _UA_END_OF_STACK	16
Packit 6c4009
Packit 6c4009
/* This is an opaque type used to refer to a system-specific data
Packit 6c4009
   structure used by the system unwinder. This context is created and
Packit 6c4009
   destroyed by the system, and passed to the personality routine
Packit 6c4009
   during unwinding.  */
Packit 6c4009
struct _Unwind_Context;
Packit 6c4009
Packit 6c4009
/* Raise an exception, passing along the given exception object.  */
Packit 6c4009
extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *);
Packit 6c4009
Packit 6c4009
/* Raise an exception for forced unwinding.  */
Packit 6c4009
Packit 6c4009
typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
Packit 6c4009
     (int, _Unwind_Action, _Unwind_Exception_Class,
Packit 6c4009
      struct _Unwind_Exception *, struct _Unwind_Context *, void *);
Packit 6c4009
Packit 6c4009
extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *,
Packit 6c4009
						 _Unwind_Stop_Fn,
Packit 6c4009
						 void *);
Packit 6c4009
Packit 6c4009
/* Helper to invoke the exception_cleanup routine.  */
Packit 6c4009
extern void _Unwind_DeleteException (struct _Unwind_Exception *);
Packit 6c4009
Packit 6c4009
/* Resume propagation of an existing exception.  This is used after
Packit 6c4009
   e.g. executing cleanup code, and not to implement rethrowing.  */
Packit 6c4009
extern void _Unwind_Resume (struct _Unwind_Exception *);
Packit 6c4009
Packit 6c4009
/* @@@ Use unwind data to perform a stack backtrace.  The trace callback
Packit 6c4009
   is called for every stack frame in the call chain, but no cleanup
Packit 6c4009
   actions are performed.  */
Packit 6c4009
typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)
Packit 6c4009
     (struct _Unwind_Context *, void *);
Packit 6c4009
Packit 6c4009
extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *);
Packit 6c4009
Packit 6c4009
/* These functions are used for communicating information about the unwind
Packit 6c4009
   context (i.e. the unwind descriptors and the user register state) between
Packit 6c4009
   the unwind library and the personality routine and landing pad.  Only
Packit 6c4009
   selected registers maybe manipulated.  */
Packit 6c4009
Packit 6c4009
extern _Unwind_Word _Unwind_GetGR (struct _Unwind_Context *, int);
Packit 6c4009
extern void _Unwind_SetGR (struct _Unwind_Context *, int, _Unwind_Word);
Packit 6c4009
Packit 6c4009
extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
Packit 6c4009
extern void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr);
Packit 6c4009
Packit 6c4009
/* @@@ Retrieve the CFA of the given context.  */
Packit 6c4009
extern _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
Packit 6c4009
Packit 6c4009
extern void *_Unwind_GetLanguageSpecificData (struct _Unwind_Context *);
Packit 6c4009
Packit 6c4009
extern _Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *);
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* The personality routine is the function in the C++ (or other language)
Packit 6c4009
   runtime library which serves as an interface between the system unwind
Packit 6c4009
   library and language-specific exception handling semantics.  It is
Packit 6c4009
   specific to the code fragment described by an unwind info block, and
Packit 6c4009
   it is always referenced via the pointer in the unwind info block, and
Packit 6c4009
   hence it has no ABI-specified name.
Packit 6c4009
Packit 6c4009
   Note that this implies that two different C++ implementations can
Packit 6c4009
   use different names, and have different contents in the language
Packit 6c4009
   specific data area.  Moreover, that the language specific data
Packit 6c4009
   area contains no version info because name of the function invoked
Packit 6c4009
   provides more effective versioning by detecting at link time the
Packit 6c4009
   lack of code to handle the different data format.  */
Packit 6c4009
Packit 6c4009
typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)
Packit 6c4009
     (int, _Unwind_Action, _Unwind_Exception_Class,
Packit 6c4009
      struct _Unwind_Exception *, struct _Unwind_Context *);
Packit 6c4009
Packit 6c4009
/* @@@ The following alternate entry points are for setjmp/longjmp
Packit 6c4009
   based unwinding.  */
Packit 6c4009
Packit 6c4009
struct SjLj_Function_Context;
Packit 6c4009
extern void _Unwind_SjLj_Register (struct SjLj_Function_Context *);
Packit 6c4009
extern void _Unwind_SjLj_Unregister (struct SjLj_Function_Context *);
Packit 6c4009
Packit 6c4009
extern _Unwind_Reason_Code _Unwind_SjLj_RaiseException
Packit 6c4009
     (struct _Unwind_Exception *);
Packit 6c4009
extern _Unwind_Reason_Code _Unwind_SjLj_ForcedUnwind
Packit 6c4009
     (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *);
Packit 6c4009
extern void _Unwind_SjLj_Resume (struct _Unwind_Exception *);
Packit 6c4009
Packit 6c4009
/* @@@ The following provide access to the base addresses for text
Packit 6c4009
   and data-relative addressing in the LDSA.  In order to stay link
Packit 6c4009
   compatible with the standard ABI for IA-64, we inline these.  */
Packit 6c4009
Packit 6c4009
#ifdef __ia64__
Packit 6c4009
#include <stdlib.h>
Packit 6c4009
Packit 6c4009
static inline _Unwind_Ptr
Packit 6c4009
_Unwind_GetDataRelBase (struct _Unwind_Context *_C)
Packit 6c4009
{
Packit 6c4009
  /* The GP is stored in R1.  */
Packit 6c4009
  return _Unwind_GetGR (_C, 1);
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
static inline _Unwind_Ptr
Packit 6c4009
_Unwind_GetTextRelBase (struct _Unwind_Context *_C)
Packit 6c4009
{
Packit 6c4009
  abort ();
Packit 6c4009
  return 0;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
/* @@@ Retrieve the Backing Store Pointer of the given context.  */
Packit 6c4009
extern _Unwind_Word _Unwind_GetBSP (struct _Unwind_Context *);
Packit 6c4009
#else
Packit 6c4009
extern _Unwind_Ptr _Unwind_GetDataRelBase (struct _Unwind_Context *);
Packit 6c4009
extern _Unwind_Ptr _Unwind_GetTextRelBase (struct _Unwind_Context *);
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* @@@ Given an address, return the entry point of the function that
Packit 6c4009
   contains it.  */
Packit 6c4009
extern void * _Unwind_FindEnclosingFunction (void *pc);
Packit 6c4009
Packit 6c4009
#ifdef __cplusplus
Packit 6c4009
}
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#endif	/* unwind.h */