148099Sbostic /*- 2*62138Sbostic * Copyright (c) 1980, 1993 3*62138Sbostic * The Regents of the University of California. All rights reserved. 448099Sbostic * 548099Sbostic * %sccs.include.redist.c% 622504Sdist */ 75494Slinton 822504Sdist #ifndef lint 9*62138Sbostic static char sccsid[] = "@(#)objaddr.c 8.1 (Berkeley) 06/06/93"; 1048099Sbostic #endif /* not lint */ 1148099Sbostic 125494Slinton /* 135884Slinton * Lookup the object address of a given line from the named file. 145884Slinton * 155884Slinton * Potentially all files in the file table need to be checked 165884Slinton * until the line is found since a particular file name may appear 175884Slinton * more than once in the file table (caused by includes). 185494Slinton */ 195494Slinton 205494Slinton #include "defs.h" 215494Slinton #include "mappings.h" 225494Slinton #include "object.h" 235494Slinton #include "source.h" 245494Slinton #include "filetab.h" 255494Slinton #include "linetab.h" 265494Slinton objaddr(line,name)275494SlintonADDRESS objaddr(line, name) 285494Slinton LINENO line; 295494Slinton char *name; 305494Slinton { 315884Slinton register FILETAB *ftp; 325884Slinton register LINENO i, j; 335884Slinton BOOLEAN foundfile; 345494Slinton 355884Slinton if (nlhdr.nlines == 0) { 365884Slinton return(-1); 375884Slinton } 385884Slinton if (name == NULL) { 395884Slinton name = cursource; 405884Slinton } 415884Slinton foundfile = FALSE; 425884Slinton for (ftp = &filetab[0]; ftp < &filetab[nlhdr.nfiles]; ftp++) { 435884Slinton if (streq(ftp->filename, name)) { 445884Slinton foundfile = TRUE; 455884Slinton i = ftp->lineindex; 465884Slinton if (ftp == &filetab[nlhdr.nfiles-1]) { 475494Slinton j = nlhdr.nlines; 485884Slinton } else { 495494Slinton j = (ftp + 1)->lineindex; 505884Slinton } 515884Slinton while (i < j) { 525494Slinton if (linetab[i].line == line) { 535884Slinton return linetab[i].addr; 545494Slinton } 555494Slinton i++; 565884Slinton } 575494Slinton } 585884Slinton } 595884Slinton if (!foundfile) { 605884Slinton error("unknown source file \"%s\"", name); 615884Slinton } 625884Slinton return(-1); 635494Slinton } 64