sdk: C++ exeptions support

git-svn-id: svn://kolibrios.org@5963 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2015-12-14 17:41:20 +00:00
parent b340790ba4
commit b393c4e9d9
27 changed files with 3029 additions and 159 deletions

View File

@ -1,6 +1,5 @@
/* Definitions for Dwarf2 EH unwind support for Windows32 targets /* Definitions for Dwarf2 EH unwind support for Windows32 targets
Copyright (C) 2007, 2009 Copyright (C) 2007-2013 Free Software Foundation, Inc.
Free Software Foundation, Inc.
Contributed by Pascal Obry <obry@adacore.com> Contributed by Pascal Obry <obry@adacore.com>
This file is part of GCC. This file is part of GCC.
@ -130,7 +129,6 @@ i386_w32_fallback_frame_state (struct _Unwind_Context *context,
/* In the test below we look for two specific patterns found /* In the test below we look for two specific patterns found
experimentally to be in the Windows signal handler. */ experimentally to be in the Windows signal handler. */
if (SIG_PAT1 || SIG_PAT2 || SIG_SEH1 || SIG_SEH2) if (SIG_PAT1 || SIG_PAT2 || SIG_SEH1 || SIG_SEH2)
{ {
PEXCEPTION_POINTERS weinfo_; PEXCEPTION_POINTERS weinfo_;
@ -148,14 +146,12 @@ i386_w32_fallback_frame_state (struct _Unwind_Context *context,
} }
/* The new context frame address is the stack pointer. */ /* The new context frame address is the stack pointer. */
new_cfa_ = proc_ctx_->Esp; new_cfa_ = proc_ctx_->Esp;
fs->regs.cfa_how = CFA_REG_OFFSET; fs->regs.cfa_how = CFA_REG_OFFSET;
fs->regs.cfa_reg = __builtin_dwarf_sp_column(); fs->regs.cfa_reg = __builtin_dwarf_sp_column();
fs->regs.cfa_offset = new_cfa_ - (long) ctx_cfa_; fs->regs.cfa_offset = new_cfa_ - (long) ctx_cfa_;
/* Save some registers. */ /* Restore registers. */
fs->regs.reg[0].how = REG_SAVED_OFFSET; fs->regs.reg[0].how = REG_SAVED_OFFSET;
fs->regs.reg[0].loc.offset = (long)&proc_ctx_->Eax - new_cfa_; fs->regs.reg[0].loc.offset = (long)&proc_ctx_->Eax - new_cfa_;
fs->regs.reg[3].how = REG_SAVED_OFFSET; fs->regs.reg[3].how = REG_SAVED_OFFSET;
@ -168,18 +164,13 @@ i386_w32_fallback_frame_state (struct _Unwind_Context *context,
fs->regs.reg[6].loc.offset = (long)&proc_ctx_->Esi - new_cfa_; fs->regs.reg[6].loc.offset = (long)&proc_ctx_->Esi - new_cfa_;
fs->regs.reg[7].how = REG_SAVED_OFFSET; fs->regs.reg[7].how = REG_SAVED_OFFSET;
fs->regs.reg[7].loc.offset = (long)&proc_ctx_->Edi - new_cfa_; fs->regs.reg[7].loc.offset = (long)&proc_ctx_->Edi - new_cfa_;
fs->regs.reg[9].how = REG_SAVED_OFFSET; fs->regs.reg[5].how = REG_SAVED_OFFSET;
fs->regs.reg[9].loc.offset = (long)&proc_ctx_->Eip - new_cfa_; fs->regs.reg[5].loc.offset = (long)&proc_ctx_->Ebp - new_cfa_;
fs->regs.reg[4].how = REG_SAVED_OFFSET;
fs->regs.reg[4].loc.offset = (long)&proc_ctx_->Ebp - new_cfa_;
/* Set the return address to Eip + 1. As we can be called multiple
times we use another register for this. */
proc_ctx_->Dr0 = proc_ctx_->Eip + 1;
fs->regs.reg[8].how = REG_SAVED_OFFSET; fs->regs.reg[8].how = REG_SAVED_OFFSET;
fs->regs.reg[8].loc.offset = (long)&proc_ctx_->Dr0 - new_cfa_; fs->regs.reg[8].loc.offset = (long)&proc_ctx_->Eip - new_cfa_;
fs->retaddr_column = 8; fs->retaddr_column = 8;
fs->signal_frame = 1;
return _URC_NO_REASON; return _URC_NO_REASON;
} }
@ -187,7 +178,6 @@ i386_w32_fallback_frame_state (struct _Unwind_Context *context,
one of it's probes prior to the real SP adjustment. The only one of it's probes prior to the real SP adjustment. The only
operations of interest performed is "pushl %ecx", followed by operations of interest performed is "pushl %ecx", followed by
ecx clobbering. */ ecx clobbering. */
else if (SIG_ALLOCA) else if (SIG_ALLOCA)
{ {
/* Only one push between entry in _alloca and the probe trap. */ /* Only one push between entry in _alloca and the probe trap. */
@ -205,6 +195,7 @@ i386_w32_fallback_frame_state (struct _Unwind_Context *context,
fs->retaddr_column = 8; fs->retaddr_column = 8;
fs->regs.reg[8].how = REG_SAVED_OFFSET; fs->regs.reg[8].how = REG_SAVED_OFFSET;
fs->regs.reg[8].loc.offset = 0; fs->regs.reg[8].loc.offset = 0;
fs->signal_frame = 1;
return _URC_NO_REASON; return _URC_NO_REASON;
} }

View File

@ -1,7 +1,6 @@
/* Threads compatibility routines for libgcc2 and libobjc. */ /* Threads compatibility routines for libgcc2 and libobjc. */
/* Compile this one with gcc. */ /* Compile this one with gcc. */
/* Copyright (C) 1997, 1999, 2000, 2004, 2008, 2009 /* Copyright (C) 1997-2013 Free Software Foundation, Inc.
Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
@ -36,6 +35,7 @@ typedef int __gthread_recursive_mutex_t;
#define __GTHREAD_ONCE_INIT 0 #define __GTHREAD_ONCE_INIT 0
#define __GTHREAD_MUTEX_INIT 0 #define __GTHREAD_MUTEX_INIT 0
#define __GTHREAD_MUTEX_INIT_FUNCTION(mx)
#define __GTHREAD_RECURSIVE_MUTEX_INIT 0 #define __GTHREAD_RECURSIVE_MUTEX_INIT 0
#define UNUSED __attribute__((unused)) #define UNUSED __attribute__((unused))
@ -285,6 +285,12 @@ __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
return __gthread_mutex_unlock (__mutex); return __gthread_mutex_unlock (__mutex);
} }
static inline int
__gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
{
return __gthread_mutex_destroy (__mutex);
}
#endif /* _LIBOBJC */ #endif /* _LIBOBJC */
#undef UNUSED #undef UNUSED

View File

@ -1,6 +1,6 @@
/* Threads compatibility routines for libgcc2. */ /* Threads compatibility routines for libgcc2. */
/* Compile this one with gcc. */ /* Compile this one with gcc. */
/* Copyright (C) 1997, 1998, 2004, 2008, 2009 Free Software Foundation, Inc. /* Copyright (C) 1997-2013 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
@ -51,11 +51,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
to initialize __gthread_mutex_t to get a fast to initialize __gthread_mutex_t to get a fast
non-recursive mutex. non-recursive mutex.
__GTHREAD_MUTEX_INIT_FUNCTION __GTHREAD_MUTEX_INIT_FUNCTION
some systems can't initialize a mutex without a to initialize __gthread_mutex_t to get a fast
function call. On such systems, define this to a non-recursive mutex.
function which looks like this: Define this to a function which looks like this:
void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *) void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *)
Don't define __GTHREAD_MUTEX_INIT in this case Some systems can't initialize a mutex without a
function call. Don't define __GTHREAD_MUTEX_INIT in this case.
__GTHREAD_RECURSIVE_MUTEX_INIT __GTHREAD_RECURSIVE_MUTEX_INIT
__GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
as above, but for a recursive mutex. as above, but for a recursive mutex.
@ -71,6 +72,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
int __gthread_setspecific (__gthread_key_t key, const void *ptr) int __gthread_setspecific (__gthread_key_t key, const void *ptr)
int __gthread_mutex_destroy (__gthread_mutex_t *mutex); int __gthread_mutex_destroy (__gthread_mutex_t *mutex);
int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex);
int __gthread_mutex_lock (__gthread_mutex_t *mutex); int __gthread_mutex_lock (__gthread_mutex_t *mutex);
int __gthread_mutex_trylock (__gthread_mutex_t *mutex); int __gthread_mutex_trylock (__gthread_mutex_t *mutex);

View File

@ -1,5 +1,5 @@
/* Supporting functions for C exception handling. /* Supporting functions for C exception handling.
Copyright (C) 2002, 2003, 2009 Free Software Foundation, Inc. Copyright (C) 2002-2013 Free Software Foundation, Inc.
Contributed by Aldy Hernandez <aldy@quesejoda.com>. Contributed by Aldy Hernandez <aldy@quesejoda.com>.
Shamelessly stolen from the Java front end. Shamelessly stolen from the Java front end.
@ -93,6 +93,8 @@ parse_lsda_header (struct _Unwind_Context *context, const unsigned char *p,
#ifdef __USING_SJLJ_EXCEPTIONS__ #ifdef __USING_SJLJ_EXCEPTIONS__
#define PERSONALITY_FUNCTION __gcc_personality_sj0 #define PERSONALITY_FUNCTION __gcc_personality_sj0
#define __builtin_eh_return_data_regno(x) x #define __builtin_eh_return_data_regno(x) x
#elif defined(__SEH__)
#define PERSONALITY_FUNCTION __gcc_personality_imp
#else #else
#define PERSONALITY_FUNCTION __gcc_personality_v0 #define PERSONALITY_FUNCTION __gcc_personality_v0
#endif #endif
@ -107,6 +109,9 @@ PERSONALITY_FUNCTION (_Unwind_State state,
struct _Unwind_Exception * ue_header, struct _Unwind_Exception * ue_header,
struct _Unwind_Context * context) struct _Unwind_Context * context)
#else #else
#if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
static
#endif
_Unwind_Reason_Code _Unwind_Reason_Code
PERSONALITY_FUNCTION (int, _Unwind_Action, _Unwind_Exception_Class, PERSONALITY_FUNCTION (int, _Unwind_Action, _Unwind_Exception_Class,
struct _Unwind_Exception *, struct _Unwind_Context *); struct _Unwind_Exception *, struct _Unwind_Context *);
@ -130,10 +135,10 @@ PERSONALITY_FUNCTION (int version,
/* The dwarf unwinder assumes the context structure holds things like the /* The dwarf unwinder assumes the context structure holds things like the
function and LSDA pointers. The ARM implementation caches these in function and LSDA pointers. The ARM implementation caches these in
the exception header (UCB). To avoid rewriting everything we make the the exception header (UCB). To avoid rewriting everything we make a
virtual IP register point at the UCB. */ virtual scratch register point at the UCB. */
ip = (_Unwind_Ptr) ue_header; ip = (_Unwind_Ptr) ue_header;
_Unwind_SetGR (context, 12, ip); _Unwind_SetGR (context, UNWIND_POINTER_REG, ip);
#else #else
if (version != 1) if (version != 1)
return _URC_FATAL_PHASE1_ERROR; return _URC_FATAL_PHASE1_ERROR;
@ -227,3 +232,13 @@ PERSONALITY_FUNCTION (int version,
_Unwind_SetIP (context, landing_pad); _Unwind_SetIP (context, landing_pad);
return _URC_INSTALL_CONTEXT; return _URC_INSTALL_CONTEXT;
} }
#if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
EXCEPTION_DISPOSITION
__gcc_personality_seh0 (PEXCEPTION_RECORD ms_exc, void *this_frame,
PCONTEXT ms_orig_context, PDISPATCHER_CONTEXT ms_disp)
{
return _GCC_specific_handler (ms_exc, this_frame, ms_orig_context,
ms_disp, __gcc_personality_imp);
}
#endif /* SEH */

View File

@ -1,6 +1,5 @@
/* Subroutines needed for unwinding stack frames for exception handling. */ /* Subroutines needed for unwinding stack frames for exception handling. */
/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008, /* Copyright (C) 1997-2013 Free Software Foundation, Inc.
2009 Free Software Foundation, Inc.
Contributed by Jason Merrill <jason@cygnus.com>. Contributed by Jason Merrill <jason@cygnus.com>.
This file is part of GCC. This file is part of GCC.
@ -64,6 +63,8 @@ init_object_mutex_once (void)
__gthread_once (&once, init_object_mutex); __gthread_once (&once, init_object_mutex);
} }
#else #else
/* ??? Several targets include this file with stubbing parts of gthr.h
and expect no locking to be done. */
#define init_object_mutex_once() #define init_object_mutex_once()
#endif #endif
@ -227,7 +228,6 @@ __deregister_frame (void *begin)
free (__deregister_frame_info (begin)); free (__deregister_frame_info (begin));
} }
/* Like base_of_encoded_value, but take the base from a struct object /* Like base_of_encoded_value, but take the base from a struct object
instead of an _Unwind_Context. */ instead of an _Unwind_Context. */
@ -265,10 +265,18 @@ get_cie_encoding (const struct dwarf_cie *cie)
_sleb128_t stmp; _sleb128_t stmp;
aug = cie->augmentation; aug = cie->augmentation;
p = aug + strlen ((const char *)aug) + 1; /* Skip the augmentation string. */
if (__builtin_expect (cie->version >= 4, 0))
{
if (p[0] != sizeof (void *) || p[1] != 0)
return DW_EH_PE_omit; /* We are not prepared to handle unexpected
address sizes or segment selectors. */
p += 2; /* Skip address size and segment size. */
}
if (aug[0] != 'z') if (aug[0] != 'z')
return DW_EH_PE_absptr; return DW_EH_PE_absptr;
p = aug + strlen ((const char *)aug) + 1; /* Skip the augmentation string. */
p = read_uleb128 (p, &utmp); /* Skip code alignment. */ p = read_uleb128 (p, &utmp); /* Skip code alignment. */
p = read_sleb128 (p, &stmp); /* Skip data alignment. */ p = read_sleb128 (p, &stmp); /* Skip data alignment. */
if (cie->version == 1) /* Skip return address column. */ if (cie->version == 1) /* Skip return address column. */
@ -307,7 +315,7 @@ get_fde_encoding (const struct dwarf_fde *f)
return get_cie_encoding (get_cie (f)); return get_cie_encoding (get_cie (f));
} }
/* Sorting an array of FDEs by address. /* Sorting an array of FDEs by address.
(Ideally we would have the linker sort the FDEs so we don't have to do (Ideally we would have the linker sort the FDEs so we don't have to do
it at run time. But the linkers are not yet prepared for this.) */ it at run time. But the linkers are not yet prepared for this.) */
@ -614,6 +622,8 @@ classify_object_over_fdes (struct object *ob, const fde *this_fde)
{ {
last_cie = this_cie; last_cie = this_cie;
encoding = get_cie_encoding (this_cie); encoding = get_cie_encoding (this_cie);
if (encoding == DW_EH_PE_omit)
return -1;
base = base_from_object (encoding, ob); base = base_from_object (encoding, ob);
if (ob->s.b.encoding == DW_EH_PE_omit) if (ob->s.b.encoding == DW_EH_PE_omit)
ob->s.b.encoding = encoding; ob->s.b.encoding = encoding;
@ -723,10 +733,26 @@ init_object (struct object* ob)
{ {
fde **p = ob->u.array; fde **p = ob->u.array;
for (count = 0; *p; ++p) for (count = 0; *p; ++p)
count += classify_object_over_fdes (ob, *p); {
size_t cur_count = classify_object_over_fdes (ob, *p);
if (cur_count == (size_t) -1)
goto unhandled_fdes;
count += cur_count;
}
} }
else else
count = classify_object_over_fdes (ob, ob->u.single); {
count = classify_object_over_fdes (ob, ob->u.single);
if (count == (size_t) -1)
{
static const fde terminator;
unhandled_fdes:
ob->s.i = 0;
ob->s.b.encoding = DW_EH_PE_omit;
ob->u.single = &terminator;
return;
}
}
/* The count field we have in the main struct object is somewhat /* The count field we have in the main struct object is somewhat
limited, but should suffice for virtually all cases. If the limited, but should suffice for virtually all cases. If the

View File

@ -1,6 +1,5 @@
/* Subroutines needed for unwinding stack frames for exception handling. */ /* Subroutines needed for unwinding stack frames for exception handling. */
/* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2009 /* Copyright (C) 1997-2013 Free Software Foundation, Inc.
Free Software Foundation, Inc.
Contributed by Jason Merrill <jason@cygnus.com>. Contributed by Jason Merrill <jason@cygnus.com>.
This file is part of GCC. This file is part of GCC.

View File

@ -1,6 +1,5 @@
/* DWARF2 exception handling and frame unwind runtime interface routines. /* DWARF2 exception handling and frame unwind runtime interface routines.
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, Copyright (C) 1997-2013 Free Software Foundation, Inc.
2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
@ -55,12 +54,79 @@
#define DWARF_REG_TO_UNWIND_COLUMN(REGNO) (REGNO) #define DWARF_REG_TO_UNWIND_COLUMN(REGNO) (REGNO)
#endif #endif
/* ??? For the public function interfaces, we tend to gcc_assert that the
column numbers are in range. For the dwarf2 unwind info this does happen,
although so far in a case that doesn't actually matter.
See PR49146, in which a call from x86_64 ms abi to x86_64 unix abi stores
the call-saved xmm registers and annotates them. We havn't bothered
providing support for the xmm registers for the x86_64 port primarily
because the 64-bit windows targets don't use dwarf2 unwind, using sjlj or
SEH instead. Adding the support for unix targets would generally be a
waste. However, some runtime libraries supplied with ICC do contain such
an unorthodox transition, as well as the unwind info to match. This loss
of register restoration doesn't matter in practice, because the exception
is caught in the native unix abi, where all of the xmm registers are
call clobbered.
Ideally, we'd record some bit to notice when we're failing to restore some
register recorded in the unwind info, but to do that we need annotation on
the unix->ms abi edge, so that we know when the register data may be
discarded. And since this edge is also within the ICC library, we're
unlikely to be able to get the new annotation.
Barring a magic solution to restore the ms abi defined 128-bit xmm registers
(as distictly opposed to the full runtime width) without causing extra
overhead for normal unix abis, the best solution seems to be to simply
ignore unwind data for unknown columns. */
#define UNWIND_COLUMN_IN_RANGE(x) \
__builtin_expect((x) <= DWARF_FRAME_REGISTERS, 1)
#ifdef REG_VALUE_IN_UNWIND_CONTEXT
typedef _Unwind_Word _Unwind_Context_Reg_Val;
#ifndef ASSUME_EXTENDED_UNWIND_CONTEXT
#define ASSUME_EXTENDED_UNWIND_CONTEXT 1
#endif
static inline _Unwind_Word
_Unwind_Get_Unwind_Word (_Unwind_Context_Reg_Val val)
{
return val;
}
static inline _Unwind_Context_Reg_Val
_Unwind_Get_Unwind_Context_Reg_Val (_Unwind_Word val)
{
return val;
}
#else
typedef void *_Unwind_Context_Reg_Val;
static inline _Unwind_Word
_Unwind_Get_Unwind_Word (_Unwind_Context_Reg_Val val)
{
return (_Unwind_Word) (_Unwind_Internal_Ptr) val;
}
static inline _Unwind_Context_Reg_Val
_Unwind_Get_Unwind_Context_Reg_Val (_Unwind_Word val)
{
return (_Unwind_Context_Reg_Val) (_Unwind_Internal_Ptr) val;
}
#endif
#ifndef ASSUME_EXTENDED_UNWIND_CONTEXT
#define ASSUME_EXTENDED_UNWIND_CONTEXT 0
#endif
/* This is the register and unwind state for a particular frame. This /* This is the register and unwind state for a particular frame. This
provides the information necessary to unwind up past a frame and return provides the information necessary to unwind up past a frame and return
to its caller. */ to its caller. */
struct _Unwind_Context struct _Unwind_Context
{ {
void *reg[DWARF_FRAME_REGISTERS+1]; _Unwind_Context_Reg_Val reg[DWARF_FRAME_REGISTERS+1];
void *cfa; void *cfa;
void *ra; void *ra;
void *lsda; void *lsda;
@ -143,7 +209,8 @@ _Unwind_SetSignalFrame (struct _Unwind_Context *context, int val)
static inline _Unwind_Word static inline _Unwind_Word
_Unwind_IsExtendedContext (struct _Unwind_Context *context) _Unwind_IsExtendedContext (struct _Unwind_Context *context)
{ {
return context->flags & EXTENDED_CONTEXT_BIT; return (ASSUME_EXTENDED_UNWIND_CONTEXT
|| (context->flags & EXTENDED_CONTEXT_BIT));
} }
/* Get the value of register INDEX as saved in CONTEXT. */ /* Get the value of register INDEX as saved in CONTEXT. */
@ -152,7 +219,7 @@ inline _Unwind_Word
_Unwind_GetGR (struct _Unwind_Context *context, int index) _Unwind_GetGR (struct _Unwind_Context *context, int index)
{ {
int size; int size;
void *ptr; _Unwind_Context_Reg_Val val;
#ifdef DWARF_ZERO_REG #ifdef DWARF_ZERO_REG
if (index == DWARF_ZERO_REG) if (index == DWARF_ZERO_REG)
@ -162,18 +229,18 @@ _Unwind_GetGR (struct _Unwind_Context *context, int index)
index = DWARF_REG_TO_UNWIND_COLUMN (index); index = DWARF_REG_TO_UNWIND_COLUMN (index);
gcc_assert (index < (int) sizeof(dwarf_reg_size_table)); gcc_assert (index < (int) sizeof(dwarf_reg_size_table));
size = dwarf_reg_size_table[index]; size = dwarf_reg_size_table[index];
ptr = context->reg[index]; val = context->reg[index];
if (_Unwind_IsExtendedContext (context) && context->by_value[index]) if (_Unwind_IsExtendedContext (context) && context->by_value[index])
return (_Unwind_Word) (_Unwind_Internal_Ptr) ptr; return _Unwind_Get_Unwind_Word (val);
/* This will segfault if the register hasn't been saved. */ /* This will segfault if the register hasn't been saved. */
if (size == sizeof(_Unwind_Ptr)) if (size == sizeof(_Unwind_Ptr))
return * (_Unwind_Ptr *) ptr; return * (_Unwind_Ptr *) (_Unwind_Internal_Ptr) val;
else else
{ {
gcc_assert (size == sizeof(_Unwind_Word)); gcc_assert (size == sizeof(_Unwind_Word));
return * (_Unwind_Word *) ptr; return * (_Unwind_Word *) (_Unwind_Internal_Ptr) val;
} }
} }
@ -205,11 +272,11 @@ _Unwind_SetGR (struct _Unwind_Context *context, int index, _Unwind_Word val)
if (_Unwind_IsExtendedContext (context) && context->by_value[index]) if (_Unwind_IsExtendedContext (context) && context->by_value[index])
{ {
context->reg[index] = (void *) (_Unwind_Internal_Ptr) val; context->reg[index] = _Unwind_Get_Unwind_Context_Reg_Val (val);
return; return;
} }
ptr = context->reg[index]; ptr = (void *) (_Unwind_Internal_Ptr) context->reg[index];
if (size == sizeof(_Unwind_Ptr)) if (size == sizeof(_Unwind_Ptr))
* (_Unwind_Ptr *) ptr = val; * (_Unwind_Ptr *) ptr = val;
@ -228,7 +295,7 @@ _Unwind_GetGRPtr (struct _Unwind_Context *context, int index)
index = DWARF_REG_TO_UNWIND_COLUMN (index); index = DWARF_REG_TO_UNWIND_COLUMN (index);
if (_Unwind_IsExtendedContext (context) && context->by_value[index]) if (_Unwind_IsExtendedContext (context) && context->by_value[index])
return &context->reg[index]; return &context->reg[index];
return context->reg[index]; return (void *) (_Unwind_Internal_Ptr) context->reg[index];
} }
/* Set the pointer to a register INDEX as saved in CONTEXT. */ /* Set the pointer to a register INDEX as saved in CONTEXT. */
@ -239,7 +306,7 @@ _Unwind_SetGRPtr (struct _Unwind_Context *context, int index, void *p)
index = DWARF_REG_TO_UNWIND_COLUMN (index); index = DWARF_REG_TO_UNWIND_COLUMN (index);
if (_Unwind_IsExtendedContext (context)) if (_Unwind_IsExtendedContext (context))
context->by_value[index] = 0; context->by_value[index] = 0;
context->reg[index] = p; context->reg[index] = (_Unwind_Context_Reg_Val) (_Unwind_Internal_Ptr) p;
} }
/* Overwrite the saved value for register INDEX in CONTEXT with VAL. */ /* Overwrite the saved value for register INDEX in CONTEXT with VAL. */
@ -250,10 +317,11 @@ _Unwind_SetGRValue (struct _Unwind_Context *context, int index,
{ {
index = DWARF_REG_TO_UNWIND_COLUMN (index); index = DWARF_REG_TO_UNWIND_COLUMN (index);
gcc_assert (index < (int) sizeof(dwarf_reg_size_table)); gcc_assert (index < (int) sizeof(dwarf_reg_size_table));
gcc_assert (dwarf_reg_size_table[index] == sizeof (_Unwind_Ptr)); /* Return column size may be smaller than _Unwind_Context_Reg_Val. */
gcc_assert (dwarf_reg_size_table[index] <= sizeof (_Unwind_Context_Reg_Val));
context->by_value[index] = 1; context->by_value[index] = 1;
context->reg[index] = (void *) (_Unwind_Internal_Ptr) val; context->reg[index] = _Unwind_Get_Unwind_Context_Reg_Val (val);
} }
/* Return nonzero if register INDEX is stored by value rather than /* Return nonzero if register INDEX is stored by value rather than
@ -356,7 +424,16 @@ extract_cie_info (const struct dwarf_cie *cie, struct _Unwind_Context *context,
aug += 2; aug += 2;
} }
/* Immediately following the augmentation are the code and /* After the augmentation resp. pointer for "eh" augmentation
follows for CIE version >= 4 address size byte and
segment size byte. */
if (__builtin_expect (cie->version >= 4, 0))
{
if (p[0] != sizeof (void *) || p[1] != 0)
return NULL;
p += 2;
}
/* Immediately following this are the code and
data alignment and return address column. */ data alignment and return address column. */
p = read_uleb128 (p, &utmp); p = read_uleb128 (p, &utmp);
fs->code_align = (_Unwind_Word)utmp; fs->code_align = (_Unwind_Word)utmp;
@ -888,14 +965,19 @@ execute_cfa_program (const unsigned char *insn_ptr,
reg = insn & 0x3f; reg = insn & 0x3f;
insn_ptr = read_uleb128 (insn_ptr, &utmp); insn_ptr = read_uleb128 (insn_ptr, &utmp);
offset = (_Unwind_Sword) utmp * fs->data_align; offset = (_Unwind_Sword) utmp * fs->data_align;
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].how reg = DWARF_REG_TO_UNWIND_COLUMN (reg);
= REG_SAVED_OFFSET; if (UNWIND_COLUMN_IN_RANGE (reg))
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].loc.offset = offset; {
fs->regs.reg[reg].how = REG_SAVED_OFFSET;
fs->regs.reg[reg].loc.offset = offset;
}
} }
else if ((insn & 0xc0) == DW_CFA_restore) else if ((insn & 0xc0) == DW_CFA_restore)
{ {
reg = insn & 0x3f; reg = insn & 0x3f;
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].how = REG_UNSAVED; reg = DWARF_REG_TO_UNWIND_COLUMN (reg);
if (UNWIND_COLUMN_IN_RANGE (reg))
fs->regs.reg[reg].how = REG_UNSAVED;
} }
else switch (insn) else switch (insn)
{ {
@ -926,26 +1008,35 @@ execute_cfa_program (const unsigned char *insn_ptr,
insn_ptr = read_uleb128 (insn_ptr, &reg); insn_ptr = read_uleb128 (insn_ptr, &reg);
insn_ptr = read_uleb128 (insn_ptr, &utmp); insn_ptr = read_uleb128 (insn_ptr, &utmp);
offset = (_Unwind_Sword) utmp * fs->data_align; offset = (_Unwind_Sword) utmp * fs->data_align;
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].how reg = DWARF_REG_TO_UNWIND_COLUMN (reg);
= REG_SAVED_OFFSET; if (UNWIND_COLUMN_IN_RANGE (reg))
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].loc.offset = offset; {
fs->regs.reg[reg].how = REG_SAVED_OFFSET;
fs->regs.reg[reg].loc.offset = offset;
}
break; break;
case DW_CFA_restore_extended: case DW_CFA_restore_extended:
insn_ptr = read_uleb128 (insn_ptr, &reg); insn_ptr = read_uleb128 (insn_ptr, &reg);
/* FIXME, this is wrong; the CIE might have said that the /* FIXME, this is wrong; the CIE might have said that the
register was saved somewhere. */ register was saved somewhere. */
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN(reg)].how = REG_UNSAVED; reg = DWARF_REG_TO_UNWIND_COLUMN (reg);
if (UNWIND_COLUMN_IN_RANGE (reg))
fs->regs.reg[reg].how = REG_UNSAVED;
break; break;
case DW_CFA_same_value: case DW_CFA_same_value:
insn_ptr = read_uleb128 (insn_ptr, &reg); insn_ptr = read_uleb128 (insn_ptr, &reg);
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN(reg)].how = REG_UNSAVED; reg = DWARF_REG_TO_UNWIND_COLUMN (reg);
if (UNWIND_COLUMN_IN_RANGE (reg))
fs->regs.reg[reg].how = REG_UNSAVED;
break; break;
case DW_CFA_undefined: case DW_CFA_undefined:
insn_ptr = read_uleb128 (insn_ptr, &reg); insn_ptr = read_uleb128 (insn_ptr, &reg);
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN(reg)].how = REG_UNDEFINED; reg = DWARF_REG_TO_UNWIND_COLUMN (reg);
if (UNWIND_COLUMN_IN_RANGE (reg))
fs->regs.reg[reg].how = REG_UNDEFINED;
break; break;
case DW_CFA_nop: case DW_CFA_nop:
@ -956,9 +1047,12 @@ execute_cfa_program (const unsigned char *insn_ptr,
_uleb128_t reg2; _uleb128_t reg2;
insn_ptr = read_uleb128 (insn_ptr, &reg); insn_ptr = read_uleb128 (insn_ptr, &reg);
insn_ptr = read_uleb128 (insn_ptr, &reg2); insn_ptr = read_uleb128 (insn_ptr, &reg2);
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].how = REG_SAVED_REG; reg = DWARF_REG_TO_UNWIND_COLUMN (reg);
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].loc.reg = if (UNWIND_COLUMN_IN_RANGE (reg))
(_Unwind_Word)reg2; {
fs->regs.reg[reg].how = REG_SAVED_REG;
fs->regs.reg[reg].loc.reg = (_Unwind_Word)reg2;
}
} }
break; break;
@ -1016,8 +1110,12 @@ execute_cfa_program (const unsigned char *insn_ptr,
case DW_CFA_expression: case DW_CFA_expression:
insn_ptr = read_uleb128 (insn_ptr, &reg); insn_ptr = read_uleb128 (insn_ptr, &reg);
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].how = REG_SAVED_EXP; reg = DWARF_REG_TO_UNWIND_COLUMN (reg);
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].loc.exp = insn_ptr; if (UNWIND_COLUMN_IN_RANGE (reg))
{
fs->regs.reg[reg].how = REG_SAVED_EXP;
fs->regs.reg[reg].loc.exp = insn_ptr;
}
insn_ptr = read_uleb128 (insn_ptr, &utmp); insn_ptr = read_uleb128 (insn_ptr, &utmp);
insn_ptr += utmp; insn_ptr += utmp;
break; break;
@ -1027,9 +1125,12 @@ execute_cfa_program (const unsigned char *insn_ptr,
insn_ptr = read_uleb128 (insn_ptr, &reg); insn_ptr = read_uleb128 (insn_ptr, &reg);
insn_ptr = read_sleb128 (insn_ptr, &stmp); insn_ptr = read_sleb128 (insn_ptr, &stmp);
offset = stmp * fs->data_align; offset = stmp * fs->data_align;
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].how reg = DWARF_REG_TO_UNWIND_COLUMN (reg);
= REG_SAVED_OFFSET; if (UNWIND_COLUMN_IN_RANGE (reg))
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].loc.offset = offset; {
fs->regs.reg[reg].how = REG_SAVED_OFFSET;
fs->regs.reg[reg].loc.offset = offset;
}
break; break;
case DW_CFA_def_cfa_sf: case DW_CFA_def_cfa_sf:
@ -1052,36 +1153,46 @@ execute_cfa_program (const unsigned char *insn_ptr,
insn_ptr = read_uleb128 (insn_ptr, &reg); insn_ptr = read_uleb128 (insn_ptr, &reg);
insn_ptr = read_uleb128 (insn_ptr, &utmp); insn_ptr = read_uleb128 (insn_ptr, &utmp);
offset = (_Unwind_Sword) utmp * fs->data_align; offset = (_Unwind_Sword) utmp * fs->data_align;
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].how reg = DWARF_REG_TO_UNWIND_COLUMN (reg);
= REG_SAVED_VAL_OFFSET; if (UNWIND_COLUMN_IN_RANGE (reg))
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].loc.offset = offset; {
fs->regs.reg[reg].how = REG_SAVED_VAL_OFFSET;
fs->regs.reg[reg].loc.offset = offset;
}
break; break;
case DW_CFA_val_offset_sf: case DW_CFA_val_offset_sf:
insn_ptr = read_uleb128 (insn_ptr, &reg); insn_ptr = read_uleb128 (insn_ptr, &reg);
insn_ptr = read_sleb128 (insn_ptr, &stmp); insn_ptr = read_sleb128 (insn_ptr, &stmp);
offset = stmp * fs->data_align; offset = stmp * fs->data_align;
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].how reg = DWARF_REG_TO_UNWIND_COLUMN (reg);
= REG_SAVED_VAL_OFFSET; if (UNWIND_COLUMN_IN_RANGE (reg))
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].loc.offset = offset; {
fs->regs.reg[reg].how = REG_SAVED_VAL_OFFSET;
fs->regs.reg[reg].loc.offset = offset;
}
break; break;
case DW_CFA_val_expression: case DW_CFA_val_expression:
insn_ptr = read_uleb128 (insn_ptr, &reg); insn_ptr = read_uleb128 (insn_ptr, &reg);
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].how reg = DWARF_REG_TO_UNWIND_COLUMN (reg);
= REG_SAVED_VAL_EXP; if (UNWIND_COLUMN_IN_RANGE (reg))
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].loc.exp = insn_ptr; {
fs->regs.reg[reg].how = REG_SAVED_VAL_EXP;
fs->regs.reg[reg].loc.exp = insn_ptr;
}
insn_ptr = read_uleb128 (insn_ptr, &utmp); insn_ptr = read_uleb128 (insn_ptr, &utmp);
insn_ptr += utmp; insn_ptr += utmp;
break; break;
case DW_CFA_GNU_window_save: case DW_CFA_GNU_window_save:
/* ??? Hardcoded for SPARC register window configuration. */ /* ??? Hardcoded for SPARC register window configuration. */
for (reg = 16; reg < 32; ++reg) if (DWARF_FRAME_REGISTERS >= 32)
{ for (reg = 16; reg < 32; ++reg)
fs->regs.reg[reg].how = REG_SAVED_OFFSET; {
fs->regs.reg[reg].loc.offset = (reg - 16) * sizeof (void *); fs->regs.reg[reg].how = REG_SAVED_OFFSET;
} fs->regs.reg[reg].loc.offset = (reg - 16) * sizeof (void *);
}
break; break;
case DW_CFA_GNU_args_size: case DW_CFA_GNU_args_size:
@ -1095,9 +1206,12 @@ execute_cfa_program (const unsigned char *insn_ptr,
insn_ptr = read_uleb128 (insn_ptr, &reg); insn_ptr = read_uleb128 (insn_ptr, &reg);
insn_ptr = read_uleb128 (insn_ptr, &utmp); insn_ptr = read_uleb128 (insn_ptr, &utmp);
offset = (_Unwind_Word) utmp * fs->data_align; offset = (_Unwind_Word) utmp * fs->data_align;
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].how reg = DWARF_REG_TO_UNWIND_COLUMN (reg);
= REG_SAVED_OFFSET; if (UNWIND_COLUMN_IN_RANGE (reg))
fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].loc.offset = -offset; {
fs->regs.reg[reg].how = REG_SAVED_OFFSET;
fs->regs.reg[reg].loc.offset = -offset;
}
break; break;
default: default:
@ -1204,7 +1318,8 @@ __frame_state_for (void *pc_target, struct frame_state *state_in)
int reg; int reg;
memset (&context, 0, sizeof (struct _Unwind_Context)); memset (&context, 0, sizeof (struct _Unwind_Context));
context.flags = EXTENDED_CONTEXT_BIT; if (!ASSUME_EXTENDED_UNWIND_CONTEXT)
context.flags = EXTENDED_CONTEXT_BIT;
context.ra = pc_target + 1; context.ra = pc_target + 1;
if (uw_frame_state_for (&context, &fs) != _URC_NO_REASON) if (uw_frame_state_for (&context, &fs) != _URC_NO_REASON)
@ -1442,7 +1557,8 @@ uw_init_context_1 (struct _Unwind_Context *context,
memset (context, 0, sizeof (struct _Unwind_Context)); memset (context, 0, sizeof (struct _Unwind_Context));
context->ra = ra; context->ra = ra;
context->flags = EXTENDED_CONTEXT_BIT; if (!ASSUME_EXTENDED_UNWIND_CONTEXT)
context->flags = EXTENDED_CONTEXT_BIT;
code = uw_frame_state_for (context, &fs); code = uw_frame_state_for (context, &fs);
gcc_assert (code == _URC_NO_REASON); gcc_assert (code == _URC_NO_REASON);
@ -1484,7 +1600,13 @@ static void
_Unwind_DebugHook (void *cfa __attribute__ ((__unused__)), _Unwind_DebugHook (void *cfa __attribute__ ((__unused__)),
void *handler __attribute__ ((__unused__))) void *handler __attribute__ ((__unused__)))
{ {
/* We only want to use stap probes starting with v3. Earlier
versions added too much startup cost. */
#if defined (HAVE_SYS_SDT_H) && defined (STAP_PROBE2) && _SDT_NOTE_TYPE >= 3
STAP_PROBE2 (libgcc, unwind, cfa, handler);
#else
asm (""); asm ("");
#endif
} }
/* Install TARGET into CURRENT so that we can return to it. This is a /* Install TARGET into CURRENT so that we can return to it. This is a
@ -1515,8 +1637,8 @@ uw_install_context_1 (struct _Unwind_Context *current,
for (i = 0; i < DWARF_FRAME_REGISTERS; ++i) for (i = 0; i < DWARF_FRAME_REGISTERS; ++i)
{ {
void *c = current->reg[i]; void *c = (void *) (_Unwind_Internal_Ptr) current->reg[i];
void *t = target->reg[i]; void *t = (void *) (_Unwind_Internal_Ptr)target->reg[i];
gcc_assert (current->by_value[i] == 0); gcc_assert (current->by_value[i] == 0);
if (target->by_value[i] && c) if (target->by_value[i] && c)

View File

@ -1,6 +1,5 @@
/* DWARF2 frame unwind data structure. /* DWARF2 frame unwind data structure.
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2009 Copyright (C) 1997-2013 Free Software Foundation, Inc.
Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.

View File

@ -1,5 +1,5 @@
/* Exception handling and frame unwind runtime interface routines. /* Exception handling and frame unwind runtime interface routines.
Copyright (C) 2001, 2002, 2003, 2004, 2008, 2009 Free Software Foundation, Inc. Copyright (C) 2001-2013 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.

View File

@ -1,5 +1,5 @@
/* Exception handling and frame unwind runtime interface routines. -*- C -*- /* Exception handling and frame unwind runtime interface routines. -*- C -*-
Copyright (C) 2001, 2003, 2008, 2009 Free Software Foundation, Inc. Copyright (C) 2001-2013 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.

View File

@ -7,17 +7,20 @@ CPP= kos32-g++
STRIP = kos32-strip STRIP = kos32-strip
CFLAGS = -U_Win32 -U_WIN32 -U__MINGW32__ -c -O2 -fno-ident -fomit-frame-pointer CFLAGS = -U_Win32 -U_WIN32 -U__MINGW32__ -c -O2 -fno-ident -fomit-frame-pointer
CPPFLAGS = -fno-rtti
ARFLAGS= crs ARFLAGS= crs
INCLUDES= -I. -I../../newlib/libc/include INCLUDES= -I. -I../include/mingw32 -I../include -I../../newlib/libc/include -I/d/mingw/include
LIBS:= -ldll -lc.dll LIBS:= -ldll -lc.dll
DEFINES= -DHAVE_CONFIG_H -DIN_GCC -DUSE_EMUTLS=1 -D_GLIBCXX_HAVE_TLS DEFINES= -DHAVE_CONFIG_H -DIN_GCC -DIN_GLIBCPP_V3 -DUSE_EMUTLS=1 -D_GLIBCXX_HAVE_TLS
SOURCES = gthr_mutex.c \ SOURCES = \
cp-demangle.c \
gthr_mutex.c \
array_type_info.cc \ array_type_info.cc \
atexit_thread.cc \ atexit_thread.cc \
bad_alloc.cc \ bad_alloc.cc \
@ -81,22 +84,22 @@ $(LIBRARY).a: $(OBJECTS) Makefile
$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $< $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $<
%.o : %.cc Makefile %.o : %.cc Makefile
$(CPP) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $< $(CPP) $(CFLAGS) $(CPPFLAGS) $(DEFINES) $(INCLUDES) -o $@ $<
eh_ptr.o: eh_ptr.cc eh_ptr.o: eh_ptr.cc
$(CPP) $(CFLAGS) -std=gnu++0x $(DEFINES) $(INCLUDES) -o $@ $< $(CPP) $(CFLAGS) -std=gnu++0x $(CPPFLAGS) $(DEFINES) $(INCLUDES) -o $@ $<
eh_throw.o: eh_throw.cc eh_throw.o: eh_throw.cc
$(CPP) $(CFLAGS) -std=gnu++0x $(DEFINES) $(INCLUDES) -o $@ $< $(CPP) $(CFLAGS) -std=gnu++0x $(CPPFLAGS) $(DEFINES) $(INCLUDES) -o $@ $<
guard.o: guard.cc guard.o: guard.cc
$(CPP) $(CFLAGS) -std=gnu++0x $(DEFINES) $(INCLUDES) -o $@ $< $(CPP) $(CFLAGS) -std=gnu++0x $(CPPFLAGS) $(DEFINES) $(INCLUDES) -o $@ $<
atexit_thread.o: atexit_thread.cc atexit_thread.o: atexit_thread.cc
$(CPP) $(CFLAGS) -std=gnu++0x $(DEFINES) $(INCLUDES) -o $@ $< $(CPP) $(CFLAGS) -std=gnu++0x $(CPPFLAGS) $(DEFINES) $(INCLUDES) -o $@ $<
nested_exception.o: nested_exception.cc nested_exception.o: nested_exception.cc
$(CPP) $(CFLAGS) -std=gnu++0x $(DEFINES) $(INCLUDES) -o $@ $< $(CPP) $(CFLAGS) -std=gnu++0x $(CPPFLAGS) $(DEFINES) $(INCLUDES) -o $@ $<
clean: clean:
-rm -f *.o -rm -f *.o

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,169 @@
/* Internal demangler interface for g++ V3 ABI.
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010
Free Software Foundation, Inc.
Written by Ian Lance Taylor <ian@wasabisystems.com>.
This file is part of the libiberty library, which is part of GCC.
This file is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combined
executable.)
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
/* This file provides some definitions shared by cp-demangle.c and
cp-demint.c. It should not be included by any other files. */
/* Information we keep for operators. */
struct demangle_operator_info
{
/* Mangled name. */
const char *code;
/* Real name. */
const char *name;
/* Length of real name. */
int len;
/* Number of arguments. */
int args;
};
/* How to print the value of a builtin type. */
enum d_builtin_type_print
{
/* Print as (type)val. */
D_PRINT_DEFAULT,
/* Print as integer. */
D_PRINT_INT,
/* Print as unsigned integer, with trailing "u". */
D_PRINT_UNSIGNED,
/* Print as long, with trailing "l". */
D_PRINT_LONG,
/* Print as unsigned long, with trailing "ul". */
D_PRINT_UNSIGNED_LONG,
/* Print as long long, with trailing "ll". */
D_PRINT_LONG_LONG,
/* Print as unsigned long long, with trailing "ull". */
D_PRINT_UNSIGNED_LONG_LONG,
/* Print as bool. */
D_PRINT_BOOL,
/* Print as float--put value in square brackets. */
D_PRINT_FLOAT,
/* Print in usual way, but here to detect void. */
D_PRINT_VOID
};
/* Information we keep for a builtin type. */
struct demangle_builtin_type_info
{
/* Type name. */
const char *name;
/* Length of type name. */
int len;
/* Type name when using Java. */
const char *java_name;
/* Length of java name. */
int java_len;
/* How to print a value of this type. */
enum d_builtin_type_print print;
};
/* The information structure we pass around. */
struct d_info
{
/* The string we are demangling. */
const char *s;
/* The end of the string we are demangling. */
const char *send;
/* The options passed to the demangler. */
int options;
/* The next character in the string to consider. */
const char *n;
/* The array of components. */
struct demangle_component *comps;
/* The index of the next available component. */
int next_comp;
/* The number of available component structures. */
int num_comps;
/* The array of substitutions. */
struct demangle_component **subs;
/* The index of the next substitution. */
int next_sub;
/* The number of available entries in the subs array. */
int num_subs;
/* The number of substitutions which we actually made from the subs
array, plus the number of template parameter references we
saw. */
int did_subs;
/* The last name we saw, for constructors and destructors. */
struct demangle_component *last_name;
/* A running total of the length of large expansions from the
mangled name to the demangled name, such as standard
substitutions and builtin types. */
int expansion;
};
/* To avoid running past the ending '\0', don't:
- call d_peek_next_char if d_peek_char returned '\0'
- call d_advance with an 'i' that is too large
- call d_check_char(di, '\0')
Everything else is safe. */
#define d_peek_char(di) (*((di)->n))
#define d_peek_next_char(di) ((di)->n[1])
#define d_advance(di, i) ((di)->n += (i))
#define d_check_char(di, c) (d_peek_char(di) == c ? ((di)->n++, 1) : 0)
#define d_next_char(di) (d_peek_char(di) == '\0' ? '\0' : *((di)->n++))
#define d_str(di) ((di)->n)
/* Functions and arrays in cp-demangle.c which are referenced by
functions in cp-demint.c. */
#ifdef IN_GLIBCPP_V3
#define CP_STATIC_IF_GLIBCPP_V3 static
#else
#define CP_STATIC_IF_GLIBCPP_V3 extern
#endif
#ifndef IN_GLIBCPP_V3
extern const struct demangle_operator_info cplus_demangle_operators[];
#endif
#define D_BUILTIN_TYPE_COUNT (33)
CP_STATIC_IF_GLIBCPP_V3
const struct demangle_builtin_type_info
cplus_demangle_builtin_types[D_BUILTIN_TYPE_COUNT];
CP_STATIC_IF_GLIBCPP_V3
struct demangle_component *
cplus_demangle_mangled_name (struct d_info *, int);
CP_STATIC_IF_GLIBCPP_V3
struct demangle_component *
cplus_demangle_type (struct d_info *);
extern void
cplus_demangle_init_info (const char *, int, size_t, struct d_info *);
/* cp-demangle.c needs to define this a little differently */
#undef CP_STATIC_IF_GLIBCPP_V3

View File

@ -0,0 +1,671 @@
/* Defs for interface to demanglers.
Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002,
2003, 2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
In addition to the permissions in the GNU Library General Public
License, the Free Software Foundation gives you unlimited
permission to link the compiled version of this file into
combinations with other programs, and to distribute those
combinations without any restriction coming from the use of this
file. (The Library Public License restrictions do apply in other
respects; for example, they cover modification of the file, and
distribution when not linked into a combined executable.)
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
02110-1301, USA. */
#if !defined (DEMANGLE_H)
#define DEMANGLE_H
#include "libiberty.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Options passed to cplus_demangle (in 2nd parameter). */
#define DMGL_NO_OPTS 0 /* For readability... */
#define DMGL_PARAMS (1 << 0) /* Include function args */
#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */
#define DMGL_JAVA (1 << 2) /* Demangle as Java rather than C++. */
#define DMGL_VERBOSE (1 << 3) /* Include implementation details. */
#define DMGL_TYPES (1 << 4) /* Also try to demangle type encodings. */
#define DMGL_RET_POSTFIX (1 << 5) /* Print function return types (when
present) after function signature.
It applies only to the toplevel
function type. */
#define DMGL_RET_DROP (1 << 6) /* Suppress printing function return
types, even if present. It applies
only to the toplevel function type.
*/
#define DMGL_AUTO (1 << 8)
#define DMGL_GNU (1 << 9)
#define DMGL_LUCID (1 << 10)
#define DMGL_ARM (1 << 11)
#define DMGL_HP (1 << 12) /* For the HP aCC compiler;
same as ARM except for
template arguments, etc. */
#define DMGL_EDG (1 << 13)
#define DMGL_GNU_V3 (1 << 14)
#define DMGL_GNAT (1 << 15)
/* If none of these are set, use 'current_demangling_style' as the default. */
#define DMGL_STYLE_MASK (DMGL_AUTO|DMGL_GNU|DMGL_LUCID|DMGL_ARM|DMGL_HP|DMGL_EDG|DMGL_GNU_V3|DMGL_JAVA|DMGL_GNAT)
/* Enumeration of possible demangling styles.
Lucid and ARM styles are still kept logically distinct, even though
they now both behave identically. The resulting style is actual the
union of both. I.E. either style recognizes both "__pt__" and "__rf__"
for operator "->", even though the first is lucid style and the second
is ARM style. (FIXME?) */
extern enum demangling_styles
{
no_demangling = -1,
unknown_demangling = 0,
auto_demangling = DMGL_AUTO,
gnu_demangling = DMGL_GNU,
lucid_demangling = DMGL_LUCID,
arm_demangling = DMGL_ARM,
hp_demangling = DMGL_HP,
edg_demangling = DMGL_EDG,
gnu_v3_demangling = DMGL_GNU_V3,
java_demangling = DMGL_JAVA,
gnat_demangling = DMGL_GNAT
} current_demangling_style;
/* Define string names for the various demangling styles. */
#define NO_DEMANGLING_STYLE_STRING "none"
#define AUTO_DEMANGLING_STYLE_STRING "auto"
#define GNU_DEMANGLING_STYLE_STRING "gnu"
#define LUCID_DEMANGLING_STYLE_STRING "lucid"
#define ARM_DEMANGLING_STYLE_STRING "arm"
#define HP_DEMANGLING_STYLE_STRING "hp"
#define EDG_DEMANGLING_STYLE_STRING "edg"
#define GNU_V3_DEMANGLING_STYLE_STRING "gnu-v3"
#define JAVA_DEMANGLING_STYLE_STRING "java"
#define GNAT_DEMANGLING_STYLE_STRING "gnat"
/* Some macros to test what demangling style is active. */
#define CURRENT_DEMANGLING_STYLE current_demangling_style
#define AUTO_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_AUTO)
#define GNU_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU)
#define LUCID_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_LUCID)
#define ARM_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_ARM)
#define HP_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_HP)
#define EDG_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_EDG)
#define GNU_V3_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU_V3)
#define JAVA_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_JAVA)
#define GNAT_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNAT)
/* Provide information about the available demangle styles. This code is
pulled from gdb into libiberty because it is useful to binutils also. */
extern const struct demangler_engine
{
const char *const demangling_style_name;
const enum demangling_styles demangling_style;
const char *const demangling_style_doc;
} libiberty_demanglers[];
extern char *
cplus_demangle (const char *mangled, int options);
extern int
cplus_demangle_opname (const char *opname, char *result, int options);
extern const char *
cplus_mangle_opname (const char *opname, int options);
/* Note: This sets global state. FIXME if you care about multi-threading. */
extern void
set_cplus_marker_for_demangling (int ch);
extern enum demangling_styles
cplus_demangle_set_style (enum demangling_styles style);
extern enum demangling_styles
cplus_demangle_name_to_style (const char *name);
/* Callback typedef for allocation-less demangler interfaces. */
typedef void (*demangle_callbackref) (const char *, size_t, void *);
/* V3 ABI demangling entry points, defined in cp-demangle.c. Callback
variants return non-zero on success, zero on error. char* variants
return a string allocated by malloc on success, NULL on error. */
extern int
cplus_demangle_v3_callback (const char *mangled, int options,
demangle_callbackref callback, void *opaque);
extern char*
cplus_demangle_v3 (const char *mangled, int options);
extern int
java_demangle_v3_callback (const char *mangled,
demangle_callbackref callback, void *opaque);
extern char*
java_demangle_v3 (const char *mangled);
char *
ada_demangle (const char *mangled, int options);
enum gnu_v3_ctor_kinds {
gnu_v3_complete_object_ctor = 1,
gnu_v3_base_object_ctor,
gnu_v3_complete_object_allocating_ctor,
gnu_v3_object_ctor_group
};
/* Return non-zero iff NAME is the mangled form of a constructor name
in the G++ V3 ABI demangling style. Specifically, return an `enum
gnu_v3_ctor_kinds' value indicating what kind of constructor
it is. */
extern enum gnu_v3_ctor_kinds
is_gnu_v3_mangled_ctor (const char *name);
enum gnu_v3_dtor_kinds {
gnu_v3_deleting_dtor = 1,
gnu_v3_complete_object_dtor,
gnu_v3_base_object_dtor,
gnu_v3_object_dtor_group
};
/* Return non-zero iff NAME is the mangled form of a destructor name
in the G++ V3 ABI demangling style. Specifically, return an `enum
gnu_v3_dtor_kinds' value, indicating what kind of destructor
it is. */
extern enum gnu_v3_dtor_kinds
is_gnu_v3_mangled_dtor (const char *name);
/* The V3 demangler works in two passes. The first pass builds a tree
representation of the mangled name, and the second pass turns the
tree representation into a demangled string. Here we define an
interface to permit a caller to build their own tree
representation, which they can pass to the demangler to get a
demangled string. This can be used to canonicalize user input into
something which the demangler might output. It could also be used
by other demanglers in the future. */
/* These are the component types which may be found in the tree. Many
component types have one or two subtrees, referred to as left and
right (a component type with only one subtree puts it in the left
subtree). */
enum demangle_component_type
{
/* A name, with a length and a pointer to a string. */
DEMANGLE_COMPONENT_NAME,
/* A qualified name. The left subtree is a class or namespace or
some such thing, and the right subtree is a name qualified by
that class. */
DEMANGLE_COMPONENT_QUAL_NAME,
/* A local name. The left subtree describes a function, and the
right subtree is a name which is local to that function. */
DEMANGLE_COMPONENT_LOCAL_NAME,
/* A typed name. The left subtree is a name, and the right subtree
describes that name as a function. */
DEMANGLE_COMPONENT_TYPED_NAME,
/* A template. The left subtree is a template name, and the right
subtree is a template argument list. */
DEMANGLE_COMPONENT_TEMPLATE,
/* A template parameter. This holds a number, which is the template
parameter index. */
DEMANGLE_COMPONENT_TEMPLATE_PARAM,
/* A function parameter. This holds a number, which is the index. */
DEMANGLE_COMPONENT_FUNCTION_PARAM,
/* A constructor. This holds a name and the kind of
constructor. */
DEMANGLE_COMPONENT_CTOR,
/* A destructor. This holds a name and the kind of destructor. */
DEMANGLE_COMPONENT_DTOR,
/* A vtable. This has one subtree, the type for which this is a
vtable. */
DEMANGLE_COMPONENT_VTABLE,
/* A VTT structure. This has one subtree, the type for which this
is a VTT. */
DEMANGLE_COMPONENT_VTT,
/* A construction vtable. The left subtree is the type for which
this is a vtable, and the right subtree is the derived type for
which this vtable is built. */
DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE,
/* A typeinfo structure. This has one subtree, the type for which
this is the tpeinfo structure. */
DEMANGLE_COMPONENT_TYPEINFO,
/* A typeinfo name. This has one subtree, the type for which this
is the typeinfo name. */
DEMANGLE_COMPONENT_TYPEINFO_NAME,
/* A typeinfo function. This has one subtree, the type for which
this is the tpyeinfo function. */
DEMANGLE_COMPONENT_TYPEINFO_FN,
/* A thunk. This has one subtree, the name for which this is a
thunk. */
DEMANGLE_COMPONENT_THUNK,
/* A virtual thunk. This has one subtree, the name for which this
is a virtual thunk. */
DEMANGLE_COMPONENT_VIRTUAL_THUNK,
/* A covariant thunk. This has one subtree, the name for which this
is a covariant thunk. */
DEMANGLE_COMPONENT_COVARIANT_THUNK,
/* A Java class. This has one subtree, the type. */
DEMANGLE_COMPONENT_JAVA_CLASS,
/* A guard variable. This has one subtree, the name for which this
is a guard variable. */
DEMANGLE_COMPONENT_GUARD,
/* The init and wrapper functions for C++11 thread_local variables. */
DEMANGLE_COMPONENT_TLS_INIT,
DEMANGLE_COMPONENT_TLS_WRAPPER,
/* A reference temporary. This has one subtree, the name for which
this is a temporary. */
DEMANGLE_COMPONENT_REFTEMP,
/* A hidden alias. This has one subtree, the encoding for which it
is providing alternative linkage. */
DEMANGLE_COMPONENT_HIDDEN_ALIAS,
/* A standard substitution. This holds the name of the
substitution. */
DEMANGLE_COMPONENT_SUB_STD,
/* The restrict qualifier. The one subtree is the type which is
being qualified. */
DEMANGLE_COMPONENT_RESTRICT,
/* The volatile qualifier. The one subtree is the type which is
being qualified. */
DEMANGLE_COMPONENT_VOLATILE,
/* The const qualifier. The one subtree is the type which is being
qualified. */
DEMANGLE_COMPONENT_CONST,
/* The restrict qualifier modifying a member function. The one
subtree is the type which is being qualified. */
DEMANGLE_COMPONENT_RESTRICT_THIS,
/* The volatile qualifier modifying a member function. The one
subtree is the type which is being qualified. */
DEMANGLE_COMPONENT_VOLATILE_THIS,
/* The const qualifier modifying a member function. The one subtree
is the type which is being qualified. */
DEMANGLE_COMPONENT_CONST_THIS,
/* C++11 A reference modifying a member function. The one subtree is the
type which is being referenced. */
DEMANGLE_COMPONENT_REFERENCE_THIS,
/* C++11: An rvalue reference modifying a member function. The one
subtree is the type which is being referenced. */
DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS,
/* A vendor qualifier. The left subtree is the type which is being
qualified, and the right subtree is the name of the
qualifier. */
DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL,
/* A pointer. The one subtree is the type which is being pointed
to. */
DEMANGLE_COMPONENT_POINTER,
/* A reference. The one subtree is the type which is being
referenced. */
DEMANGLE_COMPONENT_REFERENCE,
/* C++0x: An rvalue reference. The one subtree is the type which is
being referenced. */
DEMANGLE_COMPONENT_RVALUE_REFERENCE,
/* A complex type. The one subtree is the base type. */
DEMANGLE_COMPONENT_COMPLEX,
/* An imaginary type. The one subtree is the base type. */
DEMANGLE_COMPONENT_IMAGINARY,
/* A builtin type. This holds the builtin type information. */
DEMANGLE_COMPONENT_BUILTIN_TYPE,
/* A vendor's builtin type. This holds the name of the type. */
DEMANGLE_COMPONENT_VENDOR_TYPE,
/* A function type. The left subtree is the return type. The right
subtree is a list of ARGLIST nodes. Either or both may be
NULL. */
DEMANGLE_COMPONENT_FUNCTION_TYPE,
/* An array type. The left subtree is the dimension, which may be
NULL, or a string (represented as DEMANGLE_COMPONENT_NAME), or an
expression. The right subtree is the element type. */
DEMANGLE_COMPONENT_ARRAY_TYPE,
/* A pointer to member type. The left subtree is the class type,
and the right subtree is the member type. CV-qualifiers appear
on the latter. */
DEMANGLE_COMPONENT_PTRMEM_TYPE,
/* A fixed-point type. */
DEMANGLE_COMPONENT_FIXED_TYPE,
/* A vector type. The left subtree is the number of elements,
the right subtree is the element type. */
DEMANGLE_COMPONENT_VECTOR_TYPE,
/* An argument list. The left subtree is the current argument, and
the right subtree is either NULL or another ARGLIST node. */
DEMANGLE_COMPONENT_ARGLIST,
/* A template argument list. The left subtree is the current
template argument, and the right subtree is either NULL or
another TEMPLATE_ARGLIST node. */
DEMANGLE_COMPONENT_TEMPLATE_ARGLIST,
/* An initializer list. The left subtree is either an explicit type or
NULL, and the right subtree is a DEMANGLE_COMPONENT_ARGLIST. */
DEMANGLE_COMPONENT_INITIALIZER_LIST,
/* An operator. This holds information about a standard
operator. */
DEMANGLE_COMPONENT_OPERATOR,
/* An extended operator. This holds the number of arguments, and
the name of the extended operator. */
DEMANGLE_COMPONENT_EXTENDED_OPERATOR,
/* A typecast, represented as a unary operator. The one subtree is
the type to which the argument should be cast. */
DEMANGLE_COMPONENT_CAST,
/* A nullary expression. The left subtree is the operator. */
DEMANGLE_COMPONENT_NULLARY,
/* A unary expression. The left subtree is the operator, and the
right subtree is the single argument. */
DEMANGLE_COMPONENT_UNARY,
/* A binary expression. The left subtree is the operator, and the
right subtree is a BINARY_ARGS. */
DEMANGLE_COMPONENT_BINARY,
/* Arguments to a binary expression. The left subtree is the first
argument, and the right subtree is the second argument. */
DEMANGLE_COMPONENT_BINARY_ARGS,
/* A trinary expression. The left subtree is the operator, and the
right subtree is a TRINARY_ARG1. */
DEMANGLE_COMPONENT_TRINARY,
/* Arguments to a trinary expression. The left subtree is the first
argument, and the right subtree is a TRINARY_ARG2. */
DEMANGLE_COMPONENT_TRINARY_ARG1,
/* More arguments to a trinary expression. The left subtree is the
second argument, and the right subtree is the third argument. */
DEMANGLE_COMPONENT_TRINARY_ARG2,
/* A literal. The left subtree is the type, and the right subtree
is the value, represented as a DEMANGLE_COMPONENT_NAME. */
DEMANGLE_COMPONENT_LITERAL,
/* A negative literal. Like LITERAL, but the value is negated.
This is a minor hack: the NAME used for LITERAL points directly
to the mangled string, but since negative numbers are mangled
using 'n' instead of '-', we want a way to indicate a negative
number which involves neither modifying the mangled string nor
allocating a new copy of the literal in memory. */
DEMANGLE_COMPONENT_LITERAL_NEG,
/* A libgcj compiled resource. The left subtree is the name of the
resource. */
DEMANGLE_COMPONENT_JAVA_RESOURCE,
/* A name formed by the concatenation of two parts. The left
subtree is the first part and the right subtree the second. */
DEMANGLE_COMPONENT_COMPOUND_NAME,
/* A name formed by a single character. */
DEMANGLE_COMPONENT_CHARACTER,
/* A number. */
DEMANGLE_COMPONENT_NUMBER,
/* A decltype type. */
DEMANGLE_COMPONENT_DECLTYPE,
/* Global constructors keyed to name. */
DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS,
/* Global destructors keyed to name. */
DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS,
/* A lambda closure type. */
DEMANGLE_COMPONENT_LAMBDA,
/* A default argument scope. */
DEMANGLE_COMPONENT_DEFAULT_ARG,
/* An unnamed type. */
DEMANGLE_COMPONENT_UNNAMED_TYPE,
/* A transactional clone. This has one subtree, the encoding for
which it is providing alternative linkage. */
DEMANGLE_COMPONENT_TRANSACTION_CLONE,
/* A non-transactional clone entry point. In the i386/x86_64 abi,
the unmangled symbol of a tm_callable becomes a thunk and the
non-transactional function version is mangled thus. */
DEMANGLE_COMPONENT_NONTRANSACTION_CLONE,
/* A pack expansion. */
DEMANGLE_COMPONENT_PACK_EXPANSION,
/* A name with an ABI tag. */
DEMANGLE_COMPONENT_TAGGED_NAME,
/* A cloned function. */
DEMANGLE_COMPONENT_CLONE
};
/* Types which are only used internally. */
struct demangle_operator_info;
struct demangle_builtin_type_info;
/* A node in the tree representation is an instance of a struct
demangle_component. Note that the field names of the struct are
not well protected against macros defined by the file including
this one. We can fix this if it ever becomes a problem. */
struct demangle_component
{
/* The type of this component. */
enum demangle_component_type type;
union
{
/* For DEMANGLE_COMPONENT_NAME. */
struct
{
/* A pointer to the name (which need not NULL terminated) and
its length. */
const char *s;
int len;
} s_name;
/* For DEMANGLE_COMPONENT_OPERATOR. */
struct
{
/* Operator. */
const struct demangle_operator_info *op;
} s_operator;
/* For DEMANGLE_COMPONENT_EXTENDED_OPERATOR. */
struct
{
/* Number of arguments. */
int args;
/* Name. */
struct demangle_component *name;
} s_extended_operator;
/* For DEMANGLE_COMPONENT_FIXED_TYPE. */
struct
{
/* The length, indicated by a C integer type name. */
struct demangle_component *length;
/* _Accum or _Fract? */
short accum;
/* Saturating or not? */
short sat;
} s_fixed;
/* For DEMANGLE_COMPONENT_CTOR. */
struct
{
/* Kind of constructor. */
enum gnu_v3_ctor_kinds kind;
/* Name. */
struct demangle_component *name;
} s_ctor;
/* For DEMANGLE_COMPONENT_DTOR. */
struct
{
/* Kind of destructor. */
enum gnu_v3_dtor_kinds kind;
/* Name. */
struct demangle_component *name;
} s_dtor;
/* For DEMANGLE_COMPONENT_BUILTIN_TYPE. */
struct
{
/* Builtin type. */
const struct demangle_builtin_type_info *type;
} s_builtin;
/* For DEMANGLE_COMPONENT_SUB_STD. */
struct
{
/* Standard substitution string. */
const char* string;
/* Length of string. */
int len;
} s_string;
/* For DEMANGLE_COMPONENT_*_PARAM. */
struct
{
/* Parameter index. */
long number;
} s_number;
/* For DEMANGLE_COMPONENT_CHARACTER. */
struct
{
int character;
} s_character;
/* For other types. */
struct
{
/* Left (or only) subtree. */
struct demangle_component *left;
/* Right subtree. */
struct demangle_component *right;
} s_binary;
struct
{
/* subtree, same place as d_left. */
struct demangle_component *sub;
/* integer. */
int num;
} s_unary_num;
} u;
};
/* People building mangled trees are expected to allocate instances of
struct demangle_component themselves. They can then call one of
the following functions to fill them in. */
/* Fill in most component types with a left subtree and a right
subtree. Returns non-zero on success, zero on failure, such as an
unrecognized or inappropriate component type. */
extern int
cplus_demangle_fill_component (struct demangle_component *fill,
enum demangle_component_type,
struct demangle_component *left,
struct demangle_component *right);
/* Fill in a DEMANGLE_COMPONENT_NAME. Returns non-zero on success,
zero for bad arguments. */
extern int
cplus_demangle_fill_name (struct demangle_component *fill,
const char *, int);
/* Fill in a DEMANGLE_COMPONENT_BUILTIN_TYPE, using the name of the
builtin type (e.g., "int", etc.). Returns non-zero on success,
zero if the type is not recognized. */
extern int
cplus_demangle_fill_builtin_type (struct demangle_component *fill,
const char *type_name);
/* Fill in a DEMANGLE_COMPONENT_OPERATOR, using the name of the
operator and the number of arguments which it takes (the latter is
used to disambiguate operators which can be both binary and unary,
such as '-'). Returns non-zero on success, zero if the operator is
not recognized. */
extern int
cplus_demangle_fill_operator (struct demangle_component *fill,
const char *opname, int args);
/* Fill in a DEMANGLE_COMPONENT_EXTENDED_OPERATOR, providing the
number of arguments and the name. Returns non-zero on success,
zero for bad arguments. */
extern int
cplus_demangle_fill_extended_operator (struct demangle_component *fill,
int numargs,
struct demangle_component *nm);
/* Fill in a DEMANGLE_COMPONENT_CTOR. Returns non-zero on success,
zero for bad arguments. */
extern int
cplus_demangle_fill_ctor (struct demangle_component *fill,
enum gnu_v3_ctor_kinds kind,
struct demangle_component *name);
/* Fill in a DEMANGLE_COMPONENT_DTOR. Returns non-zero on success,
zero for bad arguments. */
extern int
cplus_demangle_fill_dtor (struct demangle_component *fill,
enum gnu_v3_dtor_kinds kind,
struct demangle_component *name);
/* This function translates a mangled name into a struct
demangle_component tree. The first argument is the mangled name.
The second argument is DMGL_* options. This returns a pointer to a
tree on success, or NULL on failure. On success, the third
argument is set to a block of memory allocated by malloc. This
block should be passed to free when the tree is no longer
needed. */
extern struct demangle_component *
cplus_demangle_v3_components (const char *mangled, int options, void **mem);
/* This function takes a struct demangle_component tree and returns
the corresponding demangled string. The first argument is DMGL_*
options. The second is the tree to demangle. The third is a guess
at the length of the demangled string, used to initially allocate
the return buffer. The fourth is a pointer to a size_t. On
success, this function returns a buffer allocated by malloc(), and
sets the size_t pointed to by the fourth argument to the size of
the allocated buffer (not the length of the returned string). On
failure, this function returns NULL, and sets the size_t pointed to
by the fourth argument to 0 for an invalid tree, or to 1 for a
memory allocation error. */
extern char *
cplus_demangle_print (int options,
const struct demangle_component *tree,
int estimated_length,
size_t *p_allocated_size);
/* This function takes a struct demangle_component tree and passes back
a demangled string in one or more calls to a callback function.
The first argument is DMGL_* options. The second is the tree to
demangle. The third is a pointer to a callback function; on each call
this receives an element of the demangled string, its length, and an
opaque value. The fourth is the opaque value passed to the callback.
The callback is called once or more to return the full demangled
string. The demangled element string is always nul-terminated, though
its length is also provided for convenience. In contrast to
cplus_demangle_print(), this function does not allocate heap memory
to grow output strings (except perhaps where alloca() is implemented
by malloc()), and so is normally safe for use where the heap has been
corrupted. On success, this function returns 1; on failure, 0. */
extern int
cplus_demangle_print_callback (int options,
const struct demangle_component *tree,
demangle_callbackref callback, void *opaque);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* DEMANGLE_H */

View File

@ -100,7 +100,7 @@ __cxxabiv1::__cxa_rethrow ()
globals->caughtExceptions = 0; globals->caughtExceptions = 0;
else else
{ {
header->handlerCount = -header->handlerCount; header->handlerCount = -header->handlerCount;
// Only notify probe for C++ exceptions. // Only notify probe for C++ exceptions.
PROBE2 (rethrow, __get_object_from_ambiguous_exception(header), PROBE2 (rethrow, __get_object_from_ambiguous_exception(header),
header->exceptionType); header->exceptionType);

View File

@ -77,7 +77,7 @@ namespace std
// One past the last element. // One past the last element.
constexpr const_iterator constexpr const_iterator
end() const noexcept { return begin() + size(); } end() const noexcept { return begin() + size(); }
}; };
/** /**
* @brief Return an iterator pointing to the first element of * @brief Return an iterator pointing to the first element of

View File

@ -0,0 +1,686 @@
/* Function declarations for libiberty.
Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
Note - certain prototypes declared in this header file are for
functions whoes implementation copyright does not belong to the
FSF. Those prototypes are present in this file for reference
purposes only and their presence in this file should not construed
as an indication of ownership by the FSF of the implementation of
those functions in any way or form whatsoever.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor,
Boston, MA 02110-1301, USA.
Written by Cygnus Support, 1994.
The libiberty library provides a number of functions which are
missing on some operating systems. We do not declare those here,
to avoid conflicts with the system header files on operating
systems that do support those functions. In this file we only
declare those functions which are specific to libiberty. */
#ifndef LIBIBERTY_H
#define LIBIBERTY_H
#ifdef __cplusplus
extern "C" {
#endif
#include "ansidecl.h"
/* Get a definition for size_t. */
#include <stddef.h>
/* Get a definition for va_list. */
#include <stdarg.h>
#include <stdio.h>
/* If the OS supports it, ensure that the supplied stream is setup to
avoid any multi-threaded locking. Otherwise leave the FILE pointer
unchanged. If the stream is NULL do nothing. */
extern void unlock_stream (FILE *);
/* If the OS supports it, ensure that the standard I/O streams, stdin,
stdout and stderr are setup to avoid any multi-threaded locking.
Otherwise do nothing. */
extern void unlock_std_streams (void);
/* Open and return a FILE pointer. If the OS supports it, ensure that
the stream is setup to avoid any multi-threaded locking. Otherwise
return the FILE pointer unchanged. */
extern FILE *fopen_unlocked (const char *, const char *);
extern FILE *fdopen_unlocked (int, const char *);
extern FILE *freopen_unlocked (const char *, const char *, FILE *);
/* Build an argument vector from a string. Allocates memory using
malloc. Use freeargv to free the vector. */
extern char **buildargv (const char *) ATTRIBUTE_MALLOC;
/* Free a vector returned by buildargv. */
extern void freeargv (char **);
/* Duplicate an argument vector. Allocates memory using malloc. Use
freeargv to free the vector. */
extern char **dupargv (char **) ATTRIBUTE_MALLOC;
/* Expand "@file" arguments in argv. */
extern void expandargv PARAMS ((int *, char ***));
/* Write argv to an @-file, inserting necessary quoting. */
extern int writeargv PARAMS ((char **, FILE *));
/* Return the number of elements in argv. */
extern int countargv (char**);
/* Return the last component of a path name. Note that we can't use a
prototype here because the parameter is declared inconsistently
across different systems, sometimes as "char *" and sometimes as
"const char *" */
/* HAVE_DECL_* is a three-state macro: undefined, 0 or 1. If it is
undefined, we haven't run the autoconf check so provide the
declaration without arguments. If it is 0, we checked and failed
to find the declaration so provide a fully prototyped one. If it
is 1, we found it so don't provide any declaration at all. */
#if !HAVE_DECL_BASENAME
#if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined(__NetBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (__MINGW32__) || defined (HAVE_DECL_BASENAME)
extern char *basename (const char *);
#else
/* Do not allow basename to be used if there is no prototype seen. We
either need to use the above prototype or have one from
autoconf which would result in HAVE_DECL_BASENAME being set. */
#define basename basename_cannot_be_used_without_a_prototype
#endif
#endif
/* A well-defined basename () that is always compiled in. */
extern const char *lbasename (const char *);
/* Same, but assumes DOS semantics (drive name, backslash is also a
dir separator) regardless of host. */
extern const char *dos_lbasename (const char *);
/* Same, but assumes Unix semantics (absolute paths always start with
a slash, only forward slash is accepted as dir separator)
regardless of host. */
extern const char *unix_lbasename (const char *);
/* A well-defined realpath () that is always compiled in. */
extern char *lrealpath (const char *);
/* Concatenate an arbitrary number of strings. You must pass NULL as
the last argument of this function, to terminate the list of
strings. Allocates memory using xmalloc. */
extern char *concat (const char *, ...) ATTRIBUTE_MALLOC ATTRIBUTE_SENTINEL;
/* Concatenate an arbitrary number of strings. You must pass NULL as
the last argument of this function, to terminate the list of
strings. Allocates memory using xmalloc. The first argument is
not one of the strings to be concatenated, but if not NULL is a
pointer to be freed after the new string is created, similar to the
way xrealloc works. */
extern char *reconcat (char *, const char *, ...) ATTRIBUTE_MALLOC ATTRIBUTE_SENTINEL;
/* Determine the length of concatenating an arbitrary number of
strings. You must pass NULL as the last argument of this function,
to terminate the list of strings. */
extern unsigned long concat_length (const char *, ...) ATTRIBUTE_SENTINEL;
/* Concatenate an arbitrary number of strings into a SUPPLIED area of
memory. You must pass NULL as the last argument of this function,
to terminate the list of strings. The supplied memory is assumed
to be large enough. */
extern char *concat_copy (char *, const char *, ...) ATTRIBUTE_SENTINEL;
/* Concatenate an arbitrary number of strings into a GLOBAL area of
memory. You must pass NULL as the last argument of this function,
to terminate the list of strings. The supplied memory is assumed
to be large enough. */
extern char *concat_copy2 (const char *, ...) ATTRIBUTE_SENTINEL;
/* This is the global area used by concat_copy2. */
extern char *libiberty_concat_ptr;
/* Concatenate an arbitrary number of strings. You must pass NULL as
the last argument of this function, to terminate the list of
strings. Allocates memory using alloca. The arguments are
evaluated twice! */
#define ACONCAT(ACONCAT_PARAMS) \
(libiberty_concat_ptr = (char *) alloca (concat_length ACONCAT_PARAMS + 1), \
concat_copy2 ACONCAT_PARAMS)
/* Check whether two file descriptors refer to the same file. */
extern int fdmatch (int fd1, int fd2);
/* Return the position of the first bit set in the argument. */
/* Prototypes vary from system to system, so we only provide a
prototype on systems where we know that we need it. */
#if defined (HAVE_DECL_FFS) && !HAVE_DECL_FFS
extern int ffs(int);
#endif
/* Get the working directory. The result is cached, so don't call
chdir() between calls to getpwd(). */
extern char * getpwd (void);
/* Get the current time. */
/* Prototypes vary from system to system, so we only provide a
prototype on systems where we know that we need it. */
#ifdef __MINGW32__
/* Forward declaration to avoid #include <sys/time.h>. */
struct timeval;
extern int gettimeofday (struct timeval *, void *);
#endif
/* Get the amount of time the process has run, in microseconds. */
extern long get_run_time (void);
/* Generate a relocated path to some installation directory. Allocates
return value using malloc. */
extern char *make_relative_prefix (const char *, const char *,
const char *) ATTRIBUTE_MALLOC;
/* Generate a relocated path to some installation directory without
attempting to follow any soft links. Allocates
return value using malloc. */
extern char *make_relative_prefix_ignore_links (const char *, const char *,
const char *) ATTRIBUTE_MALLOC;
/* Choose a temporary directory to use for scratch files. */
extern char *choose_temp_base (void) ATTRIBUTE_MALLOC;
/* Return a temporary file name or NULL if unable to create one. */
extern char *make_temp_file (const char *) ATTRIBUTE_MALLOC;
/* Remove a link to a file unless it is special. */
extern int unlink_if_ordinary (const char *);
/* Allocate memory filled with spaces. Allocates using malloc. */
extern const char *spaces (int count);
/* Return the maximum error number for which strerror will return a
string. */
extern int errno_max (void);
/* Return the name of an errno value (e.g., strerrno (EINVAL) returns
"EINVAL"). */
extern const char *strerrno (int);
/* Given the name of an errno value, return the value. */
extern int strtoerrno (const char *);
/* ANSI's strerror(), but more robust. */
extern char *xstrerror (int);
/* Return the maximum signal number for which strsignal will return a
string. */
extern int signo_max (void);
/* Return a signal message string for a signal number
(e.g., strsignal (SIGHUP) returns something like "Hangup"). */
/* This is commented out as it can conflict with one in system headers.
We still document its existence though. */
/*extern const char *strsignal (int);*/
/* Return the name of a signal number (e.g., strsigno (SIGHUP) returns
"SIGHUP"). */
extern const char *strsigno (int);
/* Given the name of a signal, return its number. */
extern int strtosigno (const char *);
/* Register a function to be run by xexit. Returns 0 on success. */
extern int xatexit (void (*fn) (void));
/* Exit, calling all the functions registered with xatexit. */
extern void xexit (int status) ATTRIBUTE_NORETURN;
/* Set the program name used by xmalloc. */
extern void xmalloc_set_program_name (const char *);
/* Report an allocation failure. */
extern void xmalloc_failed (size_t) ATTRIBUTE_NORETURN;
/* Allocate memory without fail. If malloc fails, this will print a
message to stderr (using the name set by xmalloc_set_program_name,
if any) and then call xexit. */
extern void *xmalloc (size_t) ATTRIBUTE_MALLOC;
/* Reallocate memory without fail. This works like xmalloc. Note,
realloc type functions are not suitable for attribute malloc since
they may return the same address across multiple calls. */
extern void *xrealloc (void *, size_t);
/* Allocate memory without fail and set it to zero. This works like
xmalloc. */
extern void *xcalloc (size_t, size_t) ATTRIBUTE_MALLOC;
/* Copy a string into a memory buffer without fail. */
extern char *xstrdup (const char *) ATTRIBUTE_MALLOC;
/* Copy at most N characters from string into a buffer without fail. */
extern char *xstrndup (const char *, size_t) ATTRIBUTE_MALLOC;
/* Copy an existing memory buffer to a new memory buffer without fail. */
extern void *xmemdup (const void *, size_t, size_t) ATTRIBUTE_MALLOC;
/* Physical memory routines. Return values are in BYTES. */
extern double physmem_total (void);
extern double physmem_available (void);
/* Compute the 32-bit CRC of a block of memory. */
extern unsigned int xcrc32 (const unsigned char *, int, unsigned int);
/* These macros provide a K&R/C89/C++-friendly way of allocating structures
with nice encapsulation. The XDELETE*() macros are technically
superfluous, but provided here for symmetry. Using them consistently
makes it easier to update client code to use different allocators such
as new/delete and new[]/delete[]. */
/* Scalar allocators. */
#define XALLOCA(T) ((T *) alloca (sizeof (T)))
#define XNEW(T) ((T *) xmalloc (sizeof (T)))
#define XCNEW(T) ((T *) xcalloc (1, sizeof (T)))
#define XDUP(T, P) ((T *) xmemdup ((P), sizeof (T), sizeof (T)))
#define XDELETE(P) free ((void*) (P))
/* Array allocators. */
#define XALLOCAVEC(T, N) ((T *) alloca (sizeof (T) * (N)))
#define XNEWVEC(T, N) ((T *) xmalloc (sizeof (T) * (N)))
#define XCNEWVEC(T, N) ((T *) xcalloc ((N), sizeof (T)))
#define XDUPVEC(T, P, N) ((T *) xmemdup ((P), sizeof (T) * (N), sizeof (T) * (N)))
#define XRESIZEVEC(T, P, N) ((T *) xrealloc ((void *) (P), sizeof (T) * (N)))
#define XDELETEVEC(P) free ((void*) (P))
/* Allocators for variable-sized structures and raw buffers. */
#define XALLOCAVAR(T, S) ((T *) alloca ((S)))
#define XNEWVAR(T, S) ((T *) xmalloc ((S)))
#define XCNEWVAR(T, S) ((T *) xcalloc (1, (S)))
#define XDUPVAR(T, P, S1, S2) ((T *) xmemdup ((P), (S1), (S2)))
#define XRESIZEVAR(T, P, S) ((T *) xrealloc ((P), (S)))
/* Type-safe obstack allocator. */
#define XOBNEW(O, T) ((T *) obstack_alloc ((O), sizeof (T)))
#define XOBNEWVEC(O, T, N) ((T *) obstack_alloc ((O), sizeof (T) * (N)))
#define XOBNEWVAR(O, T, S) ((T *) obstack_alloc ((O), (S)))
#define XOBFINISH(O, T) ((T) obstack_finish ((O)))
/* hex character manipulation routines */
#define _hex_array_size 256
#define _hex_bad 99
extern const unsigned char _hex_value[_hex_array_size];
extern void hex_init (void);
#define hex_p(c) (hex_value (c) != _hex_bad)
/* If you change this, note well: Some code relies on side effects in
the argument being performed exactly once. */
#define hex_value(c) ((unsigned int) _hex_value[(unsigned char) (c)])
/* Flags for pex_init. These are bits to be or'ed together. */
/* Record subprocess times, if possible. */
#define PEX_RECORD_TIMES 0x1
/* Use pipes for communication between processes, if possible. */
#define PEX_USE_PIPES 0x2
/* Save files used for communication between processes. */
#define PEX_SAVE_TEMPS 0x4
/* Prepare to execute one or more programs, with standard output of
each program fed to standard input of the next.
FLAGS As above.
PNAME The name of the program to report in error messages.
TEMPBASE A base name to use for temporary files; may be NULL to
use a random name.
Returns NULL on error. */
extern struct pex_obj *pex_init (int flags, const char *pname,
const char *tempbase);
/* Flags for pex_run. These are bits to be or'ed together. */
/* Last program in pipeline. Standard output of program goes to
OUTNAME, or, if OUTNAME is NULL, to standard output of caller. Do
not set this if you want to call pex_read_output. After this is
set, pex_run may no longer be called with the same struct
pex_obj. */
#define PEX_LAST 0x1
/* Search for program in executable search path. */
#define PEX_SEARCH 0x2
/* OUTNAME is a suffix. */
#define PEX_SUFFIX 0x4
/* Send program's standard error to standard output. */
#define PEX_STDERR_TO_STDOUT 0x8
/* Input file should be opened in binary mode. This flag is ignored
on Unix. */
#define PEX_BINARY_INPUT 0x10
/* Output file should be opened in binary mode. This flag is ignored
on Unix. For proper behaviour PEX_BINARY_INPUT and
PEX_BINARY_OUTPUT have to match appropriately--i.e., a call using
PEX_BINARY_OUTPUT should be followed by a call using
PEX_BINARY_INPUT. */
#define PEX_BINARY_OUTPUT 0x20
/* Capture stderr to a pipe. The output can be read by
calling pex_read_err and reading from the returned
FILE object. This flag may be specified only for
the last program in a pipeline.
This flag is supported only on Unix and Windows. */
#define PEX_STDERR_TO_PIPE 0x40
/* Capture stderr in binary mode. This flag is ignored
on Unix. */
#define PEX_BINARY_ERROR 0x80
/* Execute one program. Returns NULL on success. On error returns an
error string (typically just the name of a system call); the error
string is statically allocated.
OBJ Returned by pex_init.
FLAGS As above.
EXECUTABLE The program to execute.
ARGV NULL terminated array of arguments to pass to the program.
OUTNAME Sets the output file name as follows:
PEX_SUFFIX set (OUTNAME may not be NULL):
TEMPBASE parameter to pex_init not NULL:
Output file name is the concatenation of TEMPBASE
and OUTNAME.
TEMPBASE is NULL:
Output file name is a random file name ending in
OUTNAME.
PEX_SUFFIX not set:
OUTNAME not NULL:
Output file name is OUTNAME.
OUTNAME NULL, TEMPBASE not NULL:
Output file name is randomly chosen using
TEMPBASE.
OUTNAME NULL, TEMPBASE NULL:
Output file name is randomly chosen.
If PEX_LAST is not set, the output file name is the
name to use for a temporary file holding stdout, if
any (there will not be a file if PEX_USE_PIPES is set
and the system supports pipes). If a file is used, it
will be removed when no longer needed unless
PEX_SAVE_TEMPS is set.
If PEX_LAST is set, and OUTNAME is not NULL, standard
output is written to the output file name. The file
will not be removed. If PEX_LAST and PEX_SUFFIX are
both set, TEMPBASE may not be NULL.
ERRNAME If not NULL, this is the name of a file to which
standard error is written. If NULL, standard error of
the program is standard error of the caller.
ERR On an error return, *ERR is set to an errno value, or
to 0 if there is no relevant errno.
*/
extern const char *pex_run (struct pex_obj *obj, int flags,
const char *executable, char * const *argv,
const char *outname, const char *errname,
int *err);
/* As for pex_run (), but takes an extra parameter to enable the
environment for the child process to be specified.
ENV The environment for the child process, specified as
an array of character pointers. Each element of the
array should point to a string of the form VAR=VALUE,
with the exception of the last element which must be
a null pointer.
*/
extern const char *pex_run_in_environment (struct pex_obj *obj, int flags,
const char *executable,
char * const *argv,
char * const *env,
const char *outname,
const char *errname, int *err);
/* Return a stream for a temporary file to pass to the first program
in the pipeline as input. The file name is chosen as for pex_run.
pex_run closes the file automatically; don't close it yourself. */
extern FILE *pex_input_file (struct pex_obj *obj, int flags,
const char *in_name);
/* Return a stream for a pipe connected to the standard input of the
first program in the pipeline. You must have passed
`PEX_USE_PIPES' to `pex_init'. Close the returned stream
yourself. */
extern FILE *pex_input_pipe (struct pex_obj *obj, int binary);
/* Read the standard output of the last program to be executed.
pex_run can not be called after this. BINARY should be non-zero if
the file should be opened in binary mode; this is ignored on Unix.
Returns NULL on error. Don't call fclose on the returned FILE; it
will be closed by pex_free. */
extern FILE *pex_read_output (struct pex_obj *, int binary);
/* Read the standard error of the last program to be executed.
pex_run can not be called after this. BINARY should be non-zero if
the file should be opened in binary mode; this is ignored on Unix.
Returns NULL on error. Don't call fclose on the returned FILE; it
will be closed by pex_free. */
extern FILE *pex_read_err (struct pex_obj *, int binary);
/* Return exit status of all programs in VECTOR. COUNT indicates the
size of VECTOR. The status codes in the vector are in the order of
the calls to pex_run. Returns 0 on error, 1 on success. */
extern int pex_get_status (struct pex_obj *, int count, int *vector);
/* Return times of all programs in VECTOR. COUNT indicates the size
of VECTOR. struct pex_time is really just struct timeval, but that
is not portable to all systems. Returns 0 on error, 1 on
success. */
struct pex_time
{
unsigned long user_seconds;
unsigned long user_microseconds;
unsigned long system_seconds;
unsigned long system_microseconds;
};
extern int pex_get_times (struct pex_obj *, int count,
struct pex_time *vector);
/* Clean up a pex_obj. If you have not called pex_get_times or
pex_get_status, this will try to kill the subprocesses. */
extern void pex_free (struct pex_obj *);
/* Just execute one program. Return value is as for pex_run.
FLAGS Combination of PEX_SEARCH and PEX_STDERR_TO_STDOUT.
EXECUTABLE As for pex_run.
ARGV As for pex_run.
PNAME As for pex_init.
OUTNAME As for pex_run when PEX_LAST is set.
ERRNAME As for pex_run.
STATUS Set to exit status on success.
ERR As for pex_run.
*/
extern const char *pex_one (int flags, const char *executable,
char * const *argv, const char *pname,
const char *outname, const char *errname,
int *status, int *err);
/* pexecute and pwait are the old pexecute interface, still here for
backward compatibility. Don't use these for new code. Instead,
use pex_init/pex_run/pex_get_status/pex_free, or pex_one. */
/* Definitions used by the pexecute routine. */
#define PEXECUTE_FIRST 1
#define PEXECUTE_LAST 2
#define PEXECUTE_ONE (PEXECUTE_FIRST + PEXECUTE_LAST)
#define PEXECUTE_SEARCH 4
#define PEXECUTE_VERBOSE 8
/* Execute a program. */
extern int pexecute (const char *, char * const *, const char *,
const char *, char **, char **, int);
/* Wait for pexecute to finish. */
extern int pwait (int, int *, int);
#if !HAVE_DECL_ASPRINTF
/* Like sprintf but provides a pointer to malloc'd storage, which must
be freed by the caller. */
extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
#endif
#if !HAVE_DECL_VASPRINTF
/* Like vsprintf but provides a pointer to malloc'd storage, which
must be freed by the caller. */
extern int vasprintf (char **, const char *, va_list) ATTRIBUTE_PRINTF(2,0);
#endif
#if defined(HAVE_DECL_SNPRINTF) && !HAVE_DECL_SNPRINTF
/* Like sprintf but prints at most N characters. */
extern int snprintf (char *, size_t, const char *, ...) ATTRIBUTE_PRINTF_3;
#endif
#if defined(HAVE_DECL_VSNPRINTF) && !HAVE_DECL_VSNPRINTF
/* Like vsprintf but prints at most N characters. */
extern int vsnprintf (char *, size_t, const char *, va_list) ATTRIBUTE_PRINTF(3,0);
#endif
#if defined(HAVE_DECL_STRVERSCMP) && !HAVE_DECL_STRVERSCMP
/* Compare version strings. */
extern int strverscmp (const char *, const char *);
#endif
/* Set the title of a process */
extern void setproctitle (const char *name, ...);
/* Increase stack limit if possible. */
extern void stack_limit_increase (unsigned long);
#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
/* Drastically simplified alloca configurator. If we're using GCC,
we use __builtin_alloca; otherwise we use the C alloca. The C
alloca is always available. You can override GCC by defining
USE_C_ALLOCA yourself. The canonical autoconf macro C_ALLOCA is
also set/unset as it is often used to indicate whether code needs
to call alloca(0). */
extern void *C_alloca (size_t) ATTRIBUTE_MALLOC;
#undef alloca
#if GCC_VERSION >= 2000 && !defined USE_C_ALLOCA
# define alloca(x) __builtin_alloca(x)
# undef C_ALLOCA
# define ASTRDUP(X) \
(__extension__ ({ const char *const libiberty_optr = (X); \
const unsigned long libiberty_len = strlen (libiberty_optr) + 1; \
char *const libiberty_nptr = (char *const) alloca (libiberty_len); \
(char *) memcpy (libiberty_nptr, libiberty_optr, libiberty_len); }))
#else
# define alloca(x) C_alloca(x)
# undef USE_C_ALLOCA
# define USE_C_ALLOCA 1
# undef C_ALLOCA
# define C_ALLOCA 1
extern const char *libiberty_optr;
extern char *libiberty_nptr;
extern unsigned long libiberty_len;
# define ASTRDUP(X) \
(libiberty_optr = (X), \
libiberty_len = strlen (libiberty_optr) + 1, \
libiberty_nptr = (char *) alloca (libiberty_len), \
(char *) memcpy (libiberty_nptr, libiberty_optr, libiberty_len))
#endif
#ifdef __cplusplus
}
#endif
#endif /* ! defined (LIBIBERTY_H) */

View File

@ -174,7 +174,7 @@ typedef enum {
} __cxa_type_match_result; } __cxa_type_match_result;
extern "C" __cxa_type_match_result __cxa_type_match(_Unwind_Exception*, extern "C" __cxa_type_match_result __cxa_type_match(_Unwind_Exception*,
const std::type_info*, const std::type_info*,
bool, void**); bool, void**);
extern "C" bool __cxa_begin_cleanup (_Unwind_Exception*); extern "C" bool __cxa_begin_cleanup (_Unwind_Exception*);
extern "C" void __cxa_end_cleanup (void); extern "C" void __cxa_end_cleanup (void);
#endif #endif

View File

@ -47,7 +47,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
if (terminating) if (terminating)
{ {
fputs("terminate called recursively\n", stderr); fputs("terminate called recursively\n", stderr);
abort (); abort ();
} }
terminating = true; terminating = true;
@ -62,7 +62,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
int status = -1; int status = -1;
char *dem = 0; char *dem = 0;
// dem = __cxa_demangle(name, 0, 0, &status); dem = __cxa_demangle(name, 0, 0, &status);
fputs("terminate called after throwing an instance of '", stderr); fputs("terminate called after throwing an instance of '", stderr);
if (status == 0) if (status == 0)

View File

@ -79,6 +79,12 @@ SECTIONS
___iend = . ; ___iend = . ;
} }
.eh_frame BLOCK(16) :
{
PROVIDE (___EH_FRAME_BEGIN__ = .) ;
*(.eh_frame*)
}
.idata ALIGN(16): .idata ALIGN(16):
{ {
__idata_start = .; __idata_start = .;
@ -113,7 +119,6 @@ SECTIONS
*(.debug$F) *(.debug$F)
*(.drectve) *(.drectve)
*(.note.GNU-stack) *(.note.GNU-stack)
*(.eh_frame)
*(.comment) *(.comment)
*(.debug_abbrev) *(.debug_abbrev)
*(.debug_info) *(.debug_info)

View File

@ -3,7 +3,7 @@ CC = kos32-gcc
AR = kos32-ar AR = kos32-ar
LD = kos32-ld LD = kos32-ld
CFLAGS = -c -O2 -fno-ident -fomit-frame-pointer -DBUILD_DLL -DMISSING_SYSCALL_NAMES CFLAGS = -c -O2 -fno-ident -fomit-frame-pointer -fexceptions -DBUILD_DLL -DMISSING_SYSCALL_NAMES
LDFLAGS = -shared -s -T libcdll.lds --out-implib libc.dll.a --image-base 0 LDFLAGS = -shared -s -T libcdll.lds --out-implib libc.dll.a --image-base 0
#LDFLAGS+= --output-def libc.orig.def #LDFLAGS+= --output-def libc.orig.def
ARFLAGS = crs ARFLAGS = crs

View File

@ -18,28 +18,9 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
/*
typedef void (*ctp)();
static void __do_global_ctors ()
{
extern int __CTOR_LIST__;
int *c = &__CTOR_LIST__;
c++;
while (*c)
{
ctp d = (ctp)*c;
(d)();
c++;
}
}
*/
void *load_libc(); void *load_libc();
//void __main (){};
void* get_entry_point(void *raw); void* get_entry_point(void *raw);
void _pei386_runtime_relocator (void){};
void __attribute__((noreturn)) void __attribute__((noreturn))
__crt_startup (void) __crt_startup (void)
@ -48,8 +29,6 @@ __crt_startup (void)
void *img; void *img;
void __attribute__((noreturn)) (*entry)(void *img); void __attribute__((noreturn)) (*entry)(void *img);
// _pei386_runtime_relocator();
img = load_libc(); img = load_libc();
if(img == NULL) if(img == NULL)

View File

@ -424,7 +424,8 @@ static inline void get_proc_info(char *info)
__asm__ __volatile__( __asm__ __volatile__(
"int $0x40" "int $0x40"
: :
:"a"(9), "b"(info), "c"(-1)); :"a"(9), "b"(info), "c"(-1)
:"memory");
}; };
static inline void GetProcInfo(char *info) __attribute__ ((alias ("get_proc_info"))); static inline void GetProcInfo(char *info) __attribute__ ((alias ("get_proc_info")));

View File

@ -655,10 +655,6 @@ _ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
#define clearerr(p) __sclearerr(p) #define clearerr(p) __sclearerr(p)
#endif #endif
#if 0 /*ndef __STRICT_ANSI__ - FIXME: must initialize stdio first, use fn */
#define fileno(p) __sfileno(p)
#endif
#ifndef __CYGWIN__ #ifndef __CYGWIN__
#ifndef lint #ifndef lint
#define getc(fp) __sgetc_r(_REENT, fp) #define getc(fp) __sgetc_r(_REENT, fp)