1 /*- 2 * Copyright (c) 1980 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)srcfile.c 5.2 (Berkeley) 04/16/91"; 10 #endif /* not lint */ 11 12 /* 13 * get the source file name associated with a given address 14 */ 15 16 #include "defs.h" 17 #include "mappings.h" 18 #include "object.h" 19 #include "filetab.h" 20 21 char *srcfilename(addr) 22 ADDRESS addr; 23 { 24 register ADDRESS i, j, k; 25 ADDRESS a; 26 FILETAB *ftp; 27 28 if (addr < filetab[0].addr) { 29 return(NIL); 30 } 31 i = 0; 32 j = nlhdr.nfiles - 1; 33 while (i < j) { 34 k = (i + j) / 2; 35 ftp = &filetab[k]; 36 if ((a = ftp->addr) == addr) { 37 return(ftp->filename); 38 } else if (addr > a) { 39 i = k + 1; 40 } else { 41 j = k - 1; 42 } 43 } 44 if (addr >= filetab[i].addr) { 45 return(filetab[i].filename); 46 } else { 47 return(filetab[i-1].filename); 48 } 49 /*NOTREACHED*/ 50 } 51