BSD 4_4 release
[unix-history] / usr / src / old / dbx / mappings.c
index 9e05570..fefc5ee 100644 (file)
@@ -1,14 +1,39 @@
 /*
 /*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * Copyright (c) 1983 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)mappings.c 5.1 (Berkeley) %G%";
-#endif not lint
-
-static char rcsid[] = "$Header: mappings.c,v 1.4 84/12/26 10:40:25 linton Exp $";
+static char sccsid[] = "@(#)mappings.c 5.5 (Berkeley) 6/1/90";
+#endif /* not lint */
 
 /*
  * Source-to-object and vice versa mappings.
 
 /*
  * Source-to-object and vice versa mappings.
@@ -146,16 +171,28 @@ Boolean exact;
  * If it isn't, then we walk forward until the first suitable line is found.
  */
 
  * If it isn't, then we walk forward until the first suitable line is found.
  */
 
-public Lineno srcline(addr)
+public Lineno srcline (addr)
 Address addr;
 {
 Address addr;
 {
-    integer i;
-    Lineno r;
+    Lineno i, r;
     Symbol f1, f2;
     Symbol f1, f2;
+    Address a;
 
     i = findline(addr, false);
     if (i == -1) {
 
     i = findline(addr, false);
     if (i == -1) {
-       r = 0;
+       f1 = whatblock(addr);
+       if (f1 == nil or nosource(f1)) {
+           r = 0;
+       } else {
+           a = codeloc(f1);
+           for (;;) {
+               r = linelookup(a);
+               if (r != 0 or a >= CODESTART + objsize) {
+                   break;
+               }
+               ++a;
+           }
+       }
     } else {
        r = linetab[i].line;
        if (linetab[i].addr != addr) {
     } else {
        r = linetab[i].line;
        if (linetab[i].addr != addr) {