[AArch64] Add a "compnum" feature
[deliverable/binutils-gdb.git] / gas / dwarf2dbg.c
index ecaccc9cc2fc5e9b1e274647d2204ec1fd684a39..4bb658b2202f0cceaa053cda182e24d605b96a2b 100644 (file)
@@ -1,5 +1,5 @@
 /* dwarf2dbg.c - DWARF2 debug support
-   Copyright (C) 1999-2015 Free Software Foundation, Inc.
+   Copyright (C) 1999-2017 Free Software Foundation, Inc.
    Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
 
    This file is part of GAS, the GNU Assembler.
 # define DWARF2_USE_FIXED_ADVANCE_PC   linkrelax
 #endif
 
-/* First special line opcde - leave room for the standard opcodes.
+/* First special line opcode - leave room for the standard opcodes.
    Note: If you want to change this, you'll have to update the
    "standard_opcode_lengths" table that is emitted below in
    out_debug_line().  */
@@ -253,7 +253,7 @@ get_line_subseg (segT seg, subsegT subseg, bfd_boolean create_p)
       if (!create_p)
        return NULL;
 
-      s = (struct line_seg *) xmalloc (sizeof (*s));
+      s = XNEW (struct line_seg);
       s->next = NULL;
       s->seg = seg;
       s->head = NULL;
@@ -271,7 +271,7 @@ get_line_subseg (segT seg, subsegT subseg, bfd_boolean create_p)
        break;
     }
 
-  lss = (struct line_subseg *) xmalloc (sizeof (*lss));
+  lss = XNEW (struct line_subseg);
   lss->next = *pss;
   lss->subseg = subseg;
   lss->head = NULL;
@@ -291,7 +291,7 @@ dwarf2_gen_line_info_1 (symbolS *label, struct dwarf2_line_info *loc)
   struct line_subseg *lss;
   struct line_entry *e;
 
-  e = (struct line_entry *) xmalloc (sizeof (*e));
+  e = XNEW (struct line_entry);
   e->next = NULL;
   e->label = label;
   e->loc = *loc;
@@ -350,8 +350,7 @@ dwarf2_where (struct dwarf2_line_info *line)
 {
   if (debug_type == DEBUG_DWARF2)
     {
-      char *filename;
-      as_where (&filename, &line->line);
+      const char *filename = as_where (&line->line);
       line->filenum = get_filenum (filename, 0);
       line->column = 0;
       line->flags = DWARF2_FLAG_IS_STMT;
@@ -513,13 +512,10 @@ get_filenum (const char *filename, unsigned int num)
          if (dir >= dirs_allocated)
            {
              dirs_allocated = dir + 32;
-             dirs = (char **)
-                    xrealloc (dirs, (dir + 32) * sizeof (const char *));
+             dirs = XRESIZEVEC (char *, dirs, dirs_allocated);
            }
 
-         dirs[dir] = (char *) xmalloc (dir_len + 1);
-         memcpy (dirs[dir], filename, dir_len);
-         dirs[dir][dir_len] = '\0';
+         dirs[dir] = xmemdup0 (filename, dir_len);
          dirs_in_use = dir + 1;
        }
     }
@@ -544,8 +540,7 @@ get_filenum (const char *filename, unsigned int num)
       unsigned int old = files_allocated;
 
       files_allocated = i + 32;
-      files = (struct file_entry *)
-       xrealloc (files, (i + 32) * sizeof (struct file_entry));
+      files = XRESIZEVEC (struct file_entry, files, files_allocated);
 
       memset (files + old, 0, (i + 32 - old) * sizeof (struct file_entry));
     }
@@ -644,13 +639,14 @@ dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED)
        {
          size_t dir_len = strlen (dirs[files[filenum].dir]);
          size_t file_len = strlen (files[filenum].filename);
-         char *cp = (char *) alloca (dir_len + 1 + file_len + 1);
+         char *cp = XNEWVEC (char, dir_len + 1 + file_len + 1);
 
          memcpy (cp, dirs[files[filenum].dir], dir_len);
          INSERT_DIR_SEPARATOR (cp, dir_len);
          memcpy (cp + dir_len + 1, files[filenum].filename, file_len);
          cp[dir_len + file_len + 1] = '\0';
          listing_source_file (cp);
+         free (cp);
        }
       else
        listing_source_file (files[filenum].filename);
@@ -670,8 +666,7 @@ dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED)
       char *p, c;
       offsetT value;
 
-      p = input_line_pointer;
-      c = get_symbol_end ();
+      c = get_symbol_name (& p);
 
       if (strcmp (p, "basic_block") == 0)
        {
@@ -690,7 +685,7 @@ dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED)
        }
       else if (strcmp (p, "is_stmt") == 0)
        {
-         *input_line_pointer = c;
+         (void) restore_line_pointer (c);
          value = get_absolute_expression ();
          if (value == 0)
            current.flags &= ~DWARF2_FLAG_IS_STMT;
@@ -704,7 +699,7 @@ dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED)
        }
       else if (strcmp (p, "isa") == 0)
        {
-         *input_line_pointer = c;
+         (void) restore_line_pointer (c);
          value = get_absolute_expression ();
          if (value >= 0)
            current.isa = value;
@@ -716,7 +711,7 @@ dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED)
        }
       else if (strcmp (p, "discriminator") == 0)
        {
-         *input_line_pointer = c;
+         (void) restore_line_pointer (c);
          value = get_absolute_expression ();
          if (value >= 0)
            current.discriminator = value;
@@ -729,11 +724,11 @@ dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED)
       else
        {
          as_bad (_("unknown .loc sub-directive `%s'"), p);
-         *input_line_pointer = c;
+         (void) restore_line_pointer (c);
          return;
        }
 
-      SKIP_WHITESPACE ();
+      SKIP_WHITESPACE_AFTER_NAME ();
     }
 
   demand_empty_rest_of_line ();
@@ -1228,7 +1223,7 @@ dwarf2dbg_convert_frag (fragS *frag)
 
   if (DWARF2_USE_FIXED_ADVANCE_PC)
     {
-      /* If linker relaxation is enabled then the distance bewteen the two
+      /* If linker relaxation is enabled then the distance between the two
         symbols in the frag->fr_symbol expression might change.  Hence we
         cannot rely upon the value computed by resolve_symbol_value.
         Instead we leave the expression unfinalized and allow
@@ -1285,7 +1280,7 @@ process_entries (segT seg, struct line_entry *e)
       char * name;
       const char * sec_name;
 
-      /* Switch to the relevent sub-section before we start to emit
+      /* Switch to the relevant sub-section before we start to emit
         the line number table.
 
         FIXME: These sub-sections do not have a normal Line Number
@@ -1296,15 +1291,11 @@ process_entries (segT seg, struct line_entry *e)
         section, as well as our sub-sections, and we have to ensure
         that all of the sub-sections are merged into a proper
         .debug_line section before a debugger sees them.  */
-        
+
       sec_name = bfd_get_section_name (stdoutput, seg);
       if (strcmp (sec_name, ".text") != 0)
        {
-         unsigned int len;
-
-         len = strlen (sec_name);
-         name = xmalloc (len + 11 + 2);
-         sprintf (name, ".debug_line%s", sec_name);
+         name = concat (".debug_line", sec_name, (char *) NULL);
          subseg_set (subseg_get (name, FALSE), 0);
        }
       else
This page took 0.043632 seconds and 4 git commands to generate.