1995-02-07 22:34:18 +00:00
|
|
|
#include "libiberty.h"
|
|
|
|
#include "cg_arcs.h"
|
|
|
|
#include "cg_print.h"
|
|
|
|
#include "hist.h"
|
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return value of comparison functions used to sort tables:
|
|
|
|
*/
|
|
|
|
#define LESSTHAN -1
|
|
|
|
#define EQUALTO 0
|
|
|
|
#define GREATERTHAN 1
|
|
|
|
|
|
|
|
/* declarations of automatically generated functions to output blurbs: */
|
1995-02-08 02:35:44 +00:00
|
|
|
extern void bsd_callg_blurb PARAMS ((FILE * fp));
|
|
|
|
extern void fsf_callg_blurb PARAMS ((FILE * fp));
|
1995-02-07 22:34:18 +00:00
|
|
|
|
|
|
|
double print_time = 0.0;
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
1995-02-08 02:35:44 +00:00
|
|
|
DEFUN_VOID (print_header)
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
if (first_output)
|
|
|
|
{
|
|
|
|
first_output = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf ("\f\n");
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
if (!bsd_style_output)
|
|
|
|
{
|
|
|
|
if (print_descriptions)
|
|
|
|
{
|
|
|
|
printf ("\t\t Call graph (explanation follows)\n\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf ("\t\t\tCall graph\n\n");
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
printf ("\ngranularity: each sample hit covers %ld byte(s)",
|
|
|
|
(long) hist_scale * sizeof (UNIT));
|
|
|
|
if (print_time > 0.0)
|
|
|
|
{
|
|
|
|
printf (" for %.2f%% of %.2f seconds\n\n",
|
|
|
|
100.0 / print_time, print_time / hz);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf (" no time propagated\n\n");
|
|
|
|
/*
|
|
|
|
* This doesn't hurt, since all the numerators will be 0.0:
|
|
|
|
*/
|
|
|
|
print_time = 1.0;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
if (bsd_style_output)
|
|
|
|
{
|
|
|
|
printf ("%6.6s %5.5s %7.7s %11.11s %7.7s/%-7.7s %-8.8s\n",
|
|
|
|
"", "", "", "", "called", "total", "parents");
|
|
|
|
printf ("%-6.6s %5.5s %7.7s %11.11s %7.7s+%-7.7s %-8.8s\t%5.5s\n",
|
|
|
|
"index", "%time", "self", "descendents",
|
|
|
|
"called", "self", "name", "index");
|
|
|
|
printf ("%6.6s %5.5s %7.7s %11.11s %7.7s/%-7.7s %-8.8s\n",
|
|
|
|
"", "", "", "", "called", "total", "children");
|
|
|
|
printf ("\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf ("index %% time self children called name\n");
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
|
|
|
}
|
1995-02-07 22:34:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Print a cycle header.
|
|
|
|
*/
|
|
|
|
static void
|
1995-02-08 02:35:44 +00:00
|
|
|
DEFUN (print_cycle, (cyc), Sym * cyc)
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
char buf[BUFSIZ];
|
1995-02-07 22:34:18 +00:00
|
|
|
|
1995-02-08 02:35:44 +00:00
|
|
|
sprintf (buf, "[%d]", cyc->cg.index);
|
|
|
|
printf ("%-6.6s %5.1f %7.2f %11.2f %7d", buf,
|
|
|
|
100 * (cyc->cg.prop.self + cyc->cg.prop.child) / print_time,
|
|
|
|
cyc->cg.prop.self / hz, cyc->cg.prop.child / hz, cyc->ncalls);
|
|
|
|
if (cyc->cg.self_calls != 0)
|
|
|
|
{
|
|
|
|
printf ("+%-7d", cyc->cg.self_calls);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf (" %7.7s", "");
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
printf (" <cycle %d as a whole>\t[%d]\n", cyc->cg.cyc.num, cyc->cg.index);
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-07 22:34:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compare LEFT and RIGHT membmer. Major comparison key is
|
|
|
|
* CG.PROP.SELF+CG.PROP.CHILD, secondary key is NCALLS+CG.SELF_CALLS.
|
|
|
|
*/
|
|
|
|
static int
|
1995-02-08 02:35:44 +00:00
|
|
|
DEFUN (cmp_member, (left, right), Sym * left AND Sym * right)
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
double left_time = left->cg.prop.self + left->cg.prop.child;
|
|
|
|
double right_time = right->cg.prop.self + right->cg.prop.child;
|
|
|
|
long left_calls = left->ncalls + left->cg.self_calls;
|
|
|
|
long right_calls = right->ncalls + right->cg.self_calls;
|
|
|
|
|
|
|
|
if (left_time > right_time)
|
|
|
|
{
|
|
|
|
return GREATERTHAN;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
if (left_time < right_time)
|
|
|
|
{
|
|
|
|
return LESSTHAN;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
|
|
|
|
if (left_calls > right_calls)
|
|
|
|
{
|
|
|
|
return GREATERTHAN;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
if (left_calls < right_calls)
|
|
|
|
{
|
|
|
|
return LESSTHAN;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
return EQUALTO;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-07 22:34:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sort members of a cycle.
|
|
|
|
*/
|
|
|
|
static void
|
1995-02-08 02:35:44 +00:00
|
|
|
DEFUN (sort_members, (cyc), Sym * cyc)
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
Sym *todo, *doing, *prev;
|
|
|
|
/*
|
|
|
|
* Detach cycle members from cyclehead, and insertion sort them
|
|
|
|
* back on.
|
|
|
|
*/
|
|
|
|
todo = cyc->cg.cyc.next;
|
|
|
|
cyc->cg.cyc.next = 0;
|
|
|
|
for (doing = todo; doing && doing->cg.cyc.next; doing = todo)
|
|
|
|
{
|
|
|
|
todo = doing->cg.cyc.next;
|
|
|
|
for (prev = cyc; prev->cg.cyc.next; prev = prev->cg.cyc.next)
|
|
|
|
{
|
|
|
|
if (cmp_member (doing, prev->cg.cyc.next) == GREATERTHAN)
|
|
|
|
{
|
|
|
|
break;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
doing->cg.cyc.next = prev->cg.cyc.next;
|
|
|
|
prev->cg.cyc.next = doing;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
|
|
|
}
|
1995-02-07 22:34:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Print the members of a cycle.
|
|
|
|
*/
|
|
|
|
static void
|
1995-02-08 02:35:44 +00:00
|
|
|
DEFUN (print_members, (cyc), Sym * cyc)
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
Sym *member;
|
|
|
|
|
|
|
|
sort_members (cyc);
|
|
|
|
for (member = cyc->cg.cyc.next; member; member = member->cg.cyc.next)
|
|
|
|
{
|
|
|
|
printf ("%6.6s %5.5s %7.2f %11.2f %7d",
|
|
|
|
"", "", member->cg.prop.self / hz, member->cg.prop.child / hz,
|
|
|
|
member->ncalls);
|
|
|
|
if (member->cg.self_calls != 0)
|
|
|
|
{
|
|
|
|
printf ("+%-7d", member->cg.self_calls);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf (" %7.7s", "");
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
printf (" ");
|
|
|
|
print_name (member);
|
|
|
|
printf ("\n");
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
|
|
|
}
|
1995-02-07 22:34:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compare two arcs to/from the same child/parent.
|
1995-02-08 02:35:44 +00:00
|
|
|
* - if one arc is a self arc, it's least.
|
|
|
|
* - if one arc is within a cycle, it's less than.
|
|
|
|
* - if both arcs are within a cycle, compare arc counts.
|
|
|
|
* - if neither arc is within a cycle, compare with
|
|
|
|
* time + child_time as major key
|
|
|
|
* arc count as minor key
|
1995-02-07 22:34:18 +00:00
|
|
|
*/
|
|
|
|
static int
|
1995-02-08 02:35:44 +00:00
|
|
|
DEFUN (cmp_arc, (left, right), Arc * left AND Arc * right)
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
Sym *left_parent = left->parent;
|
|
|
|
Sym *left_child = left->child;
|
|
|
|
Sym *right_parent = right->parent;
|
|
|
|
Sym *right_child = right->child;
|
|
|
|
double left_time, right_time;
|
|
|
|
|
|
|
|
DBG (TIMEDEBUG,
|
|
|
|
printf ("[cmp_arc] ");
|
|
|
|
print_name (left_parent);
|
|
|
|
printf (" calls ");
|
|
|
|
print_name (left_child);
|
|
|
|
printf (" %f + %f %d/%d\n", left->time, left->child_time,
|
1995-02-07 22:34:18 +00:00
|
|
|
left->count, left_child->ncalls);
|
1995-02-08 02:35:44 +00:00
|
|
|
printf ("[cmp_arc] ");
|
|
|
|
print_name (right_parent);
|
|
|
|
printf (" calls ");
|
|
|
|
print_name (right_child);
|
|
|
|
printf (" %f + %f %d/%d\n", right->time, right->child_time,
|
1995-02-07 22:34:18 +00:00
|
|
|
right->count, right_child->ncalls);
|
1995-02-08 02:35:44 +00:00
|
|
|
printf ("\n");
|
|
|
|
);
|
|
|
|
if (left_parent == left_child)
|
|
|
|
{
|
|
|
|
return LESSTHAN; /* left is a self call */
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
if (right_parent == right_child)
|
|
|
|
{
|
|
|
|
return GREATERTHAN; /* right is a self call */
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
|
|
|
|
if (left_parent->cg.cyc.num != 0 && left_child->cg.cyc.num != 0
|
|
|
|
&& left_parent->cg.cyc.num == left_child->cg.cyc.num)
|
|
|
|
{
|
|
|
|
/* left is a call within a cycle */
|
|
|
|
if (right_parent->cg.cyc.num != 0 && right_child->cg.cyc.num != 0
|
|
|
|
&& right_parent->cg.cyc.num == right_child->cg.cyc.num)
|
|
|
|
{
|
|
|
|
/* right is a call within the cycle, too */
|
|
|
|
if (left->count < right->count)
|
|
|
|
{
|
|
|
|
return LESSTHAN;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
if (left->count > right->count)
|
|
|
|
{
|
|
|
|
return GREATERTHAN;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
return EQUALTO;
|
|
|
|
}
|
|
|
|
else
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
/* right isn't a call within the cycle */
|
|
|
|
return LESSTHAN;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* left isn't a call within a cycle */
|
|
|
|
if (right_parent->cg.cyc.num != 0 && right_child->cg.cyc.num != 0
|
|
|
|
&& right_parent->cg.cyc.num == right_child->cg.cyc.num)
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
/* right is a call within a cycle */
|
|
|
|
return GREATERTHAN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* neither is a call within a cycle */
|
|
|
|
left_time = left->time + left->child_time;
|
|
|
|
right_time = right->time + right->child_time;
|
|
|
|
if (left_time < right_time)
|
|
|
|
{
|
|
|
|
return LESSTHAN;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
if (left_time > right_time)
|
|
|
|
{
|
|
|
|
return GREATERTHAN;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
if (left->count < right->count)
|
|
|
|
{
|
|
|
|
return LESSTHAN;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
if (left->count > right->count)
|
|
|
|
{
|
|
|
|
return GREATERTHAN;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
return EQUALTO;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1995-02-07 22:34:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
1995-02-08 02:35:44 +00:00
|
|
|
DEFUN (sort_parents, (child), Sym * child)
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
Arc *arc, *detached, sorted, *prev;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Unlink parents from child, then insertion sort back on to
|
|
|
|
* sorted's parents.
|
|
|
|
* *arc the arc you have detached and are inserting.
|
|
|
|
* *detached the rest of the arcs to be sorted.
|
|
|
|
* sorted arc list onto which you insertion sort.
|
|
|
|
* *prev arc before the arc you are comparing.
|
|
|
|
*/
|
|
|
|
sorted.next_parent = 0;
|
|
|
|
for (arc = child->cg.parents; arc; arc = detached)
|
|
|
|
{
|
|
|
|
detached = arc->next_parent;
|
|
|
|
|
|
|
|
/* consider *arc as disconnected; insert it into sorted: */
|
|
|
|
for (prev = &sorted; prev->next_parent; prev = prev->next_parent)
|
|
|
|
{
|
|
|
|
if (cmp_arc (arc, prev->next_parent) != GREATERTHAN)
|
|
|
|
{
|
|
|
|
break;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
arc->next_parent = prev->next_parent;
|
|
|
|
prev->next_parent = arc;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
|
|
|
|
/* reattach sorted arcs to child: */
|
|
|
|
child->cg.parents = sorted.next_parent;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-07 22:34:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
1995-02-08 02:35:44 +00:00
|
|
|
DEFUN (print_parents, (child), Sym * child)
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
Sym *parent;
|
|
|
|
Arc *arc;
|
|
|
|
Sym *cycle_head;
|
|
|
|
|
|
|
|
if (child->cg.cyc.head != 0)
|
|
|
|
{
|
|
|
|
cycle_head = child->cg.cyc.head;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cycle_head = child;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
if (!child->cg.parents)
|
|
|
|
{
|
|
|
|
printf (bsd_style_output
|
|
|
|
? "%6.6s %5.5s %7.7s %11.11s %7.7s %7.7s <spontaneous>\n"
|
|
|
|
: "%6.6s %5.5s %7.7s %7.7s %7.7s %7.7s <spontaneous>\n",
|
|
|
|
"", "", "", "", "", "");
|
|
|
|
return;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
sort_parents (child);
|
|
|
|
for (arc = child->cg.parents; arc; arc = arc->next_parent)
|
|
|
|
{
|
|
|
|
parent = arc->parent;
|
|
|
|
if (child == parent || (child->cg.cyc.num != 0
|
|
|
|
&& parent->cg.cyc.num == child->cg.cyc.num))
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
/* selfcall or call among siblings: */
|
|
|
|
printf (bsd_style_output
|
|
|
|
? "%6.6s %5.5s %7.7s %11.11s %7d %7.7s "
|
|
|
|
: "%6.6s %5.5s %7.7s %7.7s %7d %7.7s ",
|
|
|
|
"", "", "", "",
|
|
|
|
arc->count, "");
|
|
|
|
print_name (parent);
|
|
|
|
printf ("\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* regular parent of child: */
|
|
|
|
printf (bsd_style_output
|
|
|
|
? "%6.6s %5.5s %7.2f %11.2f %7d/%-7d "
|
|
|
|
: "%6.6s %5.5s %7.2f %7.2f %7d/%-7d ",
|
|
|
|
"", "",
|
|
|
|
arc->time / hz, arc->child_time / hz,
|
|
|
|
arc->count, cycle_head->ncalls);
|
|
|
|
print_name (parent);
|
|
|
|
printf ("\n");
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1995-02-07 22:34:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
1995-02-08 02:35:44 +00:00
|
|
|
DEFUN (sort_children, (parent), Sym * parent)
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
Arc *arc, *detached, sorted, *prev;
|
|
|
|
/*
|
|
|
|
* Unlink children from parent, then insertion sort back on to
|
|
|
|
* sorted's children.
|
|
|
|
* *arc the arc you have detached and are inserting.
|
|
|
|
* *detached the rest of the arcs to be sorted.
|
|
|
|
* sorted arc list onto which you insertion sort.
|
|
|
|
* *prev arc before the arc you are comparing.
|
|
|
|
*/
|
|
|
|
sorted.next_child = 0;
|
|
|
|
for (arc = parent->cg.children; arc; arc = detached)
|
|
|
|
{
|
|
|
|
detached = arc->next_child;
|
|
|
|
|
|
|
|
/* consider *arc as disconnected; insert it into sorted: */
|
|
|
|
for (prev = &sorted; prev->next_child; prev = prev->next_child)
|
|
|
|
{
|
|
|
|
if (cmp_arc (arc, prev->next_child) != LESSTHAN)
|
|
|
|
{
|
|
|
|
break;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
arc->next_child = prev->next_child;
|
|
|
|
prev->next_child = arc;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
|
|
|
|
/* reattach sorted children to parent: */
|
|
|
|
parent->cg.children = sorted.next_child;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-07 22:34:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
1995-02-08 02:35:44 +00:00
|
|
|
DEFUN (print_children, (parent), Sym * parent)
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
Sym *child;
|
|
|
|
Arc *arc;
|
|
|
|
|
|
|
|
sort_children (parent);
|
|
|
|
arc = parent->cg.children;
|
|
|
|
for (arc = parent->cg.children; arc; arc = arc->next_child)
|
|
|
|
{
|
|
|
|
child = arc->child;
|
|
|
|
if (child == parent || (child->cg.cyc.num != 0
|
|
|
|
&& child->cg.cyc.num == parent->cg.cyc.num))
|
|
|
|
{
|
|
|
|
/* self call or call to sibling: */
|
|
|
|
printf (bsd_style_output
|
|
|
|
? "%6.6s %5.5s %7.7s %11.11s %7d %7.7s "
|
|
|
|
: "%6.6s %5.5s %7.7s %7.7s %7d %7.7s ",
|
|
|
|
"", "", "", "", arc->count, "");
|
|
|
|
print_name (child);
|
|
|
|
printf ("\n");
|
|
|
|
}
|
|
|
|
else
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
/* regular child of parent: */
|
|
|
|
printf (bsd_style_output
|
|
|
|
? "%6.6s %5.5s %7.2f %11.2f %7d/%-7d "
|
|
|
|
: "%6.6s %5.5s %7.2f %7.2f %7d/%-7d ",
|
|
|
|
"", "",
|
|
|
|
arc->time / hz, arc->child_time / hz,
|
|
|
|
arc->count, child->cg.cyc.head->ncalls);
|
|
|
|
print_name (child);
|
|
|
|
printf ("\n");
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1995-02-07 22:34:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
1995-02-08 02:35:44 +00:00
|
|
|
DEFUN (print_line, (np), Sym * np)
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
char buf[BUFSIZ];
|
|
|
|
|
|
|
|
sprintf (buf, "[%d]", np->cg.index);
|
|
|
|
printf (bsd_style_output
|
|
|
|
? "%-6.6s %5.1f %7.2f %11.2f"
|
|
|
|
: "%-6.6s %5.1f %7.2f %7.2f", buf,
|
|
|
|
100 * (np->cg.prop.self + np->cg.prop.child) / print_time,
|
|
|
|
np->cg.prop.self / hz, np->cg.prop.child / hz);
|
|
|
|
if ((np->ncalls + np->cg.self_calls) != 0)
|
|
|
|
{
|
|
|
|
printf (" %7d", np->ncalls);
|
|
|
|
if (np->cg.self_calls != 0)
|
|
|
|
{
|
|
|
|
printf ("+%-7d ", np->cg.self_calls);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf (" %7.7s ", "");
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf (" %7.7s %7.7s ", "", "");
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
print_name (np);
|
|
|
|
printf ("\n");
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-07 22:34:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Print dynamic call graph.
|
|
|
|
*/
|
|
|
|
void
|
1995-02-08 02:35:44 +00:00
|
|
|
DEFUN (cg_print, (timesortsym), Sym ** timesortsym)
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
int index;
|
|
|
|
Sym *parent;
|
1995-02-07 22:34:18 +00:00
|
|
|
|
1995-02-08 02:35:44 +00:00
|
|
|
if (print_descriptions && bsd_style_output)
|
|
|
|
{
|
|
|
|
bsd_callg_blurb (stdout);
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-07 22:34:18 +00:00
|
|
|
|
1995-02-08 02:35:44 +00:00
|
|
|
print_header ();
|
1995-02-07 22:34:18 +00:00
|
|
|
|
1995-02-08 02:35:44 +00:00
|
|
|
for (index = 0; index < symtab.len + num_cycles; ++index)
|
|
|
|
{
|
|
|
|
parent = timesortsym[index];
|
|
|
|
if ((ignore_zeros && parent->ncalls == 0
|
|
|
|
&& parent->cg.self_calls == 0 && parent->cg.prop.self == 0
|
|
|
|
&& parent->cg.prop.child == 0)
|
|
|
|
|| !parent->cg.print_flag)
|
|
|
|
{
|
|
|
|
continue;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
if (!parent->name && parent->cg.cyc.num != 0)
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
/* cycle header: */
|
|
|
|
print_cycle (parent);
|
|
|
|
print_members (parent);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print_parents (parent);
|
|
|
|
print_line (parent);
|
|
|
|
print_children (parent);
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
if (bsd_style_output)
|
|
|
|
printf ("\n");
|
|
|
|
printf ("-----------------------------------------------\n");
|
|
|
|
if (bsd_style_output)
|
|
|
|
printf ("\n");
|
1995-02-07 22:34:18 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
free (timesortsym);
|
|
|
|
if (print_descriptions && !bsd_style_output)
|
|
|
|
{
|
|
|
|
fsf_callg_blurb (stdout);
|
1995-02-07 22:34:18 +00:00
|
|
|
}
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-07 22:34:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
static int
|
1995-02-08 02:35:44 +00:00
|
|
|
DEFUN (cmp_name, (left, right), const PTR left AND const PTR right)
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
const Sym **npp1 = (const Sym **) left;
|
|
|
|
const Sym **npp2 = (const Sym **) right;
|
1995-02-07 22:34:18 +00:00
|
|
|
|
1995-02-08 02:35:44 +00:00
|
|
|
return strcmp ((*npp1)->name, (*npp2)->name);
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-07 22:34:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
void
|
1995-02-08 02:35:44 +00:00
|
|
|
DEFUN_VOID (cg_print_index)
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
int index, nnames, todo, i, j, col, starting_col;
|
|
|
|
Sym **name_sorted_syms, *sym;
|
|
|
|
const char *filename;
|
|
|
|
char buf[20];
|
|
|
|
int column_width = (output_width - 1) / 3; /* don't write in last col! */
|
|
|
|
/*
|
|
|
|
* Now, sort regular function name alphabetically to create an
|
|
|
|
* index:
|
|
|
|
*/
|
|
|
|
name_sorted_syms = (Sym **) xmalloc ((symtab.len + num_cycles) * sizeof (Sym *));
|
|
|
|
for (index = 0, nnames = 0; index < symtab.len; index++)
|
|
|
|
{
|
|
|
|
if (ignore_zeros && symtab.base[index].ncalls == 0
|
|
|
|
&& symtab.base[index].hist.time == 0)
|
|
|
|
{
|
|
|
|
continue;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
name_sorted_syms[nnames++] = &symtab.base[index];
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
qsort (name_sorted_syms, nnames, sizeof (Sym *), cmp_name);
|
|
|
|
for (index = 1, todo = nnames; index <= num_cycles; index++)
|
|
|
|
{
|
|
|
|
name_sorted_syms[todo++] = &cycle_header[index];
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
printf ("\f\nIndex by function name\n\n");
|
|
|
|
index = (todo + 2) / 3;
|
|
|
|
for (i = 0; i < index; i++)
|
|
|
|
{
|
|
|
|
col = 0;
|
|
|
|
starting_col = 0;
|
|
|
|
for (j = i; j < todo; j += index)
|
1995-02-07 22:34:18 +00:00
|
|
|
{
|
1995-02-08 02:35:44 +00:00
|
|
|
sym = name_sorted_syms[j];
|
|
|
|
if (sym->cg.print_flag)
|
|
|
|
{
|
|
|
|
sprintf (buf, "[%d]", sym->cg.index);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprintf (buf, "(%d)", sym->cg.index);
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
if (j < nnames)
|
|
|
|
{
|
|
|
|
if (bsd_style_output)
|
|
|
|
{
|
|
|
|
printf ("%6.6s %-19.19s", buf, sym->name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
col += strlen (buf);
|
|
|
|
for (; col < starting_col + 5; ++col)
|
|
|
|
{
|
|
|
|
putchar (' ');
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
printf (" %s ", buf);
|
|
|
|
col += print_name_only (sym);
|
|
|
|
if (!line_granularity && sym->is_static && sym->file)
|
|
|
|
{
|
|
|
|
filename = sym->file->name;
|
|
|
|
if (!print_path)
|
|
|
|
{
|
|
|
|
filename = strrchr (filename, '/');
|
|
|
|
if (filename)
|
|
|
|
{
|
|
|
|
++filename;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
filename = sym->file->name;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
printf (" (%s)", filename);
|
|
|
|
col += strlen (filename) + 3;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf ("%6.6s ", buf);
|
|
|
|
sprintf (buf, "<cycle %d>", sym->cg.cyc.num);
|
|
|
|
printf ("%-19.19s", buf);
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
starting_col += column_width;
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
printf ("\n");
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|
1995-02-08 02:35:44 +00:00
|
|
|
free (name_sorted_syms);
|
1995-03-14 02:58:16 +00:00
|
|
|
}
|