Create a typedef for record_line: record_line_ftype.
[deliverable/binutils-gdb.git] / gdb / dwarf2read.c
index d08f7887ccd96139b36907b7678873dde4dc821f..57a2e65246132cf8ce37143d5212ef9c8abae4fc 100644 (file)
@@ -72,7 +72,6 @@
 #include "build-id.h"
 
 #include <fcntl.h>
-#include <string.h>
 #include <sys/types.h>
 
 typedef struct symbol *symbolp;
@@ -612,8 +611,8 @@ struct dwarf2_per_cu_data
      However we can enter this file with just a "per_cu" handle.  */
   struct objfile *objfile;
 
-  /* When using partial symbol tables, the 'psymtab' field is active.
-     Otherwise the 'quick' field is active.  */
+  /* When dwarf2_per_objfile->using_index is true, the 'quick' field
+     is active.  Otherwise, the 'psymtab' field is active.  */
   union
   {
     /* The partial symbol table associated with this compilation unit,
@@ -17126,7 +17125,9 @@ psymtab_include_file_name (const struct line_header *lh, int file_index,
         include_name = "hello.c"
         dir_name = "."
         DW_AT_comp_dir = comp_dir = "/tmp"
-        DW_AT_name = "./hello.c"  */
+        DW_AT_name = "./hello.c"
+
+      */
 
       if (dir_name != NULL)
        {
@@ -17173,22 +17174,47 @@ noop_record_line (struct subfile *subfile, int line, CORE_ADDR pc)
   return;
 }
 
+/* Use P_RECORD_LINE to record line number LINE beginning at address ADDRESS
+   in the line table of subfile SUBFILE.  */
+
+static void
+dwarf_record_line (struct gdbarch *gdbarch, struct subfile *subfile,
+                  unsigned int line, CORE_ADDR address,
+                  record_line_ftype p_record_line)
+{
+  CORE_ADDR addr = gdbarch_addr_bits_remove (gdbarch, address);
+
+  (*p_record_line) (current_subfile, line, addr);
+}
+
+/* Subroutine of dwarf_decode_lines_1 to simplify it.
+   Mark the end of a set of line number records.
+   The arguments are the same as for dwarf_record_line.
+   If SUBFILE is NULL the request is ignored.  */
+
+static void
+dwarf_finish_line (struct gdbarch *gdbarch, struct subfile *subfile,
+                  CORE_ADDR address, record_line_ftype p_record_line)
+{
+  if (subfile != NULL)
+    dwarf_record_line (gdbarch, subfile, 0, address, p_record_line);
+}
+
 /* Subroutine of dwarf_decode_lines to simplify it.
    Process the line number information in LH.  */
 
 static void
 dwarf_decode_lines_1 (struct line_header *lh, const char *comp_dir,
-                     struct dwarf2_cu *cu, struct partial_symtab *pst)
+                     struct dwarf2_cu *cu, const int decode_for_pst_p)
 {
   const gdb_byte *line_ptr, *extended_end;
   const gdb_byte *line_end;
   unsigned int bytes_read, extended_len;
-  unsigned char op_code, extended_op, adj_opcode;
+  unsigned char op_code, extended_op;
   CORE_ADDR baseaddr;
   struct objfile *objfile = cu->objfile;
   bfd *abfd = objfile->obfd;
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
-  const int decode_for_pst_p = (pst != NULL);
   struct subfile *last_subfile = NULL;
   void (*p_record_line) (struct subfile *subfile, int line, CORE_ADDR pc)
     = record_line;
@@ -17205,11 +17231,8 @@ dwarf_decode_lines_1 (struct line_header *lh, const char *comp_dir,
       CORE_ADDR address = 0;
       unsigned int file = 1;
       unsigned int line = 1;
-      unsigned int column = 0;
       int is_stmt = lh->default_is_stmt;
-      int basic_block = 0;
       int end_sequence = 0;
-      CORE_ADDR addr;
       unsigned char op_index = 0;
 
       if (!decode_for_pst_p && lh->num_file_names >= file)
@@ -17241,6 +17264,7 @@ dwarf_decode_lines_1 (struct line_header *lh, const char *comp_dir,
          if (op_code >= lh->opcode_base)
            {
              /* Special opcode.  */
+             unsigned char adj_opcode;
 
              adj_opcode = op_code - lh->opcode_base;
              address += (((op_index + (adj_opcode / lh->line_range))
@@ -17260,17 +17284,15 @@ dwarf_decode_lines_1 (struct line_header *lh, const char *comp_dir,
                    {
                      if (last_subfile != current_subfile)
                        {
-                         addr = gdbarch_addr_bits_remove (gdbarch, address);
-                         if (last_subfile)
-                           (*p_record_line) (last_subfile, 0, addr);
+                         dwarf_finish_line (gdbarch, last_subfile,
+                                            address, p_record_line);
                          last_subfile = current_subfile;
                        }
                      /* Append row to matrix using current values.  */
-                     addr = gdbarch_addr_bits_remove (gdbarch, address);
-                     (*p_record_line) (current_subfile, line, addr);
+                     dwarf_record_line (gdbarch, current_subfile,
+                                        line, address, p_record_line);
                    }
                }
-             basic_block = 0;
            }
          else switch (op_code)
            {
@@ -17303,6 +17325,8 @@ dwarf_decode_lines_1 (struct line_header *lh, const char *comp_dir,
                                   "[in module %s]"),
                                 line_offset, objfile_name (objfile));
                      p_record_line = noop_record_line;
+                     /* Note: p_record_line is left as noop_record_line
+                        until we see DW_LNE_end_sequence.  */
                    }
 
                  op_index = 0;
@@ -17359,16 +17383,14 @@ dwarf_decode_lines_1 (struct line_header *lh, const char *comp_dir,
                    {
                      if (last_subfile != current_subfile)
                        {
-                         addr = gdbarch_addr_bits_remove (gdbarch, address);
-                         if (last_subfile)
-                           (*p_record_line) (last_subfile, 0, addr);
+                         dwarf_finish_line (gdbarch, last_subfile,
+                                            address, p_record_line);
                          last_subfile = current_subfile;
                        }
-                     addr = gdbarch_addr_bits_remove (gdbarch, address);
-                     (*p_record_line) (current_subfile, line, addr);
+                     dwarf_record_line (gdbarch, current_subfile,
+                                        line, address, p_record_line);
                    }
                }
-             basic_block = 0;
              break;
            case DW_LNS_advance_pc:
              {
@@ -17413,14 +17435,13 @@ dwarf_decode_lines_1 (struct line_header *lh, const char *comp_dir,
               }
              break;
            case DW_LNS_set_column:
-             column = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+             (void) read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
              line_ptr += bytes_read;
              break;
            case DW_LNS_negate_stmt:
              is_stmt = (!is_stmt);
              break;
            case DW_LNS_set_basic_block:
-             basic_block = 1;
              break;
            /* Add to the address register of the state machine the
               address increment value corresponding to special opcode
@@ -17463,8 +17484,8 @@ dwarf_decode_lines_1 (struct line_header *lh, const char *comp_dir,
           lh->file_names[file - 1].included_p = 1;
           if (!decode_for_pst_p)
            {
-             addr = gdbarch_addr_bits_remove (gdbarch, address);
-             (*p_record_line) (current_subfile, 0, addr);
+             dwarf_finish_line (gdbarch, current_subfile, address,
+                                p_record_line);
            }
         }
     }
@@ -17502,7 +17523,7 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir,
   struct subfile *first_subfile = current_subfile;
 
   if (want_line_info)
-    dwarf_decode_lines_1 (lh, comp_dir, cu, pst);
+    dwarf_decode_lines_1 (lh, comp_dir, cu, decode_for_pst_p);
 
   if (decode_for_pst_p)
     {
@@ -21673,6 +21694,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
 {
   struct dwarf2_per_cu_offset_and_type **slot, ofs;
   struct objfile *objfile = cu->objfile;
+  struct attribute *attr;
+  struct dynamic_prop prop;
 
   /* For Ada types, make sure that the gnat-specific data is always
      initialized (if not already set).  There are a few types where
@@ -21687,6 +21710,15 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
       && !HAVE_GNAT_AUX_INFO (type))
     INIT_GNAT_SPECIFIC (type);
 
+  /* Read DW_AT_data_location and set in type.  */
+  attr = dwarf2_attr (die, DW_AT_data_location, cu);
+  if (attr_to_dynamic_prop (attr, die, cu, &prop))
+    {
+      TYPE_DATA_LOCATION (type)
+        = obstack_alloc (&objfile->objfile_obstack, sizeof (prop));
+      *TYPE_DATA_LOCATION (type) = prop;
+    }
+
   if (dwarf2_per_objfile->die_type_hash == NULL)
     {
       dwarf2_per_objfile->die_type_hash =
This page took 0.031431 seconds and 4 git commands to generate.