Exemple #1
0
int
backtrace(void **buffer, int size)
{
	int i;

	for (i = 1; getframeaddr(i + 1) != NULL && i != size + 1; i++) {
		buffer[i - 1] = getreturnaddr(i);
		if (buffer[i - 1] == NULL)
			break;
	}
	return (i - 1);
}
Exemple #2
0
uintptr_t
getstackcookie(void)
{
    int i;
    uintptr_t r;
    void *p;

    r = 0;
    for (i = 1; i < STACKTRAVERSE_MAX_LEVELS + 1 && getframeaddr(i) != NULL; i++) {
        p = getreturnaddr(i);
        r ^= (uintptr_t)p;
        if (p == topframe || p == NULL)
            break;
    }
    return (r);
}
Exemple #3
0
int
backtrace(void **buffer, int size)
{
    int i;

    if (size > STACKTRAVERSE_MAX_LEVELS)
        size = STACKTRAVERSE_MAX_LEVELS;
    for (i = 1; i < size + 1 && getframeaddr(i) != NULL; i++) {
        buffer[i - 1] = getreturnaddr(i);
        if (buffer[i - 1] == NULL)
            break;
	if (buffer[i - 1] == topframe)
	    return i;
    }

    return i - 1;
}