Back to index

cell-binutils  2.17cvs20070401
Functions
i386.c File Reference
#include "gprof.h"
#include "search_list.h"
#include "source.h"
#include "symtab.h"
#include "cg_arcs.h"
#include "corefile.h"
#include "hist.h"

Go to the source code of this file.

Functions

static int i386_iscall (unsigned char *)
void i386_find_call (Sym *, bfd_vma, bfd_vma)

Function Documentation

void i386_find_call ( Sym parent,
bfd_vma  p_lowpc,
bfd_vma  p_highpc 
)

Definition at line 50 of file i386.c.

{
  unsigned char *instructp;
  Sym *child;
  bfd_vma pc, destpc;

  if (core_text_space == 0)
    {
      return;
    }
  if (p_lowpc < s_lowpc)
    {
      p_lowpc = s_lowpc;
    }
  if (p_highpc > s_highpc)
    {
      p_highpc = s_highpc;
    }
  DBG (CALLDEBUG, printf ("[findcall] %s: 0x%lx to 0x%lx\n",
                       parent->name, (unsigned long) p_lowpc,
                       (unsigned long) p_highpc));

  for (pc = p_lowpc; pc < p_highpc; ++pc)
    {
      instructp = (unsigned char *) core_text_space + pc - core_text_sect->vma;
      if (i386_iscall (instructp))
       {
         DBG (CALLDEBUG,
              printf ("[findcall]\t0x%lx:call", (unsigned long) pc));
         /*
          *  regular pc relative addressing
          *    check that this is the address of
          *    a function.
          */

         destpc = bfd_get_32 (core_bfd, instructp + 1) + pc + 5;
         if (destpc >= s_lowpc && destpc <= s_highpc)
           {
             child = sym_lookup (&symtab, destpc);
             if (child && child->addr == destpc)
              {
                /*
                 *      a hit
                 */
                DBG (CALLDEBUG,
                     printf ("\tdestpc 0x%lx (%s)\n",
                            (unsigned long) destpc, child->name));
                arc_add (parent, child, (unsigned long) 0);
                instructp += 4;    /* call is a 5 byte instruction */
                continue;
              }
           }
         /*
          *  else:
          *    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 ("\tbut it's a botch\n"));
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int i386_iscall ( unsigned char *  ip) [static]

Definition at line 41 of file i386.c.

{
  if (*ip == 0xe8)
    return 1;
  return 0;
}

Here is the caller graph for this function: