* alpha.c (alpha_find_call): Warning fixes.

* mips.c (mips_find_call): Likewise.
	* sparc.c (sparc_find_call): Likewise.
	* basic_blocks.c: Warning fixes.  Eliminate DEFUN.
	* call_graph.c: Likewise.
	* cg_arcs.c: Likewise.
	* cg_dfn.cp: Likewise.
	* gprof.c: Likewise.
	* gprof.h: Likewise.
	* hist.c: Likewise.
	* search_list.c: Likewise.
	* source.c: Likewise.
	* source.h: Likewise.
	* sym_ids.c: Likewise.
	* symtab.c: Likewise.
	* symtab.h: Likewise.
	* utils.c: Likewise.
	* cg_print.c: Likewise.
	(struct function_map, symbol_map, symbol_map_count): Move
	declaration to..
	* corefile: ..here.
	* corefile.c: Warning fixes.  Eliminate DEFUN.
	(struct function_map): Remove declaration.
	* gmon_io.c: Warning fixes.  Eliminate DEFUN.
	(gmon_io_read_64): Make static.
	(gmon_io_write_64): Likewise.
	(gmon_read_raw_arc): Likewise.
	(gmon_write_raw_arc): Likewise.
	(gmon_io_write_8): Don't pass char, pass int param.
	* gmon_io.h (gmon_io_write_8): Likewise.

and a few copyright dates that should have been done previously.
This commit is contained in:
Alan Modra
2002-02-01 08:24:16 +00:00
parent 48fa4a5def
commit 1355568ab4
25 changed files with 446 additions and 223 deletions

View File

@@ -1,5 +1,36 @@
2002-02-01 Alan Modra <amodra@bigpond.net.au> 2002-02-01 Alan Modra <amodra@bigpond.net.au>
* alpha.c (alpha_find_call): Warning fixes.
* mips.c (mips_find_call): Likewise.
* sparc.c (sparc_find_call): Likewise.
* basic_blocks.c: Warning fixes. Eliminate DEFUN.
* call_graph.c: Likewise.
* cg_arcs.c: Likewise.
* cg_dfn.cp: Likewise.
* gprof.c: Likewise.
* gprof.h: Likewise.
* hist.c: Likewise.
* search_list.c: Likewise.
* source.c: Likewise.
* source.h: Likewise.
* sym_ids.c: Likewise.
* symtab.c: Likewise.
* symtab.h: Likewise.
* utils.c: Likewise.
* cg_print.c: Likewise.
(struct function_map, symbol_map, symbol_map_count): Move
declaration to..
* corefile: ..here.
* corefile.c: Warning fixes. Eliminate DEFUN.
(struct function_map): Remove declaration.
* gmon_io.c: Warning fixes. Eliminate DEFUN.
(gmon_io_read_64): Make static.
(gmon_io_write_64): Likewise.
(gmon_read_raw_arc): Likewise.
(gmon_write_raw_arc): Likewise.
(gmon_io_write_8): Don't pass char, pass int param.
* gmon_io.h (gmon_io_write_8): Likewise.
* Makefile.am: Run "make dep-am" * Makefile.am: Run "make dep-am"
* Makefile.in: Regenerate. * Makefile.in: Regenerate.

View File

@@ -84,7 +84,7 @@ alpha_find_call (parent, p_lowpc, p_highpc)
bfd_vma p_highpc; bfd_vma p_highpc;
{ {
bfd_vma pc, dest_pc; bfd_vma pc, dest_pc;
unsigned long insn; unsigned int insn;
Sym *child; Sym *child;
if (indirect_child.name == NULL) if (indirect_child.name == NULL)
@@ -110,7 +110,7 @@ alpha_find_call (parent, p_lowpc, p_highpc)
DBG (CALLDEBUG, printf (_("[find_call] %s: 0x%lx to 0x%lx\n"), DBG (CALLDEBUG, printf (_("[find_call] %s: 0x%lx to 0x%lx\n"),
parent->name, (unsigned long) p_lowpc, parent->name, (unsigned long) p_lowpc,
(unsigned long) p_highpc)); (unsigned long) p_highpc));
for (pc = (p_lowpc + 3) & ~3; pc < p_highpc; pc += 4) for (pc = (p_lowpc + 3) & ~(bfd_vma) 3; pc < p_highpc; pc += 4)
{ {
insn = bfd_get_32 (core_bfd, ((unsigned char *) core_text_space insn = bfd_get_32 (core_bfd, ((unsigned char *) core_text_space
+ pc - core_text_sect->vma)); + pc - core_text_sect->vma));

View File

@@ -2,7 +2,7 @@
of basic-block info to/from gmon.out; computing and formatting of of basic-block info to/from gmon.out; computing and formatting of
basic-block related statistics. basic-block related statistics.
Copyright 2000, 2001 Free Software Foundation, Inc. Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Binutils. This file is part of GNU Binutils.
@@ -32,6 +32,11 @@
#include "symtab.h" #include "symtab.h"
#include "sym_ids.h" #include "sym_ids.h"
static int cmp_bb PARAMS ((const PTR, const PTR));
static int cmp_ncalls PARAMS ((const PTR, const PTR));
static void fskip_string PARAMS ((FILE *));
static void annotate_with_count PARAMS ((char *, unsigned int, int, PTR));
/* Default option values: */ /* Default option values: */
boolean bb_annotate_all_lines = false; boolean bb_annotate_all_lines = false;
unsigned long bb_min_calls = 1; unsigned long bb_min_calls = 1;
@@ -47,7 +52,9 @@ static long num_lines_executed;
number, and address (in that order). */ number, and address (in that order). */
static int static int
DEFUN (cmp_bb, (lp, rp), const void *lp AND const void *rp) cmp_bb (lp, rp)
const PTR lp;
const PTR rp;
{ {
int r; int r;
const Sym *left = *(const Sym **) lp; const Sym *left = *(const Sym **) lp;
@@ -76,7 +83,9 @@ DEFUN (cmp_bb, (lp, rp), const void *lp AND const void *rp)
/* Helper for sorting. Order basic blocks in decreasing number of /* Helper for sorting. Order basic blocks in decreasing number of
calls, ties are broken in increasing order of line numbers. */ calls, ties are broken in increasing order of line numbers. */
static int static int
DEFUN (cmp_ncalls, (lp, rp), const void *lp AND const void *rp) cmp_ncalls (lp, rp)
const PTR lp;
const PTR rp;
{ {
const Sym *left = *(const Sym **) lp; const Sym *left = *(const Sym **) lp;
const Sym *right = *(const Sym **) rp; const Sym *right = *(const Sym **) rp;
@@ -96,7 +105,8 @@ DEFUN (cmp_ncalls, (lp, rp), const void *lp AND const void *rp)
/* Skip over variable length string. */ /* Skip over variable length string. */
static void static void
DEFUN (fskip_string, (fp), FILE * fp) fskip_string (fp)
FILE *fp;
{ {
int ch; int ch;
@@ -111,7 +121,9 @@ DEFUN (fskip_string, (fp), FILE * fp)
of file IFP and is provided for formatting error-messages only. */ of file IFP and is provided for formatting error-messages only. */
void void
DEFUN (bb_read_rec, (ifp, filename), FILE * ifp AND const char *filename) bb_read_rec (ifp, filename)
FILE *ifp;
const char *filename;
{ {
int nblocks, b; int nblocks, b;
bfd_vma addr, ncalls; bfd_vma addr, ncalls;
@@ -199,9 +211,11 @@ DEFUN (bb_read_rec, (ifp, filename), FILE * ifp AND const char *filename)
is the name of OFP and is provided for producing error-messages is the name of OFP and is provided for producing error-messages
only. */ only. */
void void
DEFUN (bb_write_blocks, (ofp, filename), FILE * ofp AND const char *filename) bb_write_blocks (ofp, filename)
FILE *ofp;
const char *filename;
{ {
int nblocks = 0; unsigned int nblocks = 0;
Sym *sym; Sym *sym;
int i; int i;
@@ -227,7 +241,7 @@ DEFUN (bb_write_blocks, (ofp, filename), FILE * ofp AND const char *filename)
for (i = 0; i < NBBS && sym->bb_addr[i]; i++) for (i = 0; i < NBBS && sym->bb_addr[i]; i++)
{ {
if (gmon_io_write_vma (ofp, sym->bb_addr[i]) if (gmon_io_write_vma (ofp, sym->bb_addr[i])
|| gmon_io_write_vma (ofp, sym->bb_calls[i])) || gmon_io_write_vma (ofp, (bfd_vma) sym->bb_calls[i]))
{ {
perror (filename); perror (filename);
done (1); done (1);
@@ -242,10 +256,10 @@ DEFUN (bb_write_blocks, (ofp, filename), FILE * ofp AND const char *filename)
<filename>:<line-number>: (<function-name>:<bb-addr): <ncalls> */ <filename>:<line-number>: (<function-name>:<bb-addr): <ncalls> */
void void
DEFUN_VOID (print_exec_counts) print_exec_counts ()
{ {
Sym **sorted_bbs, *sym; Sym **sorted_bbs, *sym;
int i, j, len; unsigned int i, j, len;
if (first_output) if (first_output)
first_output = false; first_output = false;
@@ -309,12 +323,15 @@ DEFUN_VOID (print_exec_counts)
that starts the basic-block. */ that starts the basic-block. */
static void static void
DEFUN (annotate_with_count, (buf, width, line_num, arg), annotate_with_count (buf, width, line_num, arg)
char *buf AND int width AND int line_num AND void *arg) char *buf;
unsigned int width;
int line_num;
PTR arg;
{ {
Source_File *sf = arg; Source_File *sf = arg;
Sym *b; Sym *b;
int i; unsigned int i;
static unsigned long last_count; static unsigned long last_count;
unsigned long last_print = (unsigned long) -1; unsigned long last_print = (unsigned long) -1;
@@ -335,7 +352,7 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
char *p; char *p;
unsigned long ncalls; unsigned long ncalls;
int ncalls_set; int ncalls_set;
int len; unsigned int len;
++num_executable_lines; ++num_executable_lines;
@@ -411,7 +428,7 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
if (! ncalls_set) if (! ncalls_set)
{ {
int c; unsigned int c;
for (c = 0; c < width; c++) for (c = 0; c < width; c++)
buf[c] = ' '; buf[c] = ' ';
@@ -438,7 +455,7 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
} }
else else
{ {
int c; unsigned int c;
strcpy (buf + width - len, tmpbuf); strcpy (buf + width - len, tmpbuf);
for (c = 0; c < width - len; ++c) for (c = 0; c < width - len; ++c)
@@ -452,7 +469,7 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
regarding that source file are printed. */ regarding that source file are printed. */
void void
DEFUN_VOID (print_annotated_source) print_annotated_source ()
{ {
Sym *sym, *line_stats, *new_line; Sym *sym, *line_stats, *new_line;
Source_File *sf; Source_File *sf;

View File

@@ -1,5 +1,5 @@
/* basic_blocks.h /* basic_blocks.h
Copyright 2000 Free Software Foundation, Inc. Copyright 2000, 2002 Free Software Foundation, Inc.
This file is part of GNU Binutils. This file is part of GNU Binutils.

View File

@@ -1,6 +1,6 @@
/* call_graph.c - Create call graphs. /* call_graph.c - Create call graphs.
Copyright 2000, 2001 Free Software Foundation, Inc. Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Binutils. This file is part of GNU Binutils.
@@ -30,9 +30,11 @@
#include "gmon_out.h" #include "gmon_out.h"
#include "sym_ids.h" #include "sym_ids.h"
extern void void
DEFUN (cg_tally, (from_pc, self_pc, count), cg_tally (from_pc, self_pc, count)
bfd_vma from_pc AND bfd_vma self_pc AND unsigned long count) bfd_vma from_pc;
bfd_vma self_pc;
unsigned long count;
{ {
Sym *parent; Sym *parent;
Sym *child; Sym *child;
@@ -78,7 +80,9 @@ DEFUN (cg_tally, (from_pc, self_pc, count),
for formatting error-messages only. */ for formatting error-messages only. */
void void
DEFUN (cg_read_rec, (ifp, filename), FILE * ifp AND CONST char *filename) cg_read_rec (ifp, filename)
FILE *ifp;
const char *filename;
{ {
bfd_vma from_pc, self_pc; bfd_vma from_pc, self_pc;
unsigned int count; unsigned int count;
@@ -105,7 +109,9 @@ DEFUN (cg_read_rec, (ifp, filename), FILE * ifp AND CONST char *filename)
only. */ only. */
void void
DEFUN (cg_write_arcs, (ofp, filename), FILE * ofp AND const char *filename) cg_write_arcs (ofp, filename)
FILE *ofp;
const char *filename;
{ {
Arc *arc; Arc *arc;
Sym *sym; Sym *sym;

View File

@@ -28,6 +28,14 @@
#include "utils.h" #include "utils.h"
#include "sym_ids.h" #include "sym_ids.h"
static int cmp_topo PARAMS ((const PTR, const PTR));
static void propagate_time PARAMS ((Sym *));
static void cycle_time PARAMS ((void));
static void cycle_link PARAMS ((void));
static void inherit_flags PARAMS ((Sym *));
static void propagate_flags PARAMS ((Sym **));
static int cmp_total PARAMS ((const PTR, const PTR));
Sym *cycle_header; Sym *cycle_header;
unsigned int num_cycles; unsigned int num_cycles;
Arc **arcs; Arc **arcs;
@@ -38,7 +46,9 @@ unsigned int numarcs;
* range covered by CHILD. * range covered by CHILD.
*/ */
Arc * Arc *
DEFUN (arc_lookup, (parent, child), Sym * parent AND Sym * child) arc_lookup (parent, child)
Sym *parent;
Sym *child;
{ {
Arc *arc; Arc *arc;
@@ -67,8 +77,10 @@ DEFUN (arc_lookup, (parent, child), Sym * parent AND Sym * child)
* Add (or just increment) an arc: * Add (or just increment) an arc:
*/ */
void void
DEFUN (arc_add, (parent, child, count), arc_add (parent, child, count)
Sym * parent AND Sym * child AND unsigned long count) Sym *parent;
Sym *child;
unsigned long count;
{ {
static unsigned int maxarcs = 0; static unsigned int maxarcs = 0;
Arc *arc, **newarcs; Arc *arc, **newarcs;
@@ -134,7 +146,9 @@ DEFUN (arc_add, (parent, child, count),
static int static int
DEFUN (cmp_topo, (lp, rp), const PTR lp AND const PTR rp) cmp_topo (lp, rp)
const PTR lp;
const PTR rp;
{ {
const Sym *left = *(const Sym **) lp; const Sym *left = *(const Sym **) lp;
const Sym *right = *(const Sym **) rp; const Sym *right = *(const Sym **) rp;
@@ -144,7 +158,8 @@ DEFUN (cmp_topo, (lp, rp), const PTR lp AND const PTR rp)
static void static void
DEFUN (propagate_time, (parent), Sym * parent) propagate_time (parent)
Sym *parent;
{ {
Arc *arc; Arc *arc;
Sym *child; Sym *child;
@@ -228,7 +243,7 @@ DEFUN (propagate_time, (parent), Sym * parent)
* its members. * its members.
*/ */
static void static void
DEFUN_VOID (cycle_time) cycle_time ()
{ {
Sym *member, *cyc; Sym *member, *cyc;
@@ -252,7 +267,7 @@ DEFUN_VOID (cycle_time)
static void static void
DEFUN_VOID (cycle_link) cycle_link ()
{ {
Sym *sym, *cyc, *member; Sym *sym, *cyc, *member;
Arc *arc; Arc *arc;
@@ -340,7 +355,8 @@ DEFUN_VOID (cycle_link)
* fractions from parents. * fractions from parents.
*/ */
static void static void
DEFUN (inherit_flags, (child), Sym * child) inherit_flags (child)
Sym *child;
{ {
Sym *head, *parent, *member; Sym *head, *parent, *member;
Arc *arc; Arc *arc;
@@ -418,7 +434,8 @@ DEFUN (inherit_flags, (child), Sym * child)
* and while we're here, sum time for functions. * and while we're here, sum time for functions.
*/ */
static void static void
DEFUN (propagate_flags, (symbols), Sym ** symbols) propagate_flags (symbols)
Sym **symbols;
{ {
int index; int index;
Sym *old_head, *child; Sym *old_head, *child;
@@ -518,7 +535,9 @@ DEFUN (propagate_flags, (symbols), Sym ** symbols)
* first. All else being equal, compare by names. * first. All else being equal, compare by names.
*/ */
static int static int
DEFUN (cmp_total, (lp, rp), const PTR lp AND const PTR rp) cmp_total (lp, rp)
const PTR lp;
const PTR rp;
{ {
const Sym *left = *(const Sym **) lp; const Sym *left = *(const Sym **) lp;
const Sym *right = *(const Sym **) rp; const Sym *right = *(const Sym **) rp;
@@ -575,7 +594,7 @@ DEFUN (cmp_total, (lp, rp), const PTR lp AND const PTR rp)
* time bottom up and flags top down. * time bottom up and flags top down.
*/ */
Sym ** Sym **
DEFUN_VOID (cg_assemble) cg_assemble ()
{ {
Sym *parent, **time_sorted_syms, **top_sorted_syms; Sym *parent, **time_sorted_syms, **top_sorted_syms;
unsigned int index; unsigned int index;

View File

@@ -34,6 +34,12 @@ typedef struct
} }
DFN_Stack; DFN_Stack;
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; DFN_Stack *dfn_stack = NULL;
int dfn_maxdepth = 0; int dfn_maxdepth = 0;
int dfn_depth = 0; int dfn_depth = 0;
@@ -44,7 +50,8 @@ int dfn_counter = DFN_NAN;
* Is CHILD already numbered? * Is CHILD already numbered?
*/ */
static boolean static boolean
DEFUN (is_numbered, (child), Sym * child) is_numbered (child)
Sym *child;
{ {
return child->cg.top_order != DFN_NAN && child->cg.top_order != DFN_BUSY; return child->cg.top_order != DFN_NAN && child->cg.top_order != DFN_BUSY;
} }
@@ -54,7 +61,8 @@ DEFUN (is_numbered, (child), Sym * child)
* Is CHILD already busy? * Is CHILD already busy?
*/ */
static boolean static boolean
DEFUN (is_busy, (child), Sym * child) is_busy (child)
Sym *child;
{ {
if (child->cg.top_order == DFN_NAN) if (child->cg.top_order == DFN_NAN)
{ {
@@ -71,7 +79,8 @@ DEFUN (is_busy, (child), Sym * child)
* depth-first number). * depth-first number).
*/ */
static void static void
DEFUN (find_cycle, (child), Sym * child) find_cycle (child)
Sym *child;
{ {
Sym *head = 0; Sym *head = 0;
Sym *tail; Sym *tail;
@@ -194,7 +203,8 @@ DEFUN (find_cycle, (child), Sym * child)
* the stack and mark it busy. * the stack and mark it busy.
*/ */
static void static void
DEFUN (pre_visit, (parent), Sym * parent) pre_visit (parent)
Sym *parent;
{ {
++dfn_depth; ++dfn_depth;
@@ -218,7 +228,8 @@ DEFUN (pre_visit, (parent), Sym * parent)
* and number functions if PARENT is head of a cycle. * and number functions if PARENT is head of a cycle.
*/ */
static void static void
DEFUN (post_visit, (parent), Sym * parent) post_visit (parent)
Sym *parent;
{ {
Sym *member; Sym *member;
@@ -252,7 +263,8 @@ DEFUN (post_visit, (parent), Sym * parent)
* Given this PARENT, depth first number its children. * Given this PARENT, depth first number its children.
*/ */
void void
DEFUN (cg_dfn, (parent), Sym * parent) cg_dfn (parent)
Sym *parent;
{ {
Arc *arc; Arc *arc;

View File

@@ -28,15 +28,30 @@
#include "cg_print.h" #include "cg_print.h"
#include "hist.h" #include "hist.h"
#include "utils.h" #include "utils.h"
#include "corefile.h"
/* Return value of comparison functions used to sort tables. */ /* Return value of comparison functions used to sort tables. */
#define LESSTHAN -1 #define LESSTHAN -1
#define EQUALTO 0 #define EQUALTO 0
#define GREATERTHAN 1 #define GREATERTHAN 1
static void order_and_dump_functions_by_arcs PARAMS ((Arc **, unsigned long, static void print_header PARAMS ((void));
int, Arc **, static void print_cycle PARAMS ((Sym *));
unsigned long *)); static int cmp_member PARAMS ((Sym *, Sym *));
static void sort_members PARAMS ((Sym *));
static void print_members PARAMS ((Sym *));
static int cmp_arc PARAMS ((Arc *, Arc *));
static void sort_parents PARAMS ((Sym *));
static void print_parents PARAMS ((Sym *));
static void sort_children PARAMS ((Sym *));
static void print_children PARAMS ((Sym *));
static void print_line PARAMS ((Sym *));
static int cmp_name PARAMS ((const PTR, const PTR));
static int cmp_arc_count PARAMS ((const PTR, const PTR));
static int cmp_fun_nuses PARAMS ((const PTR, const PTR));
static void order_and_dump_functions_by_arcs
PARAMS ((Arc **, unsigned long, int, Arc **, unsigned long *));
/* Declarations of automatically generated functions to output blurbs. */ /* Declarations of automatically generated functions to output blurbs. */
extern void bsd_callg_blurb PARAMS ((FILE * fp)); extern void bsd_callg_blurb PARAMS ((FILE * fp));
extern void fsf_callg_blurb PARAMS ((FILE * fp)); extern void fsf_callg_blurb PARAMS ((FILE * fp));
@@ -45,7 +60,7 @@ double print_time = 0.0;
static void static void
DEFUN_VOID (print_header) print_header ()
{ {
if (first_output) if (first_output)
first_output = false; first_output = false;
@@ -94,7 +109,8 @@ DEFUN_VOID (print_header)
/* Print a cycle header. */ /* Print a cycle header. */
static void static void
DEFUN (print_cycle, (cyc), Sym * cyc) print_cycle (cyc)
Sym *cyc;
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
@@ -117,7 +133,9 @@ DEFUN (print_cycle, (cyc), Sym * cyc)
CG.PROP.SELF+CG.PROP.CHILD, secondary key is NCALLS+CG.SELF_CALLS. */ CG.PROP.SELF+CG.PROP.CHILD, secondary key is NCALLS+CG.SELF_CALLS. */
static int static int
DEFUN (cmp_member, (left, right), Sym * left AND Sym * right) cmp_member (left, right)
Sym *left;
Sym *right;
{ {
double left_time = left->cg.prop.self + left->cg.prop.child; double left_time = left->cg.prop.self + left->cg.prop.child;
double right_time = right->cg.prop.self + right->cg.prop.child; double right_time = right->cg.prop.self + right->cg.prop.child;
@@ -142,7 +160,8 @@ DEFUN (cmp_member, (left, right), Sym * left AND Sym * right)
/* Sort members of a cycle. */ /* Sort members of a cycle. */
static void static void
DEFUN (sort_members, (cyc), Sym * cyc) sort_members (cyc)
Sym *cyc;
{ {
Sym *todo, *doing, *prev; Sym *todo, *doing, *prev;
@@ -169,7 +188,8 @@ DEFUN (sort_members, (cyc), Sym * cyc)
/* Print the members of a cycle. */ /* Print the members of a cycle. */
static void static void
DEFUN (print_members, (cyc), Sym * cyc) print_members (cyc)
Sym *cyc;
{ {
Sym *member; Sym *member;
@@ -203,7 +223,9 @@ DEFUN (print_members, (cyc), Sym * cyc)
arc count as minor key. */ arc count as minor key. */
static int static int
DEFUN (cmp_arc, (left, right), Arc * left AND Arc * right) cmp_arc (left, right)
Arc *left;
Arc *right;
{ {
Sym *left_parent = left->parent; Sym *left_parent = left->parent;
Sym *left_child = left->child; Sym *left_child = left->child;
@@ -289,7 +311,8 @@ DEFUN (cmp_arc, (left, right), Arc * left AND Arc * right)
static void static void
DEFUN (sort_parents, (child), Sym * child) sort_parents (child)
Sym * child;
{ {
Arc *arc, *detached, sorted, *prev; Arc *arc, *detached, sorted, *prev;
@@ -322,7 +345,8 @@ DEFUN (sort_parents, (child), Sym * child)
static void static void
DEFUN (print_parents, (child), Sym * child) print_parents (child)
Sym *child;
{ {
Sym *parent; Sym *parent;
Arc *arc; Arc *arc;
@@ -376,7 +400,8 @@ DEFUN (print_parents, (child), Sym * child)
static void static void
DEFUN (sort_children, (parent), Sym * parent) sort_children (parent)
Sym *parent;
{ {
Arc *arc, *detached, sorted, *prev; Arc *arc, *detached, sorted, *prev;
@@ -409,7 +434,8 @@ DEFUN (sort_children, (parent), Sym * parent)
static void static void
DEFUN (print_children, (parent), Sym * parent) print_children (parent)
Sym *parent;
{ {
Sym *child; Sym *child;
Arc *arc; Arc *arc;
@@ -448,7 +474,8 @@ DEFUN (print_children, (parent), Sym * parent)
static void static void
DEFUN (print_line, (np), Sym * np) print_line (np)
Sym *np;
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
@@ -481,7 +508,8 @@ DEFUN (print_line, (np), Sym * np)
/* Print dynamic call graph. */ /* Print dynamic call graph. */
void void
DEFUN (cg_print, (timesortsym), Sym ** timesortsym) cg_print (timesortsym)
Sym ** timesortsym;
{ {
unsigned int index; unsigned int index;
Sym *parent; Sym *parent;
@@ -532,7 +560,9 @@ DEFUN (cg_print, (timesortsym), Sym ** timesortsym)
static int static int
DEFUN (cmp_name, (left, right), const PTR left AND const PTR right) cmp_name (left, right)
const PTR left;
const PTR right;
{ {
const Sym **npp1 = (const Sym **) left; const Sym **npp1 = (const Sym **) left;
const Sym **npp2 = (const Sym **) right; const Sym **npp2 = (const Sym **) right;
@@ -542,7 +572,7 @@ DEFUN (cmp_name, (left, right), const PTR left AND const PTR right)
void void
DEFUN_VOID (cg_print_index) cg_print_index ()
{ {
unsigned int index; unsigned int index;
unsigned int nnames, todo, i, j; unsigned int nnames, todo, i, j;
@@ -656,7 +686,9 @@ DEFUN_VOID (cg_print_index)
We want to sort in descending order. */ We want to sort in descending order. */
static int static int
DEFUN (cmp_arc_count, (left, right), const PTR left AND const PTR right) cmp_arc_count (left, right)
const PTR left;
const PTR right;
{ {
const Arc **npp1 = (const Arc **) left; const Arc **npp1 = (const Arc **) left;
const Arc **npp2 = (const Arc **) right; const Arc **npp2 = (const Arc **) right;
@@ -673,7 +705,9 @@ DEFUN (cmp_arc_count, (left, right), const PTR left AND const PTR right)
We want to sort in descending order. */ We want to sort in descending order. */
static int static int
DEFUN (cmp_fun_nuses, (left, right), const PTR left AND const PTR right) cmp_fun_nuses (left, right)
const PTR left;
const PTR right;
{ {
const Sym **npp1 = (const Sym **) left; const Sym **npp1 = (const Sym **) left;
const Sym **npp2 = (const Sym **) right; const Sym **npp2 = (const Sym **) right;
@@ -755,7 +789,7 @@ DEFUN (cmp_fun_nuses, (left, right), const PTR left AND const PTR right)
of function ordering). */ of function ordering). */
void void
DEFUN_VOID (cg_print_function_ordering) cg_print_function_ordering ()
{ {
unsigned long index, used, unused, scratch_index; unsigned long index, used, unused, scratch_index;
unsigned long unplaced_arc_count, high_arc_count, scratch_arc_count; unsigned long unplaced_arc_count, high_arc_count, scratch_arc_count;
@@ -960,18 +994,18 @@ DEFUN_VOID (cg_print_function_ordering)
free (unplaced_arcs); free (unplaced_arcs);
} }
/* Place functions based on the arcs in ARCS with NUMARCS entries; /* Place functions based on the arcs in THE_ARCS with ARC_COUNT entries;
place unused arcs into UNPLACED_ARCS/UNPLACED_ARC_COUNT. place unused arcs into UNPLACED_ARCS/UNPLACED_ARC_COUNT.
If ALL is nonzero, then place all functions referenced by ARCS, If ALL is nonzero, then place all functions referenced by THE_ARCS,
else only place those referenced in the top 99% of the arcs in ARCS. */ else only place those referenced in the top 99% of the arcs in THE_ARCS. */
#define MOST 0.99 #define MOST 0.99
static void static void
order_and_dump_functions_by_arcs (arcs, numarcs, all, order_and_dump_functions_by_arcs (the_arcs, arc_count, all,
unplaced_arcs, unplaced_arc_count) unplaced_arcs, unplaced_arc_count)
Arc **arcs; Arc **the_arcs;
unsigned long numarcs; unsigned long arc_count;
int all; int all;
Arc **unplaced_arcs; Arc **unplaced_arcs;
unsigned long *unplaced_arc_count; unsigned long *unplaced_arc_count;
@@ -989,27 +1023,27 @@ order_and_dump_functions_by_arcs (arcs, numarcs, all,
if (! all) if (! all)
{ {
total_arcs = 0; total_arcs = 0;
for (index = 0; index < numarcs; index++) for (index = 0; index < arc_count; index++)
total_arcs += arcs[index]->count; total_arcs += the_arcs[index]->count;
} }
else else
total_arcs = 0; total_arcs = 0;
tmp_arcs = 0; tmp_arcs = 0;
for (index = 0; index < numarcs; index++) for (index = 0; index < arc_count; index++)
{ {
Sym *sym1, *sym2; Sym *sym1, *sym2;
Sym *child, *parent; Sym *child, *parent;
tmp_arcs += arcs[index]->count; tmp_arcs += the_arcs[index]->count;
/* Ignore this arc if it's already been placed. */ /* Ignore this arc if it's already been placed. */
if (arcs[index]->has_been_placed) if (the_arcs[index]->has_been_placed)
continue; continue;
child = arcs[index]->child; child = the_arcs[index]->child;
parent = arcs[index]->parent; parent = the_arcs[index]->parent;
/* If we're not using all arcs, and this is a rarely used /* If we're not using all arcs, and this is a rarely used
arc, then put it on the unplaced_arc list. Similarly arc, then put it on the unplaced_arc list. Similarly
@@ -1017,7 +1051,7 @@ order_and_dump_functions_by_arcs (arcs, numarcs, all,
if ((! all && (double)tmp_arcs / (double)total_arcs > MOST) if ((! all && (double)tmp_arcs / (double)total_arcs > MOST)
|| child->has_been_placed || parent->has_been_placed) || child->has_been_placed || parent->has_been_placed)
{ {
unplaced_arcs[(*unplaced_arc_count)++] = arcs[index]; unplaced_arcs[(*unplaced_arc_count)++] = the_arcs[index];
continue; continue;
} }
@@ -1027,7 +1061,7 @@ order_and_dump_functions_by_arcs (arcs, numarcs, all,
algorithm can use it to place function chains. */ algorithm can use it to place function chains. */
if (parent->next && parent->prev && child->next && child->prev) if (parent->next && parent->prev && child->next && child->prev)
{ {
unplaced_arcs[(*unplaced_arc_count)++] = arcs[index]; unplaced_arcs[(*unplaced_arc_count)++] = the_arcs[index];
continue; continue;
} }
@@ -1082,7 +1116,7 @@ order_and_dump_functions_by_arcs (arcs, numarcs, all,
{ {
/* Couldn't find anywhere to attach the functions, /* Couldn't find anywhere to attach the functions,
put the arc on the unplaced arc list. */ put the arc on the unplaced arc list. */
unplaced_arcs[(*unplaced_arc_count)++] = arcs[index]; unplaced_arcs[(*unplaced_arc_count)++] = the_arcs[index];
continue; continue;
} }
@@ -1107,7 +1141,7 @@ order_and_dump_functions_by_arcs (arcs, numarcs, all,
&& sym2 == parent) && sym2 == parent)
{ {
/* This would tie two ends together. */ /* This would tie two ends together. */
unplaced_arcs[(*unplaced_arc_count)++] = arcs[index]; unplaced_arcs[(*unplaced_arc_count)++] = the_arcs[index];
continue; continue;
} }
@@ -1119,7 +1153,7 @@ order_and_dump_functions_by_arcs (arcs, numarcs, all,
/* parent-prev and child-next */ /* parent-prev and child-next */
parent->prev = child; parent->prev = child;
child->next = parent; child->next = parent;
arcs[index]->has_been_placed = 1; the_arcs[index]->has_been_placed = 1;
} }
} }
else if (parent->prev) else if (parent->prev)
@@ -1130,7 +1164,7 @@ order_and_dump_functions_by_arcs (arcs, numarcs, all,
/* parent-next and child-prev */ /* parent-next and child-prev */
parent->next = child; parent->next = child;
child->prev = parent; child->prev = parent;
arcs[index]->has_been_placed = 1; the_arcs[index]->has_been_placed = 1;
} }
} }
else else
@@ -1142,27 +1176,27 @@ order_and_dump_functions_by_arcs (arcs, numarcs, all,
/* parent-prev and child-next. */ /* parent-prev and child-next. */
parent->prev = child; parent->prev = child;
child->next = parent; child->next = parent;
arcs[index]->has_been_placed = 1; the_arcs[index]->has_been_placed = 1;
} }
else else
{ {
/* parent-next and child-prev. */ /* parent-next and child-prev. */
parent->next = child; parent->next = child;
child->prev = parent; child->prev = parent;
arcs[index]->has_been_placed = 1; the_arcs[index]->has_been_placed = 1;
} }
} }
} }
/* Dump the chains of functions we've made. */ /* Dump the chains of functions we've made. */
for (index = 0; index < numarcs; index++) for (index = 0; index < arc_count; index++)
{ {
Sym *sym; Sym *sym;
if (arcs[index]->parent->has_been_placed if (the_arcs[index]->parent->has_been_placed
|| arcs[index]->child->has_been_placed) || the_arcs[index]->child->has_been_placed)
continue; continue;
sym = arcs[index]->parent; sym = the_arcs[index]->parent;
/* If this symbol isn't attached to any other /* If this symbol isn't attached to any other
symbols, then we've got a rarely used arc. symbols, then we've got a rarely used arc.
@@ -1188,14 +1222,14 @@ order_and_dump_functions_by_arcs (arcs, numarcs, all,
/* If we want to place all the arcs, then output /* If we want to place all the arcs, then output
those which weren't placed by the main algorithm. */ those which weren't placed by the main algorithm. */
if (all) if (all)
for (index = 0; index < numarcs; index++) for (index = 0; index < arc_count; index++)
{ {
Sym *sym; Sym *sym;
if (arcs[index]->parent->has_been_placed if (the_arcs[index]->parent->has_been_placed
|| arcs[index]->child->has_been_placed) || the_arcs[index]->child->has_been_placed)
continue; continue;
sym = arcs[index]->parent; sym = the_arcs[index]->parent;
sym->has_been_placed = 1; sym->has_been_placed = 1;
printf ("%s\n", sym->name); printf ("%s\n", sym->name);
@@ -1206,19 +1240,11 @@ order_and_dump_functions_by_arcs (arcs, numarcs, all,
on profiling information. This uses the function placement on profiling information. This uses the function placement
code for the bulk of its work. */ code for the bulk of its work. */
struct function_map
{
char *function_name;
char *file_name;
};
void void
DEFUN_VOID (cg_print_file_ordering) cg_print_file_ordering ()
{ {
unsigned long scratch_arc_count, index; unsigned long scratch_arc_count, index;
Arc **scratch_arcs; Arc **scratch_arcs;
extern struct function_map *symbol_map;
extern unsigned int symbol_map_count;
char *last; char *last;
scratch_arc_count = 0; scratch_arc_count = 0;

View File

@@ -36,15 +36,14 @@ int min_insn_size;
int offset_to_code; int offset_to_code;
/* For mapping symbols to specific .o files during file ordering. */ /* For mapping symbols to specific .o files during file ordering. */
struct function_map
{
char *function_name;
char *file_name;
};
struct function_map *symbol_map; struct function_map *symbol_map;
unsigned int symbol_map_count; unsigned int symbol_map_count;
static void read_function_mappings PARAMS ((const char *));
static int core_sym_class PARAMS ((asymbol *));
static boolean get_src_info
PARAMS ((bfd_vma, const char **, const char **, int *));
extern void i386_find_call PARAMS ((Sym *, bfd_vma, bfd_vma)); extern void i386_find_call PARAMS ((Sym *, bfd_vma, bfd_vma));
extern void alpha_find_call PARAMS ((Sym *, bfd_vma, bfd_vma)); extern void alpha_find_call PARAMS ((Sym *, bfd_vma, bfd_vma));
extern void vax_find_call PARAMS ((Sym *, bfd_vma, bfd_vma)); extern void vax_find_call PARAMS ((Sym *, bfd_vma, bfd_vma));
@@ -53,7 +52,8 @@ extern void sparc_find_call PARAMS ((Sym *, bfd_vma, bfd_vma));
extern void mips_find_call PARAMS ((Sym *, bfd_vma, bfd_vma)); extern void mips_find_call PARAMS ((Sym *, bfd_vma, bfd_vma));
static void static void
DEFUN (read_function_mappings, (filename), const char *filename) read_function_mappings (filename)
const char *filename;
{ {
FILE *file = fopen (filename, "r"); FILE *file = fopen (filename, "r");
char dummy[1024]; char dummy[1024];
@@ -139,19 +139,20 @@ DEFUN (read_function_mappings, (filename), const char *filename)
void void
DEFUN (core_init, (a_out_name), const char *a_out_name) core_init (aout_name)
const char *aout_name;
{ {
core_bfd = bfd_openr (a_out_name, 0); core_bfd = bfd_openr (aout_name, 0);
if (!core_bfd) if (!core_bfd)
{ {
perror (a_out_name); perror (aout_name);
done (1); done (1);
} }
if (!bfd_check_format (core_bfd, bfd_object)) if (!bfd_check_format (core_bfd, bfd_object))
{ {
fprintf (stderr, _("%s: %s: not in a.out format\n"), whoami, a_out_name); fprintf (stderr, _("%s: %s: not in a.out format\n"), whoami, aout_name);
done (1); done (1);
} }
@@ -163,7 +164,7 @@ DEFUN (core_init, (a_out_name), const char *a_out_name)
if (!core_text_sect) if (!core_text_sect)
{ {
fprintf (stderr, _("%s: can't find .text section in %s\n"), fprintf (stderr, _("%s: can't find .text section in %s\n"),
whoami, a_out_name); whoami, aout_name);
done (1); done (1);
} }
} }
@@ -174,7 +175,7 @@ DEFUN (core_init, (a_out_name), const char *a_out_name)
core_num_syms = bfd_get_symtab_upper_bound (core_bfd); core_num_syms = bfd_get_symtab_upper_bound (core_bfd);
if (core_num_syms < 0) if (core_num_syms < 0)
{ {
fprintf (stderr, "%s: %s: %s\n", whoami, a_out_name, fprintf (stderr, "%s: %s: %s\n", whoami, aout_name,
bfd_errmsg (bfd_get_error ())); bfd_errmsg (bfd_get_error ()));
done (1); done (1);
} }
@@ -184,7 +185,7 @@ DEFUN (core_init, (a_out_name), const char *a_out_name)
if (core_num_syms < 0) if (core_num_syms < 0)
{ {
fprintf (stderr, "%s: %s: %s\n", whoami, a_out_name, fprintf (stderr, "%s: %s: %s\n", whoami, aout_name,
bfd_errmsg (bfd_get_error ())); bfd_errmsg (bfd_get_error ()));
done (1); done (1);
} }
@@ -214,9 +215,10 @@ DEFUN (core_init, (a_out_name), const char *a_out_name)
/* Read in the text space of an a.out file. */ /* Read in the text space of an a.out file. */
void void
DEFUN (core_get_text_space, (core_bfd), bfd * core_bfd) core_get_text_space (cbfd)
bfd *cbfd;
{ {
core_text_space = (PTR) malloc (core_text_sect->_raw_size); core_text_space = (PTR) malloc ((unsigned int) core_text_sect->_raw_size);
if (!core_text_space) if (!core_text_space)
{ {
@@ -225,8 +227,8 @@ DEFUN (core_get_text_space, (core_bfd), bfd * core_bfd)
done (1); done (1);
} }
if (!bfd_get_section_contents (core_bfd, core_text_sect, core_text_space, if (!bfd_get_section_contents (cbfd, core_text_sect, core_text_space,
0, core_text_sect->_raw_size)) (bfd_vma) 0, core_text_sect->_raw_size))
{ {
bfd_perror ("bfd_get_section_contents"); bfd_perror ("bfd_get_section_contents");
free (core_text_space); free (core_text_space);
@@ -239,8 +241,10 @@ DEFUN (core_get_text_space, (core_bfd), bfd * core_bfd)
void void
DEFUN (find_call, (parent, p_lowpc, p_highpc), find_call (parent, p_lowpc, p_highpc)
Sym * parent AND bfd_vma p_lowpc AND bfd_vma p_highpc) Sym *parent;
bfd_vma p_lowpc;
bfd_vma p_highpc;
{ {
switch (bfd_get_arch (core_bfd)) switch (bfd_get_arch (core_bfd))
{ {
@@ -283,7 +287,8 @@ DEFUN (find_call, (parent, p_lowpc, p_highpc),
't' -> symbol is a local (static) name. */ 't' -> symbol is a local (static) name. */
static int static int
DEFUN (core_sym_class, (sym), asymbol * sym) core_sym_class (sym)
asymbol *sym;
{ {
symbol_info syminfo; symbol_info syminfo;
const char *name; const char *name;
@@ -366,9 +371,11 @@ DEFUN (core_sym_class, (sym), asymbol * sym)
/* Get whatever source info we can get regarding address ADDR. */ /* Get whatever source info we can get regarding address ADDR. */
static boolean static boolean
DEFUN (get_src_info, (addr, filename, name, line_num), get_src_info (addr, filename, name, line_num)
bfd_vma addr AND const char **filename AND const char **name bfd_vma addr;
AND int *line_num) const char **filename;
const char **name;
int *line_num;
{ {
const char *fname = 0, *func_name = 0; const char *fname = 0, *func_name = 0;
int l = 0; int l = 0;
@@ -398,10 +405,11 @@ DEFUN (get_src_info, (addr, filename, name, line_num),
One symbol per function is entered. */ One symbol per function is entered. */
void void
core_create_function_syms (core_bfd) core_create_function_syms (cbfd)
bfd *core_bfd ATTRIBUTE_UNUSED; bfd *cbfd ATTRIBUTE_UNUSED;
{ {
bfd_vma min_vma = ~0, max_vma = 0; bfd_vma min_vma = ~(bfd_vma) 0;
bfd_vma max_vma = 0;
int class; int class;
long i, found, skip; long i, found, skip;
unsigned int j; unsigned int j;
@@ -560,7 +568,7 @@ core_create_function_syms (core_bfd)
sym_init (symtab.limit); sym_init (symtab.limit);
symtab.limit->name = "<hicore>"; symtab.limit->name = "<hicore>";
symtab.limit->addr = max_vma + 1; symtab.limit->addr = max_vma + 1;
symtab.limit->end_addr = ~0; symtab.limit->end_addr = ~(bfd_vma) 0;
++symtab.limit; ++symtab.limit;
symtab.len = symtab.limit - symtab.base; symtab.len = symtab.limit - symtab.base;
@@ -571,11 +579,12 @@ core_create_function_syms (core_bfd)
One symbol per line of source code is entered. */ One symbol per line of source code is entered. */
void void
DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd) core_create_line_syms (cbfd)
bfd *cbfd;
{ {
char *prev_name, *prev_filename; char *prev_name, *prev_filename;
int prev_name_len, prev_filename_len; unsigned int prev_name_len, prev_filename_len;
bfd_vma vma, min_vma = ~0, max_vma = 0; bfd_vma vma, min_vma = ~(bfd_vma) 0, max_vma = 0;
bfd_vma offset; bfd_vma offset;
Sym *prev, dummy, *sentinel, *sym; Sym *prev, dummy, *sentinel, *sym;
const char *filename; const char *filename;
@@ -585,7 +594,7 @@ DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd)
/* Create symbols for functions as usual. This is necessary in /* Create symbols for functions as usual. This is necessary in
cases where parts of a program were not compiled with -g. For cases where parts of a program were not compiled with -g. For
those parts we still want to get info at the function level. */ those parts we still want to get info at the function level. */
core_create_function_syms (core_bfd); core_create_function_syms (cbfd);
/* Pass 1 - counter number of symbols. */ /* Pass 1 - counter number of symbols. */
@@ -605,7 +614,7 @@ DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd)
for (offset = 0; offset < core_text_sect->_raw_size; offset += min_insn_size) for (offset = 0; offset < core_text_sect->_raw_size; offset += min_insn_size)
{ {
int len; unsigned int len;
vma = core_text_sect->vma + offset; vma = core_text_sect->vma + offset;
@@ -718,13 +727,13 @@ DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd)
} }
/* Update sentinels. */ /* Update sentinels. */
sentinel = sym_lookup (&symtab, 0); sentinel = sym_lookup (&symtab, (bfd_vma) 0);
if (strcmp (sentinel->name, "<locore>") == 0 if (strcmp (sentinel->name, "<locore>") == 0
&& min_vma <= sentinel->end_addr) && min_vma <= sentinel->end_addr)
sentinel->end_addr = min_vma - 1; sentinel->end_addr = min_vma - 1;
sentinel = sym_lookup (&symtab, ~0); sentinel = sym_lookup (&symtab, ~(bfd_vma) 0);
if (strcmp (sentinel->name, "<hicore>") == 0 && max_vma >= sentinel->addr) if (strcmp (sentinel->name, "<hicore>") == 0 && max_vma >= sentinel->addr)
sentinel->addr = max_vma + 1; sentinel->addr = max_vma + 1;

View File

@@ -1,6 +1,6 @@
/* corefile.h /* corefile.h
Copyright 2000, 2001 Free Software Foundation, Inc. Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Binutils. This file is part of GNU Binutils.
@@ -21,6 +21,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef corefile_h #ifndef corefile_h
#define corefile_h #define corefile_h
struct function_map
{
char *function_name;
char *file_name;
};
extern struct function_map *symbol_map;
extern unsigned int symbol_map_count;
extern bfd *core_bfd; /* BFD for core-file. */ extern bfd *core_bfd; /* BFD for core-file. */
extern int core_num_syms; /* # of entries in symbol-table. */ extern int core_num_syms; /* # of entries in symbol-table. */
extern asymbol **core_syms; /* Symbol table in a.out. */ extern asymbol **core_syms; /* Symbol table in a.out. */

View File

@@ -34,11 +34,20 @@
#include "hist.h" #include "hist.h"
#include "libiberty.h" #include "libiberty.h"
static int gmon_io_read_64 PARAMS ((FILE *, BFD_HOST_U_64_BIT *));
static int gmon_io_write_64 PARAMS ((FILE *, BFD_HOST_U_64_BIT));
static int gmon_read_raw_arc
PARAMS ((FILE *, bfd_vma *, bfd_vma *, unsigned long *));
static int gmon_write_raw_arc
PARAMS ((FILE *, bfd_vma, bfd_vma, unsigned long));
int gmon_input = 0; int gmon_input = 0;
int gmon_file_version = 0; /* 0 == old (non-versioned) file format. */ int gmon_file_version = 0; /* 0 == old (non-versioned) file format. */
int int
DEFUN (gmon_io_read_32, (ifp, valp), FILE * ifp AND unsigned int *valp) gmon_io_read_32 (ifp, valp)
FILE *ifp;
unsigned int *valp;
{ {
char buf[4]; char buf[4];
@@ -48,8 +57,10 @@ DEFUN (gmon_io_read_32, (ifp, valp), FILE * ifp AND unsigned int *valp)
return 0; return 0;
} }
int static int
DEFUN (gmon_io_read_64, (ifp, valp), FILE * ifp AND BFD_HOST_U_64_BIT *valp) gmon_io_read_64 (ifp, valp)
FILE *ifp;
BFD_HOST_U_64_BIT *valp;
{ {
char buf[8]; char buf[8];
@@ -60,7 +71,9 @@ DEFUN (gmon_io_read_64, (ifp, valp), FILE * ifp AND BFD_HOST_U_64_BIT *valp)
} }
int int
DEFUN (gmon_io_read_vma, (ifp, valp), FILE * ifp AND bfd_vma *valp) gmon_io_read_vma (ifp, valp)
FILE *ifp;
bfd_vma *valp;
{ {
unsigned int val32; unsigned int val32;
BFD_HOST_U_64_BIT val64; BFD_HOST_U_64_BIT val64;
@@ -88,7 +101,10 @@ DEFUN (gmon_io_read_vma, (ifp, valp), FILE * ifp AND bfd_vma *valp)
} }
int int
DEFUN (gmon_io_read, (ifp, buf, n), FILE * ifp AND char *buf AND size_t n) gmon_io_read (ifp, buf, n)
FILE *ifp;
char *buf;
size_t n;
{ {
if (fread (buf, 1, n, ifp) != n) if (fread (buf, 1, n, ifp) != n)
return 1; return 1;
@@ -96,29 +112,35 @@ DEFUN (gmon_io_read, (ifp, buf, n), FILE * ifp AND char *buf AND size_t n)
} }
int int
DEFUN (gmon_io_write_32, (ofp, val), FILE * ofp AND unsigned int val) gmon_io_write_32 (ofp, val)
FILE *ofp;
unsigned int val;
{ {
char buf[4]; char buf[4];
bfd_put_32 (core_bfd, val, buf); bfd_put_32 (core_bfd, (bfd_vma) val, buf);
if (fwrite (buf, 1, 4, ofp) != 4) if (fwrite (buf, 1, 4, ofp) != 4)
return 1; return 1;
return 0; return 0;
} }
int static int
DEFUN (gmon_io_write_64, (ofp, val), FILE * ofp AND BFD_HOST_U_64_BIT val) gmon_io_write_64 (ofp, val)
FILE *ofp;
BFD_HOST_U_64_BIT val;
{ {
char buf[8]; char buf[8];
bfd_put_64 (core_bfd, val, buf); bfd_put_64 (core_bfd, (bfd_vma) val, buf);
if (fwrite (buf, 1, 8, ofp) != 8) if (fwrite (buf, 1, 8, ofp) != 8)
return 1; return 1;
return 0; return 0;
} }
int int
DEFUN (gmon_io_write_vma, (ofp, val), FILE * ofp AND bfd_vma val) gmon_io_write_vma (ofp, val)
FILE *ofp;
bfd_vma val;
{ {
switch (bfd_arch_bits_per_address (core_bfd)) switch (bfd_arch_bits_per_address (core_bfd))
@@ -142,7 +164,9 @@ DEFUN (gmon_io_write_vma, (ofp, val), FILE * ofp AND bfd_vma val)
} }
int int
DEFUN (gmon_io_write_8, (ofp, val), FILE * ofp AND unsigned char val) gmon_io_write_8 (ofp, val)
FILE *ofp;
unsigned int val;
{ {
char buf[1]; char buf[1];
@@ -153,15 +177,22 @@ DEFUN (gmon_io_write_8, (ofp, val), FILE * ofp AND unsigned char val)
} }
int int
DEFUN (gmon_io_write, (ofp, buf, n), FILE * ofp AND char *buf AND size_t n) gmon_io_write (ofp, buf, n)
FILE *ofp;
char *buf;
size_t n;
{ {
if (fwrite (buf, 1, n, ofp) != n) if (fwrite (buf, 1, n, ofp) != n)
return 1; return 1;
return 0; return 0;
} }
int static int
DEFUN (gmon_read_raw_arc, (ifp, fpc, spc, cnt), FILE * ifp AND bfd_vma * fpc AND bfd_vma * spc AND unsigned long * cnt) gmon_read_raw_arc (ifp, fpc, spc, cnt)
FILE *ifp;
bfd_vma *fpc;
bfd_vma *spc;
unsigned long *cnt;
{ {
BFD_HOST_U_64_BIT cnt64; BFD_HOST_U_64_BIT cnt64;
unsigned int cnt32; unsigned int cnt32;
@@ -192,8 +223,12 @@ DEFUN (gmon_read_raw_arc, (ifp, fpc, spc, cnt), FILE * ifp AND bfd_vma * fpc AND
return 0; return 0;
} }
int static int
DEFUN (gmon_write_raw_arc, (ofp, fpc, spc, cnt), FILE * ofp AND bfd_vma fpc AND bfd_vma spc AND unsigned long cnt) gmon_write_raw_arc (ofp, fpc, spc, cnt)
FILE *ofp;
bfd_vma fpc;
bfd_vma spc;
unsigned long cnt;
{ {
if (gmon_io_write_vma (ofp, fpc) if (gmon_io_write_vma (ofp, fpc)
@@ -221,7 +256,8 @@ DEFUN (gmon_write_raw_arc, (ofp, fpc, spc, cnt), FILE * ofp AND bfd_vma fpc AND
} }
void void
DEFUN (gmon_out_read, (filename), const char *filename) gmon_out_read (filename)
const char *filename;
{ {
FILE *ifp; FILE *ifp;
struct gmon_hdr ghdr; struct gmon_hdr ghdr;
@@ -538,7 +574,8 @@ DEFUN (gmon_out_read, (filename), const char *filename)
void void
DEFUN (gmon_out_write, (filename), const char *filename) gmon_out_write (filename)
const char *filename;
{ {
FILE *ofp; FILE *ofp;
struct gmon_hdr ghdr; struct gmon_hdr ghdr;
@@ -555,7 +592,7 @@ DEFUN (gmon_out_write, (filename), const char *filename)
/* Write gmon header. */ /* Write gmon header. */
memcpy (&ghdr.cookie[0], GMON_MAGIC, 4); memcpy (&ghdr.cookie[0], GMON_MAGIC, 4);
bfd_put_32 (core_bfd, GMON_VERSION, (bfd_byte *) ghdr.version); bfd_put_32 (core_bfd, (bfd_vma) GMON_VERSION, (bfd_byte *) ghdr.version);
if (fwrite (&ghdr, sizeof (ghdr), 1, ofp) != 1) if (fwrite (&ghdr, sizeof (ghdr), 1, ofp) != 1)
{ {
@@ -652,7 +689,7 @@ DEFUN (gmon_out_write, (filename), const char *filename)
|| hz != hertz()) || hz != hertz())
{ {
if (gmon_io_write_32 (ofp, GMONVERSION) if (gmon_io_write_32 (ofp, GMONVERSION)
|| gmon_io_write_32 (ofp, hz)) || gmon_io_write_32 (ofp, (unsigned int) hz))
{ {
perror (filename); perror (filename);
done (1); done (1);
@@ -671,7 +708,8 @@ DEFUN (gmon_out_write, (filename), const char *filename)
/* Dump the samples. */ /* Dump the samples. */
for (i = 0; i < hist_num_bins; ++i) for (i = 0; i < hist_num_bins; ++i)
{ {
bfd_put_16 (core_bfd, hist_sample[i], (bfd_byte *) & raw_bin_count[0]); bfd_put_16 (core_bfd, (bfd_vma) hist_sample[i],
(bfd_byte *) &raw_bin_count[0]);
if (fwrite (&raw_bin_count[0], sizeof (raw_bin_count), 1, ofp) != 1) if (fwrite (&raw_bin_count[0], sizeof (raw_bin_count), 1, ofp) != 1)
{ {
perror (filename); perror (filename);

View File

@@ -1,6 +1,6 @@
/* gmon_io.h /* gmon_io.h
Copyright 2000, 2001 Free Software Foundation, Inc. Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Binutils. This file is part of GNU Binutils.
@@ -51,7 +51,7 @@ extern int gmon_io_read_32 PARAMS ((FILE *ifp, unsigned int *valp));
extern int gmon_io_read PARAMS ((FILE *ifp, char *buf, size_t n)); extern int gmon_io_read PARAMS ((FILE *ifp, char *buf, size_t n));
extern int gmon_io_write_vma PARAMS ((FILE *ifp, bfd_vma val)); extern int gmon_io_write_vma PARAMS ((FILE *ifp, bfd_vma val));
extern int gmon_io_write_32 PARAMS ((FILE *ifp, unsigned int val)); extern int gmon_io_write_32 PARAMS ((FILE *ifp, unsigned int val));
extern int gmon_io_write_8 PARAMS ((FILE *ifp, unsigned char val)); extern int gmon_io_write_8 PARAMS ((FILE *ifp, unsigned int val));
extern int gmon_io_write PARAMS ((FILE *ifp, char *buf, size_t n)); extern int gmon_io_write PARAMS ((FILE *ifp, char *buf, size_t n));
extern void gmon_out_read PARAMS ((const char *)); extern void gmon_out_read PARAMS ((const char *));

View File

@@ -33,6 +33,9 @@
#include "sym_ids.h" #include "sym_ids.h"
#include "demangle.h" #include "demangle.h"
static void usage PARAMS ((FILE *, int)) ATTRIBUTE_NORETURN;
int main PARAMS ((int, char **));
const char *whoami; const char *whoami;
const char *function_mapping_file; const char *function_mapping_file;
const char *a_out_name = A_OUTNAME; const char *a_out_name = A_OUTNAME;
@@ -142,7 +145,9 @@ static struct option long_options[] =
static void static void
DEFUN (usage, (stream, status), FILE * stream AND int status) usage (stream, status)
FILE *stream;
int status;
{ {
fprintf (stream, _("\ fprintf (stream, _("\
Usage: %s [-[abcDhilLsTvwxyz]] [-[ACeEfFJnNOpPqQZ][name]] [-I dirs]\n\ Usage: %s [-[abcDhilLsTvwxyz]] [-[ACeEfFJnNOpPqQZ][name]] [-I dirs]\n\
@@ -166,7 +171,9 @@ Usage: %s [-[abcDhilLsTvwxyz]] [-[ACeEfFJnNOpPqQZ][name]] [-I dirs]\n\
int int
DEFUN (main, (argc, argv), int argc AND char **argv) main (argc, argv)
int argc;
char **argv;
{ {
char **sp, *str; char **sp, *str;
Sym **cg = 0; Sym **cg = 0;

View File

@@ -126,6 +126,6 @@ extern File_Format file_format; /* requested file format */
extern boolean first_output; /* no output so far? */ extern boolean first_output; /* no output so far? */
extern void done PARAMS ((int status)); extern void done PARAMS ((int status)) ATTRIBUTE_NORETURN;
#endif /* gprof_h */ #endif /* gprof_h */

View File

@@ -1,6 +1,6 @@
/* hist.c - Histogram related operations. /* hist.c - Histogram related operations.
Copyright 2000, 2001 Free Software Foundation, Inc. Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Binutils. This file is part of GNU Binutils.
@@ -34,6 +34,9 @@
#define UNITS_TO_CODE (offset_to_code / sizeof(UNIT)) #define UNITS_TO_CODE (offset_to_code / sizeof(UNIT))
static void scale_and_align_entries PARAMS ((void)); static void scale_and_align_entries PARAMS ((void));
static void print_header PARAMS ((int));
static void print_line PARAMS ((Sym *, double));
static int cmp_time PARAMS ((const PTR, const PTR));
/* Declarations of automatically generated functions to output blurbs. */ /* Declarations of automatically generated functions to output blurbs. */
extern void flat_blurb PARAMS ((FILE * fp)); extern void flat_blurb PARAMS ((FILE * fp));
@@ -77,7 +80,9 @@ SItab[] =
is provided for formatting error messages only. */ is provided for formatting error messages only. */
void void
DEFUN (hist_read_rec, (ifp, filename), FILE * ifp AND const char *filename) hist_read_rec (ifp, filename)
FILE * ifp;
const char *filename;
{ {
bfd_vma n_lowpc, n_highpc; bfd_vma n_lowpc, n_highpc;
int i, ncnt, profrate; int i, ncnt, profrate;
@@ -152,7 +157,9 @@ DEFUN (hist_read_rec, (ifp, filename), FILE * ifp AND const char *filename)
of OFP and is provided for formatting error-messages only. */ of OFP and is provided for formatting error-messages only. */
void void
DEFUN (hist_write_hist, (ofp, filename), FILE * ofp AND const char *filename) hist_write_hist (ofp, filename)
FILE * ofp;
const char *filename;
{ {
UNIT count; UNIT count;
int i; int i;
@@ -173,7 +180,7 @@ DEFUN (hist_write_hist, (ofp, filename), FILE * ofp AND const char *filename)
for (i = 0; i < hist_num_bins; ++i) for (i = 0; i < hist_num_bins; ++i)
{ {
bfd_put_16 (core_bfd, hist_sample[i], (bfd_byte *) & count[0]); bfd_put_16 (core_bfd, (bfd_vma) hist_sample[i], (bfd_byte *) &count[0]);
if (fwrite (&count[0], sizeof (count), 1, ofp) != 1) if (fwrite (&count[0], sizeof (count), 1, ofp) != 1)
{ {
@@ -255,7 +262,7 @@ scale_and_align_entries ()
cases, above). */ cases, above). */
void void
DEFUN_VOID (hist_assign_samples) hist_assign_samples ()
{ {
bfd_vma bin_low_pc, bin_high_pc; bfd_vma bin_low_pc, bin_high_pc;
bfd_vma sym_low_pc, sym_high_pc; bfd_vma sym_low_pc, sym_high_pc;
@@ -344,7 +351,8 @@ DEFUN_VOID (hist_assign_samples)
/* Print header for flag histogram profile. */ /* Print header for flag histogram profile. */
static void static void
DEFUN (print_header, (prefix), const char prefix) print_header (prefix)
int prefix;
{ {
char unit[64]; char unit[64];
@@ -383,7 +391,9 @@ DEFUN (print_header, (prefix), const char prefix)
static void static void
DEFUN (print_line, (sym, scale), Sym * sym AND double scale) print_line (sym, scale)
Sym *sym;
double scale;
{ {
if (ignore_zeros && sym->ncalls == 0 && sym->hist.time == 0) if (ignore_zeros && sym->ncalls == 0 && sym->hist.time == 0)
return; return;
@@ -420,7 +430,9 @@ DEFUN (print_line, (sym, scale), Sym * sym AND double scale)
lexicographic order of the function names. */ lexicographic order of the function names. */
static int static int
DEFUN (cmp_time, (lp, rp), const PTR lp AND const PTR rp) cmp_time (lp, rp)
const PTR lp;
const PTR rp;
{ {
const Sym *left = *(const Sym **) lp; const Sym *left = *(const Sym **) lp;
const Sym *right = *(const Sym **) rp; const Sym *right = *(const Sym **) rp;
@@ -447,7 +459,7 @@ DEFUN (cmp_time, (lp, rp), const PTR lp AND const PTR rp)
/* Print the flat histogram profile. */ /* Print the flat histogram profile. */
void void
DEFUN_VOID (hist_print) hist_print ()
{ {
Sym **time_sorted_syms, *top_dog, *sym; Sym **time_sorted_syms, *top_dog, *sym;
unsigned int index; unsigned int index;

View File

@@ -74,7 +74,7 @@ mips_find_call (parent, p_lowpc, p_highpc)
DBG (CALLDEBUG, DBG (CALLDEBUG,
printf (_("[find_call] 0x%lx: jal"), (unsigned long) pc)); printf (_("[find_call] 0x%lx: jal"), (unsigned long) pc));
offset = (op & 0x03ffffff) << 2; offset = (op & 0x03ffffff) << 2;
dest_pc = (pc & ~0xfffffff) | offset; dest_pc = (pc & ~(bfd_vma) 0xfffffff) | offset;
if (dest_pc >= s_lowpc && dest_pc <= s_highpc) if (dest_pc >= s_lowpc && dest_pc <= s_highpc)
{ {
child = sym_lookup (&symtab, dest_pc); child = sym_lookup (&symtab, dest_pc);

View File

@@ -1,6 +1,6 @@
/* search-list.c /* search-list.c
Copyright 2000, 2001 Free Software Foundation, Inc. Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Binutils. This file is part of GNU Binutils.
@@ -25,12 +25,13 @@
void void
DEFUN (search_list_append, (list, paths), search_list_append (list, paths)
Search_List * list AND const char *paths) Search_List *list;
const char *paths;
{ {
Search_List_Elem *new_el; Search_List_Elem *new_el;
const char *beg, *colon; const char *beg, *colon;
int len; unsigned int len;
colon = paths - 1; colon = paths - 1;
do do

View File

@@ -1,6 +1,6 @@
/* source.c - Keep track of source files. /* source.c - Keep track of source files.
Copyright 2000, 2001 Free Software Foundation, Inc. Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Binutils. This file is part of GNU Binutils.
@@ -35,7 +35,8 @@ Source_File *first_src_file = 0;
Source_File * Source_File *
DEFUN (source_file_lookup_path, (path), const char *path) source_file_lookup_path (path)
const char *path;
{ {
Source_File *sf; Source_File *sf;
@@ -62,7 +63,8 @@ DEFUN (source_file_lookup_path, (path), const char *path)
Source_File * Source_File *
DEFUN (source_file_lookup_name, (filename), const char *filename) source_file_lookup_name (filename)
const char *filename;
{ {
const char *fname; const char *fname;
Source_File *sf; Source_File *sf;
@@ -89,10 +91,11 @@ DEFUN (source_file_lookup_name, (filename), const char *filename)
FILE * FILE *
DEFUN (annotate_source, (sf, max_width, annote, arg), annotate_source (sf, max_width, annote, arg)
Source_File * sf AND int max_width Source_File *sf;
AND void (*annote) PARAMS ((char *buf, int w, int l, void *arg)) unsigned int max_width;
AND void *arg) void (*annote) PARAMS ((char *, unsigned int, int, void *));
void *arg;
{ {
static boolean first_file = true; static boolean first_file = true;
int i, line_num, nread; int i, line_num, nread;

View File

@@ -1,6 +1,6 @@
/* source.h /* source.h
Copyright 2000, 2001 Free Software Foundation, Inc. Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Binutils. This file is part of GNU Binutils.
@@ -53,8 +53,8 @@ extern Source_File *source_file_lookup_name PARAMS ((const char *));
Returns a pointer to the output file (which maybe stdout) such Returns a pointer to the output file (which maybe stdout) such
that summary statistics can be printed. If the returned file that summary statistics can be printed. If the returned file
is not stdout, it should be closed when done with it. */ is not stdout, it should be closed when done with it. */
extern FILE *annotate_source PARAMS ((Source_File * sf, int max_width, extern FILE *annotate_source
void (*annote) (char *b, int w, int l, PARAMS ((Source_File *sf, unsigned int max_width,
void *arg), void (*annote) (char *, unsigned int, int, PTR arg),
void *arg)); PTR arg));
#endif /* source_h */ #endif /* source_h */

View File

@@ -38,7 +38,7 @@ sparc_find_call (parent, p_lowpc, p_highpc)
bfd_vma p_highpc; bfd_vma p_highpc;
{ {
bfd_vma pc, dest_pc; bfd_vma pc, dest_pc;
unsigned long insn; unsigned int insn;
Sym *child; Sym *child;
if (core_text_space == 0) if (core_text_space == 0)
@@ -56,7 +56,7 @@ sparc_find_call (parent, p_lowpc, p_highpc)
DBG (CALLDEBUG, printf ("[find_call] %s: 0x%lx to 0x%lx\n", DBG (CALLDEBUG, printf ("[find_call] %s: 0x%lx to 0x%lx\n",
parent->name, (unsigned long) p_lowpc, parent->name, (unsigned long) p_lowpc,
(unsigned long) p_highpc)); (unsigned long) p_highpc));
for (pc = (p_lowpc + 3) & ~3; pc < p_highpc; pc += 4) for (pc = (p_lowpc + 3) & ~(bfd_vma) 3; pc < p_highpc; pc += 4)
{ {
insn = bfd_get_32 (core_bfd, ((unsigned char *) core_text_space insn = bfd_get_32 (core_bfd, ((unsigned char *) core_text_space
+ pc - core_text_sect->vma)); + pc - core_text_sect->vma));

View File

@@ -1,6 +1,6 @@
/* sym_ids.c /* sym_ids.c
Copyright 2000, 2001 Free Software Foundation, Inc. Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Binutils. This file is part of GNU Binutils.
@@ -46,6 +46,12 @@ struct sym_id
} }
*id_list; *id_list;
static void parse_spec PARAMS ((char *, Sym *));
static void parse_id PARAMS ((struct sym_id *));
static boolean match PARAMS ((Sym *, Sym *));
static void extend_match PARAMS ((struct match *, Sym *, Sym_Table *, boolean));
Sym_Table syms[NUM_TABLES]; Sym_Table syms[NUM_TABLES];
#ifdef DEBUG #ifdef DEBUG
@@ -74,8 +80,9 @@ static Source_File non_existent_file =
void void
DEFUN (sym_id_add, (spec, which_table), sym_id_add (spec, which_table)
const char *spec AND Table_Id which_table) const char *spec;
Table_Id which_table;
{ {
struct sym_id *id; struct sym_id *id;
int len = strlen (spec); int len = strlen (spec);
@@ -103,7 +110,9 @@ DEFUN (sym_id_add, (spec, which_table),
FILENAME not containing a dot can be specified by FILENAME. */ FILENAME not containing a dot can be specified by FILENAME. */
static void static void
DEFUN (parse_spec, (spec, sym), char *spec AND Sym * sym) parse_spec (spec, sym)
char *spec;
Sym *sym;
{ {
char *colon; char *colon;
@@ -158,7 +167,8 @@ DEFUN (parse_spec, (spec, sym), char *spec AND Sym * sym)
by parse_spec(). */ by parse_spec(). */
static void static void
DEFUN (parse_id, (id), struct sym_id *id) parse_id (id)
struct sym_id *id;
{ {
char *slash; char *slash;
@@ -207,7 +217,9 @@ DEFUN (parse_id, (id), struct sym_id *id)
/* Return TRUE iff PATTERN matches SYM. */ /* Return TRUE iff PATTERN matches SYM. */
static boolean static boolean
DEFUN (match, (pattern, sym), Sym * pattern AND Sym * sym) match (pattern, sym)
Sym *pattern;
Sym *sym;
{ {
return (pattern->file ? pattern->file == sym->file : true) return (pattern->file ? pattern->file == sym->file : true)
&& (pattern->line_num ? pattern->line_num == sym->line_num : true) && (pattern->line_num ? pattern->line_num == sym->line_num : true)
@@ -219,8 +231,11 @@ DEFUN (match, (pattern, sym), Sym * pattern AND Sym * sym)
static void static void
DEFUN (extend_match, (m, sym, tab, second_pass), extend_match (m, sym, tab, second_pass)
struct match *m AND Sym * sym AND Sym_Table * tab AND boolean second_pass) struct match *m;
Sym *sym;
Sym_Table *tab;
boolean second_pass;
{ {
if (m->prev_match != sym - 1) if (m->prev_match != sym - 1)
{ {
@@ -255,7 +270,7 @@ DEFUN (extend_match, (m, sym, tab, second_pass),
requests---you get what you ask for! */ requests---you get what you ask for! */
void void
DEFUN_VOID (sym_id_parse) sym_id_parse ()
{ {
Sym *sym, *left, *right; Sym *sym, *left, *right;
struct sym_id *id; struct sym_id *id;
@@ -354,12 +369,14 @@ DEFUN_VOID (sym_id_parse)
very big (the user has to type them!), so a linear search is probably very big (the user has to type them!), so a linear search is probably
tolerable. */ tolerable. */
boolean boolean
DEFUN (sym_id_arc_is_present, (symtab, from, to), sym_id_arc_is_present (sym_tab, from, to)
Sym_Table * symtab AND Sym * from AND Sym * to) Sym_Table *sym_tab;
Sym *from;
Sym *to;
{ {
Sym *sym; Sym *sym;
for (sym = symtab->base; sym < symtab->limit; ++sym) for (sym = sym_tab->base; sym < sym_tab->limit; ++sym)
{ {
if (from->addr >= sym->addr && from->addr <= sym->end_addr if (from->addr >= sym->addr && from->addr <= sym->end_addr
&& arc_lookup (sym, to)) && arc_lookup (sym, to))

View File

@@ -1,6 +1,6 @@
/* sym_ids.h /* sym_ids.h
Copyright 2000, 2001 Free Software Foundation, Inc. Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Binutils. This file is part of GNU Binutils.

View File

@@ -1,6 +1,6 @@
/* symtab.c /* symtab.c
Copyright 2000, 2001 Free Software Foundation, Inc. Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Binutils. This file is part of GNU Binutils.
@@ -26,13 +26,16 @@
#include "cg_arcs.h" #include "cg_arcs.h"
#include "corefile.h" #include "corefile.h"
static int cmp_addr PARAMS ((const PTR, const PTR));
Sym_Table symtab; Sym_Table symtab;
/* Initialize a symbol (so it's empty). */ /* Initialize a symbol (so it's empty). */
void void
DEFUN (sym_init, (sym), Sym * sym) sym_init (sym)
Sym *sym;
{ {
memset (sym, 0, sizeof (*sym)); memset (sym, 0, sizeof (*sym));
@@ -56,10 +59,12 @@ DEFUN (sym_init, (sym), Sym * sym)
the global symbol survives. */ the global symbol survives. */
static int static int
DEFUN (cmp_addr, (lp, rp), const PTR lp AND const PTR rp) cmp_addr (lp, rp)
const PTR lp;
const PTR rp;
{ {
Sym *left = (Sym *) lp; const Sym *left = (const Sym *) lp;
Sym *right = (Sym *) rp; const Sym *right = (const Sym *) rp;
if (left->addr > right->addr) if (left->addr > right->addr)
return 1; return 1;
@@ -74,7 +79,8 @@ DEFUN (cmp_addr, (lp, rp), const PTR lp AND const PTR rp)
void void
DEFUN (symtab_finalize, (tab), Sym_Table * tab) symtab_finalize (tab)
Sym_Table *tab;
{ {
Sym *src, *dst; Sym *src, *dst;
bfd_vma prev_addr; bfd_vma prev_addr;
@@ -171,7 +177,9 @@ DEFUN (symtab_finalize, (tab), Sym_Table * tab)
#ifdef DEBUG #ifdef DEBUG
Sym * Sym *
DEFUN (dbg_sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address) dbg_sym_lookup (sym_tab, address)
Sym_Table *sym_tab;
bfd_vma address;
{ {
long low, mid, high; long low, mid, high;
Sym *sym; Sym *sym;
@@ -179,8 +187,8 @@ DEFUN (dbg_sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address
fprintf (stderr, "[dbg_sym_lookup] address 0x%lx\n", fprintf (stderr, "[dbg_sym_lookup] address 0x%lx\n",
(unsigned long) address); (unsigned long) address);
sym = symtab->base; sym = sym_tab->base;
for (low = 0, high = symtab->len - 1; low != high;) for (low = 0, high = sym_tab->len - 1; low != high;)
{ {
mid = (high + low) >> 1; mid = (high + low) >> 1;
@@ -210,7 +218,9 @@ DEFUN (dbg_sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address
/* Look up an address in the symbol-table that is sorted by address. /* Look up an address in the symbol-table that is sorted by address.
If address does not hit any symbol, 0 is returned. */ If address does not hit any symbol, 0 is returned. */
Sym * Sym *
DEFUN (sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address) sym_lookup (sym_tab, address)
Sym_Table *sym_tab;
bfd_vma address;
{ {
long low, high; long low, high;
long mid = -1; long mid = -1;
@@ -219,11 +229,11 @@ DEFUN (sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address)
int probes = 0; int probes = 0;
#endif /* DEBUG */ #endif /* DEBUG */
if (!symtab->len) if (!sym_tab->len)
return 0; return 0;
sym = symtab->base; sym = sym_tab->base;
for (low = 0, high = symtab->len - 1; low != high;) for (low = 0, high = sym_tab->len - 1; low != high;)
{ {
DBG (LOOKUPDEBUG, ++probes); DBG (LOOKUPDEBUG, ++probes);
mid = (high + low) / 2; mid = (high + low) / 2;
@@ -240,7 +250,7 @@ DEFUN (sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address)
{ {
DBG (LOOKUPDEBUG, DBG (LOOKUPDEBUG,
printf ("[sym_lookup] %d probes (symtab->len=%u)\n", printf ("[sym_lookup] %d probes (symtab->len=%u)\n",
probes, symtab->len - 1)); probes, sym_tab->len - 1));
return &sym[mid]; return &sym[mid];
} }
} }
@@ -261,7 +271,7 @@ DEFUN (sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address)
else else
{ {
DBG (LOOKUPDEBUG, printf ("[sym_lookup] %d (%u) probes, fall off\n", DBG (LOOKUPDEBUG, printf ("[sym_lookup] %d (%u) probes, fall off\n",
probes, symtab->len - 1)); probes, sym_tab->len - 1));
return &sym[mid + 1]; return &sym[mid + 1];
} }
} }

View File

@@ -1,6 +1,6 @@
/* symtab.h /* symtab.h
Copyright 2000, 2001 Free Software Foundation, Inc. Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GNU Binutils. This file is part of GNU Binutils.
@@ -113,6 +113,9 @@ extern Sym_Table symtab; /* The symbol table. */
extern void sym_init PARAMS ((Sym *)); extern void sym_init PARAMS ((Sym *));
extern void symtab_finalize PARAMS ((Sym_Table *)); extern void symtab_finalize PARAMS ((Sym_Table *));
#ifdef DEBUG
extern Sym *dbg_sym_lookup PARAMS ((Sym_Table *, bfd_vma));
#endif
extern Sym *sym_lookup PARAMS ((Sym_Table *, bfd_vma)); extern Sym *sym_lookup PARAMS ((Sym_Table *, bfd_vma));
extern void find_call PARAMS ((Sym *, bfd_vma, bfd_vma)); extern void find_call PARAMS ((Sym *, bfd_vma, bfd_vma));

View File

@@ -22,13 +22,15 @@
#include "source.h" #include "source.h"
#include "symtab.h" #include "symtab.h"
#include "cg_arcs.h" #include "cg_arcs.h"
#include "utils.h"
/* /*
* Print name of symbol. Return number of characters printed. * Print name of symbol. Return number of characters printed.
*/ */
int int
DEFUN (print_name_only, (self), Sym * self) print_name_only (self)
Sym *self;
{ {
const char *name = self->name; const char *name = self->name;
const char *filename; const char *filename;
@@ -87,7 +89,8 @@ DEFUN (print_name_only, (self), Sym * self)
void void
DEFUN (print_name, (self), Sym * self) print_name (self)
Sym *self;
{ {
print_name_only (self); print_name_only (self);