1*22504Sdist /* 2*22504Sdist * Copyright (c) 1980 Regents of the University of California. 3*22504Sdist * All rights reserved. The Berkeley software License Agreement 4*22504Sdist * specifies the terms and conditions for redistribution. 5*22504Sdist */ 65494Slinton 7*22504Sdist #ifndef lint 8*22504Sdist static char sccsid[] = "@(#)objaddr.c 5.1 (Berkeley) 06/06/85"; 9*22504Sdist #endif not lint 105494Slinton /* 115884Slinton * Lookup the object address of a given line from the named file. 125884Slinton * 135884Slinton * Potentially all files in the file table need to be checked 145884Slinton * until the line is found since a particular file name may appear 155884Slinton * more than once in the file table (caused by includes). 165494Slinton */ 175494Slinton 185494Slinton #include "defs.h" 195494Slinton #include "mappings.h" 205494Slinton #include "object.h" 215494Slinton #include "source.h" 225494Slinton #include "filetab.h" 235494Slinton #include "linetab.h" 245494Slinton 255494Slinton ADDRESS objaddr(line, name) 265494Slinton LINENO line; 275494Slinton char *name; 285494Slinton { 295884Slinton register FILETAB *ftp; 305884Slinton register LINENO i, j; 315884Slinton BOOLEAN foundfile; 325494Slinton 335884Slinton if (nlhdr.nlines == 0) { 345884Slinton return(-1); 355884Slinton } 365884Slinton if (name == NULL) { 375884Slinton name = cursource; 385884Slinton } 395884Slinton foundfile = FALSE; 405884Slinton for (ftp = &filetab[0]; ftp < &filetab[nlhdr.nfiles]; ftp++) { 415884Slinton if (streq(ftp->filename, name)) { 425884Slinton foundfile = TRUE; 435884Slinton i = ftp->lineindex; 445884Slinton if (ftp == &filetab[nlhdr.nfiles-1]) { 455494Slinton j = nlhdr.nlines; 465884Slinton } else { 475494Slinton j = (ftp + 1)->lineindex; 485884Slinton } 495884Slinton while (i < j) { 505494Slinton if (linetab[i].line == line) { 515884Slinton return linetab[i].addr; 525494Slinton } 535494Slinton i++; 545884Slinton } 555494Slinton } 565884Slinton } 575884Slinton if (!foundfile) { 585884Slinton error("unknown source file \"%s\"", name); 595884Slinton } 605884Slinton return(-1); 615494Slinton } 62