Fix problems with stab order and include files.
authorDonn Seeley <donn@ucbvax.Berkeley.EDU>
Sat, 16 Mar 1991 07:50:12 +0000 (23:50 -0800)
committerDonn Seeley <donn@ucbvax.Berkeley.EDU>
Sat, 16 Mar 1991 07:50:12 +0000 (23:50 -0800)
SCCS-vsn: contrib/gas-1.38/input-scrub.c 6.3
SCCS-vsn: contrib/gas-1.38/read.c 6.3

usr/src/contrib/gas-1.38/input-scrub.c
usr/src/contrib/gas-1.38/read.c

index 7391baa..abd35a1 100644 (file)
@@ -1,4 +1,4 @@
-/*     @(#)input-scrub.c       6.2 (Berkeley) %G%
+/*     @(#)input-scrub.c       6.3 (Berkeley) %G%
 
 Modified for Berkeley Unix by Donn Seeley, donn@okeeffe.berkeley.edu  */
 
 
 Modified for Berkeley Unix by Donn Seeley, donn@okeeffe.berkeley.edu  */
 
@@ -305,27 +305,24 @@ as_where()
 }
 \f
 /*
 }
 \f
 /*
- * linestab() -- generate a line number stab for the current source line.
- * If the filename has changed, generate a file stab first.
+ * Support for source file debugging.  These functions handle
+ * logical lines and logical files.
  */
  */
+static char *saved_file;
+static int saved_len;
+static line_numberT saved_line;
+
 void
 void
-linestab()
+filestab()
 {
 {
-  static char *saved_file;
-  static int saved_len;
-  static line_numberT saved_line;
   char *file;
   char *file;
-  line_numberT line;
   int len;
 
   int len;
 
-  if (!flagseen['g'] ||
-      !physical_input_file ||
-      !input_file_is_open() ||
-      now_seg != SEG_TEXT)
+  if (!physical_input_file ||
+      !input_file_is_open())
     return;
 
   file = logical_input_file ? logical_input_file : physical_input_file;
     return;
 
   file = logical_input_file ? logical_input_file : physical_input_file;
-  line = logical_input_line ? logical_input_line : physical_input_line;
 
   if (saved_file == 0 || strcmp(file, saved_file) != 0)
     {
 
   if (saved_file == 0 || strcmp(file, saved_file) != 0)
     {
@@ -344,6 +341,30 @@ linestab()
        strcpy(saved_file, file);
       saved_line = 0;
     }
        strcpy(saved_file, file);
       saved_line = 0;
     }
+}
+
+void
+funcstab(func)
+     char *func;
+{
+  if (now_seg != SEG_TEXT)
+    return;
+
+  filestab();
+  stabf(func);
+}
+
+void
+linestab()
+{
+  line_numberT line;
+
+  if (now_seg != SEG_TEXT)
+    return;
+
+  filestab();
+
+  line = logical_input_line ? logical_input_line : physical_input_line;
 
   if (saved_line == 0 || line != saved_line)
     {
 
   if (saved_line == 0 || line != saved_line)
     {
index 12b33cb..937dbb3 100644 (file)
@@ -1,4 +1,4 @@
-/*     @(#)read.c      6.2 (Berkeley) %G%
+/*     @(#)read.c      6.3 (Berkeley) %G%
 
 Modified for Berkeley Unix by Donn Seeley, donn@okeeffe.berkeley.edu  */
 
 
 Modified for Berkeley Unix by Donn Seeley, donn@okeeffe.berkeley.edu  */
 
@@ -331,9 +331,10 @@ read_a_source_file (buffer)
               */
              if ( c == ':' )
                {
               */
              if ( c == ':' )
                {
-                 colon(s);     /* user-defined label */
                  if (flagseen['g'])
                  if (flagseen['g'])
-                   stabf(s);   /* set line number for function definition */
+                   /* set line number for function definition */
+                   funcstab(s);
+                 colon(s);     /* user-defined label */
                  * input_line_pointer ++ = ':'; /* Put ':' back for error messages' sake. */
                                /* Input_line_pointer -> after ':'. */
                  SKIP_WHITESPACE();
                  * input_line_pointer ++ = ':'; /* Put ':' back for error messages' sake. */
                                /* Input_line_pointer -> after ':'. */
                  SKIP_WHITESPACE();
@@ -1386,14 +1387,13 @@ pseudo_set (symbolP)
  * stabs(file), stabf(func) and stabd(line) -- for the purpose of
  * source file debugging of assembly files, generate file,
  * function and line number stabs, respectively.
  * stabs(file), stabf(func) and stabd(line) -- for the purpose of
  * source file debugging of assembly files, generate file,
  * function and line number stabs, respectively.
- * stabs() and stabd() are normally called through a function linestab()
- * in input-scrub.c which understands about logical line numbers.
+ * These functions have corresponding functions named
+ * filestab(), funcstab() and linestab() in input-scrub.c,
+ * where logical files and logical line numbers are handled.
  */
 
 #include <stab.h>
 
  */
 
 #include <stab.h>
 
-static int stabs_done;
-
 stabs(file)
      char *file;
 {
 stabs(file)
      char *file;
 {
@@ -1404,7 +1404,6 @@ stabs(file)
                    0,
                    obstack_next_free(& frags) - frag_now->fr_literal,
                    frag_now);
                    0,
                    obstack_next_free(& frags) - frag_now->fr_literal,
                    frag_now);
-  stabs_done = 1;
 }
 
 stabf(func)
 }
 
 stabf(func)
@@ -1414,13 +1413,9 @@ stabf(func)
   static int void_undefined = 1;
 
   /* crudely filter uninteresting labels: require an initial '_' */
   static int void_undefined = 1;
 
   /* crudely filter uninteresting labels: require an initial '_' */
-  if (now_seg != SEG_TEXT || *func++ != '_')
+  if (*func++ != '_')
     return;
 
     return;
 
-  /* don't emit a function stab until a file stab has been seen */
-  if (!stabs_done)
-    linestab();
-
   /* assembly functions are assumed to have void type */
   if (void_undefined)
     {
   /* assembly functions are assumed to have void type */
   if (void_undefined)
     {