Changeset 609 for branches/GNU/src/binutils/gprof/vax.c
- Timestamp:
- Aug 16, 2003, 6:59:22 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/binutils/gprof/vax.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r608 r609 1 1 /* 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. 4 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. 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. 18 28 */ 19 29 #include "gprof.h" 30 #include "search_list.h" 31 #include "source.h" 32 #include "symtab.h" 20 33 #include "cg_arcs.h" 21 34 #include "corefile.h" 22 35 #include "hist.h" 23 #include "symtab.h"24 36 25 37 /* … … 42 54 typedef enum opermodes operandenum; 43 55 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. */ 44 59 struct modebyte 45 60 { … … 47 62 unsigned int modefield:4; 48 63 }; 64 #endif 49 65 50 66 /* 51 67 * A symbol to be the child of indirect calls: 52 68 */ 53 Sym indirectchild; 54 69 static Sym indirectchild; 70 71 static operandenum vax_operandmode PARAMS ((unsigned char *)); 72 static char *vax_operandname PARAMS ((operandenum)); 73 static long vax_operandlength PARAMS ((unsigned char *)); 74 static bfd_signed_vma vax_offset PARAMS ((unsigned char *)); 75 void vax_find_call PARAMS ((Sym *, bfd_vma, bfd_vma)); 55 76 56 77 static operandenum 57 78 vax_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) 63 84 { 64 85 case 0: … … 152 173 static long 153 174 vax_operandlength (modep) 154 struct modebyte*modep;175 unsigned char *modep; 155 176 { 156 177 … … 182 203 return 5; 183 204 case indexed: 184 return 1 + vax_operandlength ( (struct modebyte *) ((char *) modep)+ 1);205 return 1 + vax_operandlength (modep + 1); 185 206 } 186 207 /* NOTREACHED */ … … 188 209 } 189 210 190 static bfd_ vma191 vax_ reladdr(modep)192 struct modebyte*modep;211 static bfd_signed_vma 212 vax_offset (modep) 213 unsigned char *modep; 193 214 { 194 215 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 */ 201 218 switch (mode) 202 219 { 203 220 default: 204 221 fprintf (stderr, "[reladdr] not relative address\n"); 205 return (bfd_vma) modep;222 return 0; 206 223 case byterel: 207 return (bfd_vma) (cp + sizeof *cp + *cp);224 return 1 + bfd_get_signed_8 (core_bfd, modep); 208 225 case wordrel: 209 sp = (short *) cp; 210 return (bfd_vma) (cp + sizeof *sp + *sp); 226 return 2 + bfd_get_signed_16 (core_bfd, modep); 211 227 case longrel: 212 lp = (long *) cp; 213 return (bfd_vma) (cp + sizeof *lp + *lp); 228 return 4 + bfd_get_signed_32 (core_bfd, modep); 214 229 } 215 230 } … … 227 242 operandenum mode; 228 243 operandenum firstmode; 229 bfd_vma destpc;230 static b oolinited = FALSE;244 bfd_vma pc, destpc; 245 static bfd_boolean inited = FALSE; 231 246 232 247 if (!inited) … … 253 268 parent->name, (unsigned long) p_lowpc, 254 269 (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) 258 271 { 259 272 length = 1; 260 if (*instructp == CALLS) 273 instructp = ((unsigned char *) core_text_space 274 + pc - core_text_sect->vma); 275 if ((*instructp & 0xff) == CALLS) 261 276 { 262 277 /* … … 265 280 */ 266 281 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); 271 284 switch (firstmode) 272 285 { … … 277 290 goto botched; 278 291 } 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); 281 294 DBG (CALLDEBUG, 282 295 printf ("\tfirst operand is %s", vax_operandname (firstmode)); … … 300 313 */ 301 314 arc_add (parent, &indirectchild, (unsigned long) 0); 302 length += vax_operandlength ( 303 (struct modebyte *) (instructp + length)); 315 length += vax_operandlength (instructp + length); 304 316 continue; 305 317 case byterel: … … 311 323 * a function. 312 324 */ 313 destpc = vax_reladdr ((struct modebyte *) (instructp + length)) 314 - (bfd_vma) core_text_space; 325 destpc = pc + vax_offset (instructp + length); 315 326 if (destpc >= s_lowpc && destpc <= s_highpc) 316 327 { … … 329 340 */ 330 341 arc_add (parent, child, (unsigned long) 0); 331 length += vax_operandlength ((struct modebyte *) 332 (instructp + length)); 342 length += vax_operandlength (instructp + length); 333 343 continue; 334 344 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.