This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Introduce support for location views


On Jul 18, 2017, Alexandre Oliva <aoliva@redhat.com> wrote:

> I figured I'd restore the original behavior of .loc, and arrange for it
> to emit a row for the current address (which is what my plans and the
> GCC implementation expects), rather than for the subsequent asm insn
> (which is what GAS used to do), only when a "view" option is given.  So
> you'll get the new behavior only when you ask for views.  I'm still
> working on that, reverting all the new calls to dwarf2_emit_insn, so
> I'll post that big change as a follow up.

Much reverting...  dwarf2_directive_loc() is where the new change is.


diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index 176d635..4eeb5ee 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -15865,7 +15865,6 @@ mips_align (int to, int *fill, struct insn_label_list *labels)
 {
   mips_emit_delays ();
   mips_record_compressed_mode ();
-  dwarf2_emit_insn (0);
   if (fill == NULL && subseg_text_p (now_seg))
     frag_align_code (to, 0);
   else
diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c
index 8baae26..cb5fb24 100644
--- a/gas/config/tc-sh.c
+++ b/gas/config/tc-sh.c
@@ -831,8 +831,6 @@ sh_elf_cons (int nbytes)
       return;
     }
 
-  dwarf2_emit_insn (0);
-
 #ifdef md_cons_align
   md_cons_align (nbytes);
 #endif
diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo
index a6ddc7c..65b14a4 100644
--- a/gas/doc/as.texinfo
+++ b/gas/doc/as.texinfo
@@ -5834,18 +5834,17 @@ This directive will set the @code{discriminator} register in the @code{.debug_li
 state machine to @var{value}, which must be an unsigned integer.
 
 @item view @var{value}
-This directive will verify that the @code{view} register in the
-@code{.debug_line} state machine matches @var{value}.  In general, the
-@code{view} register counts how many prior @code{.loc} directives are at the
-same program location, but there are a few exceptions, such as that view
-numbers may be forced reset e.g. at function entry points, or they may not be
-reset even when the location changes.  The assembler will determine the view
-number for that @code{.loc}.  Then, if @var{value} is a label, it will set the
-label to the @var{value}.  Otherwise, @var{value} may be either @code{0}, in
-which case the assembler will error out if the computed view number is not
-zero, or @code{-0}, that will cause the assembler to arrange for the
-@code{view} register to be reset for this @code{.loc} even if for @code{0} it
-would have issued an error.
+This option causes a row to be added to @code{.debug_line} in reference to the
+current address (which might not be the same as that of the following assembly
+instruction), and to associate @var{value} with the @code{view} register in the
+@code{.debug_line} state machine.  If @var{value} is a label, both the
+@code{view} register and the label are set to the number of prior @code{.loc}
+directives at the same program location.  If @var{value} is the literal
+@code{0}, the @code{view} register is set to zero, and the assembler asserts
+that there aren't any prior @code{.loc} directives at the same program
+location.  If @var{value} is the literal @code{-0}, the assembler arrange for
+the @code{view} register to be reset in this row, even if there are prior
+@code{.loc} directives at the same program location.
 
 @end table
 
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 04d7ef9..c3d6043 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -957,6 +957,10 @@ dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED)
   demand_empty_rest_of_line ();
   dwarf2_loc_directive_seen = TRUE;
   debug_type = DEBUG_NONE;
+
+  /* If we were given a view id, emit the row right away.  */
+  if (current.view)
+    dwarf2_emit_insn (0);
 }
 
 void
diff --git a/gas/read.c b/gas/read.c
index 629e1a0..9627ef5 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -37,7 +37,6 @@
 #include "macro.h"
 #include "obstack.h"
 #include "ecoff.h"
-#include "dwarf2dbg.h"
 #include "dw2gencfi.h"
 #include "wchar.h"
 
@@ -779,8 +778,6 @@ do_align (unsigned int n, char *fill, unsigned int len, unsigned int max)
   md_flush_pending_output ();
 #endif
 
-  dwarf2_emit_insn (0);
-
 #ifdef md_do_align
   md_do_align (n, fill, len, max, just_record_alignment);
 #endif
@@ -2201,8 +2198,6 @@ s_fill (int ignore ATTRIBUTE_UNUSED)
   md_flush_pending_output ();
 #endif
 
-  dwarf2_emit_insn (0);
-
 #ifdef md_cons_align
   md_cons_align (1);
 #endif
@@ -2853,8 +2848,6 @@ s_org (int ignore ATTRIBUTE_UNUSED)
   md_flush_pending_output ();
 #endif
 
-  dwarf2_emit_insn (0);
-
   /* The m68k MRI assembler has a different meaning for .org.  It
      means to create an absolute section at a given address.  We can't
      support that--use a linker script instead.  */
@@ -3325,8 +3318,6 @@ s_space (int mult)
   md_flush_pending_output ();
 #endif
 
-  dwarf2_emit_insn (0);
-
 #ifdef md_cons_align
   md_cons_align (1);
 #endif
@@ -3976,8 +3967,6 @@ cons_worker (int nbytes,	/* 1=.byte, 2=.word, 4=.long.  */
   md_flush_pending_output ();
 #endif
 
-  dwarf2_emit_insn (0);
-
   if (flag_mri)
     stop = mri_comment_field (&stopc);
 
@@ -4970,8 +4959,6 @@ float_cons (/* Clobbers input_line-pointer, checks end-of-line.  */
   md_flush_pending_output ();
 #endif
 
-  dwarf2_emit_insn (0);
-
 #ifdef md_cons_align
   md_cons_align (1);
 #endif
@@ -5395,8 +5382,6 @@ s_leb128 (int sign)
   md_flush_pending_output ();
 #endif
 
-  dwarf2_emit_insn (0);
-
   do
     {
       deferred_expression (&exp);
@@ -5466,8 +5451,6 @@ stringer (int bits_appendzero)
   md_flush_pending_output ();
 #endif
 
-  dwarf2_emit_insn (0);
-
 #ifdef md_cons_align
   md_cons_align (1);
 #endif
@@ -5862,8 +5845,6 @@ s_incbin (int x ATTRIBUTE_UNUSED)
   md_flush_pending_output ();
 #endif
 
-  dwarf2_emit_insn (0);
-
 #ifdef md_cons_align
   md_cons_align (1);
 #endif
diff --git a/gas/subsegs.c b/gas/subsegs.c
index 76e3c6b..73bc349 100644
--- a/gas/subsegs.c
+++ b/gas/subsegs.c
@@ -25,8 +25,6 @@
 #include "subsegs.h"
 #include "obstack.h"
 
-#include "dwarf2dbg.h"
-
 frchainS *frchain_now;
 
 static struct obstack frchains;
@@ -82,10 +80,7 @@ subseg_set_rest (segT seg, subsegT subseg)
   mri_common_symbol = NULL;
 
   if (frag_now && frchain_now)
-    {
-      frchain_now->frch_frag_now = frag_now;
-      dwarf2_emit_insn (0);
-    }
+    frchain_now->frch_frag_now = frag_now;
 
   gas_assert (frchain_now == 0
 	  || frchain_now->frch_last == frag_now);
diff --git a/gas/testsuite/gas/elf/dwarf2-8.l b/gas/testsuite/gas/elf/dwarf2-8.l
index 457f648..60c73e5 100644
--- a/gas/testsuite/gas/elf/dwarf2-8.l
+++ b/gas/testsuite/gas/elf/dwarf2-8.l
@@ -1,2 +1,2 @@
 [^:]*: Assembler messages:
-[^:]*:26: Error: view number mismatch
+[^:]*:25: Error: view number mismatch
diff --git a/gas/testsuite/gas/elf/dwarf2-9.l b/gas/testsuite/gas/elf/dwarf2-9.l
index 43eb606..7f107fa 100644
--- a/gas/testsuite/gas/elf/dwarf2-9.l
+++ b/gas/testsuite/gas/elf/dwarf2-9.l
@@ -1,2 +1,2 @@
 [^:]*: Assembler messages:
-[^:]*:31: Error: view number mismatch
+[^:]*:30: Error: view number mismatch


-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]