2 * Copyright (c) 1983 Regents of the University of California.
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.
21 static char sccsid
[] = "@(#)tahoe.c 1.5 (Berkeley) 6/1/90";
27 * a namelist entry to be the child of indirect callf
29 nltype indirectchild
= {
30 "(*)" , /* the name */
31 (unsigned long) 0 , /* the pc entry point */
32 (unsigned long) 0 , /* entry point aligned to histogram */
33 (double) 0.0 , /* ticks in this routine */
34 (double) 0.0 , /* cumulative ticks in children */
35 (long) 0 , /* how many times called */
36 (long) 0 , /* how many calls to self */
37 (double) 1.0 , /* propagation fraction */
38 (double) 0.0 , /* self propagation time */
39 (double) 0.0 , /* child propagation time */
40 (bool) 0 , /* print flag */
41 (int) 0 , /* index in the graph list */
42 (int) 0 , /* graph call chain top-sort order */
43 (int) 0 , /* internal number of cycle on */
44 (struct nl
*) &indirectchild
, /* pointer to head of cycle */
45 (struct nl
*) 0 , /* pointer to next member of cycle */
46 (arctype
*) 0 , /* list of caller arcs */
47 (arctype
*) 0 /* list of callee arcs */
54 long usesreg
= ((long)*modep
) & 0xf;
56 switch ( ((long)*modep
) >> 4 ) {
71 return ( usesreg
!= 0xe ? autoinc
: immediate
);
73 return ( usesreg
!= PC
? autoincdef
: absolute
);
75 return ( usesreg
!= PC
? bytedisp
: byterel
);
77 return ( usesreg
!= PC
? bytedispdef
: bytereldef
);
79 return ( usesreg
!= PC
? worddisp
: wordrel
);
81 return ( usesreg
!= PC
? worddispdef
: wordreldef
);
83 return ( usesreg
!= PC
? longdisp
: longrel
);
85 return ( usesreg
!= PC
? longdispdef
: longreldef
);
103 return "register deferred";
105 return "autodecrement";
107 return "autoincrement";
109 return "autoincrement deferred";
111 return "byte displacement";
113 return "byte displacement deferred";
115 return "byte relative";
117 return "byte relative deferred";
119 return "word displacement";
121 return "word displacement deferred";
123 return "word relative";
125 return "word relative deferred";
131 return "long displacement";
133 return "long displacement deferred";
135 return "long relative";
137 return "long relative deferred";
143 operandlength( modep
)
144 unsigned char *modep
;
147 switch ( operandmode( modep
) ) {
173 return 1+operandlength( modep
+ 1 );
182 operandenum mode
= operandmode( modep
);
190 cp
+= 1; /* skip over the mode */
193 fprintf( stderr
, "[reladdr] not relative address\n" );
194 return (unsigned long) modep
;
196 return (unsigned long) ( cp
+ sizeof *cp
+ *cp
);
198 for (i
= 0; i
< sizeof *sp
; i
++)
199 value
= (value
<< 8) + (cp
[i
] & 0xff);
200 return (unsigned long) ( cp
+ sizeof *sp
+ value
);
202 for (i
= 0; i
< sizeof *lp
; i
++)
203 value
= (value
<< 8) + (cp
[i
] & 0xff);
204 return (unsigned long) ( cp
+ sizeof *lp
+ value
);
208 findcall( parentp
, p_lowpc
, p_highpc
)
210 unsigned long p_lowpc
;
211 unsigned long p_highpc
;
213 unsigned char *instructp
;
217 operandenum firstmode
;
218 unsigned long destpc
;
220 if ( textspace
== 0 ) {
223 if ( p_lowpc
< s_lowpc
) {
226 if ( p_highpc
> s_highpc
) {
230 if ( debug
& CALLDEBUG
) {
231 printf( "[findcall] %s: 0x%x to 0x%x\n" ,
232 parentp
-> name
, p_lowpc
, p_highpc
);
235 for ( instructp
= textspace
+ p_lowpc
;
236 instructp
< textspace
+ p_highpc
;
237 instructp
+= length
) {
239 if ( *instructp
== CALLF
) {
241 * maybe a callf, better check it out.
242 * skip the count of the number of arguments.
245 if ( debug
& CALLDEBUG
) {
246 printf( "[findcall]\t0x%x:callf" , instructp
- textspace
);
249 firstmode
= operandmode( instructp
+length
);
250 switch ( firstmode
) {
257 length
+= operandlength( instructp
+length
);
258 mode
= operandmode( instructp
+ length
);
260 if ( debug
& CALLDEBUG
) {
261 printf( "\tfirst operand is %s", operandname( firstmode
) );
262 printf( "\tsecond operand is %s\n" , operandname( mode
) );
274 * indirect call: call through pointer
275 * either *d(r) as a parameter or local
276 * (r) as a return value
277 * *f as a global pointer
278 * [are there others that we miss?,
279 * e.g. arrays of pointers to functions???]
281 addarc( parentp
, &indirectchild
, (long) 0 );
282 length
+= operandlength( instructp
+ length
);
288 * regular pc relative addressing
289 * check that this is the address of
292 destpc
= reladdr( instructp
+length
)
293 - (unsigned long) textspace
;
294 if ( destpc
>= s_lowpc
&& destpc
<= s_highpc
) {
295 childp
= nllookup( destpc
);
297 if ( debug
& CALLDEBUG
) {
298 printf( "[findcall]\tdestpc 0x%x" , destpc
);
299 printf( " childp->name %s" , childp
-> name
);
300 printf( " childp->value 0x%x\n" ,
304 if ( childp
-> value
== destpc
) {
308 addarc( parentp
, childp
, (long) 0 );
309 length
+= operandlength( instructp
+ length
);
316 * it looked like a callf,
317 * but it wasn't to anywhere.
323 * something funny going on.
326 if ( debug
& CALLDEBUG
) {
327 printf( "[findcall]\tbut it's a botch\n" );
This page took 0.041088 seconds and 4 git commands to generate.