Article View: gnu.gdb.bug
Article #10056Re: Apparent bug(s) in remcom.c file for m68k
From: Glenn Engel
Date: Fri, 22 Jun 1990 16:07
Date: Fri, 22 Jun 1990 16:07
408 lines
13536 bytes
13536 bytes
>The C function _returnFromException takes one (pointer)
>argument, however this "function" gets invoked from the
>assembly code level in a coupld of places and I can't
>see that any proper actual parameter value is being
>supplied to the function.
>
>Is this a bug or what?
This bug and others have been fixed and will hopefully be in the next
gdb release. Attached are patches relative to gdb3.5.
--
Glenn
-------------------------------------------------
| ___ | |
| / / | Glenn R. Engel |
| HEWLETT/hp/PACKARD | glenne@hplsla.hp.com |
| /__/ | (206) 335-2066 |
| Lake Stevens | NN7N |
| Instrument Division | |
-------------------------------------------------
*** remcom.c.orig Fri Jun 21 09:00:52 1990
--- remcom.c Fri Jun 22 08:31:52 1990
***************
*** 14,20
****************************************************************************/
/****************************************************************************
! * $Header: remcom.c,v 1.25 89/05/16 14:34:00 glenne Exp $
*
* $Module name: remcom.c $
* $Revision: 1.25 $
--- 14,20 -----
****************************************************************************/
/****************************************************************************
! * $Header: remcom.c,v 1.30 90/06/22 08:30:57 glenne Exp $
*
* $Module name: remcom.c $
* $Revision: 1.30 $
***************
*** 17,24
* $Header: remcom.c,v 1.25 89/05/16 14:34:00 glenne Exp $
*
* $Module name: remcom.c $
! * $Revision: 1.25 $
! * $Date: 89/05/16 14:34:00 $
* $Contributor: Lake Stevens Instrument Division$
*
* $Description: low level support for gdb debugger. $
--- 17,24 -----
* $Header: remcom.c,v 1.30 90/06/22 08:30:57 glenne Exp $
*
* $Module name: remcom.c $
! * $Revision: 1.30 $
! * $Date: 90/06/22 08:30:57 $
* $Contributor: Lake Stevens Instrument Division$
*
* $Description: low level support for gdb debugger. $
***************
*** 119,124
extern Function exceptionHandler(); /* assign an exception handler */
extern ExceptionHook exceptionHook; /* hook variable for errors/exceptions */
/************************************************************************/
/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
--- 119,128 -----
extern Function exceptionHandler(); /* assign an exception handler */
extern ExceptionHook exceptionHook; /* hook variable for errors/exceptions */
+ /************************/
+ /* FORWARD DECLARATIONS */
+ /************************/
+ void initializeRemcomErrorFrame(void);
/************************************************************************/
/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
***************
*** 156,162
} Frame;
#define FRAMESIZE 500
- static Frame *lastFrame;
static int frameStack[FRAMESIZE];
/*
--- 160,165 -----
} Frame;
#define FRAMESIZE 500
static int frameStack[FRAMESIZE];
static Frame *lastFrame;
***************
*** 158,163
#define FRAMESIZE 500
static Frame *lastFrame;
static int frameStack[FRAMESIZE];
/*
* these should not be static cuz they can be used outside this module
--- 161,167 -----
#define FRAMESIZE 500
static int frameStack[FRAMESIZE];
+ static Frame *lastFrame;
/*
* these should not be static cuz they can be used outside this module
***************
*** 165,172
int registers[NUMREGBYTES/4];
int superStack;
! static int remcomStack[400];
! static int* stackPtr = &remcomStack[399];
/*
* In many cases, the system will want to continue exception processing
--- 169,177 -----
int registers[NUMREGBYTES/4];
int superStack;
! #define STACKSIZE 10000
! static int remcomStack[STACKSIZE/sizeof(int)];
! static int* stackPtr = &remcomStack[STACKSIZE/sizeof(int) - 1];
/*
* In many cases, the system will want to continue exception processing
***************
*** 183,189
static short exceptionSize[] = { 4,4,6,4,4,4,4,4,29,10,16,46,4,4,4,4 };
/************* jump buffer used for setjmp/longjmp **************************/
! jmp_buf env;
/*************************** ASSEMBLY CODE MACROS *************************/
/* */
--- 188,194 -----
static short exceptionSize[] = { 4,4,6,4,4,4,4,4,29,10,16,46,4,4,4,4 };
/************* jump buffer used for setjmp/longjmp **************************/
! static jmp_buf env;
/*************************** ASSEMBLY CODE MACROS *************************/
/* */
***************
*** 351,357
movel d2,sp@- /* push exception num */
movel _exceptionHook,a0 /* get address of handler */
jbsr a0@ /* and call it */
! jmp __returnFromException /* now, return */
");
#else /* mc68000 */
/* This function is called when an exception occurs. It translates the
--- 356,363 -----
movel d2,sp@- /* push exception num */
movel _exceptionHook,a0 /* get address of handler */
jbsr a0@ /* and call it */
! clrl sp@ /* replace exception num parm with frame ptr */
! jbsr __returnFromException /* jbsr, but never returns */
");
#else /* mc68000 */
/* This function is called when an exception occurs. It translates the
***************
*** 423,429
movel d2,sp@- /* push exception num */
movel _exceptionHook,a0 /* get address of handler */
jbsr a0@ /* and call it */
! jmp __returnFromException /* now, return */
");
#endif
--- 429,436 -----
movel d2,sp@- /* push exception num */
movel _exceptionHook,a0 /* get address of handler */
jbsr a0@ /* and call it */
! clrl sp@ /* replace exception num parm with frame ptr */
! jbsr __returnFromException /* jbsr, but never returns */
");
#endif
***************
*** 443,449
void _returnFromException( Frame *frame )
{
! /* if no existing frame, dummy one up */
if (! frame)
{
frame = lastFrame -1;
--- 450,456 -----
void _returnFromException( Frame *frame )
{
! /* if no passed in frame, use the last one */
if (! frame)
{
frame = lastFrame;
***************
*** 446,453
/* if no existing frame, dummy one up */
if (! frame)
{
! frame = lastFrame -1;
! frame->frameSize = 4;
frame->format = 0;
frame->fsaveHeader = 0;
frame->previous = lastFrame;
--- 453,460 -----
/* if no passed in frame, use the last one */
if (! frame)
{
! frame = lastFrame;
! frame->frameSize = 4;
frame->format = 0;
frame->fsaveHeader = 0;
}
***************
*** 450,456
frame->frameSize = 4;
frame->format = 0;
frame->fsaveHeader = 0;
- frame->previous = lastFrame;
}
#ifndef mc68020
--- 457,462 -----
frame->frameSize = 4;
frame->format = 0;
frame->fsaveHeader = 0;
}
#ifndef mc68020
***************
*** 641,646
case 9 : sigval = 5; break; /* trace trap */
case 10: sigval = 4; break; /* line 1010 emulator */
case 11: sigval = 4; break; /* line 1111 emulator */
case 31: sigval = 2; break; /* interrupt */
case 33: sigval = 5; break; /* breakpoint */
case 40: sigval = 8; break; /* floating point err */
--- 647,653 -----
case 9 : sigval = 5; break; /* trace trap */
case 10: sigval = 4; break; /* line 1010 emulator */
case 11: sigval = 4; break; /* line 1111 emulator */
+ case 13: sigval = 8; break; /* floating point err */
case 31: sigval = 2; break; /* interrupt */
case 33: sigval = 5; break; /* breakpoint */
case 40: sigval = 8; break; /* floating point err */
***************
*** 776,782
*/
if ((frame->exceptionVector == 33) &&
(frame->exceptionPC == (newPC+2))) break;
! frame = frame->previous;
}
/*
--- 783,794 -----
*/
if ((frame->exceptionVector == 33) &&
(frame->exceptionPC == (newPC+2))) break;
! if (frame == frame->previous)
! {
! frame = 0; /* no match found */
! break;
! }
! frame = frame->previous;
}
/*
***************
*** 803,811
printf("frame at 0x%x has pc=0x%x, except#=%d\n",
frame,frame->exceptionPC,
frame->exceptionVector);
! /* dispose of this frame, we're skipping it (longjump?)*/
! lastFrame = frame->previous;
! frame = (Frame *) 0;
}
}
}
--- 815,823 -----
printf("frame at 0x%x has pc=0x%x, except#=%d\n",
frame,frame->exceptionPC,
frame->exceptionVector);
! /* re-use the last frame, we're skipping it (longjump?)*/
! frame = (Frame *) 0;
! _returnFromException( frame ); /* this is a jump */
}
}
}
***************
*** 810,816
}
}
! _returnFromException( frame );
break;
--- 822,848 -----
}
}
! /* if we couldn't find a frame, create one */
! if (frame == 0)
! {
! frame = lastFrame -1 ;
!
! /* by using a bunch of print commands with breakpoints,
! it's possible for the frame stack to creep down. If it creeps
! too far, give up and reset it to the top. Normal use should
! not see this happen.
! */
! if ((int) (frame-2) < (int) &frameStack)
! {
! initializeRemcomErrorFrame();
! frame = lastFrame;
! }
! frame->previous = lastFrame;
! lastFrame = frame;
! frame = 0; /* null so _return... will properly initialize it */
! }
!
! _returnFromException( frame ); /* this is a jump */
break;
***************
*** 825,830
}
/* this function is used to set up exception handlers for tracing and
breakpoints */
void set_debug_traps()
--- 857,868 -----
}
+ void initializeRemcomErrorFrame(void)
+ {
+ lastFrame = ((Frame *) &frameStack[FRAMESIZE-1]) - 1;
+ lastFrame->previous = lastFrame;
+ }
+
/* this function is used to set up exception handlers for tracing and
breakpoints */
void set_debug_traps()
***************
*** 833,838
extern void remcomHandler();
int exception;
for (exception = 2; exception <= 23; exception++)
exceptionHandler(exception,_catchException);
--- 871,878 -----
extern void remcomHandler();
int exception;
+ initializeRemcomErrorFrame();
+
for (exception = 2; exception <= 23; exception++)
exceptionHandler(exception,_catchException);
***************
*** 857,864
initialized = 1;
- lastFrame = (Frame *) &frameStack[FRAMESIZE-1];
- lastFrame->previous = (Frame *) 0;
}
/* This function will generate a breakpoint exception. It is used at the
--- 897,902 -----
initialized = 1;
}
/* This function will generate a breakpoint exception. It is used at the
Technical Details
Message-ID:
<9006221607.AA08297@hplslk.lsid.hp.com>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!HPLSLA.HP.COM!glenneReferences:
<9006220046.AA20921@lupine.ncd.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f5053,1c4fc6f511b7e4f5 X-Google-Attributes: gidf5053,public X-Google-ArrivalTime: 1990-06-22 21:31:36 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!HPLSLA.HP.COM!glenne From: glenne@HPLSLA.HP.COM (Glenn Engel) Newsgroups: gnu.gdb.bug Subject: Re: Apparent bug(s) in remcom.c file for m68k Message-ID: <9006221607.AA08297@hplslk.lsid.hp.com> Date: 22 Jun 90 16:07:19 GMT References: <9006220046.AA20921@lupine.ncd.com> Sender: daemon@tut.cis.ohio-state.edu Reply-To: glenne@hplsla.hp.com Distribution: gnu Organization: GNUs Not Usenet Lines: 408 Posted: Fri Jun 22 17:07:19 1990