OSDN Git Service

* t-sh (MULTILIB_EXCEPTIONS): Set to ml.
[pf3gnuchains/gcc-fork.git] / gcc / vmsdbgout.c
index b86719d..68e0bb8 100644 (file)
@@ -1,6 +1,6 @@
 /* Output VMS debug format symbol table information from the GNU C compiler.
    Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Douglas B. Rupp (rupp@gnat.com).
 
 This file is part of GNU CC.
@@ -72,16 +72,13 @@ dst_file_info_entry;
 #define ASM_COMMENT_START ";#"
 #endif
 
-/* Maximum size (in bytes) of an artificially generated label.   */
+/* Maximum size (in bytes) of an artificially generated label.  */
 #define MAX_ARTIFICIAL_LABEL_BYTES     30
 
 /* Make sure we know the sizes of the various types debug can describe. These
    are only defaults.  If the sizes are different for your target, you should
    override these values by defining the appropriate symbols in your tm.h
    file.  */
-#ifndef CHAR_TYPE_SIZE
-#define CHAR_TYPE_SIZE BITS_PER_UNIT
-#endif
 #ifndef PTR_SIZE
 #define PTR_SIZE 4 /* Must be 32 bits for VMS debug info */
 #endif
@@ -126,13 +123,6 @@ static unsigned int line_info_table_in_use;
 /* Size (in elements) of increments by which we may expand line_info_table.  */
 #define LINE_INFO_TABLE_INCREMENT 1024
 
-/* The number of the current function definition for which debugging
-   information is being generated.  These numbers range from 1 up to the
-   maximum number of function definitions contained within the current
-   compilation unit.  These numbers are used to create unique label id's unique
-   to each function definition.  */
-static unsigned int current_funcdef_number = 0;
-
 /* Forward declarations for functions defined in this file.  */
 static char *full_name                 PARAMS ((const char *));
 static unsigned int lookup_filename PARAMS ((const char *));
@@ -173,7 +163,7 @@ static void vmsdbgout_abstract_function PARAMS ((tree));
 
 /* The debug hooks structure.  */
 
-struct gcc_debug_hooks vmsdbg_debug_hooks
+const struct gcc_debug_hooks vmsdbg_debug_hooks
 = {vmsdbgout_init,
    vmsdbgout_finish,
    vmsdbgout_define,
@@ -277,37 +267,49 @@ static char text_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
 #endif
 
 #ifndef ASM_OUTPUT_DEBUG_DELTA2
-#define ASM_OUTPUT_DEBUG_DELTA2(FILE,LABEL1,LABEL2)                    \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP);             \
-       assemble_name (FILE, LABEL1);                                   \
-       fprintf (FILE, "-");                                            \
-       assemble_name (FILE, LABEL2);                                   \
-  } while (0)
+#define ASM_OUTPUT_DEBUG_DELTA2(FILE,LABEL1,LABEL2)                     \
+  do                                                                    \
+    {                                                                   \
+      fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP);               \
+      assemble_name (FILE, LABEL1);                                     \
+      fprintf (FILE, "-");                                              \
+      assemble_name (FILE, LABEL2);                                     \
+    }                                                                   \
+  while (0)
 #endif
 
 #ifndef ASM_OUTPUT_DEBUG_DELTA4
-#define ASM_OUTPUT_DEBUG_DELTA4(FILE,LABEL1,LABEL2)                    \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP);               \
-       assemble_name (FILE, LABEL1);                                   \
-       fprintf (FILE, "-");                                            \
-       assemble_name (FILE, LABEL2);                                   \
-  } while (0)
+#define ASM_OUTPUT_DEBUG_DELTA4(FILE,LABEL1,LABEL2)                     \
+  do                                                                    \
+    {                                                                   \
+      fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP);                         \
+      assemble_name (FILE, LABEL1);                                     \
+      fprintf (FILE, "-");                                              \
+      assemble_name (FILE, LABEL2);                                     \
+    }                                                                   \
+  while (0)
 #endif
 
 #ifndef ASM_OUTPUT_DEBUG_ADDR_DELTA
-#define ASM_OUTPUT_DEBUG_ADDR_DELTA(FILE,LABEL1,LABEL2)                        \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_PTR_ASM_OP);               \
-       assemble_name (FILE, LABEL1);                                   \
-       fprintf (FILE, "-");                                            \
-       assemble_name (FILE, LABEL2);                                   \
-  } while (0)
+#define ASM_OUTPUT_DEBUG_ADDR_DELTA(FILE,LABEL1,LABEL2)                         \
+  do                                                                    \
+    {                                                                   \
+      fprintf ((FILE), "\t%s\t", UNALIGNED_PTR_ASM_OP);                         \
+      assemble_name (FILE, LABEL1);                                     \
+      fprintf (FILE, "-");                                              \
+      assemble_name (FILE, LABEL2);                                     \
+    }                                                                   \
+  while (0)
 #endif
 
 #ifndef ASM_OUTPUT_DEBUG_ADDR
-#define ASM_OUTPUT_DEBUG_ADDR(FILE,LABEL)                              \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_PTR_ASM_OP);               \
-       assemble_name (FILE, LABEL);                                    \
-  } while (0)
+#define ASM_OUTPUT_DEBUG_ADDR(FILE,LABEL)                               \
+  do                                                                    \
+    {                                                                   \
+      fprintf ((FILE), "\t%s\t", UNALIGNED_PTR_ASM_OP);                         \
+      assemble_name (FILE, LABEL);                                      \
+    }                                                                   \
+  while (0)
 #endif
 
 #ifndef ASM_OUTPUT_DEBUG_ADDR_CONST
@@ -352,24 +354,25 @@ static char text_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
    newline is produced.  When flag_verbose_asm is asserted, we add commnetary
    at the end of the line, so we must avoid output of a newline here.  */
 #ifndef ASM_OUTPUT_DEBUG_STRING
-#define ASM_OUTPUT_DEBUG_STRING(FILE,P)        \
-  do {                                 \
-    register int slen = strlen(P);      \
-    register char *p = (P);            \
-    register int i;                    \
-    fprintf (FILE, "\t.ascii \"");     \
-    for (i = 0; i < slen; i++)         \
-      {                                        \
-         register int c = p[i];        \
-         if (c == '\"' || c == '\\')   \
-           putc ('\\', FILE);          \
-         if (c >= ' ' && c < 0177)     \
-           putc (c, FILE);             \
-         else                          \
-           fprintf (FILE, "\\%o", c);  \
-      }                                        \
-    fprintf (FILE, "\"");              \
-  }                                    \
+#define ASM_OUTPUT_DEBUG_STRING(FILE,P)                \
+  do                                           \
+    {                                          \
+      register int slen = strlen(P);           \
+      register char *p = (P);                  \
+      register int i;                          \
+      fprintf (FILE, "\t.ascii \"");           \
+      for (i = 0; i < slen; i++)               \
+       {                                       \
+         register int c = p[i];                \
+         if (c == '\"' || c == '\\')           \
+           putc ('\\', FILE);                  \
+         if (c >= ' ' && c < 0177)             \
+           putc (c, FILE);                     \
+         else                                  \
+           fprintf (FILE, "\\%o", c);          \
+       }                                       \
+      fprintf (FILE, "\"");                    \
+    }                                          \
   while (0)
 #endif
 
@@ -377,13 +380,14 @@ static char text_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
    macro has the same effect as ASM_OUTPUT_LABELREF, but copies to
    a string rather than writing to a file.  */
 #ifndef ASM_NAME_TO_STRING
-#define ASM_NAME_TO_STRING(STR, NAME) \
-  do {                                                                       \
-      if ((NAME)[0] == '*')                                                  \
-       strcpy (STR, NAME+1);                                                 \
-      else                                                                   \
-       strcpy (STR, NAME);                                                   \
-  }                                                                           \
+#define ASM_NAME_TO_STRING(STR, NAME)          \
+  do                                           \
+    {                                          \
+      if ((NAME)[0] == '*')                    \
+       strcpy (STR, NAME+1);                   \
+      else                                     \
+       strcpy (STR, NAME);                     \
+    }                                          \
   while (0)
 #endif
 
@@ -438,7 +442,7 @@ restart:
       break;
 
     case CONST:
-      /* This used to output parentheses around the expression, but that does 
+      /* This used to output parentheses around the expression, but that does
          not work on the 386 (either ATT or BSD assembler).  */
       addr_const_to_string (buf1, XEXP (x, 0));
       strcat (str, buf1);
@@ -633,7 +637,7 @@ write_debug_data4 (data4, comment, dosizeonly)
        fprintf (asm_out_file, "\t%s %s", ASM_COMMENT_START, comment);
       fputc ('\n', asm_out_file);
     }
-  
+
   return 4;
 }
 
@@ -696,7 +700,7 @@ write_debug_string (string, comment, dosizeonly)
        fprintf (asm_out_file, "\t%s %s", ASM_COMMENT_START, comment);
       fputc ('\n', asm_out_file);
     }
-  
+
   return strlen (string);
 }
 
@@ -818,7 +822,7 @@ write_rtnbeg (rtnnum, dosizeonly)
       /* header size - 1st byte + flag byte + STO_LW size
         + string count byte + string length */
       header.dst__header_length.dst_w_length
-        = DST_K_DST_HEADER_SIZE - 1 + 1 + 4 + 1 + strlen (go);
+       = DST_K_DST_HEADER_SIZE - 1 + 1 + 4 + 1 + strlen (go);
       header.dst__header_type.dst_w_type = 0x17;
 
       totsize += write_debug_header (&header, "transfer", dosizeonly);
@@ -1122,7 +1126,7 @@ write_srccorr (fileid, file_info_entry, dosizeonly)
     = DST_K_SOURCE;
 
   src_cmdtrlr.dst_b_src_df_libmodname = 0;
-  
+
   totsize += write_debug_header (&src_header.dst_a_source_corr_header,
                                 "source corr", dosizeonly);
   totsize += write_debug_data1 (src_command.dst_b_src_command,
@@ -1142,7 +1146,7 @@ write_srccorr (fileid, file_info_entry, dosizeonly)
   totsize += write_debug_data8
     (src_command.dst_a_src_cmd_fields.dst_a_src_decl_src.dst_q_src_df_rms_cdt,
      "source_corr (creation date)", dosizeonly);
-  
+
   totsize += write_debug_data4
     (src_command.dst_a_src_cmd_fields.dst_a_src_decl_src.dst_l_src_df_rms_ebk,
      "source_corr (EOF block number)", dosizeonly);
@@ -1262,7 +1266,7 @@ write_srccorrs (dosizeonly)
     totsize += write_srccorr (i, file_info_table[i], dosizeonly);
 
   return totsize;
-}     
+}
 \f
 /* Output a marker (i.e. a label) for the beginning of a function, before
    the prologue.  */
@@ -1279,9 +1283,8 @@ vmsdbgout_begin_prologue (line, file)
 
   if (debug_info_level > DINFO_LEVEL_NONE)
     {
-      current_funcdef_number++;
       ASM_GENERATE_INTERNAL_LABEL (label, FUNC_BEGIN_LABEL,
-                                  current_funcdef_number);
+                                  current_function_funcdef_no);
       ASM_OUTPUT_LABEL (asm_out_file, label);
     }
 }
@@ -1297,7 +1300,7 @@ vmsdbgout_after_prologue ()
   if (debug_info_level > DINFO_LEVEL_TERSE)
     {
       ASM_GENERATE_INTERNAL_LABEL (label, FUNC_PROLOG_LABEL,
-                                  current_funcdef_number);
+                                  current_function_funcdef_no);
       ASM_OUTPUT_LABEL (asm_out_file, label);
     }
 }
@@ -1317,9 +1320,9 @@ vmsdbgout_end_epilogue ()
   if (debug_info_level > DINFO_LEVEL_NONE)
     {
       /* Output a label to mark the endpoint of the code generated for this
-         function.        */
+         function.  */
       ASM_GENERATE_INTERNAL_LABEL (label, FUNC_END_LABEL,
-                                  current_funcdef_number);
+                                  current_function_funcdef_no);
       ASM_OUTPUT_LABEL (asm_out_file, label);
     }
 }
@@ -1444,15 +1447,26 @@ lookup_filename (file_name)
 
   if (stat (file_name, &statbuf) == 0)
     {
-      cdt = 10000000 * (statbuf.st_ctime + vms_epoch_offset);
-      ebk = statbuf.st_size / 512 + 1;
-      ffb = statbuf.st_size - ((statbuf.st_size / 512) * 512);
+      long gmtoff;
 #ifdef VMS
+      struct tm *ts;
+
+      /* Adjust for GMT */
+      ts = (struct tm *) localtime (&statbuf.st_ctime);
+      gmtoff = ts->tm_gmtoff;
+
+      /* VMS has multiple file format types */
       rfo = statbuf.st_fab_rfm;
 #else
+      /* Is GMT adjustment an issue with a cross-compiler? */
+      gmtoff = 0;
+
       /* Assume stream LF type file */
       rfo = 2;
 #endif
+      cdt = 10000000 * (statbuf.st_ctime + gmtoff + vms_epoch_offset);
+      ebk = statbuf.st_size / 512 + 1;
+      ffb = statbuf.st_size - ((statbuf.st_size / 512) * 512);
       fnam = full_name (file_name);
       flen = strlen (fnam);
     }
@@ -1486,7 +1500,7 @@ lookup_filename (file_name)
        }
     }
 
-  /* Prepare to add a new table entry by making sure there is enough space in 
+  /* Prepare to add a new table entry by making sure there is enough space in
      the table to do so.  If not, expand the current table.  */
   if (file_info_table_in_use == file_info_table_allocated)
     {
@@ -1538,7 +1552,7 @@ vmsdbgout_source_line (line, filename)
            = (dst_line_info_ref) xrealloc (line_info_table,
                                            (line_info_table_allocated
                                             * sizeof (dst_line_info_entry)));
-         }
+       }
 
       /* Add the new entry at the end of the line_info_table.  */
       line_info = &line_info_table[line_info_table_in_use++];
@@ -1625,7 +1639,7 @@ vmsdbgout_init (main_input_filename)
 
   module_producer
     = (char *) xmalloc (strlen (language_string) + 1
-                       + strlen (version_string + 1));
+                       + strlen (version_string) + 1);
   sprintf (module_producer, "%s %s", language_string, version_string);
 
   ASM_GENERATE_INTERNAL_LABEL (text_end_label, TEXT_END_LABEL, 0);