1*48099Sbostic /*- 2*48099Sbostic * Copyright (c) 1980 The Regents of the University of California. 3*48099Sbostic * All rights reserved. 4*48099Sbostic * 5*48099Sbostic * %sccs.include.redist.c% 622505Sdist */ 75495Slinton 822505Sdist #ifndef lint 9*48099Sbostic static char sccsid[] = "@(#)srcfile.c 5.2 (Berkeley) 04/16/91"; 10*48099Sbostic #endif /* not lint */ 115495Slinton 125495Slinton /* 135495Slinton * get the source file name associated with a given address 145495Slinton */ 155495Slinton 165495Slinton #include "defs.h" 175495Slinton #include "mappings.h" 185495Slinton #include "object.h" 195495Slinton #include "filetab.h" 205495Slinton 215495Slinton char *srcfilename(addr) 225495Slinton ADDRESS addr; 235495Slinton { 245495Slinton register ADDRESS i, j, k; 255495Slinton ADDRESS a; 265495Slinton FILETAB *ftp; 275495Slinton 285495Slinton if (addr < filetab[0].addr) { 295495Slinton return(NIL); 305495Slinton } 315495Slinton i = 0; 325495Slinton j = nlhdr.nfiles - 1; 335495Slinton while (i < j) { 345495Slinton k = (i + j) / 2; 355495Slinton ftp = &filetab[k]; 365495Slinton if ((a = ftp->addr) == addr) { 375495Slinton return(ftp->filename); 385495Slinton } else if (addr > a) { 395495Slinton i = k + 1; 405495Slinton } else { 415495Slinton j = k - 1; 425495Slinton } 435495Slinton } 445495Slinton if (addr >= filetab[i].addr) { 455495Slinton return(filetab[i].filename); 465495Slinton } else { 475495Slinton return(filetab[i-1].filename); 485495Slinton } 495495Slinton /*NOTREACHED*/ 505495Slinton } 51