keep Windows GDB, believe it or not
[deliverable/binutils-gdb.git] / gdb / dwarfread.c
index dec5a3f99de99834d3498d8cf4e050d10f47dd90..ec6182d367db07b1d81272a1f121a25e33504578 100644 (file)
@@ -1,5 +1,5 @@
 /* DWARF debugging format support for GDB.
-   Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+   Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
    Written by Fred Fish at Cygnus Support.  Portions based on dbxread.c,
    mipsread.c, coffread.c, and dwarfread.c from a Data General SVR4 gdb port.
 
@@ -39,13 +39,10 @@ other things to work on, if you get bored. :-)
 */
 
 #include "defs.h"
-#include "bfd.h"
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "symfile.h"
 #include "objfiles.h"
-#include <time.h> /* For time_t in libbfd.h.  */
-#include "libbfd.h"    /* FIXME Secret Internal BFD stuff (bfd_read) */
 #include "elf/dwarf.h"
 #include "buildsym.h"
 #include "demangle.h"
@@ -55,7 +52,6 @@ other things to work on, if you get bored. :-)
 
 #include <fcntl.h>
 #include <string.h>
-#include <sys/types.h>
 
 #ifndef        NO_SYS_FILE
 #include <sys/file.h>
@@ -196,6 +192,11 @@ typedef unsigned int DIE_REF;      /* Reference to a DIE */
 #define CHILL_PRODUCER "GNU Chill "
 #endif
 
+/* Provide a default mapping from a DWARF register number to a gdb REGNUM.  */
+#ifndef DWARF_REG_TO_REGNUM
+#define DWARF_REG_TO_REGNUM(num) (num)
+#endif
+
 /* Flags to target_to_host() that tell whether or not the data object is
    expected to be signed.  Used, for example, when fetching a signed
    integer in the target environment which is used as a signed integer
@@ -989,9 +990,7 @@ struct_type (dip, thisdie, enddie, objfile)
   int n;
   struct dieinfo mbr;
   char *nextdie;
-#if !BITS_BIG_ENDIAN
   int anonymous_size;
-#endif
   
   if ((type = lookup_utype (dip -> die_ref)) == NULL)
     {
@@ -1064,39 +1063,47 @@ struct_type (dip, thisdie, enddie, objfile)
          list -> field.bitpos = 8 * locval (mbr.at_location);
          /* Handle bit fields. */
          list -> field.bitsize = mbr.at_bit_size;
-#if BITS_BIG_ENDIAN
-         /* For big endian bits, the at_bit_offset gives the additional
-            bit offset from the MSB of the containing anonymous object to
-            the MSB of the field.  We don't have to do anything special
-            since we don't need to know the size of the anonymous object. */
-         list -> field.bitpos += mbr.at_bit_offset;
-#else
-         /* For little endian bits, we need to have a non-zero at_bit_size,
-            so that we know we are in fact dealing with a bitfield.  Compute
-            the bit offset to the MSB of the anonymous object, subtract off
-            the number of bits from the MSB of the field to the MSB of the
-            object, and then subtract off the number of bits of the field
-            itself.  The result is the bit offset of the LSB of the field. */
-         if (mbr.at_bit_size > 0)
+         if (BITS_BIG_ENDIAN)
            {
-             if (mbr.has_at_byte_size)
-               {
-                 /* The size of the anonymous object containing the bit field
-                    is explicit, so use the indicated size (in bytes). */
-                 anonymous_size = mbr.at_byte_size;
-               }
-             else
+             /* For big endian bits, the at_bit_offset gives the
+                additional bit offset from the MSB of the containing
+                anonymous object to the MSB of the field.  We don't
+                have to do anything special since we don't need to
+                know the size of the anonymous object. */
+             list -> field.bitpos += mbr.at_bit_offset;
+           }
+         else
+           {
+             /* For little endian bits, we need to have a non-zero
+                at_bit_size, so that we know we are in fact dealing
+                with a bitfield.  Compute the bit offset to the MSB
+                of the anonymous object, subtract off the number of
+                bits from the MSB of the field to the MSB of the
+                object, and then subtract off the number of bits of
+                the field itself.  The result is the bit offset of
+                the LSB of the field. */
+             if (mbr.at_bit_size > 0)
                {
-                 /* The size of the anonymous object containing the bit field
-                    matches the size of an object of the bit field's type.
-                    DWARF allows at_byte_size to be left out in such cases,
-                    as a debug information size optimization. */
-                 anonymous_size = TYPE_LENGTH (list -> field.type);
+                 if (mbr.has_at_byte_size)
+                   {
+                     /* The size of the anonymous object containing
+                        the bit field is explicit, so use the
+                        indicated size (in bytes). */
+                     anonymous_size = mbr.at_byte_size;
+                   }
+                 else
+                   {
+                     /* The size of the anonymous object containing
+                        the bit field matches the size of an object
+                        of the bit field's type.  DWARF allows
+                        at_byte_size to be left out in such cases, as
+                        a debug information size optimization. */
+                     anonymous_size = TYPE_LENGTH (list -> field.type);
+                   }
+                 list -> field.bitpos +=
+                   anonymous_size * 8 - mbr.at_bit_offset - mbr.at_bit_size;
                }
-             list -> field.bitpos +=
-               anonymous_size * 8 - mbr.at_bit_offset - mbr.at_bit_size;
            }
-#endif
          nfields++;
          break;
        default:
@@ -1593,7 +1600,6 @@ read_subroutine_type (dip, thisdie, enddie)
       /* We have an existing partially constructed type, so bash it
         into the correct type. */
       TYPE_TARGET_TYPE (ftype) = type;
-      TYPE_FUNCTION_TYPE (type) = ftype;
       TYPE_LENGTH (ftype) = 1;
       TYPE_CODE (ftype) = TYPE_CODE_FUNC;
     }
@@ -1988,10 +1994,21 @@ process_dies (thisdie, enddie, objfile)
            {
              nextdie = thisdie + di.die_length;
            }
+#ifdef SMASH_TEXT_ADDRESS
+         /* I think that these are always text, not data, addresses.  */
+         SMASH_TEXT_ADDRESS (di.at_low_pc);
+         SMASH_TEXT_ADDRESS (di.at_high_pc);
+#endif
          switch (di.die_tag)
            {
            case TAG_compile_unit:
-             read_file_scope (&di, thisdie, nextdie, objfile);
+             /* Skip Tag_compile_unit if we are already inside a compilation
+                unit, we are unable to handle nested compilation units
+                properly (FIXME).  */
+             if (current_subfile == NULL)
+               read_file_scope (&di, thisdie, nextdie, objfile);
+             else
+               nextdie = thisdie + di.die_length;
              break;
            case TAG_global_subroutine:
            case TAG_subroutine:
@@ -2197,8 +2214,10 @@ locval (loc)
            break;
          case OP_REG:
            /* push register (number) */
-           stack[++stacki] = target_to_host (loc, loc_value_size,
-                                             GET_UNSIGNED, current_objfile);
+           stack[++stacki]
+             = DWARF_REG_TO_REGNUM (target_to_host (loc, loc_value_size,
+                                                    GET_UNSIGNED,
+                                                    current_objfile));
            loc += loc_value_size;
            isreg = 1;
            break;
@@ -2363,14 +2382,14 @@ psymtab_to_symtab_1 (pst)
                  /* Inform about additional files that need to be read in. */
                  if (info_verbose)
                    {
-                     fputs_filtered (" ", stdout);
+                     fputs_filtered (" ", gdb_stdout);
                      wrap_here ("");
-                     fputs_filtered ("and ", stdout);
+                     fputs_filtered ("and ", gdb_stdout);
                      wrap_here ("");
                      printf_filtered ("%s...",
                                       pst -> dependencies[i] -> filename);
                      wrap_here ("");
-                     fflush (stdout);          /* Flush output */
+                     gdb_flush (gdb_stdout);           /* Flush output */
                    }
                  psymtab_to_symtab_1 (pst -> dependencies[i]);
                }
@@ -2384,7 +2403,7 @@ psymtab_to_symtab_1 (pst)
                {
                  printf_filtered ("%d DIE's, sorting...", diecount);
                  wrap_here ("");
-                 fflush (stdout);
+                 gdb_flush (gdb_stdout);
                }
              sort_symtab_syms (pst -> symtab);
              do_cleanups (old_chain);
@@ -2434,7 +2453,7 @@ dwarf_psymtab_to_symtab (pst)
                {
                  printf_filtered ("Reading in symbols for %s...",
                                   pst -> filename);
-                 fflush (stdout);
+                 gdb_flush (gdb_stdout);
                }
              
              psymtab_to_symtab_1 (pst);
@@ -2452,7 +2471,7 @@ dwarf_psymtab_to_symtab (pst)
              if (info_verbose)
                {
                  printf_filtered ("done.\n");
-                 fflush (stdout);
+                 gdb_flush (gdb_stdout);
                }
            }
        }
@@ -2612,6 +2631,9 @@ add_partial_symbol (dip, objfile)
     case TAG_structure_type:
     case TAG_union_type:
     case TAG_enumeration_type:
+      /* Do not add opaque aggregate definitions to the psymtab.  */
+      if (!dip -> has_at_byte_size)
+       break;
       ADD_PSYMBOL_TO_LIST (dip -> at_name, strlen (dip -> at_name),
                           STRUCT_NAMESPACE, LOC_TYPEDEF,
                           objfile -> static_psymbols,
This page took 0.026108 seconds and 4 git commands to generate.