/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include "gprof.h"
struct dfnstruct {
int cycletop;
};
int dfn_depth = 0;
int dfn_sz = 0;
/*
* given this parent, depth first number its children.
*/
void
{
#ifdef DEBUG
(void) printf("[dfn] dfn(");
(void) printf(")\n");
}
#endif /* DEBUG */
if (!dfn_stack) {
if (!dfn_stack) {
"fatal: can't malloc %d objects\n", dfn_sz);
exit(1);
}
}
/*
* if we're already numbered, no need to look any furthur.
*/
if (dfn_numbered(parentp))
return;
/*
* if we're already busy, must be a cycle
*/
return;
}
/*
* visit yourself before your children
*/
/*
* visit children
*/
/*
* visit yourself after your children
*/
}
/*
* push a parent onto the stack and mark it busy
*/
void
{
if (!dfn_stack) {
if (!dfn_stack) {
(void) printf("fatal: can't malloc %d objects\n",
dfn_sz);
exit(1);
}
}
dfn_depth += 1;
if (!dfn_stack) {
"fatal: can't realloc %d objects\n", dfn_sz);
exit(1);
}
}
#ifdef DEBUG
(void) printf("\n");
}
#endif /* DEBUG */
}
/*
* are we already numbered?
*/
bool
{
}
/*
* are we already busy?
*/
bool
{
return (FALSE);
return (TRUE);
}
void
{
int cycletop;
int index;
if (childp == cycleheadp)
break;
break;
}
if (cycletop <= 0) {
/*
* don't report non existent functions
*/
"[dfn_findcycle] couldn't find head "
return;
}
}
#ifdef DEBUG
(void) printf("[dfn_findcycle] dfn_depth %d cycletop %d ",
(void) printf("\n");
}
#endif /* DEBUG */
/*
* this is previous function, e.g. this calls itself
* sort of boring
*/
} else {
/*
* glom intervening functions that aren't already
* glommed into this cycle.
* things have been glommed when their cyclehead field
* points to the head of the cycle they are glommed into.
*/
/* void: chase down to tail of things already glommed */
#ifdef DEBUG
(void) printf("[dfn_findcycle] tail ");
(void) printf("\n");
}
#endif /* DEBUG */
}
/*
* if what we think is the top of the cycle
* has a cyclehead field, then it's not really the
* head of the cycle, which is really what we want
*/
#ifdef DEBUG
(void) printf("[dfn_findcycle] new cyclehead ");
(void) printf("\n");
}
#endif /* DEBUG */
}
/*
* not yet glommed anywhere, glom it
* and fix any children it has glommed
*/
#ifdef DEBUG
(void) printf(
"[dfn_findcycle] glomming ");
(void) printf(" onto ");
(void) printf("\n");
}
#endif /* DEBUG */
#ifdef DEBUG
(void) printf("[dfn_findcycle]"
" and its tail ");
(void) printf(" onto ");
(void) printf("\n");
}
#endif /* DEBUG */
}
" but not to cyclehead\n");
}
}
}
}
/*
* deal with self-cycles
* for lint: ARGSUSED
*/
/* ARGSUSED */
void
{
/*
* since we are taking out self-cycles elsewhere
* no need for the special case, here.
*/
#ifdef DEBUG
(void) printf("[dfn_self_cycle] ");
(void) printf("\n");
}
#endif /* DEBUG */
}
/*
* visit a node after all its children
* [MISSING: an explanation]
* and pop it off the stack
*/
void
{
#ifdef DEBUG
(void) printf("\n");
}
#endif /* DEBUG */
/*
* number functions and things in their cycles
* unless the function is itself part of a cycle
*/
dfn_counter += 1;
#ifdef DEBUG
(void) printf("[dfn_post_visit]\t\tmember ");
(void) printf(" -> toporder = %d\n",
}
#endif /* DEBUG */
}
#ifdef DEBUG
} else {
(void) printf(
"[dfn_post_visit]\t\tis part of a cycle\n");
#endif /* DEBUG */
}
dfn_depth -= 1;
}