X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gprof%2Fcg_dfn.c;h=463f22e5d25b8ca386485f46ec8d8768c19c7d47;hb=1355568ab48a9dcfd079493f7deb5e1c5e88015b;hp=c9e37ab29e526adfc0b87f13e4fcd108b7e3fbfe;hpb=e98fe4f7b54cbdf29aef9287bbb1bea8801dd05a;p=deliverable%2Fbinutils-gdb.git diff --git a/gprof/cg_dfn.c b/gprof/cg_dfn.c index c9e37ab29e..463f22e5d2 100644 --- a/gprof/cg_dfn.c +++ b/gprof/cg_dfn.c @@ -16,14 +16,16 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#include +#include "libiberty.h" #include "gprof.h" +#include "search_list.h" +#include "source.h" +#include "symtab.h" #include "cg_arcs.h" #include "cg_dfn.h" -#include "symtab.h" #include "utils.h" -#define DFN_DEPTH 100 +#define DFN_INCR_DEPTH (128) typedef struct { @@ -32,7 +34,14 @@ typedef struct } DFN_Stack; -DFN_Stack dfn_stack[DFN_DEPTH]; +static boolean is_numbered PARAMS ((Sym *)); +static boolean is_busy PARAMS ((Sym *)); +static void find_cycle PARAMS ((Sym *)); +static void pre_visit PARAMS ((Sym *)); +static void post_visit PARAMS ((Sym *)); + +DFN_Stack *dfn_stack = NULL; +int dfn_maxdepth = 0; int dfn_depth = 0; int dfn_counter = DFN_NAN; @@ -40,8 +49,9 @@ int dfn_counter = DFN_NAN; /* * Is CHILD already numbered? */ -static bool -DEFUN (is_numbered, (child), Sym * child) +static boolean +is_numbered (child) + Sym *child; { return child->cg.top_order != DFN_NAN && child->cg.top_order != DFN_BUSY; } @@ -50,14 +60,15 @@ DEFUN (is_numbered, (child), Sym * child) /* * Is CHILD already busy? */ -static bool -DEFUN (is_busy, (child), Sym * child) +static boolean +is_busy (child) + Sym *child; { if (child->cg.top_order == DFN_NAN) { - return FALSE; + return false; } - return TRUE; + return true; } @@ -68,7 +79,8 @@ DEFUN (is_busy, (child), Sym * child) * depth-first number). */ static void -DEFUN (find_cycle, (child), Sym * child) +find_cycle (child) + Sym *child; { Sym *head = 0; Sym *tail; @@ -191,14 +203,17 @@ DEFUN (find_cycle, (child), Sym * child) * the stack and mark it busy. */ static void -DEFUN (pre_visit, (parent), Sym * parent) +pre_visit (parent) + Sym *parent; { ++dfn_depth; - if (dfn_depth >= DFN_DEPTH) + + if (dfn_depth >= dfn_maxdepth) { - fprintf (stderr, "[pre_visit] dfn_stack overflow\n"); - done (1); + dfn_maxdepth += DFN_INCR_DEPTH; + dfn_stack = xrealloc (dfn_stack, dfn_maxdepth * sizeof *dfn_stack); } + dfn_stack[dfn_depth].sym = parent; dfn_stack[dfn_depth].cycle_top = dfn_depth; parent->cg.top_order = DFN_BUSY; @@ -213,7 +228,8 @@ DEFUN (pre_visit, (parent), Sym * parent) * and number functions if PARENT is head of a cycle. */ static void -DEFUN (post_visit, (parent), Sym * parent) +post_visit (parent) + Sym *parent; { Sym *member; @@ -247,7 +263,8 @@ DEFUN (post_visit, (parent), Sym * parent) * Given this PARENT, depth first number its children. */ void -DEFUN (cg_dfn, (parent), Sym * parent) +cg_dfn (parent) + Sym *parent; { Arc *arc;