Commit | Line | Data |
---|---|---|
2aed990c | 1 | /* |
3d6c6501 SEF |
2 | * Copyright (c) 1983 Regents of the University of California. |
3 | * All rights reserved. | |
4 | * | |
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. | |
18 | */ | |
5489fcc3 KR |
19 | #include "gprof.h" |
20 | #include "cg_arcs.h" | |
21 | #include "core.h" | |
22 | #include "hist.h" | |
23 | #include "symtab.h" | |
3d6c6501 | 24 | |
3d6c6501 | 25 | |
5489fcc3 KR |
26 | void |
27 | find_call(parent, p_lowpc, p_highpc) | |
28 | Sym *parent; | |
29 | bfd_vma p_lowpc; | |
30 | bfd_vma p_highpc; | |
3d6c6501 | 31 | { |
5489fcc3 KR |
32 | bfd_vma dest_pc, delta; |
33 | unsigned int *instr; | |
34 | Sym *child; | |
35 | ||
36 | delta = (bfd_vma) core_text_space - core_text_sect->vma; | |
37 | ||
38 | if (core_text_space == 0) { | |
3d6c6501 | 39 | return; |
5489fcc3 KR |
40 | } /* if */ |
41 | if (p_lowpc < s_lowpc) { | |
3d6c6501 | 42 | p_lowpc = s_lowpc; |
5489fcc3 KR |
43 | } /* if */ |
44 | if (p_highpc > s_highpc) { | |
3d6c6501 | 45 | p_highpc = s_highpc; |
5489fcc3 KR |
46 | } /* if */ |
47 | DBG(CALLDEBUG, printf("[find_call] %s: 0x%lx to 0x%lx\n", | |
48 | parent->name, p_lowpc, p_highpc)); | |
49 | for (instr = (unsigned int*)(p_lowpc + delta); | |
50 | instr < (unsigned int*)(p_highpc + delta); | |
51 | ++instr) | |
52 | { | |
53 | if ((*instr & CALL)) { | |
54 | DBG(CALLDEBUG, | |
55 | printf("[find_call] 0x%lx: callf", (bfd_vma) instr - delta)); | |
56 | /* | |
57 | * Regular pc relative addressing check that this is the | |
58 | * address of a function. | |
59 | */ | |
60 | dest_pc = ((bfd_vma) (instr + (*instr & ~CALL))) - delta; | |
61 | if (dest_pc >= s_lowpc && dest_pc <= s_highpc) { | |
62 | child = sym_lookup(&symtab, dest_pc); | |
63 | DBG(CALLDEBUG, | |
64 | printf("\tdest_pc=0x%lx, (name=%s, addr=0x%lx)\n", | |
65 | dest_pc, child->name, child->addr)); | |
66 | if (child->addr == dest_pc) { | |
67 | /* a hit: */ | |
68 | arc_add(parent, child, 0); | |
69 | continue; | |
70 | } /* if */ | |
71 | } /* if */ | |
72 | /* | |
73 | * Something funny going on. | |
74 | */ | |
75 | DBG(CALLDEBUG, printf("\tbut it's a botch\n")); | |
76 | } /* if */ | |
77 | } /* for */ | |
78 | } /* find_call */ | |
79 | /*** end of sparc.c ***/ |