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