unwind-dw2-fde-glibc.c (base_from_cb_data, [...]): Use gcc_assert and gcc_unreachable as appropriate.

* unwind-dw2-fde-glibc.c (base_from_cb_data,
	_Unwind_IteratePhdrCallback): Use gcc_assert and gcc_unreachable as
	appropriate.
	* unwind-dw2-fde.c (__deregister_frame_info_bases,
	base_from_object, fde_split, end_fde_sort): Likewise.
	* unwind-dw2.c (_Unwind_GetGR, _Unwind_SetGR, execute_stack_op,
	execute_cfa_program, _Unwind_SetSpColumn, uw_update_context_1,
	uw_init_context_1): Likewise.
	* unwind.inc (_Unwind_RaiseException_Phase2, _Unwind_Resume,
	_Unwind_Resume_or_Rethrow): Likewise.
	* unwind-pe.h (__gxx_abort): Do not define.
	(size_of_encoded_value, base_of_encoded_value,
	read_encoded_value_with_base): Use gcc_unreachable.
	* unwind.h (_Unwind_GetTextRelBase): Likewise.

From-SVN: r99835
This commit is contained in:
Nathan Sidwell 2005-05-17 15:37:47 +00:00 committed by Nathan Sidwell
parent d0f11b1653
commit 79d0dfa314
11 changed files with 93 additions and 88 deletions

View File

@ -1,3 +1,20 @@
2005-05-17 Nathan Sidwell <nathan@codesourcery.com>
* unwind-dw2-fde-glibc.c (base_from_cb_data,
_Unwind_IteratePhdrCallback): Use gcc_assert and gcc_unreachable as
appropriate.
* unwind-dw2-fde.c (__deregister_frame_info_bases,
base_from_object, fde_split, end_fde_sort): Likewise.
* unwind-dw2.c (_Unwind_GetGR, _Unwind_SetGR, execute_stack_op,
execute_cfa_program, _Unwind_SetSpColumn, uw_update_context_1,
uw_init_context_1): Likewise.
* unwind.inc (_Unwind_RaiseException_Phase2, _Unwind_Resume,
_Unwind_Resume_or_Rethrow): Likewise.
* unwind-pe.h (__gxx_abort): Do not define.
(size_of_encoded_value, base_of_encoded_value,
read_encoded_value_with_base): Use gcc_unreachable.
* unwind.h (_Unwind_GetTextRelBase): Likewise.
2005-05-17 Daniel Jacobowitz <dan@codesourcery.com> 2005-05-17 Daniel Jacobowitz <dan@codesourcery.com>
* config/arm/lib1funcs.asm (cfi_pop, cfi_push, cfi_start) * config/arm/lib1funcs.asm (cfi_pop, cfi_push, cfi_start)

View File

@ -118,8 +118,9 @@ base_from_cb_data (unsigned char encoding, struct unw_eh_callback_data *data)
return (_Unwind_Ptr) data->tbase; return (_Unwind_Ptr) data->tbase;
case DW_EH_PE_datarel: case DW_EH_PE_datarel:
return (_Unwind_Ptr) data->dbase; return (_Unwind_Ptr) data->dbase;
default:
gcc_unreachable ();
} }
abort ();
} }
static int static int
@ -358,8 +359,7 @@ _Unwind_IteratePhdrCallback (struct dl_phdr_info *info, size_t size, void *ptr)
break; break;
} }
if (lo >= hi) gcc_assert (lo < hi);
__gxx_abort ();
} }
f = (fde *) (table[mid].fde + data_base); f = (fde *) (table[mid].fde + data_base);

View File

@ -164,7 +164,7 @@ __register_frame_table (void *begin)
from crtbegin (wherein it is declared weak), and this object does from crtbegin (wherein it is declared weak), and this object does
not get pulled from libgcc.a for other reasons, then the not get pulled from libgcc.a for other reasons, then the
invocation of __deregister_frame_info will be resolved from glibc. invocation of __deregister_frame_info will be resolved from glibc.
Since the registration did not happen there, we'll abort. Since the registration did not happen there, we'll die.
Therefore, declare a new deregistration entry point that does the Therefore, declare a new deregistration entry point that does the
exact same thing, but will resolve to the same library as exact same thing, but will resolve to the same library as
@ -212,11 +212,9 @@ __deregister_frame_info_bases (const void *begin)
} }
} }
__gthread_mutex_unlock (&object_mutex);
abort ();
out: out:
__gthread_mutex_unlock (&object_mutex); __gthread_mutex_unlock (&object_mutex);
gcc_assert (ob);
return (void *) ob; return (void *) ob;
} }
@ -255,8 +253,9 @@ base_from_object (unsigned char encoding, struct object *ob)
return (_Unwind_Ptr) ob->tbase; return (_Unwind_Ptr) ob->tbase;
case DW_EH_PE_datarel: case DW_EH_PE_datarel:
return (_Unwind_Ptr) ob->dbase; return (_Unwind_Ptr) ob->dbase;
default:
gcc_unreachable ();
} }
abort ();
} }
/* Return the FDE pointer encoding from the CIE. */ /* Return the FDE pointer encoding from the CIE. */
@ -441,8 +440,7 @@ fde_split (struct object *ob, fde_compare_t fde_compare,
/* This should optimize out, but it is wise to make sure this assumption /* This should optimize out, but it is wise to make sure this assumption
is correct. Should these have different sizes, we cannot cast between is correct. Should these have different sizes, we cannot cast between
them and the overlaying onto ERRATIC will not work. */ them and the overlaying onto ERRATIC will not work. */
if (sizeof (const fde *) != sizeof (const fde **)) gcc_assert (sizeof (const fde *) == sizeof (const fde **));
abort ();
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
@ -566,8 +564,7 @@ end_fde_sort (struct object *ob, struct fde_accumulator *accu, size_t count)
{ {
fde_compare_t fde_compare; fde_compare_t fde_compare;
if (accu->linear && accu->linear->count != count) gcc_assert (!accu->linear || accu->linear->count == count);
abort ();
if (ob->s.b.mixed_encoding) if (ob->s.b.mixed_encoding)
fde_compare = fde_mixed_encoding_compare; fde_compare = fde_mixed_encoding_compare;
@ -579,8 +576,7 @@ end_fde_sort (struct object *ob, struct fde_accumulator *accu, size_t count)
if (accu->erratic) if (accu->erratic)
{ {
fde_split (ob, fde_compare, accu->linear, accu->erratic); fde_split (ob, fde_compare, accu->linear, accu->erratic);
if (accu->linear->count + accu->erratic->count != count) gcc_assert (accu->linear->count + accu->erratic->count == count);
abort ();
frame_heapsort (ob, fde_compare, accu->erratic); frame_heapsort (ob, fde_compare, accu->erratic);
fde_merge (ob, fde_compare, accu->linear, accu->erratic); fde_merge (ob, fde_compare, accu->linear, accu->erratic);
free (accu->erratic); free (accu->erratic);

View File

@ -131,19 +131,18 @@ _Unwind_GetGR (struct _Unwind_Context *context, int index)
#endif #endif
index = DWARF_REG_TO_UNWIND_COLUMN (index); index = DWARF_REG_TO_UNWIND_COLUMN (index);
if (index >= (int) sizeof(dwarf_reg_size_table)) gcc_assert (index < (int) sizeof(dwarf_reg_size_table));
abort ();
size = dwarf_reg_size_table[index]; size = dwarf_reg_size_table[index];
ptr = context->reg[index]; ptr = context->reg[index];
/* 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 *) ptr;
else
if (size == sizeof(_Unwind_Word)) {
return * (_Unwind_Word *) ptr; gcc_assert (size == sizeof(_Unwind_Word));
return * (_Unwind_Word *) ptr;
abort (); }
} }
static inline void * static inline void *
@ -169,17 +168,17 @@ _Unwind_SetGR (struct _Unwind_Context *context, int index, _Unwind_Word val)
void *ptr; void *ptr;
index = DWARF_REG_TO_UNWIND_COLUMN (index); index = DWARF_REG_TO_UNWIND_COLUMN (index);
if (index >= (int) sizeof(dwarf_reg_size_table)) gcc_assert (index < (int) sizeof(dwarf_reg_size_table));
abort ();
size = dwarf_reg_size_table[index]; size = dwarf_reg_size_table[index];
ptr = context->reg[index]; ptr = context->reg[index];
if (size == sizeof(_Unwind_Ptr)) if (size == sizeof(_Unwind_Ptr))
* (_Unwind_Ptr *) ptr = val; * (_Unwind_Ptr *) ptr = val;
else if (size == sizeof(_Unwind_Word))
* (_Unwind_Word *) ptr = val;
else else
abort (); {
gcc_assert (size == sizeof(_Unwind_Word));
* (_Unwind_Word *) ptr = val;
}
} }
/* Get the pointer to a register INDEX as saved in CONTEXT. */ /* Get the pointer to a register INDEX as saved in CONTEXT. */
@ -518,26 +517,23 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
break; break;
case DW_OP_dup: case DW_OP_dup:
if (stack_elt < 1) gcc_assert (stack_elt);
abort ();
result = stack[stack_elt - 1]; result = stack[stack_elt - 1];
break; break;
case DW_OP_drop: case DW_OP_drop:
if (--stack_elt < 0) gcc_assert (stack_elt);
abort (); stack_elt -= 1;
goto no_push; goto no_push;
case DW_OP_pick: case DW_OP_pick:
offset = *op_ptr++; offset = *op_ptr++;
if (offset >= stack_elt - 1) gcc_assert (offset < stack_elt - 1);
abort ();
result = stack[stack_elt - 1 - offset]; result = stack[stack_elt - 1 - offset];
break; break;
case DW_OP_over: case DW_OP_over:
if (stack_elt < 2) gcc_assert (stack_elt >= 2);
abort ();
result = stack[stack_elt - 2]; result = stack[stack_elt - 2];
break; break;
@ -545,8 +541,7 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
{ {
_Unwind_Word t1, t2, t3; _Unwind_Word t1, t2, t3;
if (stack_elt < 3) gcc_assert (stack_elt >= 3);
abort ();
t1 = stack[stack_elt - 1]; t1 = stack[stack_elt - 1];
t2 = stack[stack_elt - 2]; t2 = stack[stack_elt - 2];
t3 = stack[stack_elt - 3]; t3 = stack[stack_elt - 3];
@ -563,8 +558,9 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
case DW_OP_not: case DW_OP_not:
case DW_OP_plus_uconst: case DW_OP_plus_uconst:
/* Unary operations. */ /* Unary operations. */
if (--stack_elt < 0) gcc_assert (stack_elt);
abort (); stack_elt -= 1;
result = stack[stack_elt]; result = stack[stack_elt];
switch (op) switch (op)
@ -594,7 +590,7 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
result = read_8u (ptr); result = read_8u (ptr);
break; break;
default: default:
abort (); gcc_unreachable ();
} }
} }
break; break;
@ -615,7 +611,7 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
break; break;
default: default:
abort (); gcc_unreachable ();
} }
break; break;
@ -639,8 +635,9 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
{ {
/* Binary operations. */ /* Binary operations. */
_Unwind_Word first, second; _Unwind_Word first, second;
if ((stack_elt -= 2) < 0) gcc_assert (stack_elt >= 2);
abort (); stack_elt -= 2;
second = stack[stack_elt]; second = stack[stack_elt];
first = stack[stack_elt + 1]; first = stack[stack_elt + 1];
@ -699,7 +696,7 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
break; break;
default: default:
abort (); gcc_unreachable ();
} }
} }
break; break;
@ -711,8 +708,9 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
goto no_push; goto no_push;
case DW_OP_bra: case DW_OP_bra:
if (--stack_elt < 0) gcc_assert (stack_elt);
abort (); stack_elt -= 1;
offset = read_2s (op_ptr); offset = read_2s (op_ptr);
op_ptr += 2; op_ptr += 2;
if (stack[stack_elt] != 0) if (stack[stack_elt] != 0)
@ -723,20 +721,19 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end,
goto no_push; goto no_push;
default: default:
abort (); gcc_unreachable ();
} }
/* Most things push a result value. */ /* Most things push a result value. */
if ((size_t) stack_elt >= sizeof(stack)/sizeof(*stack)) gcc_assert ((size_t) stack_elt < sizeof(stack)/sizeof(*stack));
abort ();
stack[stack_elt++] = result; stack[stack_elt++] = result;
no_push:; no_push:;
} }
/* We were executing this program to get a value. It should be /* We were executing this program to get a value. It should be
at top of stack. */ at top of stack. */
if (--stack_elt < 0) gcc_assert (stack_elt);
abort (); stack_elt -= 1;
return stack[stack_elt]; return stack[stack_elt];
} }
@ -944,7 +941,7 @@ execute_cfa_program (const unsigned char *insn_ptr,
break; break;
default: default:
abort (); gcc_unreachable ();
} }
} }
} }
@ -1088,10 +1085,11 @@ _Unwind_SetSpColumn (struct _Unwind_Context *context, void *cfa,
if (size == sizeof(_Unwind_Ptr)) if (size == sizeof(_Unwind_Ptr))
tmp_sp->ptr = (_Unwind_Ptr) cfa; tmp_sp->ptr = (_Unwind_Ptr) cfa;
else if (size == sizeof(_Unwind_Word))
tmp_sp->word = (_Unwind_Ptr) cfa;
else else
abort (); {
gcc_assert (size == sizeof(_Unwind_Word));
tmp_sp->word = (_Unwind_Ptr) cfa;
}
_Unwind_SetGRPtr (context, __builtin_dwarf_sp_column (), tmp_sp); _Unwind_SetGRPtr (context, __builtin_dwarf_sp_column (), tmp_sp);
} }
@ -1145,7 +1143,7 @@ uw_update_context_1 (struct _Unwind_Context *context, _Unwind_FrameState *fs)
} }
default: default:
abort (); gcc_unreachable ();
} }
context->cfa = cfa; context->cfa = cfa;
@ -1229,12 +1227,13 @@ uw_init_context_1 (struct _Unwind_Context *context,
void *ra = __builtin_extract_return_addr (__builtin_return_address (0)); void *ra = __builtin_extract_return_addr (__builtin_return_address (0));
_Unwind_FrameState fs; _Unwind_FrameState fs;
_Unwind_SpTmp sp_slot; _Unwind_SpTmp sp_slot;
_Unwind_Reason_Code code;
memset (context, 0, sizeof (struct _Unwind_Context)); memset (context, 0, sizeof (struct _Unwind_Context));
context->ra = ra; context->ra = ra;
if (uw_frame_state_for (context, &fs) != _URC_NO_REASON) code = uw_frame_state_for (context, &fs);
abort (); gcc_assert (code == _URC_NO_REASON);
#if __GTHREADS #if __GTHREADS
{ {

View File

@ -34,13 +34,6 @@
#ifndef GCC_UNWIND_PE_H #ifndef GCC_UNWIND_PE_H
#define GCC_UNWIND_PE_H #define GCC_UNWIND_PE_H
/* If using C++, references to abort have to be qualified with std::. */
#if __cplusplus
#define __gxx_abort std::abort
#else
#define __gxx_abort abort
#endif
/* Pointer encodings, from dwarf2.h. */ /* Pointer encodings, from dwarf2.h. */
#define DW_EH_PE_absptr 0x00 #define DW_EH_PE_absptr 0x00
#define DW_EH_PE_omit 0xff #define DW_EH_PE_omit 0xff
@ -86,8 +79,9 @@ size_of_encoded_value (unsigned char encoding)
return 4; return 4;
case DW_EH_PE_udata8: case DW_EH_PE_udata8:
return 8; return 8;
default:
gcc_unreachable ();
} }
__gxx_abort ();
} }
#endif #endif
@ -118,8 +112,9 @@ base_of_encoded_value (unsigned char encoding, struct _Unwind_Context *context)
return _Unwind_GetDataRelBase (context); return _Unwind_GetDataRelBase (context);
case DW_EH_PE_funcrel: case DW_EH_PE_funcrel:
return _Unwind_GetRegionStart (context); return _Unwind_GetRegionStart (context);
default:
gcc_unreachable ();
} }
__gxx_abort ();
} }
#endif #endif
@ -256,7 +251,7 @@ read_encoded_value_with_base (unsigned char encoding, _Unwind_Ptr base,
break; break;
default: default:
__gxx_abort (); gcc_unreachable ();
} }
if (result != 0) if (result != 0)

View File

@ -214,8 +214,7 @@ _Unwind_GetDataRelBase (struct _Unwind_Context *_C)
static inline _Unwind_Ptr static inline _Unwind_Ptr
_Unwind_GetTextRelBase (struct _Unwind_Context *_C __attribute__ ((__unused__))) _Unwind_GetTextRelBase (struct _Unwind_Context *_C __attribute__ ((__unused__)))
{ {
abort (); gcc_unreachable ();
return 0;
} }
/* @@@ Retrieve the Backing Store Pointer of the given context. */ /* @@@ Retrieve the Backing Store Pointer of the given context. */

View File

@ -72,8 +72,7 @@ _Unwind_RaiseException_Phase2(struct _Unwind_Exception *exc,
} }
/* Don't let us unwind past the handler context. */ /* Don't let us unwind past the handler context. */
if (match_handler) gcc_assert (!match_handler);
abort ();
uw_update_context (context, &fs); uw_update_context (context, &fs);
} }
@ -144,8 +143,8 @@ _Unwind_RaiseException(struct _Unwind_Exception *exc)
/* Subroutine of _Unwind_ForcedUnwind also invoked from _Unwind_Resume. */ /* Subroutine of _Unwind_ForcedUnwind also invoked from _Unwind_Resume. */
static _Unwind_Reason_Code static _Unwind_Reason_Code
_Unwind_ForcedUnwind_Phase2(struct _Unwind_Exception *exc, _Unwind_ForcedUnwind_Phase2 (struct _Unwind_Exception *exc,
struct _Unwind_Context *context) struct _Unwind_Context *context)
{ {
_Unwind_Stop_Fn stop = (_Unwind_Stop_Fn) (_Unwind_Ptr) exc->private_1; _Unwind_Stop_Fn stop = (_Unwind_Stop_Fn) (_Unwind_Ptr) exc->private_1;
void *stop_argument = (void *) (_Unwind_Ptr) exc->private_2; void *stop_argument = (void *) (_Unwind_Ptr) exc->private_2;
@ -235,8 +234,7 @@ _Unwind_Resume (struct _Unwind_Exception *exc)
else else
code = _Unwind_ForcedUnwind_Phase2 (exc, &cur_context); code = _Unwind_ForcedUnwind_Phase2 (exc, &cur_context);
if (code != _URC_INSTALL_CONTEXT) gcc_assert (code == _URC_INSTALL_CONTEXT);
abort ();
uw_install_context (&this_context, &cur_context); uw_install_context (&this_context, &cur_context);
} }
@ -261,8 +259,7 @@ _Unwind_Resume_or_Rethrow (struct _Unwind_Exception *exc)
code = _Unwind_ForcedUnwind_Phase2 (exc, &cur_context); code = _Unwind_ForcedUnwind_Phase2 (exc, &cur_context);
if (code != _URC_INSTALL_CONTEXT) gcc_assert (code == _URC_INSTALL_CONTEXT);
abort ();
uw_install_context (&this_context, &cur_context); uw_install_context (&this_context, &cur_context);
} }

View File

@ -1,3 +1,8 @@
2005-05-17 Nathan Sidwell <nathan@codesourcery.com>
* exception.cc (abort): Remove std::abort hack.
(gcc_unreacheable): Define.
2005-05-17 Paolo Bonzini <bonzini@gnu.org> 2005-05-17 Paolo Bonzini <bonzini@gnu.org>
* Makefile.am (Makefile.deps): Do not create native.list and * Makefile.am (Makefile.deps): Do not create native.list and

View File

@ -19,17 +19,9 @@ details. */
#include <gcj/cni.h> #include <gcj/cni.h>
#include <jvm.h> #include <jvm.h>
// unwind-pe.h uses std::abort(), but sometimes we compile libjava // Sometimes we compile libjava without libstdc++-v3. Therefore make
// without libstdc++-v3. The following hack forces it to use // sure we use stdlib.h's abort().
// stdlib.h's abort(). #define gcc_unreachable() ::abort ()
namespace std
{
static __attribute__ ((__noreturn__)) void
abort ()
{
::abort ();
}
}
#include "unwind.h" #include "unwind.h"
struct alignment_test_struct struct alignment_test_struct

View File

@ -1,3 +1,7 @@
2005-05-17 Nathan Sidwell <nathan@codesourcery.com>
* libsupc++/eh_personality.cc (gcc_unreachable): Define.
2005-05-16 Paolo Carlini <pcarlini@suse.de> 2005-05-16 Paolo Carlini <pcarlini@suse.de>
* docs/html/install.html: Update list of required named * docs/html/install.html: Update list of required named

View File

@ -35,6 +35,7 @@
using namespace __cxxabiv1; using namespace __cxxabiv1;
#define gcc_unreachable() std::abort()
#include "unwind-pe.h" #include "unwind-pe.h"