/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "misc.h"
#include <ucontext.h>
#include <stdio.h>
extern void flush_windows(void);
/*
* On x86, MINFRAME is defined to be 0, but we want to be sure we can
* dereference the entire frame structure.
*/
#else
#endif
/*
* Get a pc-only stacktrace. Used for kmem_alloc() buffer ownership tracking.
* Returns MIN(current stack depth, pcstack_limit).
*/
/*ARGSUSED*/
int
{
int depth = 0;
#ifndef UMEM_STANDALONE
int on_altstack = 0;
if (stack_getbounds(&st) != 0) {
if (thr_stksegment(&st) != 0 ||
return (0); /* unable to get stack bounds */
}
/*
* thr_stksegment(3C) has a slightly different interface than
* stack_getbounds(3C) -- correct it
*/
}
} else {
/*
* If size == 0, then ss_sp is the *top* of the stack.
*
* Since we only allow increasing frame pointers, and we
* know our caller set his up correctly, we can treat ss_sp
* as an upper bound safely.
*/
base = 0;
}
if (check_signal != 0) {
int sigfuncsize = 0;
extern void thr_sighndlrinfo(void (**)(), int *);
}
#else /* UMEM_STANDALONE */
#endif
/*
* shorten size so that fr_savfp and fr_savpc will be within the stack
* bounds.
*/
else
size = 0;
#endif
/* LINTED alignment */
return (0); /* the frame pointer isn't in our stack */
while (depth < pcstack_limit) {
/* LINTED alignment */
/*
* Check nextfp for validity. It must be properly aligned,
* increasing compared to the last %fp (or the top of the
* stack we just switched to), and it must be inside
* [base, base + size).
*/
break;
#ifndef UMEM_STANDALONE
break;
/*
* If we're on an alternate signal stack, try jumping
* to the main thread stack.
*
* If the main thread stack has an unlimited size, we
* punt, since we don't know where the frame pointer's
* been.
*
* (thr_stksegment() returns the *top of stack*
* in ss_sp, not the bottom)
*/
if (thr_stksegment(&st) == 0) {
break;
on_altstack = 0;
continue; /* try again */
}
#endif
break;
}
#ifndef UMEM_STANDALONE
umem_panic("called from signal handler");
#endif
}
return (depth);
}