Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/gprof/vax.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/*
    2  * Copyright (c) 1983, 2001 Regents of the University of California.
    3  * All rights reserved.
     2 * Copyright (c) 1983, 1993, 2001
     3 *      The Regents of the University of California.  All rights reserved.
    44 *
    5  * Redistribution and use in source and binary forms are permitted
    6  * provided that: (1) source distributions retain this entire copyright
    7  * notice and comment, and (2) distributions including binaries display
    8  * the following acknowledgement:  ``This product includes software
    9  * developed by the University of California, Berkeley and its contributors''
    10  * in the documentation or other materials provided with the distribution
    11  * and in all advertising materials mentioning features or use of this
    12  * software. Neither the name of the University nor the names of its
    13  * contributors may be used to endorse or promote products derived
    14  * from this software without specific prior written permission.
    15  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
    16  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
    17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 * 1. Redistributions of source code must retain the above copyright
     9 *    notice, this list of conditions and the following disclaimer.
     10 * 2. Redistributions in binary form must reproduce the above copyright
     11 *    notice, this list of conditions and the following disclaimer in the
     12 *    documentation and/or other materials provided with the distribution.
     13 * 3. Neither the name of the University nor the names of its contributors
     14 *    may be used to endorse or promote products derived from this software
     15 *    without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     27 * SUCH DAMAGE.
    1828 */
    1929#include "gprof.h"
     30#include "search_list.h"
     31#include "source.h"
     32#include "symtab.h"
    2033#include "cg_arcs.h"
    2134#include "corefile.h"
    2235#include "hist.h"
    23 #include "symtab.h"
    2436
    2537    /*
     
    4254typedef enum opermodes operandenum;
    4355
     56#if 0
     57/* Here to document only.  We can't use this when cross compiling as
     58   the bitfield layout might not be the same as native.  */
    4459struct modebyte
    4560  {
     
    4762    unsigned int modefield:4;
    4863  };
     64#endif
    4965
    5066/*
    5167 * A symbol to be the child of indirect calls:
    5268 */
    53 Sym indirectchild;
    54 
     69static Sym indirectchild;
     70
     71static operandenum vax_operandmode PARAMS ((unsigned char *));
     72static char *vax_operandname PARAMS ((operandenum));
     73static long vax_operandlength PARAMS ((unsigned char *));
     74static bfd_signed_vma vax_offset PARAMS ((unsigned char *));
     75void vax_find_call PARAMS ((Sym *, bfd_vma, bfd_vma));
    5576
    5677static operandenum
    5778vax_operandmode (modep)
    58      struct modebyte *modep;
    59 {
    60   long usesreg = modep->regfield;
    61 
    62   switch (modep->modefield)
     79     unsigned char *modep;
     80{
     81  int usesreg = *modep & 0xf;
     82
     83  switch ((*modep >> 4) & 0xf)
    6384    {
    6485    case 0:
     
    152173static long
    153174vax_operandlength (modep)
    154      struct modebyte *modep;
     175     unsigned char *modep;
    155176{
    156177
     
    182203      return 5;
    183204    case indexed:
    184       return 1 + vax_operandlength ((struct modebyte *) ((char *) modep) + 1);
     205      return 1 + vax_operandlength (modep + 1);
    185206    }
    186207  /* NOTREACHED */
     
    188209}
    189210
    190 static bfd_vma
    191 vax_reladdr (modep)
    192      struct modebyte *modep;
     211static bfd_signed_vma
     212vax_offset (modep)
     213     unsigned char *modep;
    193214{
    194215  operandenum mode = vax_operandmode (modep);
    195   char *cp;
    196   short *sp;
    197   long *lp;
    198 
    199   cp = (char *) modep;
    200   ++cp;                         /* skip over the mode */
     216
     217  ++modep;                              /* skip over the mode */
    201218  switch (mode)
    202219    {
    203220    default:
    204221      fprintf (stderr, "[reladdr] not relative address\n");
    205       return (bfd_vma) modep;
     222      return 0;
    206223    case byterel:
    207       return (bfd_vma) (cp + sizeof *cp + *cp);
     224      return 1 + bfd_get_signed_8 (core_bfd, modep);
    208225    case wordrel:
    209       sp = (short *) cp;
    210       return (bfd_vma) (cp + sizeof *sp + *sp);
     226      return 2 + bfd_get_signed_16 (core_bfd, modep);
    211227    case longrel:
    212       lp = (long *) cp;
    213       return (bfd_vma) (cp + sizeof *lp + *lp);
     228      return 4 + bfd_get_signed_32 (core_bfd, modep);
    214229    }
    215230}
     
    227242  operandenum mode;
    228243  operandenum firstmode;
    229   bfd_vma destpc;
    230   static bool inited = FALSE;
     244  bfd_vma pc, destpc;
     245  static bfd_boolean inited = FALSE;
    231246
    232247  if (!inited)
     
    253268                          parent->name, (unsigned long) p_lowpc,
    254269                          (unsigned long) p_highpc));
    255   for (instructp = (unsigned char *) core_text_space + p_lowpc;
    256        instructp < (unsigned char *) core_text_space + p_highpc;
    257        instructp += length)
     270  for (pc = p_lowpc; pc < p_highpc; pc += length)
    258271    {
    259272      length = 1;
    260       if (*instructp == CALLS)
     273      instructp = ((unsigned char *) core_text_space
     274                   + pc - core_text_sect->vma);
     275      if ((*instructp & 0xff) == CALLS)
    261276        {
    262277          /*
     
    265280           */
    266281          DBG (CALLDEBUG,
    267                printf ("[findcall]\t0x%lx:calls",
    268                        ((unsigned long)
    269                         (instructp - (unsigned char *) core_text_space))));
    270           firstmode = vax_operandmode ((struct modebyte *) (instructp + length));
     282               printf ("[findcall]\t0x%lx:calls", (unsigned long) pc));
     283          firstmode = vax_operandmode (instructp + length);
    271284          switch (firstmode)
    272285            {
     
    277290              goto botched;
    278291            }
    279           length += vax_operandlength ((struct modebyte *) (instructp + length));
    280           mode = vax_operandmode ((struct modebyte *) (instructp + length));
     292          length += vax_operandlength (instructp + length);
     293          mode = vax_operandmode (instructp + length);
    281294          DBG (CALLDEBUG,
    282295               printf ("\tfirst operand is %s", vax_operandname (firstmode));
     
    300313               */
    301314              arc_add (parent, &indirectchild, (unsigned long) 0);
    302               length += vax_operandlength (
    303                                   (struct modebyte *) (instructp + length));
     315              length += vax_operandlength (instructp + length);
    304316              continue;
    305317            case byterel:
     
    311323               *      a function.
    312324               */
    313               destpc = vax_reladdr ((struct modebyte *) (instructp + length))
    314                 - (bfd_vma) core_text_space;
     325              destpc = pc + vax_offset (instructp + length);
    315326              if (destpc >= s_lowpc && destpc <= s_highpc)
    316327                {
     
    329340                       */
    330341                      arc_add (parent, child, (unsigned long) 0);
    331                       length += vax_operandlength ((struct modebyte *)
    332                                                    (instructp + length));
     342                      length += vax_operandlength (instructp + length);
    333343                      continue;
    334344                    }
Note: See TracChangeset for help on using the changeset viewer.