This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [RFA] gprof static call support for MIPS
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: binutils at sources dot redhat dot com
- Cc: Jason R Thorpe <thorpej at wasabisystems dot com>
- Date: Sun, 20 Jan 2002 18:26:05 -0500
- Subject: Re: [RFA] gprof static call support for MIPS
- References: <20020120150822.Q8364@dr-evil.shagadelic.org>
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