+Fri May 4 22:23:33 2001 Christopher Faylor <cgf@cygnus.com>
+
+ * exceptions.cc (stack_info): Add some controls.
+ (stack_info::init): Add extra arguments to control method of
+ initialization.. If we have a known good frame, set things up so that
+ this frame is not skipped the first time through. Record whether
+ caller cares about arguments or not.
+ (stack_info::walk): Don't store arguments if they're unwanted.
+ (stackdump): Add isexception parameter for use when called by exception
+ handler.
+ (cygwin_stackdump): Accomodate extra argument to stackdump.
+ (handle_exceptions): Ditto.
+ (sig_handle): Ditto.
+ (interrupt_on_return): Accomodate extra arguments to stack walk
+ initialization.
+
Fri May 4 21:05:20 2001 Christopher Faylor <cgf@cygnus.com>
* localtime.c: Revert exclusion of windows.h.
{
int walk (); /* Uses the "old" method */
char *next_offset () {return *((char **) sf.AddrFrame.Offset);}
+ bool needargs;
+ DWORD dummy_frame;
public:
- STACKFRAME sf; /* For storing the stack information */
- void init (DWORD); /* Called the first time that stack info is needed */
+ STACKFRAME sf; /* For storing the stack information */
+ void init (DWORD, bool, bool); /* Called the first time that stack info is needed */
/* Postfix ++ iterates over the stack, returning zero when nothing is left. */
int operator ++(int) { return this->walk (); }
/* Initialize everything needed to start iterating. */
void
-stack_info::init (DWORD ebp)
+stack_info::init (DWORD ebp, bool wantargs, bool goodframe)
{
# define debp ((DWORD *) ebp)
memset (&sf, 0, sizeof (sf));
- sf.AddrFrame.Offset = ebp;
+ if (!goodframe)
+ sf.AddrFrame.Offset = ebp;
+ else
+ {
+ dummy_frame = ebp;
+ sf.AddrFrame.Offset = (DWORD) &dummy_frame;
+ }
sf.AddrReturn.Offset = debp[1];
sf.AddrFrame.Mode = AddrModeFlat;
+ needargs = wantargs;
# undef debp
}
stack_info::walk ()
{
char **ebp;
- if ((ebp = (char **) next_offset ()) != NULL)
- {
- sf.AddrFrame.Offset = (DWORD) ebp;
- sf.AddrPC.Offset = sf.AddrReturn.Offset;
- }
- else
+ if ((ebp = (char **) next_offset ()) == NULL)
return 0;
+ sf.AddrFrame.Offset = (DWORD) ebp;
+ sf.AddrPC.Offset = sf.AddrReturn.Offset;
+
if (!sf.AddrPC.Offset)
return 0; /* stack frames are exhausted */
/* The return address always follows the stack pointer */
sf.AddrReturn.Offset = (DWORD) *++ebp;
- /* The arguments follow the return address */
- for (unsigned i = 0; i < NPARAMS; i++)
- sf.Params[i] = (DWORD) *++ebp;
+ if (needargs)
+ /* The arguments follow the return address */
+ for (unsigned i = 0; i < NPARAMS; i++)
+ sf.Params[i] = (DWORD) *++ebp;
+
return 1;
}
static void
-stackdump (DWORD ebp, int open_file)
+stackdump (DWORD ebp, int open_file, bool isexception)
{
extern unsigned long rlim_core;
int i;
- thestack.init (ebp); /* Initialize from the input CONTEXT */
+ thestack.init (ebp, 1, !isexception); /* Initialize from the input CONTEXT */
small_printf ("Stack trace:\r\nFrame Function Args\r\n");
for (i = 0; i < 16 && thestack++; i++)
{
CONTEXT c;
c.ContextFlags = CONTEXT_FULL;
GetThreadContext (GetCurrentThread (), &c);
- stackdump (c.Ebp, 0);
+ stackdump (c.Ebp, 0, 0);
}
#define TIME_TO_WAIT_FOR_DEBUGGER 10000
open_stackdumpfile ();
exception (e, in);
- stackdump ((DWORD) ebp, 0);
+ stackdump ((DWORD) ebp, 0, 1);
}
signal_exit (0x80 | sig); // Flag signal + core dump
if (!ebp)
return 0;
- thestack.init (ebp); /* Initialize from the input CONTEXT */
+ thestack.init (ebp, 0, 1); /* Initialize from the input CONTEXT */
for (i = 0; i < 32 && thestack++ ; i++)
if (th->exception || interruptible (thestack.sf.AddrReturn.Offset))
{
c.ContextFlags = CONTEXT_FULL;
GetThreadContext (hMainThread, &c);
if (!try_to_debug ())
- stackdump (c.Ebp, 1);
+ stackdump (c.Ebp, 1, 1);
sig |= 0x80;
}
sigproc_printf ("signal %d, about to call do_exit", sig);