From: Ian Lance Taylor Date: Tue, 3 Feb 1998 19:52:41 +0000 (+0000) Subject: Tue Feb 3 14:25:25 1998 Brent Baccala X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c3de2a19e8e6b333525efb65de2e83791c73a378;p=binutils-gdb.git Tue Feb 3 14:25:25 1998 Brent Baccala Make it possible to build a cross gprof, although a few cases are still not handled: * configure.in: Don't set MY_TARGET. * gprof.h: Don't include MACHINE_H. Don't define FOPEN_RB or FOPEN_WB; just get them from sysdep.h. * core.h (min_insn_size, offset_to_code): Declare. * core.c (MIN_INSN_SIZE): Don't define. (min_insn_size, offset_to_code): New variables. (core_init): Initialize min_insn_size and offset_to_code. (find_call): New function. (core_create_line_syms): Don't use min_dist. Set is_static in pass 2. * hist.c (UNITS_TO_CODE): Define. * gprof.c (default_excluded_list): Add "__mcount_internal". * gmon.h: Change TARGET_alpha to __alpha__. * hertz.h: Ifdef MACH, define hertz as HZ. * alpha.c (alpha_Instruction): Rename from Instruction. Change all references. (alpha_find_call): Rename from find_call. * alpha.h: Remove. * dummy.c, dummy.h: Remove. * i386.c (i386_iscall): Rename from iscall. Change all references. Check for call instruction, not jump or lcall. (i386_find_call): Rename from find_call. Correct for VMA. Correct call destination computation. Don't dereference symbol if it is NULL. * i386.h: Remove. * ns532.c, ns532.h: Remove. * sparc.c (CALL): Define. (sparc_find_call): Rename from find_call. * sparc.h: Remove. * tahoe.c: Include cg_arcs.h, core.h, hist.h, and symtab.h. Don't include time_host.h. (CALLF, PC): Define. (enum tahoe_opermodes, tahoe_operandenum): Define. Rename all references to opermodes or operandenum to these. (tahoe_operandmode): Rename from operandmode. Call abort if switch does not return. (tahoe_operandname): Rename from operandname. Call abort if switch does not return. (tahoe_operandlength): Rename from operandlength. Call abort if switch does not return. (tahoe_reladdr): Rename from reladdr. (tahoe_find_call): Rename from find_call. Use core_text_space rather than textspace. * tahoe.h: Remove. * vax.c (CALLS, PC): Define. (enum opermodes, operandenum, struct modebyte): Define. (vax_operandmode): Rename from operandmode. Call abort if switch does not return. (vax_operandname): Rename from operandname. Call abort if switch does not return. (vax_operandlength): Rename from operandlength. Call abort if switch does not return. (vax_reladdr): Rename from reladdr. (vax_find_call): Rename from find_call. * vax.h: Remove. * Makefile.am (AUTOMAKE_OPTIONS): Set to cygnus. (MY_TARGET): Remove. (INCLUDES): Remove -DTARGET_$(MY_TARGET) and -DMACHINE_H= \"$(MY_TARGET).h\". (gprof_SOURCES): Add i386.c, alpha.c, vax.c, tahoe.c, sparc.c. (gprof_DEPENDENCIES): Remove $(MY_TARGET).o. (gprof_LDADD): Likewise. (noinst_HEADERS): Remove alpha.h, i386.h, ns532.h, sparc.h, tahoe.h, vax.h, dummy.h. (EXTRA_DIST): Remove alpha.c, i386.c, ns532.c, sparc.c, tahoe.c, vax.c, dummy.c. ($(OBJECTS)): Don't depend upon $(MY_TARGET).h. ($(MY_TARGET).o): Remove target. (i386.o, alpha.o, vax.o, tahoe.o, sparc.o): New targets. * configure, Makefile.in, aclocal.m4: Rebuild. --- diff --git a/gprof/.Sanitize b/gprof/.Sanitize index 2cc7502fe7d..ea68878fa99 100644 --- a/gprof/.Sanitize +++ b/gprof/.Sanitize @@ -35,7 +35,6 @@ TODO acconfig.h aclocal.m4 alpha.c -alpha.h basic_blocks.c basic_blocks.h bsd_callg_bl.m @@ -52,8 +51,6 @@ configure.bat configure.in core.c core.h -dummy.c -dummy.h flat_bl.m fsf_callg_bl.m gconfig.in @@ -71,26 +68,20 @@ hertz.h hist.c hist.h i386.c -i386.h -ns532.c -ns532.h search_list.c search_list.h source.c source.h sparc.c -sparc.h stamp-h.in sym_ids.c sym_ids.h symtab.c symtab.h tahoe.c -tahoe.h utils.c utils.h vax.c -vax.h Things-to-lose: diff --git a/gprof/ChangeLog b/gprof/ChangeLog index e10ee4f752c..cd8e4266de6 100644 --- a/gprof/ChangeLog +++ b/gprof/ChangeLog @@ -1,3 +1,78 @@ +Tue Feb 3 14:25:25 1998 Brent Baccala + + Make it possible to build a cross gprof, although a few cases are + still not handled: + * configure.in: Don't set MY_TARGET. + * gprof.h: Don't include MACHINE_H. Don't define FOPEN_RB or + FOPEN_WB; just get them from sysdep.h. + * core.h (min_insn_size, offset_to_code): Declare. + * core.c (MIN_INSN_SIZE): Don't define. + (min_insn_size, offset_to_code): New variables. + (core_init): Initialize min_insn_size and offset_to_code. + (find_call): New function. + (core_create_line_syms): Don't use min_dist. Set is_static in + pass 2. + * hist.c (UNITS_TO_CODE): Define. + * gprof.c (default_excluded_list): Add "__mcount_internal". + * gmon.h: Change TARGET_alpha to __alpha__. + * hertz.h: Ifdef MACH, define hertz as HZ. + * alpha.c (alpha_Instruction): Rename from Instruction. Change + all references. + (alpha_find_call): Rename from find_call. + * alpha.h: Remove. + * dummy.c, dummy.h: Remove. + * i386.c (i386_iscall): Rename from iscall. Change all + references. Check for call instruction, not jump or lcall. + (i386_find_call): Rename from find_call. Correct for VMA. + Correct call destination computation. Don't dereference symbol if + it is NULL. + * i386.h: Remove. + * ns532.c, ns532.h: Remove. + * sparc.c (CALL): Define. + (sparc_find_call): Rename from find_call. + * sparc.h: Remove. + * tahoe.c: Include cg_arcs.h, core.h, hist.h, and symtab.h. Don't + include time_host.h. + (CALLF, PC): Define. + (enum tahoe_opermodes, tahoe_operandenum): Define. Rename all + references to opermodes or operandenum to these. + (tahoe_operandmode): Rename from operandmode. Call abort if + switch does not return. + (tahoe_operandname): Rename from operandname. Call abort if + switch does not return. + (tahoe_operandlength): Rename from operandlength. Call abort if + switch does not return. + (tahoe_reladdr): Rename from reladdr. + (tahoe_find_call): Rename from find_call. Use core_text_space + rather than textspace. + * tahoe.h: Remove. + * vax.c (CALLS, PC): Define. + (enum opermodes, operandenum, struct modebyte): Define. + (vax_operandmode): Rename from operandmode. Call abort if switch + does not return. + (vax_operandname): Rename from operandname. Call abort if switch + does not return. + (vax_operandlength): Rename from operandlength. Call abort if + switch does not return. + (vax_reladdr): Rename from reladdr. + (vax_find_call): Rename from find_call. + * vax.h: Remove. + * Makefile.am (AUTOMAKE_OPTIONS): Set to cygnus. + (MY_TARGET): Remove. + (INCLUDES): Remove -DTARGET_$(MY_TARGET) and -DMACHINE_H= + \"$(MY_TARGET).h\". + (gprof_SOURCES): Add i386.c, alpha.c, vax.c, tahoe.c, sparc.c. + (gprof_DEPENDENCIES): Remove $(MY_TARGET).o. + (gprof_LDADD): Likewise. + (noinst_HEADERS): Remove alpha.h, i386.h, ns532.h, sparc.h, + tahoe.h, vax.h, dummy.h. + (EXTRA_DIST): Remove alpha.c, i386.c, ns532.c, sparc.c, tahoe.c, + vax.c, dummy.c. + ($(OBJECTS)): Don't depend upon $(MY_TARGET).h. + ($(MY_TARGET).o): Remove target. + (i386.o, alpha.o, vax.o, tahoe.o, sparc.o): New targets. + * configure, Makefile.in, aclocal.m4: Rebuild. + Mon Dec 29 14:17:08 1997 Ian Lance Taylor * core.c (core_sym_class): Treat weak symbols as text symbols. diff --git a/gprof/Makefile.am b/gprof/Makefile.am index 39524ad7fd8..a9768b63780 100644 --- a/gprof/Makefile.am +++ b/gprof/Makefile.am @@ -1,32 +1,27 @@ ## Process this file with automake to generate Makefile.in -## We should have cygnus in AUTOMAKE_OPTIONS, but it doesn't work yet. -AUTOMAKE_OPTIONS = foreign +AUTOMAKE_OPTIONS = cygnus SUFFIXES = .m -INCLUDES = -D_GNU_SOURCE -DDEBUG -DTARGET_$(MY_TARGET) -DMACHINE_H=\"$(MY_TARGET).h\" -I../bfd -I$(srcdir)/../include -I$(srcdir)/../bfd - -MY_TARGET = @MY_TARGET@ +INCLUDES = -D_GNU_SOURCE -DDEBUG -I../bfd -I$(srcdir)/../include -I$(srcdir)/../bfd bin_PROGRAMS = gprof gprof_SOURCES = basic_blocks.c call_graph.c cg_arcs.c cg_dfn.c \ cg_print.c core.c gmon_io.c gprof.c hertz.c hist.c source.c \ search_list.c symtab.c sym_ids.c utils.c \ - flat_bl.c bsd_callg_bl.c fsf_callg_bl.c -gprof_DEPENDENCIES = $(MY_TARGET).o ../bfd/libbfd.la ../libiberty/libiberty.a -gprof_LDADD = $(MY_TARGET).o ../bfd/libbfd.la ../libiberty/libiberty.a + flat_bl.c bsd_callg_bl.c fsf_callg_bl.c \ + i386.c alpha.c vax.c tahoe.c sparc.c +gprof_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a +gprof_LDADD = ../bfd/libbfd.la ../libiberty/libiberty.a noinst_HEADERS = \ - alpha.h i386.h ns532.h sparc.h tahoe.h vax.h dummy.h \ basic_blocks.h call_graph.h cg_arcs.h cg_dfn.h cg_print.h \ core.h gmon.h gmon_io.h gmon_out.h gprof.h hertz.h hist.h \ - search_list.h source.h sparc.h sym_ids.h symtab.h utils.h + search_list.h source.h sym_ids.h symtab.h utils.h -EXTRA_DIST = \ - alpha.c i386.c ns532.c sparc.c tahoe.c vax.c dummy.c \ - flat_bl.c bsd_callg_bl.c fsf_callg_bl.c \ +EXTRA_DIST = flat_bl.c bsd_callg_bl.c fsf_callg_bl.c BUILT_SOURCES = flat_bl.c bsd_callg_bl.c fsf_callg_bl.c @@ -43,8 +38,7 @@ $(OBJECTS): ../bfd/bfd.h call_graph.h cg_arcs.h cg_print.h \ core.h gmon_io.h gmon_out.h gprof.h hertz.h hist.h \ search_list.h source.h sym_ids.h symtab.h utils.h \ $(srcdir)/../include/libiberty.h $(srcdir)/../bfd/sysdep.h \ - gconfig.h ../bfd/config.h $(MY_TARGET).h -$(MY_TARGET).o: $(MY_TARGET).c + gconfig.h ../bfd/config.h basic_blocks.o: basic_blocks.c bsd_call_bl.o: bsd_call_bl.c call_graph.o: call_graph.c @@ -63,3 +57,8 @@ source.o: source.c symtab.o: symtab.c sym_ids.o: sym_ids.c utils.o: utils.c +i386.o: i386.c +alpha.o: alpha.c +vax.o: vax.c +tahoe.o: tahoe.c +sparc.o: sparc.c diff --git a/gprof/Makefile.in b/gprof/Makefile.in index 1cbdc59c1a6..3df926017d5 100644 --- a/gprof/Makefile.in +++ b/gprof/Makefile.in @@ -5,7 +5,7 @@ # gives unlimited permission to copy, distribute and modify it. -SHELL = /bin/sh +SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ @@ -66,32 +66,29 @@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ VERSION = @VERSION@ -AUTOMAKE_OPTIONS = foreign +AUTOMAKE_OPTIONS = cygnus SUFFIXES = .m -INCLUDES = -D_GNU_SOURCE -DDEBUG -DTARGET_$(MY_TARGET) -DMACHINE_H=\"$(MY_TARGET).h\" -I../bfd -I$(srcdir)/../include -I$(srcdir)/../bfd - -MY_TARGET = @MY_TARGET@ +INCLUDES = -D_GNU_SOURCE -DDEBUG -I../bfd -I$(srcdir)/../include -I$(srcdir)/../bfd bin_PROGRAMS = gprof gprof_SOURCES = basic_blocks.c call_graph.c cg_arcs.c cg_dfn.c \ cg_print.c core.c gmon_io.c gprof.c hertz.c hist.c source.c \ search_list.c symtab.c sym_ids.c utils.c \ - flat_bl.c bsd_callg_bl.c fsf_callg_bl.c -gprof_DEPENDENCIES = $(MY_TARGET).o ../bfd/libbfd.la ../libiberty/libiberty.a -gprof_LDADD = $(MY_TARGET).o ../bfd/libbfd.la ../libiberty/libiberty.a + flat_bl.c bsd_callg_bl.c fsf_callg_bl.c \ + i386.c alpha.c vax.c tahoe.c sparc.c +gprof_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a +gprof_LDADD = ../bfd/libbfd.la ../libiberty/libiberty.a noinst_HEADERS = \ - alpha.h i386.h ns532.h sparc.h tahoe.h vax.h dummy.h \ basic_blocks.h call_graph.h cg_arcs.h cg_dfn.h cg_print.h \ core.h gmon.h gmon_io.h gmon_out.h gprof.h hertz.h hist.h \ - search_list.h source.h sparc.h sym_ids.h symtab.h utils.h + search_list.h source.h sym_ids.h symtab.h utils.h + +EXTRA_DIST = flat_bl.c bsd_callg_bl.c fsf_callg_bl.c -EXTRA_DIST = \ - alpha.c i386.c ns532.c sparc.c tahoe.c vax.c dummy.c \ - flat_bl.c bsd_callg_bl.c fsf_callg_bl.c \ BUILT_SOURCES = flat_bl.c bsd_callg_bl.c fsf_callg_bl.c info_TEXINFOS = gprof.texi @@ -111,7 +108,7 @@ LIBS = @LIBS@ gprof_OBJECTS = basic_blocks.o call_graph.o cg_arcs.o cg_dfn.o \ cg_print.o core.o gmon_io.o gprof.o hertz.o hist.o source.o \ search_list.o symtab.o sym_ids.o utils.o flat_bl.o bsd_callg_bl.o \ -fsf_callg_bl.o +fsf_callg_bl.o i386.o alpha.o vax.o tahoe.o sparc.o gprof_LDFLAGS = CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @@ -141,7 +138,7 @@ OBJECTS = $(gprof_OBJECTS) default: all .SUFFIXES: -.SUFFIXES: .c .dvi .info .lo .m .o .ps .texi .texinfo +.SUFFIXES: .S .c .dvi .info .lo .m .o .ps .s .texi .texinfo $(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --cygnus Makefile @@ -202,6 +199,12 @@ uninstall-binPROGRAMS: rm -f $(bindir)/`echo $$p|sed '$(transform)'`; \ done +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + .c.o: $(COMPILE) -c $< @@ -218,6 +221,13 @@ maintainer-clean-compile: .c.lo: $(LIBTOOL) --mode=compile $(COMPILE) -c $< +# These are just copies of the above rule. +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + mostlyclean-libtool: rm -f *.lo @@ -482,8 +492,7 @@ $(OBJECTS): ../bfd/bfd.h call_graph.h cg_arcs.h cg_print.h \ core.h gmon_io.h gmon_out.h gprof.h hertz.h hist.h \ search_list.h source.h sym_ids.h symtab.h utils.h \ $(srcdir)/../include/libiberty.h $(srcdir)/../bfd/sysdep.h \ - gconfig.h ../bfd/config.h $(MY_TARGET).h -$(MY_TARGET).o: $(MY_TARGET).c + gconfig.h ../bfd/config.h basic_blocks.o: basic_blocks.c bsd_call_bl.o: bsd_call_bl.c call_graph.o: call_graph.c @@ -502,6 +511,11 @@ source.o: source.c symtab.o: symtab.c sym_ids.o: sym_ids.c utils.o: utils.c +i386.o: i386.c +alpha.o: alpha.c +vax.o: vax.c +tahoe.o: tahoe.c +sparc.o: sparc.c # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/gprof/TODO b/gprof/TODO index 30a3cb25c02..20111c61e74 100644 --- a/gprof/TODO +++ b/gprof/TODO @@ -1,14 +1,14 @@ -Thu Feb 9 16:48:04 1995 -- documentation -- optimize bfd_find_nearest_line_num() (or replace by different interface) - gmon_io.c cannot deal with target architecture that have a pointer size that is different from the host architectures pointer size---fix this (gmon_out.h, and gmon_io.c) - add support for prof file format so that prof files can be displayed at the line-level (this is useful for the uprofile tool under DEC's OSF/1) +- take a hard look at --file-ordering (broken) and --function-ordering ++ documentation ++ optimize bfd_find_nearest_line_num() (or replace by different interface) + cleanup _bfd_ecoff_find_nearest_line_num() fixes & description + ensure "cc -pg" produces good files under OSF/1 v3.0 + make sure gprof works together with OSF/1 v3.0's profiling libraries diff --git a/gprof/aclocal.m4 b/gprof/aclocal.m4 index 39d4683386c..9d0b5aa1d89 100644 --- a/gprof/aclocal.m4 +++ b/gprof/aclocal.m4 @@ -100,19 +100,26 @@ AC_REQUIRE([AM_PROG_LD]) AC_REQUIRE([AC_PROG_LN_S]) # Always use our own libtool. -LIBTOOL='$(top_builddir)/libtool' +LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL) +dnl CYGNUS LOCAL arguments to enable-shared dnl Allow the --disable-shared flag to stop us from building shared libs. AC_ARG_ENABLE(shared, [ --enable-shared build shared libraries [default=yes]], -[if test "$enableval" = no; then - enable_shared=no -else - enable_shared=yes -fi]) +[p=${PACKAGE-bogus-package-name} + case "$enableval" in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + # The value of $p (aka $PACKAGE) is assumed to come from AM_INIT_AUTOMAKE. + # If it didn't, it'll be `bogus-package-name', thus making this condition + # not be used. + *$p*) enable_shared=yes ;; + *) shared=no ;; +esac]) libtool_shared= test "$enable_shared" = no && libtool_shared=" --disable-shared" +dnl END CYGNUS LOCAL dnl Allow the --disable-static flag to stop us from building static libs. AC_ARG_ENABLE(static, @@ -267,7 +274,7 @@ AC_DEFUN(AM_MAINTAINER_MODE, dnl AM_CYGWIN32() AC_DEFUN(AM_CYGWIN32, [AC_CACHE_CHECK(for Cygwin32 environment, am_cv_cygwin32, -[AC_TRY_COMPILE(,[int main () { return __CYGWIN32__; }], +[AC_TRY_COMPILE(,[return __CYGWIN32__;], am_cv_cygwin32=yes, am_cv_cygwin32=no) rm -f conftest*]) CYGWIN32= @@ -283,9 +290,10 @@ dnl environment. But if we're not, then it compiles a test program dnl to see if there is a suffix for executables. AC_DEFUN(AM_EXEEXT, [AC_REQUIRE([AM_CYGWIN32]) +AC_REQUIRE([AM_MINGW32]) AC_MSG_CHECKING([for executable suffix]) -AC_CACHE_VAL(am_cv_exeext, -[if test "$CYGWIN32" = yes; then +AC_CACHE_VAL(am_cv_exeext,[ +if test "$CYGWIN32" = yes -o "$MINGW32" = yes; then am_cv_exeext=.exe else cat > am_c_test.c << 'EOF' @@ -303,3 +311,16 @@ test x"${am_cv_exeext}" != xno && EXEEXT=${am_cv_exeext} AC_MSG_RESULT(${am_cv_exeext}) AC_SUBST(EXEEXT)]) +# Check to see if we're running under Mingw, without using +# AC_CANONICAL_*. If so, set output variable MINGW32 to "yes". +# Otherwise set it to "no". + +dnl AM_MINGW32() +AC_DEFUN(AM_MINGW32, +[AC_CACHE_CHECK(for Mingw32 environment, am_cv_mingw32, +[AC_TRY_COMPILE(,[return __MINGW32__;], +am_cv_mingw32=yes, am_cv_mingw32=no) +rm -f conftest*]) +MINGW32= +test "$am_cv_mingw32" = yes && MINGW32=yes]) + diff --git a/gprof/alpha.c b/gprof/alpha.c index e99fee53e99..843dda30e09 100644 --- a/gprof/alpha.c +++ b/gprof/alpha.c @@ -58,7 +58,7 @@ typedef union } j; /* jump format */ } -Instruction; +alpha_Instruction; static Sym indirect_child; @@ -71,14 +71,14 @@ static Sym indirect_child; * potentially call integer division routines, for example.) */ void -find_call (parent, p_lowpc, p_highpc) +alpha_find_call (parent, p_lowpc, p_highpc) Sym *parent; bfd_vma p_lowpc; bfd_vma p_highpc; { static bfd_vma delta = 0; bfd_vma dest_pc; - Instruction *pc; + alpha_Instruction *pc; Sym *child; if (!delta) @@ -105,8 +105,8 @@ find_call (parent, p_lowpc, p_highpc) } DBG (CALLDEBUG, printf ("[find_call] %s: 0x%lx to 0x%lx\n", parent->name, p_lowpc, p_highpc)); - for (pc = (Instruction *) (p_lowpc + delta); - pc < (Instruction *) (p_highpc + delta); + for (pc = (alpha_Instruction *) (p_lowpc + delta); + pc < (alpha_Instruction *) (p_highpc + delta); ++pc) { switch (pc->a.op_code) diff --git a/gprof/alpha.h b/gprof/alpha.h deleted file mode 100644 index b91324ed8db..00000000000 --- a/gprof/alpha.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * @(#)alpha.h 1.4 (Berkeley) 6/1/90 - */ -#ifndef alpha_h -#define alpha_h - -/* - * Offset (in bytes) of the code from the entry address of a routine. - * (see hist_assign_samples for use and explanation.) - */ -#define OFFSET_TO_CODE 0 -#define UNITS_TO_CODE (OFFSET_TO_CODE / sizeof(UNIT)) - -/* - * Minimum size of an instruction (in bytes): - */ -#define MIN_INSN_SIZE 4 - -#endif /* alpha_h */ diff --git a/gprof/configure b/gprof/configure index 5a9b2fa819b..3ededd3d14b 100755 --- a/gprof/configure +++ b/gprof/configure @@ -58,6 +58,7 @@ mandir='${prefix}/man' # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 @@ -575,7 +576,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:579: checking host system type" >&5 +echo "configure:580: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -596,7 +597,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 echo $ac_n "checking target system type""... $ac_c" 1>&6 -echo "configure:600: checking target system type" >&5 +echo "configure:601: checking target system type" >&5 target_alias=$target case "$target_alias" in @@ -614,7 +615,7 @@ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$target" 1>&6 echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:618: checking build system type" >&5 +echo "configure:619: checking build system type" >&5 build_alias=$build case "$build_alias" in @@ -644,11 +645,12 @@ test "$host_alias" != "$target_alias" && # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:652: checking for a BSD compatible install" >&5 +echo "configure:654: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -660,12 +662,13 @@ else /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. - for ac_prog in ginstall installbsd scoinst install; do + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. - # OSF/1 installbsd also uses dspmsg, but is usable. : else ac_cv_path_install="$ac_dir/$ac_prog -c" @@ -717,7 +720,7 @@ cat >> confdefs.h <&6 -echo "configure:721: checking whether build environment is sane" >&5 +echo "configure:724: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile @@ -764,7 +767,7 @@ test "$program_transform_name" = "" && program_transform_name="s,x,x," missing_dir=`cd $ac_aux_dir && pwd` echo $ac_n "checking for working aclocal""... $ac_c" 1>&6 -echo "configure:768: checking for working aclocal" >&5 +echo "configure:771: checking for working aclocal" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -777,7 +780,7 @@ else fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:781: checking for working autoconf" >&5 +echo "configure:784: checking for working autoconf" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -790,7 +793,7 @@ else fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:794: checking for working automake" >&5 +echo "configure:797: checking for working automake" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -803,7 +806,7 @@ else fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:807: checking for working autoheader" >&5 +echo "configure:810: checking for working autoheader" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -816,7 +819,7 @@ else fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:820: checking for working makeinfo" >&5 +echo "configure:823: checking for working makeinfo" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -829,7 +832,7 @@ else fi echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:833: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:836: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -859,7 +862,7 @@ fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:863: checking for $ac_word" >&5 +echo "configure:866: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -888,7 +891,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:892: checking for $ac_word" >&5 +echo "configure:895: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -936,7 +939,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:940: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:943: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -946,11 +949,11 @@ ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:957: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -970,12 +973,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:974: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:977: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:979: checking whether we are using GNU C" >&5 +echo "configure:982: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -984,7 +987,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:988: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:991: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -999,7 +1002,7 @@ if test $ac_cv_prog_gcc = yes; then ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1003: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1006: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1029,7 +1032,7 @@ fi # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1033: checking for $ac_word" >&5 +echo "configure:1036: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1065,10 +1068,10 @@ fi if test "$with_gnu_ld" = yes; then echo $ac_n "checking for GNU ld""... $ac_c" 1>&6 -echo "configure:1069: checking for GNU ld" >&5 +echo "configure:1072: checking for GNU ld" >&5 else echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 -echo "configure:1072: checking for non-GNU ld" >&5 +echo "configure:1075: checking for non-GNU ld" >&5 fi if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1107,7 +1110,7 @@ fi test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; } echo $ac_n "checking whether we are using GNU ld""... $ac_c" 1>&6 -echo "configure:1111: checking whether we are using GNU ld" >&5 +echo "configure:1114: checking whether we are using GNU ld" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gnu_ld'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1123,7 +1126,7 @@ echo "$ac_t""$ac_cv_prog_gnu_ld" 1>&6 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:1127: checking whether ln -s works" >&5 +echo "configure:1130: checking whether ln -s works" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1150,17 +1153,22 @@ fi # Always use our own libtool. -LIBTOOL='$(top_builddir)/libtool' +LIBTOOL='$(SHELL) $(top_builddir)/libtool' # Check whether --enable-shared or --disable-shared was given. if test "${enable_shared+set}" = set; then enableval="$enable_shared" - if test "$enableval" = no; then - enable_shared=no -else - enable_shared=yes -fi + p=${PACKAGE-bogus-package-name} + case "$enableval" in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + # The value of $p (aka $PACKAGE) is assumed to come from AM_INIT_AUTOMAKE. + # If it didn't, it'll be `bogus-package-name', thus making this condition + # not be used. + *$p*) enable_shared=yes ;; + *) shared=no ;; +esac fi libtool_shared= @@ -1220,7 +1228,7 @@ $libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \ # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1224: checking for $ac_word" >&5 +echo "configure:1232: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1249,7 +1257,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1253: checking for $ac_word" >&5 +echo "configure:1261: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1297,7 +1305,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1301: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:1309: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1307,11 +1315,11 @@ ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1323: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1331,12 +1339,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1335: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1343: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1340: checking whether we are using GNU C" >&5 +echo "configure:1348: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1345,7 +1353,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1349: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1357: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1360,7 +1368,7 @@ if test $ac_cv_prog_gcc = yes; then ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1364: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1372: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1392,7 +1400,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6 -echo "configure:1396: checking for POSIXized ISC" >&5 +echo "configure:1404: checking for POSIXized ISC" >&5 if test -d /etc/conf/kconfig.d && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1 then @@ -1413,18 +1421,6 @@ else fi -case "${target}" in -alpha-*-*) MY_TARGET=alpha ;; -i[3456]86-*-*) MY_TARGET=i386 ;; -sparc-*-*) MY_TARGET=sparc ;; -tahoe-*-*) MY_TARGET=tahoe ;; -vax-*-*) MY_TARGET=vax ;; -ns32k-*-*) MY_TARGET=ns532;; -*-*-*) MY_TARGET=dummy ;; -esac - - - case "${target}" in *-*-bsd4.4* | *-*-netbsd* | *-*-freebsd* | *-*-openbsd*) cat >> confdefs.h <<\EOF @@ -1435,7 +1431,7 @@ EOF esac echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6 -echo "configure:1439: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo "configure:1435: checking whether to enable maintainer-specific portions of Makefiles" >&5 # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then enableval="$enable_maintainer_mode" @@ -1453,19 +1449,19 @@ fi echo $ac_n "checking for Cygwin32 environment""... $ac_c" 1>&6 -echo "configure:1457: checking for Cygwin32 environment" >&5 +echo "configure:1453: checking for Cygwin32 environment" >&5 if eval "test \"`echo '$''{'am_cv_cygwin32'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1465: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* am_cv_cygwin32=yes else @@ -1481,13 +1477,44 @@ fi echo "$ac_t""$am_cv_cygwin32" 1>&6 CYGWIN32= test "$am_cv_cygwin32" = yes && CYGWIN32=yes +echo $ac_n "checking for Mingw32 environment""... $ac_c" 1>&6 +echo "configure:1482: checking for Mingw32 environment" >&5 +if eval "test \"`echo '$''{'am_cv_mingw32'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + am_cv_mingw32=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + am_cv_mingw32=no +fi +rm -f conftest* +rm -f conftest* +fi + +echo "$ac_t""$am_cv_mingw32" 1>&6 +MINGW32= +test "$am_cv_mingw32" = yes && MINGW32=yes + echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:1487: checking for executable suffix" >&5 +echo "configure:1513: checking for executable suffix" >&5 if eval "test \"`echo '$''{'am_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - if test "$CYGWIN32" = yes; then + +if test "$CYGWIN32" = yes -o "$MINGW32" = yes; then am_cv_exeext=.exe else cat > am_c_test.c << 'EOF' @@ -1530,7 +1557,7 @@ EOF # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | - case `(ac_space=' '; set) 2>&1` in + case `(ac_space=' '; set) 2>&1 | grep ac_space` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). @@ -1617,6 +1644,7 @@ sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF $ac_vpsub $extrasub +s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g @@ -1669,7 +1697,6 @@ s%@RANLIB@%$RANLIB%g s%@LD@%$LD%g s%@LN_S@%$LN_S%g s%@LIBTOOL@%$LIBTOOL%g -s%@MY_TARGET@%$MY_TARGET%g s%@MAINT@%$MAINT%g s%@EXEEXT@%$EXEEXT%g diff --git a/gprof/configure.in b/gprof/configure.in index 7144e5db32a..33f60899f78 100644 --- a/gprof/configure.in +++ b/gprof/configure.in @@ -19,20 +19,6 @@ AM_PROG_INSTALL AC_ISC_POSIX -case "${target}" in -alpha-*-*) MY_TARGET=alpha ;; -changequote(,)dnl -i[3456]86-*-*) MY_TARGET=i386 ;; -changequote([,])dnl -sparc-*-*) MY_TARGET=sparc ;; -tahoe-*-*) MY_TARGET=tahoe ;; -vax-*-*) MY_TARGET=vax ;; -ns32k-*-*) MY_TARGET=ns532;; -*-*-*) MY_TARGET=dummy ;; -esac - -AC_SUBST(MY_TARGET) - dnl We need to set BSD44_FORMAT on a host which uses the additional dnl header fields. This is an attempt to do that. I can't think of a dnl good feature test for this. diff --git a/gprof/core.c b/gprof/core.c index e390b1e299a..11b21a6f6ec 100644 --- a/gprof/core.c +++ b/gprof/core.c @@ -3,19 +3,15 @@ #include "core.h" #include "symtab.h" -#ifndef MIN_INSN_SIZE -/* If not defined in MACHINE_H, assume smallest instruction is 1 byte - long. THis is safe but may be needlessly slow on machines where - all instructions are longer. */ -#define MIN_INSN_SIZE 1 -#endif - bfd *core_bfd; int core_num_syms; asymbol **core_syms; asection *core_text_sect; PTR core_text_space; +int min_insn_size; +int offset_to_code; + /* For mapping symbols to specific .o files during file ordering. */ struct function_map { char *function_name; @@ -25,6 +21,12 @@ struct function_map { struct function_map *symbol_map; int symbol_map_count; +extern void i386_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 tahoe_find_call PARAMS ((Sym *, bfd_vma, bfd_vma)); +extern void sparc_find_call PARAMS ((Sym *, bfd_vma, bfd_vma)); + static void DEFUN (read_function_mappings, (filename), const char *filename) { @@ -160,6 +162,23 @@ DEFUN (core_init, (a_out_name), const char *a_out_name) done (1); } + min_insn_size = 1; + offset_to_code = 0; + + switch (bfd_get_arch (core_bfd)) + { + case bfd_arch_vax: + case bfd_arch_tahoe: + offset_to_code = 2; + break; + + case bfd_arch_alpha: + min_insn_size = 4; + break; + + default: + } + if (function_mapping_file) read_function_mappings (function_mapping_file); } @@ -193,6 +212,41 @@ DEFUN (core_get_text_space, (core_bfd), bfd * core_bfd) } +void +DEFUN (find_call, (parent, p_lowpc, p_highpc), + Sym * parent AND bfd_vma p_lowpc AND bfd_vma p_highpc) +{ + switch (bfd_get_arch (core_bfd)) + { + case bfd_arch_i386: + i386_find_call (parent, p_lowpc, p_highpc); + break; + + case bfd_arch_alpha: + alpha_find_call (parent, p_lowpc, p_highpc); + break; + + case bfd_arch_vax: + vax_find_call (parent, p_lowpc, p_highpc); + break; + + case bfd_arch_sparc: + sparc_find_call (parent, p_lowpc, p_highpc); + break; + + case bfd_arch_tahoe: + tahoe_find_call (parent, p_lowpc, p_highpc); + break; + + default: + fprintf (stderr, "%s: -c not supported on architecture %s\n", + whoami, bfd_printable_name(core_bfd)); + + /* Don't give the error more than once. */ + ignore_direct_calls = FALSE; + } +} + /* * Return class of symbol SYM. The returned class can be any of: * 0 -> symbol is not interesting to us @@ -429,15 +483,8 @@ DEFUN (core_create_function_syms, (core_bfd), bfd * core_bfd) symtab.limit->mapped = 0; } -#ifdef __osf__ - /* - * Suppress symbols that are not function names. This is - * useful to suppress code-labels and aliases. - * - * This is known to be useful under DEC's OSF/1. Under SunOS 4.x, - * labels do not appear in the symbol table info, so this isn't - * necessary. - */ + /* Lookup filename and line number, if we can */ + { const char *filename, *func_name; @@ -446,6 +493,18 @@ DEFUN (core_create_function_syms, (core_bfd), bfd * core_bfd) { symtab.limit->file = source_file_lookup_path (filename); + /* FIXME: Checking __osf__ here does not work with a cross + gprof. */ +#ifdef __osf__ + /* + * Suppress symbols that are not function names. This is + * useful to suppress code-labels and aliases. + * + * This is known to be useful under DEC's OSF/1. Under SunOS 4.x, + * labels do not appear in the symbol table info, so this isn't + * necessary. + */ + if (strcmp (symtab.limit->name, func_name) != 0) { /* @@ -458,9 +517,9 @@ DEFUN (core_create_function_syms, (core_bfd), bfd * core_bfd) symtab.limit->name, func_name)); continue; } +#endif } } -#endif symtab.limit->is_func = TRUE; symtab.limit->is_bb_head = TRUE; @@ -516,10 +575,10 @@ DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd) { char prev_name[PATH_MAX], prev_filename[PATH_MAX]; bfd_vma vma, min_vma = ~0, max_vma = 0; - bfd_vma offset, prev_offset, min_dist; + bfd_vma offset; Sym *prev, dummy, *sentinel, *sym; const char *filename; - int prev_line_num, i; + int prev_line_num; Sym_Table ltab; /* * Create symbols for functions as usual. This is necessary in @@ -537,18 +596,13 @@ DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd) * it is time to create a new symbol. * * Of course, this is rather slow and it would be better if - * bfd would provide an iterator for enumerating all line - * infos, but for now, we try to speed up the second pass - * by determining what the minimum code distance between two - * lines is. + * bfd would provide an iterator for enumerating all line infos */ prev_name[0] = '\0'; ltab.len = 0; - min_dist = core_text_sect->_raw_size; - prev_offset = -min_dist; prev_filename[0] = '\0'; prev_line_num = 0; - 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) { vma = core_text_sect->vma + offset; if (!get_src_info (vma, &filename, &dummy.name, &dummy.line_num) @@ -564,18 +618,10 @@ DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd) strcpy (prev_name, dummy.name); strcpy (prev_filename, filename); - if (offset - prev_offset < min_dist) - { - min_dist = offset - prev_offset; - } - prev_offset = offset; - min_vma = MIN (vma, min_vma); max_vma = MAX (vma, max_vma); } - DBG (AOUTDEBUG, printf ("[core_create_line_syms] min_dist=%lx\n", min_dist)); - /* make room for function symbols, too: */ ltab.len += symtab.len; ltab.base = (Sym *) xmalloc (ltab.len * sizeof (Sym)); @@ -583,8 +629,25 @@ DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd) /* pass 2 - create symbols: */ + /* We now set is_static as we go along, rather than by running + through the symbol table at the end. + + The old way called symtab_finalize before the is_static pass, + causing a problem since symtab_finalize uses is_static as part of + its address conflict resolution algorithm. Since global symbols + were prefered over static symbols, and all line symbols were + global at that point, static function names that conflicted with + their own line numbers (static, but labeled as global) were + rejected in favor of the line num. + + This was not the desired functionality. We always want to keep + our function symbols and discard any conflicting line symbols. + Perhaps symtab_finalize should be modified to make this + distinction as well, but the current fix works and the code is a + lot cleaner now. */ + prev = 0; - for (offset = 0; offset < core_text_sect->_raw_size; offset += min_dist) + for (offset = 0; offset < core_text_sect->_raw_size; offset += min_insn_size) { sym_init (ltab.limit); if (!get_src_info (core_text_sect->vma + offset, &filename, @@ -601,6 +664,23 @@ DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd) ltab.limit->file = source_file_lookup_path (filename); ltab.limit->addr = core_text_sect->vma + offset; + + /* Set is_static based on the enclosing function, using either: + * 1) the previous symbol, if it's from the same function, or + * 2) a symtab lookup + */ + + if (prev && ltab.limit->file == prev->file && + strcmp (ltab.limit->name, prev->name) == 0) + { + ltab.limit->is_static = prev->is_static; + } + else + { + sym = sym_lookup(&symtab, ltab.limit->addr); + ltab.limit->is_static = sym->is_static; + } + prev = ltab.limit; /* @@ -614,7 +694,7 @@ DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd) } DBG (AOUTDEBUG, printf ("[core_create_line_syms] %d %s 0x%lx\n", - ltab.len, ltab.limit->name, + ltab.limit - ltab.base, ltab.limit->name, ltab.limit->addr)); ++ltab.limit; } @@ -641,8 +721,8 @@ DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd) if (ltab.limit - ltab.base != ltab.len) { fprintf (stderr, - "%s: somebody miscounted: ltab.len=%ld instead of %d\n", - whoami, (long) (ltab.limit - ltab.base), ltab.len); + "%s: somebody miscounted: ltab.len=%d instead of %ld\n", + whoami, ltab.len, (long) (ltab.limit - ltab.base)); done (1); } @@ -652,21 +732,4 @@ DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd) free (symtab.base); symtab = ltab; - /* now go through all core symbols and set is_static accordingly: */ - - for (i = 0; i < core_num_syms; ++i) - { - if (core_sym_class (core_syms[i]) == 't') - { - sym = sym_lookup (&symtab, core_syms[i]->value - + core_syms[i]->section->vma); - do - { - sym++->is_static = TRUE; - } - while (sym->file == sym[-1].file && - strcmp (sym->name, sym[-1].name) == 0); - } - } - } diff --git a/gprof/core.h b/gprof/core.h index 81c79ad4559..a78b58a2cda 100644 --- a/gprof/core.h +++ b/gprof/core.h @@ -9,6 +9,10 @@ extern asymbol **core_syms; /* symbol table in a.out */ extern asection *core_text_sect; /* core text section */ extern PTR core_text_space; /* text space of a.out in core */ +extern int min_insn_size; /* size of smallest instruction, in bytes */ +extern int offset_to_code; /* offset (in bytes) of code from entry + address of routine */ + extern void core_init PARAMS ((const char *a_out_name)); extern void core_get_text_space PARAMS ((bfd * core_bfd)); extern void core_create_function_syms PARAMS ((bfd * core_bfd)); diff --git a/gprof/dummy.c b/gprof/dummy.c deleted file mode 100644 index 184cec65052..00000000000 --- a/gprof/dummy.c +++ /dev/null @@ -1,19 +0,0 @@ -#include "gprof.h" -#include "symtab.h" - - -/* - * dummy.c -- This file should be used for an unsupported processor type. - * It does nothing, but prevents findcall() from being unresolved. - */ - -void -DEFUN (find_call, (parent, p_lowpc, p_highpc), - Sym * parent AND bfd_vma p_lowpc AND bfd_vma p_highpc) -{ - fprintf (stderr, "%s: -c not supported on this machine architecture\n", - whoami); - - /* Don't give the error more than once. */ - ignore_direct_calls = FALSE; -} diff --git a/gprof/dummy.h b/gprof/dummy.h deleted file mode 100644 index 4c37c15f072..00000000000 --- a/gprof/dummy.h +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)dummy.h 5.1 (Berkeley) 4/18/91 - */ -#ifndef dummy_h -#define dummy_h - -/* - * dummy.h -- This file should be used when a processor is not yet supported. - */ - -/* - * Offset (in bytes) of the code from the entry address of a routine. - * (see hist_assign_samples()) for use and explanation.) - */ -#define OFFSET_TO_CODE 0 -#define UNITS_TO_CODE (OFFSET_TO_CODE / sizeof(UNIT)) - -enum opermodes - { - dummy - }; -typedef enum opermodes operandenum; - -#endif /* dummy_h */ diff --git a/gprof/gmon.h b/gprof/gmon.h index 019cb6cc0ae..6d0f7438947 100644 --- a/gprof/gmon.h +++ b/gprof/gmon.h @@ -37,7 +37,9 @@ struct raw_phdr { -#ifdef TARGET_alpha + /* FIXME: Checking a host compiler define means that we can't use + a cross gprof to the alpha. */ +#ifdef __alpha__ char low_pc[8]; /* base pc address of sample buffer */ char high_pc[8]; /* max pc address of sampled buffer */ #else @@ -46,6 +48,8 @@ struct raw_phdr #endif char ncnt[4]; /* size of sample buffer (plus this header) */ + /* FIXME: Checking host compiler defines here means that we can't + use a cross gprof alpha OSF. */ #if defined (__alpha__) && defined (__osf__) /* * DEC's OSF v3.0 uses 4 bytes of padding to bring the header to @@ -116,7 +120,9 @@ struct tostruct */ struct raw_arc { -#ifdef TARGET_alpha + /* FIXME: Checking a host compiler define means that we can't use + a cross gprof to the alpha. */ +#ifdef __alpha__ char from_pc[8]; char self_pc[8]; char count[8]; diff --git a/gprof/gprof.c b/gprof/gprof.c index 1af7fa18369..449ab203b54 100644 --- a/gprof/gprof.c +++ b/gprof/gprof.c @@ -67,7 +67,8 @@ bfd *abfd; */ static char *default_excluded_list[] = { - "_gprof_mcount", "mcount", "_mcount", "__mcount", "__mcleanup", + "_gprof_mcount", "mcount", "_mcount", "__mcount", "__mcount_internal", + "__mcleanup", "", "", 0 }; diff --git a/gprof/gprof.h b/gprof/gprof.h index 303588cb714..20eb108afeb 100644 --- a/gprof/gprof.h +++ b/gprof/gprof.h @@ -43,27 +43,6 @@ /* AIX defines hz as a macro. */ #undef hz -#ifdef MACHINE_H -#include MACHINE_H -#else -#if vax -#include "vax.h" -#endif -#if sun -#include "sun.h" -#endif -#if tahoe -#include "tahoe.h" -#endif -#endif - -#ifndef FOPEN_RB -#define FOPEN_RB "r" -#endif -#ifndef FOPEN_WB -#define FOPEN_WB "w" -#endif - #ifndef PATH_MAX #define PATH_MAX 1024 #endif diff --git a/gprof/hertz.h b/gprof/hertz.h index d5a23d3224a..2ea01bac882 100644 --- a/gprof/hertz.h +++ b/gprof/hertz.h @@ -9,6 +9,14 @@ * Discover the tick frequency of the machine if something goes wrong, * we return HZ_WRONG, an impossible sampling frequency. */ + +/* FIXME: Checking for MACH here makes no sense when for a cross + gprof. */ +#ifdef MACH +#include +#define hertz() (HZ) +#else extern int hertz PARAMS ((void)); +#endif #endif /* hertz_h */ diff --git a/gprof/hist.c b/gprof/hist.c index 2b2dceb817b..e87d846a462 100644 --- a/gprof/hist.c +++ b/gprof/hist.c @@ -12,6 +12,8 @@ #include "sym_ids.h" #include "utils.h" +#define UNITS_TO_CODE (offset_to_code / sizeof(UNIT)) + static void scale_and_align_entries PARAMS ((void)); /* declarations of automatically generated functions to output blurbs: */ diff --git a/gprof/i386.c b/gprof/i386.c index 01202a7c854..d09d34ed5a1 100644 --- a/gprof/i386.c +++ b/gprof/i386.c @@ -24,24 +24,23 @@ int -DEFUN (iscall, (ip), unsigned char *ip) +DEFUN (i386_iscall, (ip), unsigned char *ip) { - if (*ip == 0xeb || *ip == 0x9a) + if (*ip == 0xe8) return 1; return 0; } void -find_call (parent, p_lowpc, p_highpc) +i386_find_call (parent, p_lowpc, p_highpc) Sym *parent; bfd_vma p_lowpc; bfd_vma p_highpc; { unsigned char *instructp; - long length; Sym *child; - bfd_vma destpc; + bfd_vma destpc, delta; if (core_text_space == 0) { @@ -57,54 +56,49 @@ find_call (parent, p_lowpc, p_highpc) } DBG (CALLDEBUG, printf ("[findcall] %s: 0x%lx to 0x%lx\n", parent->name, p_lowpc, p_highpc)); - for (instructp = (unsigned char *) core_text_space + p_lowpc; - instructp < (unsigned char *) core_text_space + p_highpc; - instructp += length) + + delta = (bfd_vma) core_text_space - core_text_sect->vma; + + for (instructp = (unsigned char *) (p_lowpc + delta); + instructp < (unsigned char *) (p_highpc + delta); + instructp ++) { - length = 1; - if (iscall (instructp)) + if (i386_iscall (instructp)) { DBG (CALLDEBUG, - printf ("[findcall]\t0x%x:callf", - instructp - (unsigned char *) core_text_space)); - length = 4; + printf ("[findcall]\t0x%x:call", + instructp - (unsigned char *) delta)); /* * regular pc relative addressing * check that this is the address of * a function. */ - destpc = ((bfd_vma) instructp + 5 - (bfd_vma) core_text_space); + + destpc = ((bfd_vma) bfd_get_32 (core_bfd, instructp + 1) + + (bfd_vma) instructp - (bfd_vma) delta + 5); if (destpc >= s_lowpc && destpc <= s_highpc) { child = sym_lookup (&symtab, destpc); - DBG (CALLDEBUG, - printf ("[findcall]\tdestpc 0x%lx", destpc); - printf (" child->name %s", child->name); - printf (" child->addr 0x%lx\n", child->addr); - ); - if (child->addr == destpc) + if (child && child->addr == destpc) { /* * a hit */ + DBG (CALLDEBUG, + printf ("\tdestpc 0x%lx (%s)\n", destpc, child->name)); arc_add (parent, child, (long) 0); - length += 4; /* constant lengths */ + instructp += 4; /* call is a 5 byte instruction */ continue; } - goto botched; } /* * else: - * it looked like a callf, - * but it wasn't to anywhere. - */ - botched: - /* - * something funny going on. + * it looked like a callf, but it: + * a) wasn't actually a callf, or + * b) didn't point to a known function in the symtab, or + * c) something funny is going on. */ - DBG (CALLDEBUG, printf ("[findcall]\tbut it's a botch\n")); - length = 1; - continue; + DBG (CALLDEBUG, printf ("\tbut it's a botch\n")); } } } diff --git a/gprof/i386.h b/gprof/i386.h deleted file mode 100644 index f85f55cbbd9..00000000000 --- a/gprof/i386.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * @(#)tahoe.h 1.4 (Berkeley) 6/1/90 - */ - -/* - * Right now, this does very little - */ - - /* - * opcode of the `callf' instruction - */ - /* - * offset (in bytes) of the code from the entry address of a routine. - * (see asgnsamples for use and explanation.) - */ -#define OFFSET_TO_CODE 0 -#define UNITS_TO_CODE (OFFSET_TO_CODE / sizeof(UNIT)) - -#ifdef __MSDOS__ -#define FOPEN_RB "rb" -#endif diff --git a/gprof/ns532.c b/gprof/ns532.c deleted file mode 100644 index c68fae4473c..00000000000 --- a/gprof/ns532.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "gprof.h" -#include "symtab.h" - -/* - * dummy.c -- This file should be used for an unsupported processor type. - * It does nothing, but prevents findcall() from being unresolved. - */ - -void -find_call (parent, p_lowpc, p_highpc) - Sym *parent; - bfd_vma p_lowpc; - bfd_vma p_highpc; -{ - fprintf (stderr, "%s: -c supported on this machine architecture\n", - whoami); -} diff --git a/gprof/ns532.h b/gprof/ns532.h deleted file mode 100644 index 2fa22334e03..00000000000 --- a/gprof/ns532.h +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)dummy.h 5.1 (Berkeley) 4/18/91 - */ - -/* - * offset (in bytes) of the code from the entry address of a routine. - * (see asgnsamples for use and explanation.) - */ -#ifdef MACH -#include -#define hertz() (HZ) -#endif -#define OFFSET_OF_CODE 0 -#define UNITS_TO_CODE (OFFSET_OF_CODE / sizeof(UNIT)) - -enum opermodes - { - dummy - }; -typedef enum opermodes operandenum; diff --git a/gprof/sparc.c b/gprof/sparc.c index 6316bffc78a..77457ac4de1 100644 --- a/gprof/sparc.c +++ b/gprof/sparc.c @@ -22,9 +22,13 @@ #include "hist.h" #include "symtab.h" + /* + * opcode of the `callf' instruction + */ +#define CALL (0xc0000000) void -find_call (parent, p_lowpc, p_highpc) +sparc_find_call (parent, p_lowpc, p_highpc) Sym *parent; bfd_vma p_lowpc; bfd_vma p_highpc; diff --git a/gprof/sparc.h b/gprof/sparc.h deleted file mode 100644 index 48e5d230aa7..00000000000 --- a/gprof/sparc.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * @(#)tahoe.h 1.4 (Berkeley) 6/1/90 - */ - - /* - * opcode of the `callf' instruction - */ -#define CALL (0xc0000000) - /* - * offset (in bytes) of the code from the entry address of a routine. - * (see asgnsamples for use and explanation.) - */ -#define OFFSET_TO_CODE 0 -#define UNITS_TO_CODE (OFFSET_TO_CODE / sizeof(UNIT)) diff --git a/gprof/tahoe.c b/gprof/tahoe.c index 967ea019574..a9585df2a73 100644 --- a/gprof/tahoe.c +++ b/gprof/tahoe.c @@ -17,7 +17,29 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include "gprof.h" -#include "time_host.h" +#include "cg_arcs.h" +#include "core.h" +#include "hist.h" +#include "symtab.h" + + /* + * opcode of the `callf' instruction + */ +#define CALLF 0xfe + + /* + * register for pc relative addressing + */ +#define PC 0xf + +enum tahoe_opermodes + { + literal, indexed, reg, regdef, autodec, autoinc, autoincdef, + bytedisp, bytedispdef, worddisp, worddispdef, longdisp, longdispdef, + immediate, absolute, byterel, bytereldef, wordrel, wordreldef, + longrel, longreldef + }; +typedef enum tahoe_opermodes tahoe_operandenum; /* * A symbol to be the child of indirect callf: @@ -25,8 +47,8 @@ Sym indirectchild; -operandenum -operandmode (modep) +tahoe_operandenum +tahoe_operandmode (modep) unsigned char *modep; { long usesreg = ((long) *modep) & 0xf; @@ -64,11 +86,12 @@ operandmode (modep) return usesreg != PC ? longdispdef : longreldef; } /* NOTREACHED */ + abort (); } char * -operandname (mode) - operandenum mode; +tahoe_operandname (mode) + tahoe_operandenum mode; { switch (mode) @@ -117,14 +140,15 @@ operandname (mode) return "long relative deferred"; } /* NOTREACHED */ + abort (); } long -operandlength (modep) +tahoe_operandlength (modep) unsigned char *modep; { - switch (operandmode (modep)) + switch (tahoe_operandmode (modep)) { case literal: case reg: @@ -151,16 +175,17 @@ operandlength (modep) case longreldef: return 5; case indexed: - return 1 + operandlength (modep + 1); + return 1 + tahoe_operandlength (modep + 1); } /* NOTREACHED */ + abort (); } bfd_vma -reladdr (modep) +tahoe_reladdr (modep) char *modep; { - operandenum mode = operandmode (modep); + tahoe_operandenum mode = tahoe_operandmode (modep); char *cp; short *sp; long *lp; @@ -187,7 +212,8 @@ reladdr (modep) } } -find_call (parent, p_lowpc, p_highpc) +void +tahoe_find_call (parent, p_lowpc, p_highpc) Sym *parent; bfd_vma p_lowpc; bfd_vma p_highpc; @@ -195,8 +221,8 @@ find_call (parent, p_lowpc, p_highpc) unsigned char *instructp; long length; Sym *child; - operandenum mode; - operandenum firstmode; + tahoe_operandenum mode; + tahoe_operandenum firstmode; bfd_vma destpc; static bool inited = FALSE; @@ -208,7 +234,7 @@ find_call (parent, p_lowpc, p_highpc) indirectchild.cg.cyc.head = &indirectchild; } - if (textspace == 0) + if (core_text_space == 0) { return; } @@ -220,10 +246,10 @@ find_call (parent, p_lowpc, p_highpc) { p_highpc = s_highpc; } - DBG (CALLDEBUG, printf ("[findcall] %s: 0x%x to 0x%x\n", + DBG (CALLDEBUG, printf ("[findcall] %s: 0x%lx to 0x%lx\n", parent->name, p_lowpc, p_highpc)); - for (instructp = textspace + p_lowpc; - instructp < textspace + p_highpc; + for (instructp = (unsigned char *) core_text_space + p_lowpc; + instructp < (unsigned char *) core_text_space + p_highpc; instructp += length) { length = 1; @@ -234,8 +260,8 @@ find_call (parent, p_lowpc, p_highpc) * skip the count of the number of arguments. */ DBG (CALLDEBUG, printf ("[findcall]\t0x%x:callf", - instructp - textspace)); - firstmode = operandmode (instructp + length); + instructp - (unsigned char *) core_text_space)); + firstmode = tahoe_operandmode (instructp + length); switch (firstmode) { case literal: @@ -244,11 +270,11 @@ find_call (parent, p_lowpc, p_highpc) default: goto botched; } - length += operandlength (instructp + length); - mode = operandmode (instructp + length); + length += tahoe_operandlength (instructp + length); + mode = tahoe_operandmode (instructp + length); DBG (CALLDEBUG, - printf ("\tfirst operand is %s", operandname (firstmode)); - printf ("\tsecond operand is %s\n", operandname (mode)); + printf ("\tfirst operand is %s", tahoe_operandname (firstmode)); + printf ("\tsecond operand is %s\n", tahoe_operandname (mode)); ); switch (mode) { @@ -268,7 +294,7 @@ find_call (parent, p_lowpc, p_highpc) * e.g. arrays of pointers to functions???] */ arc_add (parent, &indirectchild, (long) 0); - length += operandlength (instructp + length); + length += tahoe_operandlength (instructp + length); continue; case byterel: case wordrel: @@ -278,15 +304,15 @@ find_call (parent, p_lowpc, p_highpc) * check that this is the address of * a function. */ - destpc = reladdr (instructp + length) - - (bfd_vma) textspace; + destpc = tahoe_reladdr (instructp + length) + - (bfd_vma) core_text_space; if (destpc >= s_lowpc && destpc <= s_highpc) { - child = sym_lookup (destpc); + child = sym_lookup (&symtab, destpc); DBG (CALLDEBUG, - printf ("[findcall]\tdestpc 0x%x", destpc); + printf ("[findcall]\tdestpc 0x%lx", destpc); printf (" child->name %s", child->name); - printf (" child->addr 0x%x\n", child->addr); + printf (" child->addr 0x%lx\n", child->addr); ); if (child->addr == destpc) { @@ -294,7 +320,7 @@ find_call (parent, p_lowpc, p_highpc) * a hit */ arc_add (parent, child, (long) 0); - length += operandlength (instructp + length); + length += tahoe_operandlength (instructp + length); continue; } goto botched; diff --git a/gprof/tahoe.h b/gprof/tahoe.h deleted file mode 100644 index 4d153a44f54..00000000000 --- a/gprof/tahoe.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * @(#)tahoe.h 1.4 (Berkeley) 6/1/90 - */ - - /* - * opcode of the `callf' instruction - */ -#define CALLF 0xfe - - /* - * offset (in bytes) of the code from the entry address of a routine. - * (see asgnsamples for use and explanation.) - */ -#define OFFSET_TO_CODE 2 -#define UNITS_TO_CODE (OFFSET_TO_CODE / sizeof(UNIT)) - - /* - * register for pc relative addressing - */ -#define PC 0xf - -enum opermodes - { - literal, indexed, reg, regdef, autodec, autoinc, autoincdef, - bytedisp, bytedispdef, worddisp, worddispdef, longdisp, longdispdef, - immediate, absolute, byterel, bytereldef, wordrel, wordreldef, - longrel, longreldef - }; -typedef enum opermodes operandenum; diff --git a/gprof/vax.c b/gprof/vax.c index 6a1034c82d3..020409cba6f 100644 --- a/gprof/vax.c +++ b/gprof/vax.c @@ -22,6 +22,31 @@ #include "hist.h" #include "symtab.h" + /* + * opcode of the `calls' instruction + */ +#define CALLS 0xfb + + /* + * register for pc relative addressing + */ +#define PC 0xf + +enum opermodes + { + literal, indexed, reg, regdef, autodec, autoinc, autoincdef, + bytedisp, bytedispdef, worddisp, worddispdef, longdisp, longdispdef, + immediate, absolute, byterel, bytereldef, wordrel, wordreldef, + longrel, longreldef + }; +typedef enum opermodes operandenum; + +struct modebyte + { + unsigned int regfield:4; + unsigned int modefield:4; + }; + /* * A symbol to be the child of indirect calls: */ @@ -29,7 +54,7 @@ Sym indirectchild; static operandenum -operandmode (modep) +vax_operandmode (modep) struct modebyte *modep; { long usesreg = modep->regfield; @@ -67,10 +92,11 @@ operandmode (modep) return usesreg != PC ? longdispdef : longreldef; } /* NOTREACHED */ + abort (); } static char * -operandname (mode) +vax_operandname (mode) operandenum mode; { @@ -120,14 +146,15 @@ operandname (mode) return "long relative deferred"; } /* NOTREACHED */ + abort (); } static long -operandlength (modep) +vax_operandlength (modep) struct modebyte *modep; { - switch (operandmode (modep)) + switch (vax_operandmode (modep)) { case literal: case reg: @@ -154,16 +181,17 @@ operandlength (modep) case longreldef: return 5; case indexed: - return 1 + operandlength ((struct modebyte *) ((char *) modep) + 1); + return 1 + vax_operandlength ((struct modebyte *) ((char *) modep) + 1); } /* NOTREACHED */ + abort (); } static bfd_vma -reladdr (modep) +vax_reladdr (modep) struct modebyte *modep; { - operandenum mode = operandmode (modep); + operandenum mode = vax_operandmode (modep); char *cp; short *sp; long *lp; @@ -188,7 +216,7 @@ reladdr (modep) void -find_call (parent, p_lowpc, p_highpc) +vax_find_call (parent, p_lowpc, p_highpc) Sym *parent; bfd_vma p_lowpc; bfd_vma p_highpc; @@ -237,7 +265,7 @@ find_call (parent, p_lowpc, p_highpc) DBG (CALLDEBUG, printf ("[findcall]\t0x%x:calls", instructp - (unsigned char *) core_text_space)); - firstmode = operandmode ((struct modebyte *) (instructp + length)); + firstmode = vax_operandmode ((struct modebyte *) (instructp + length)); switch (firstmode) { case literal: @@ -246,11 +274,11 @@ find_call (parent, p_lowpc, p_highpc) default: goto botched; } - length += operandlength ((struct modebyte *) (instructp + length)); - mode = operandmode ((struct modebyte *) (instructp + length)); + length += vax_operandlength ((struct modebyte *) (instructp + length)); + mode = vax_operandmode ((struct modebyte *) (instructp + length)); DBG (CALLDEBUG, - printf ("\tfirst operand is %s", operandname (firstmode)); - printf ("\tsecond operand is %s\n", operandname (mode))); + printf ("\tfirst operand is %s", vax_operandname (firstmode)); + printf ("\tsecond operand is %s\n", vax_operandname (mode))); switch (mode) { case regdef: @@ -269,7 +297,7 @@ find_call (parent, p_lowpc, p_highpc) * e.g. arrays of pointers to functions???] */ arc_add (parent, &indirectchild, (long) 0); - length += operandlength ( + length += vax_operandlength ( (struct modebyte *) (instructp + length)); continue; case byterel: @@ -280,7 +308,7 @@ find_call (parent, p_lowpc, p_highpc) * check that this is the address of * a function. */ - destpc = reladdr ((struct modebyte *) (instructp + length)) + destpc = vax_reladdr ((struct modebyte *) (instructp + length)) - (bfd_vma) core_text_space; if (destpc >= s_lowpc && destpc <= s_highpc) { @@ -296,8 +324,8 @@ find_call (parent, p_lowpc, p_highpc) * a hit */ arc_add (parent, child, (long) 0); - length += operandlength ((struct modebyte *) - (instructp + length)); + length += vax_operandlength ((struct modebyte *) + (instructp + length)); continue; } goto botched; diff --git a/gprof/vax.h b/gprof/vax.h deleted file mode 100644 index 69ec9c26ee9..00000000000 --- a/gprof/vax.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * @(#)vax.h 5.4 (Berkeley) 6/1/90 - */ - - /* - * opcode of the `calls' instruction - */ -#define CALLS 0xfb - - /* - * offset (in bytes) of the code from the entry address of a routine. - * (see asgnsamples for use and explanation.) - */ -#define OFFSET_TO_CODE 2 -#define UNITS_TO_CODE (OFFSET_TO_CODE / sizeof(UNIT)) - - /* - * register for pc relative addressing - */ -#define PC 0xf - -enum opermodes - { - literal, indexed, reg, regdef, autodec, autoinc, autoincdef, - bytedisp, bytedispdef, worddisp, worddispdef, longdisp, longdispdef, - immediate, absolute, byterel, bytereldef, wordrel, wordreldef, - longrel, longreldef - }; -typedef enum opermodes operandenum; - -struct modebyte - { - unsigned int regfield:4; - unsigned int modefield:4; - };