This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] gprof static call support for MIPS


On Sun, Jan 20, 2002 at 03:08:22PM -0800, Jason R Thorpe wrote:
> The following adds support for the gprof -c option (static call
> graph by hueristic) on the MIPS.  It was derived from similar code
> for the Alpha.
> 
> OK to commit?
> 
> 	* mips.c: New file.
> 	* Makefile.am (sources): Add mips.c.
> 	(mips.o): New rule.
> 	* Makefile.in: Regenerate.
> 	* corefile.c: Update copyright years.
> 	(find_call): Call mips_find_call for bfd_arch_mips.
> 
> -- 
>         -- Jason R. Thorpe <thorpej@wasabisystems.com>

> +   for (pc = p_lowpc; pc < p_highpc; pc += 4)
> +     {
> +       op = bfd_get_32 (core_bfd, &((char *)core_text_space)[pc - s_lowpc]);
> +       if ((op & 0xfc000000) == 0x0c000000)
> + 	{
> + 	  /* This is a "jal" instruction.  Check that the destination
> + 	     is the address of a function.  */
> + 	  DBG (CALLDEBUG,
> + 	       printf (_("[find_call] 0x%lx: jal"), (unsigned long) pc));
> +           offset = (op & 0x03ffffff) << 2;
> + 	  dest_pc = (pc & ~0xfffffff) | offset;
> + 	  if (dest_pc >= s_lowpc && dest_pc <= s_highpc)
> + 	    {
> + 	      child = sym_lookup (&symtab, dest_pc);
> + 	      DBG (CALLDEBUG,
> + 		   printf (" 0x%lx\t; name=%s, addr=0x%lx",
> + 			   (unsigned long) dest_pc, child->name,
> + 			   (unsigned long) child->addr));
> + 	      if (child->addr == dest_pc)
> + 		{
> + 		  DBG (CALLDEBUG, printf ("\n"));
> + 		  /* a hit:  */
> + 		  arc_add (parent, child, (unsigned long) 0);
> + 		  continue;
> + 		}
> + 	    }
> + 	  /* Something funny going on.  */
> + 	  DBG (CALLDEBUG, printf ("\tbut it's a botch\n"));
> + 	}
> +       else if ((op & 0xfc00f83f) == 0x0000f809)
> + 	{
> + 	  /* This is a "jalr" instruction (indirect call).  */
> + 	  DBG (CALLDEBUG,
> + 	       printf (_("[find_call] 0x%lx: jalr\n"), (unsigned long) pc));
> + 	  arc_add (parent, &indirect_child, (unsigned long) 0);
> + 	}
> +     }
> + }

Is this going to do any good for NetBSD?  I thought I remembered you
saying that NetBSD/MIPS used -mabicalls, when you posted the profiling
patch.  In that case all interesting calls are indirect!

Then again I don't see abicalls set for netbsd in the community GCC
tree.
-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]