Patch from Jiri Gaisler <jgais@ws.estec.esa.nl> to fix remote gdb use:

I just released erc32ccs-2.0.6 which includes some fixes and the
    Ada-self optimisation. Remote debugging of Ada programs did not
    work due to a conflict between monior and rtems trap handlers.
    I have attached a modified gnatsupp.c that makes remote debugging
    possible again.
This commit is contained in:
Joel Sherrill
1999-08-06 16:00:32 +00:00
parent a92280e02d
commit f42fb02e1d

View File

@@ -1,6 +1,6 @@
/* /*
* *
* Support for gnat/rtems machine error exception handling. * Support for gnat/rtems interrupts and exception handling.
* Jiri Gaisler, ESA/ESTEC, 17-02-1999. * Jiri Gaisler, ESA/ESTEC, 17-02-1999.
* *
*/ */
@@ -14,42 +14,43 @@
*/ */
rtems_isr __gnat_exception_handler rtems_isr __gnat_exception_handler
( rtems_vector_number trap) (rtems_vector_number trap)
{ {
rtems_unsigned32 real_trap; rtems_unsigned32 real_trap;
rtems_unsigned32 signal; rtems_unsigned32 signal;
real_trap = SPARC_REAL_TRAP_NUMBER(trap); real_trap = SPARC_REAL_TRAP_NUMBER (trap);
switch (real_trap) { switch (real_trap)
case 0x08: /* FPU exception */ {
case 0x0A: /* TAG overflow */ case 0x08: /* FPU exception */
case 0x82: /* divide by zero */ case 0x0A: /* TAG overflow */
signal = SIGFPE; /* Will cause Constraint_Error */ case 0x82: /* divide by zero */
break; signal = SIGFPE; /* Will cause Constraint_Error */
case 0x01: /* Instruction access exception */ break;
case 0x09: /* Data access exception */ case 0x01: /* Instruction access exception */
signal = SIGSEGV; /* Will cause Storage_Error */ case 0x09: /* Data access exception */
break; signal = SIGSEGV; /* Will cause Storage_Error */
default: /* Anything else ... */ break;
signal = SIGILL; /* Will cause Program_Error */ default: /* Anything else ... */
break; signal = SIGILL; /* Will cause Program_Error */
break;
} }
kill(getpid(),signal); kill (getpid (), signal);
} }
/* /*
* Asynchronous trap handler. As it happens, the interrupt trap numbers for * Asynchronous trap handler. As it happens, the interrupt trap numbers for
* SPARC is 17 - 31, so we just map then directly on the same signal. * SPARC is 17 - 31, so we just map then directly on the same signal number.
*/ */
rtems_isr __gnat_interrupt_handler rtems_isr __gnat_interrupt_handler
( rtems_vector_number trap) (rtems_vector_number trap)
{ {
rtems_unsigned32 real_trap; rtems_unsigned32 real_trap;
real_trap = SPARC_REAL_TRAP_NUMBER(trap); real_trap = SPARC_REAL_TRAP_NUMBER (trap);
kill(getpid(),real_trap); kill (getpid (), real_trap);
} }
@@ -57,52 +58,57 @@ rtems_isr __gnat_interrupt_handler
* Default signal handler with error reporting * Default signal handler with error reporting
*/ */
void __gnat_signals_Abormal_termination_handler( int signo ) void
__gnat_signals_Abormal_termination_handler (int signo)
{ {
switch ( signo ) { switch (signo)
case SIGFPE: {
DEBUG_puts("\nConstraint_Error\n"); case SIGFPE:
break; DEBUG_puts ("\nConstraint_Error\n");
case SIGSEGV: break;
DEBUG_puts("\nStorage_Error\n"); case SIGSEGV:
break; DEBUG_puts ("\nStorage_Error\n");
default: break;
DEBUG_puts("\nProgram_Error\n"); default:
break; DEBUG_puts ("\nProgram_Error\n");
} break;
exit( 1 ); }
exit (1);
} }
const struct sigaction __gnat_error_vector = { const struct sigaction __gnat_error_vector =
0, -1, {__gnat_signals_Abormal_termination_handler}}; {0, -1,
{__gnat_signals_Abormal_termination_handler}};
void __gnat_install_handler() void
__gnat_install_handler ()
{ {
rtems_unsigned32 trap; rtems_unsigned32 trap;
rtems_isr_entry previous_isr; rtems_isr_entry previous_isr;
sigaction(SIGSEGV, &__gnat_error_vector, NULL); sigaction (SIGSEGV, &__gnat_error_vector, NULL);
sigaction(SIGFPE , &__gnat_error_vector, NULL); sigaction (SIGFPE, &__gnat_error_vector, NULL);
sigaction(SIGILL , &__gnat_error_vector, NULL); sigaction (SIGILL, &__gnat_error_vector, NULL);
for ( trap=0 ; trap<256 ; trap++ ) { for (trap = 0; trap < 256; trap++)
{
/* /*
* Skip window overflow, underflow, and flush as well as software * Skip window overflow, underflow, and flush as well as software
* trap 0 which we will use as a shutdown. Also avoid trap 0x70 - 0x7f * trap 0 which we will use as a shutdown. Also avoid trap 0x70 - 0x7f
* which cannot happen and where some of the space is used to pass * which cannot happen and where some of the space is used to pass
* paramaters to the program. Trap 0x1d is used by the clock tick * paramaters to the program. Trap 0x1d is used by the clock tick,
* and 0x83 by the remote debugging stub. Traps 0x14, 0x15, and 0x17 * 0x80 for system traps and 0x81 - 0x83 by the remote debugging stub.
* are used by the console device driver. * Avoid 0x15 (UART B interrupt) which is also used by the stub
*/ * to generate a 'break-in' interrupt.
*/
if (( trap >= 0x11 ) && ( trap <= 0x1f )) { if ((trap >= 0x11) && (trap <= 0x1f))
if ( trap != 0x1d && trap != 0x14 && trap != 0x15 && trap != 0x17 ) {
rtems_interrupt_catch( __gnat_interrupt_handler, if ((trap != 0x1d) && (trap != 0x15))
trap, &previous_isr ); rtems_interrupt_catch (__gnat_interrupt_handler, trap, &previous_isr);
} else if (( trap != 5 && trap != 6 && trap != 0x83 ) && }
(( trap < 0x70 ) || ( trap > 0x80 ))) else if ((trap != 5 && trap != 6) && ((trap < 0x70) || (trap > 0x83)))
set_vector( __gnat_exception_handler, set_vector (__gnat_exception_handler, SPARC_SYNCHRONOUS_TRAP (trap), 1);
SPARC_SYNCHRONOUS_TRAP( trap ), 1 );
} }
} }