* exceptions.cc (stack_info::walk): Use method to find offset.

(handle_exceptions): Be more assertive in finding ebp for use under W2K.
Create a dummy stack frame for cases where program is dying and a stack dump is
being output.
(sig_handle): Fill out a GetThreadContext for use with a user-generated "core
dump".
This commit is contained in:
Christopher Faylor
2000-07-03 20:14:06 +00:00
parent 4bedf498d6
commit 8366e93be9
6 changed files with 68 additions and 37 deletions

View File

@ -20,6 +20,8 @@ details. */
static unsigned page_const = 0;
HANDLE cygwin_heap;
static __inline__ int
getpagesize(void)
{
@ -36,9 +38,9 @@ heap_init ()
/* If we're the forkee, we must allocate the heap at exactly the same place
as our parent. If not, we don't care where it ends up. */
page_const = getpagesize();
if (brkbase)
{
DWORD chunk = brkchunk; /* allocation chunk */
/* total size commited in parent */
DWORD allocsize = (char *) brktop - (char *) brkbase;
@ -46,14 +48,13 @@ heap_init ()
DWORD reserve_size = chunk * ((allocsize + (chunk - 1)) / chunk);
/* Loop until we've managed to reserve an adequate amount of memory. */
char *p;
void *p;
for (;;)
{
p = (char *) VirtualAlloc (brkbase, reserve_size,
MEM_RESERVE, PAGE_READWRITE);
p = MapViewOfFileEx (cygwin_heap, FILE_MAP_COPY, 0L, 0L, 0L, brkbase);
if (p)
break;
if ((reserve_size -= page_const) <= allocsize)
if ((reserve_size -= (page_const + 1)) <= allocsize)
break;
}
if (p == NULL)
@ -61,20 +62,25 @@ heap_init ()
brkchunk, myself->pid);
if (p != brkbase)
api_fatal ("heap allocated but not at %p", brkbase);
if (! VirtualAlloc (brkbase, allocsize, MEM_COMMIT, PAGE_READWRITE))
if (!VirtualAlloc (brkbase, allocsize, MEM_COMMIT, PAGE_READWRITE))
api_fatal ("MEM_COMMIT failed, %E");
}
else
{
page_const = getpagesize() - 1;
/* Initialize page mask and default heap size. Preallocate a heap
* to assure contiguous memory. */
brk = brktop = brkbase = VirtualAlloc(NULL, brkchunk, MEM_RESERVE, PAGE_NOACCESS);
cygwin_heap = CreateFileMapping ((HANDLE) 0xffffffff, &sec_all, PAGE_WRITECOPY | SEC_RESERVE, 0L, brkchunk, NULL);
if (cygwin_heap == NULL)
api_fatal ("2. unable to allocate shared memory for heap, heap_chunk_size %d, %E", brkchunk);
brk = brktop = brkbase = MapViewOfFile (cygwin_heap, 0, 0L, 0L, 0);
// brk = brktop = brkbase = VirtualAlloc(NULL, brkchunk, MEM_RESERVE, PAGE_NOACCESS);
if (brkbase == NULL)
api_fatal ("2. unable to allocate heap, heap_chunk_size %d, %E",
brkchunk);
}
page_const--;
malloc_init ();
}