[PATCH] PR debug/77315 - use DW_OP_form_tls_address

Tom Tromey tom@tromey.com
Fri Oct 21 20:38:00 GMT 2016


>>>>> "Jakub" == Jakub Jelinek <jakub@redhat.com> writes:

Jakub> Also, as this effectively requires the latest unreleased GDB under the
Jakub> default options for something that has been working previously, I wonder
Jakub> if it e.g. for some time shouldn't be guarded with dwarf_version >= 5

Here's what that looks like.

Tom

commit 7865ede46e519fa6bc3d6367f943a40179b4d380
Author: Tom Tromey <tom@tromey.com>
Date:   Thu Oct 20 17:03:35 2016 -0600

    PR debug/77315 - use DW_OP_form_tls_address
    
    This patch changes gcc to emit DW_OP_form_tls_address rather than
    DW_OP_GNU_push_tls_address.  This is PR debug/77315.
    
    DW_OP_form_tls_address was added in DWARF 3.  However, this patch checks
    for DWARF version 5 or above to decide which opcode to emit, because gdb
    did not implement the DWARF 3 opcode until recently -- not until after
    7.12.  This approach seems safest because DWARF 5 is also going to
    require other gdb changes.
    
    Built and regtested on x86-64 Fedora 24.
    
    2016-10-21  Tom Tromey  <tom@tromey.com>
    
    	PR debug/77315:
    	* dwarf2out.c (mem_loc_descriptor): Use DW_OP_form_tls_address.
    	(resolve_args_picking_1): Move DW_OP_form_tls_address case next to
    	DW_OP_GNU_push_tls_address case.
    	(loc_list_from_tree_1): Use DW_OP_form_tls_address.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6102719..481a2a9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2016-10-21  Tom Tromey  <tom@tromey.com>
+
+	PR debug/77315:
+	* dwarf2out.c (mem_loc_descriptor): Use DW_OP_form_tls_address.
+	(resolve_args_picking_1): Move DW_OP_form_tls_address case next to
+	DW_OP_GNU_push_tls_address case.
+	(loc_list_from_tree_1): Use DW_OP_form_tls_address.
+
 2016-10-21  Jakub Jelinek  <jakub@redhat.com>
 
 	* config/i386/adxintrin.h (_subborrow_u32, _addcarry_u32,
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 4683e1c..73b0ea0 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -13619,7 +13619,12 @@ mem_loc_descriptor (rtx rtl, machine_mode mode,
 
           temp = new_addr_loc_descr (rtl, dtprel_true);
 
-	  mem_loc_result = new_loc_descr (DW_OP_GNU_push_tls_address, 0, 0);
+	  /* We check for DWARF 5 here because gdb did not implement
+	     DW_OP_form_tls_address until after 7.12.  */
+	  mem_loc_result = new_loc_descr ((dwarf_version >= 5
+					   ? DW_OP_form_tls_address
+					   : DW_OP_GNU_push_tls_address),
+					  0, 0);
 	  add_loc_descr (&mem_loc_result, temp);
 
 	  break;
@@ -15467,7 +15472,6 @@ resolve_args_picking_1 (dw_loc_descr_ref loc, unsigned initial_frame_offset,
 	case DW_OP_piece:
 	case DW_OP_deref_size:
 	case DW_OP_nop:
-	case DW_OP_form_tls_address:
 	case DW_OP_bit_piece:
 	case DW_OP_implicit_value:
 	case DW_OP_stack_value:
@@ -15595,6 +15599,7 @@ resolve_args_picking_1 (dw_loc_descr_ref loc, unsigned initial_frame_offset,
 	    break;
 	  }
 
+	case DW_OP_form_tls_address:
 	case DW_OP_GNU_push_tls_address:
 	case DW_OP_GNU_uninit:
 	case DW_OP_GNU_encoded_addr:
@@ -15924,8 +15929,11 @@ loc_list_from_tree_1 (tree loc, int want_address,
 		  operand shouldn't be.  */
 	      if (DECL_EXTERNAL (loc) && !targetm.binds_local_p (loc))
 		return 0;
-             dtprel = dtprel_true;
-             tls_op = DW_OP_GNU_push_tls_address;
+	      dtprel = dtprel_true;
+	      /* We check for DWARF 5 here because gdb did not implement
+		 DW_OP_form_tls_address until after 7.12.  */
+	      tls_op = (dwarf_version >= 5 ? DW_OP_form_tls_address
+			: DW_OP_GNU_push_tls_address);
 	    }
 	  else
 	    {



More information about the Gcc-patches mailing list