Add --gdwarf2 support to ARM port

Nick Clifton nickc@redhat.com
Fri Oct 20 15:18:00 GMT 2000


Hi Guys,

  I am proposing to apply the patch below unless anyone has any
  objections.  It adds the ability to support to the --gdwarf2 command
  line switch to GAS for the ARM-ELF port.

  As part of adding this feature I have added a utility function to
  dwarf2dbg.c to help with generating the line number information and
  I have modified the HPPA, M68HC11 and SH ports to make use of this
  function.

  I have also updated a comment in read.c describing why this
  information is not generated automatically by GAS, but instead needs
  support from the target specific back end.  I have also updated the
  text in as.texinfo describing the switch, noting that it is not
  implemented for all ports, but only some.

  Any comments ?

Cheers
	Nick

2000-10-20  Nick Clifton  <nickc@redhat.com>

	* dwarf2out.c (dwarf2_generate_asm_lineno): New function: Generate
	a DWARF2 line number information sequence.

	*dwarf2out.h: Add prototype for dwarf2_generate_asm_lineno.

	* read.c (generate_lineno_debug): Update comment describing why
	DWARF2 line number debug information is not generated
	automatically by this function.

	* doc/as.texinfo: Note that --gdwarf2 only works on some targets,
	not all.
	
	* config/tc-arm.h (md_end): Define.
	(DWARF2_LINE_MIN_INSN_LENGTH): Define.
	
	* config/tc-arm.c (output_inst): Call dwarf2_generate_asm_lineno
	if generating DWARF2 line numbers.
	(arm_end_of_source): New function.  Call dwarf2_finish if
	necessary.

	* config/tc-hppa.c (md_assemble): Use dwarf2_generate_asm_lineno.
	* config/tc-m68hc11.c (m68hc11_new_insn): Use dwarf2_generate_asm_lineno.
	* config/tc-sh.c (md_assemble): Use dwarf2_generate_asm_lineno.
	
Index: gas/dwarf2dbg.c
===================================================================
RCS file: /cvs/src//src/gas/dwarf2dbg.c,v
retrieving revision 1.16
diff -p -r1.16 dwarf2dbg.c
*** dwarf2dbg.c	2000/10/17 20:21:45	1.16
--- dwarf2dbg.c	2000/10/20 22:10:30
*************** dwarf2_where (line)
*** 772,774 ****
--- 772,796 ----
        line->flags = DWARF2_FLAG_BEGIN_STMT;
      }
  }
+ 
+ /* Generate a DWARF2 line statement for an
+    instruction of SIZE bytes in length.  */
+ 
+ void
+ dwarf2_generate_asm_lineno (size)
+      int size;
+ {
+   bfd_vma addr;
+   static struct dwarf2_line_info debug_line;
+   
+   /* First update the notion of the current source line.  */
+   dwarf2_where (& debug_line);
+   
+   /* We want the offset of the start of this
+      instruction within the the current frag.  */
+   addr = frag_now->fr_address + frag_now_fix () - size;
+   
+   /* And record the information.  */
+   dwarf2_gen_line_info (addr, & debug_line);
+ } 

Index: gas/dwarf2dbg.h
===================================================================
RCS file: /cvs/src//src/gas/dwarf2dbg.h,v
retrieving revision 1.6
diff -p -r1.6 dwarf2dbg.h
*** dwarf2dbg.h	2000/10/17 20:21:45	1.6
--- dwarf2dbg.h	2000/10/20 22:10:30
*************** extern void dwarf2_gen_line_info PARAMS 
*** 65,68 ****
--- 65,70 ----
     .debug_line section.  */
  extern void dwarf2_finish PARAMS ((void));
  
+ extern void dwarf2_generate_asm_lineno PARAMS ((int));
+ 
  #endif /* AS_DWARF2DBG_H */

Index: gas/read.c
===================================================================
RCS file: /cvs/src//src/gas/read.c,v
retrieving revision 1.27
diff -p -r1.27 read.c
*** read.c	2000/09/12 03:56:22	1.27
--- read.c	2000/10/20 22:10:30
*************** generate_lineno_debug ()
*** 5002,5008 ****
        break;
      case DEBUG_DWARF:
      case DEBUG_DWARF2:
!       /* FIXME.  */
        break;
      }
  }
--- 5002,5015 ----
        break;
      case DEBUG_DWARF:
      case DEBUG_DWARF2:
!       /* This cannot safely be done in a generic manner.  A single
! 	 binary instruction word may span mutliple lines of assembler
! 	 source and may occupy a variable number of bytes.  Instead,
! 	 if a port wishes to support DWARF2 line number generation by
! 	 the assembler, it should add a call to dwarf2_generate_asm_lineno
! 	 inside md_assemble() at whatever point is appropriate.  Note,
! 	 such a port should also define md_end and make sure that
! 	 dwarf2_finish is called, to emit the accumulated line information.  */
        break;
      }
  }

Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src//src/gas/config/tc-arm.c,v
retrieving revision 1.60
diff -p -r1.60 tc-arm.c
*** tc-arm.c	2000/09/15 01:06:52	1.60
--- tc-arm.c	2000/10/20 22:10:30
*************** output_inst PARAMS ((void))
*** 6380,6386 ****
      fix_new_arm (frag_now, to - frag_now->fr_literal,
  		 inst.size, & inst.reloc.exp, inst.reloc.pc_rel,
  		 inst.reloc.type);
! 
    return;
  }
  
--- 6380,6389 ----
      fix_new_arm (frag_now, to - frag_now->fr_literal,
  		 inst.size, & inst.reloc.exp, inst.reloc.pc_rel,
  		 inst.reloc.type);
! #ifdef OBJ_ELF
!   if (debug_type == DEBUG_DWARF2)
!     dwarf2_generate_asm_lineno (inst.size);
! #endif
    return;
  }
  
*************** s_arm_elf_cons (nbytes)
*** 7501,7506 ****
--- 7504,7518 ----
    /* Put terminator back into stream.  */
    input_line_pointer --;
    demand_empty_rest_of_line ();
+ }
+ 
+ /* Stuff to do after assembling all of the source file.  */
+ 
+ void
+ arm_end_of_source ()
+ {
+   if (debug_type == DEBUG_DWARF2)
+     dwarf2_finish ();
  }
  
  #endif /* OBJ_ELF */

Index: gas/config/tc-arm.h
===================================================================
RCS file: /cvs/src//src/gas/config/tc-arm.h,v
retrieving revision 1.8
diff -p -r1.8 tc-arm.h
*** tc-arm.h	2000/09/15 01:06:52	1.8
--- tc-arm.h	2000/10/20 22:10:30
*************** void armelf_frob_symbol PARAMS ((symbolS
*** 210,212 ****
--- 210,219 ----
  #else
  #define GLOBAL_OFFSET_TABLE_NAME "__GLOBAL_OFFSET_TABLE_"
  #endif
+ 
+ #ifdef OBJ_ELF
+ #define md_end() arm_end_of_source ()
+  extern void arm_end_of_source PARAMS ((void));
+ 
+ #define DWARF2_LINE_MIN_INSN_LENGTH 2
+ #endif

Index: gas/config/tc-hppa.c
===================================================================
RCS file: /cvs/src//src/gas/config/tc-hppa.c,v
retrieving revision 1.70
diff -p -r1.70 tc-hppa.c
*** tc-hppa.c	2000/10/07 14:38:32	1.70
--- tc-hppa.c	2000/10/20 22:10:31
*************** error only one of OBJ_ELF and OBJ_SOM ca
*** 42,48 ****
     then we want to use the assembler support for compact line numbers.  */
  #ifdef OBJ_ELF
  #include "dwarf2dbg.h"
- struct dwarf2_line_info debug_line;
  
  /* A "convient" place to put object file dependencies which do
     not need to be seen outside of tc-hppa.c.  */
--- 42,47 ----
*************** md_assemble (str)
*** 1493,1511 ****
  
  #ifdef OBJ_ELF
    if (debug_type == DEBUG_DWARF2)
!     {
!       bfd_vma addr;
! 
!       /* First update the notion of the current source line.  */
!       dwarf2_where (&debug_line);
! 
!       /* We want the offset of the start of this instruction within the
! 	 the current frag.  */
!       addr = frag_now->fr_address + frag_now_fix () - 4;
! 
!       /* And record the information.  */
!       dwarf2_gen_line_info (addr, &debug_line);
!     }
  #endif
  }
  
--- 1492,1498 ----
  
  #ifdef OBJ_ELF
    if (debug_type == DEBUG_DWARF2)
!     dwarf2_generate_asm_lineno (4);
  #endif
  }
  
Index: gas/config/tc-m68hc11.c
===================================================================
RCS file: /cvs/src//src/gas/config/tc-m68hc11.c,v
retrieving revision 1.5
diff -p -r1.5 tc-m68hc11.c
*** tc-m68hc11.c	2000/09/20 22:05:08	1.5
--- tc-m68hc11.c	2000/10/20 22:10:31
***************
*** 26,33 ****
  #include "opcode/m68hc11.h"
  #include "dwarf2dbg.h"
  
- struct dwarf2_line_info debug_line;
- 
  const char comment_chars[] = ";!";
  const char line_comment_chars[] = "#*";
  const char line_separator_chars[] = "";
--- 26,31 ----
*************** m68hc11_new_insn (size)
*** 1375,1387 ****
  
    /* Emit line number information in dwarf2 debug sections.  */
    if (debug_type == DEBUG_DWARF2)
!     {
!       bfd_vma addr;
  
-       dwarf2_where (&debug_line);
-       addr = frag_now->fr_address + frag_now_fix () - size;
-       dwarf2_gen_line_info (addr, &debug_line);
-     }
    return f;
  }
  
--- 1373,1380 ----
  
    /* Emit line number information in dwarf2 debug sections.  */
    if (debug_type == DEBUG_DWARF2)
!     dwarf2_generate_asm_lineno (size);
  
    return f;
  }
  
Index: gas/config/tc-sh.c
===================================================================
RCS file: /cvs/src//src/gas/config/tc-sh.c,v
retrieving revision 1.24
diff -p -r1.24 tc-sh.c
*** tc-sh.c	2000/10/16 19:44:39	1.24
--- tc-sh.c	2000/10/20 22:10:31
***************
*** 34,40 ****
  #endif
  
  #include "dwarf2dbg.h"
- struct dwarf2_line_info debug_line;
  
  const char comment_chars[] = "!";
  const char line_separator_chars[] = ";";
--- 34,39 ----
*************** md_assemble (str)
*** 1931,1949 ****
      }
  
    if (debug_type == DEBUG_DWARF2)
!     {
!       bfd_vma addr;
! 
!       /* First update the notion of the current source line.  */
!       dwarf2_where (&debug_line);
! 
!       /* We want the offset of the start of this instruction within the
! 	 the current frag.  may be used later */
!       addr = frag_now->fr_address + frag_now_fix () - size;
! 
!       /* And record the information.  */
!       dwarf2_gen_line_info (addr, &debug_line);
!     }
  }
  
  /* This routine is called each time a label definition is seen.  It
--- 1930,1936 ----
      }
  
    if (debug_type == DEBUG_DWARF2)
!     dwarf2_generate_asm_lineno (size);
  }
  
  /* This routine is called each time a label definition is seen.  It

Index: gas/doc/as.texinfo
===================================================================
RCS file: /cvs/src//src/gas/doc/as.texinfo,v
retrieving revision 1.21
diff -p -r1.21 as.texinfo
*** as.texinfo	2000/10/17 20:08:37	1.21
--- as.texinfo	2000/10/20 22:10:31
*************** may help debugging assembler code, if th
*** 338,344 ****
  
  @item --gdwarf2
  Generate DWARF2 debugging information for each assembler line.  This
! may help debugging assembler code, if the debugger can handle it.
  
  @item --help
  Print a summary of the command line options and exit.
--- 338,345 ----
  
  @item --gdwarf2
  Generate DWARF2 debugging information for each assembler line.  This
! may help debugging assembler code, if the debugger can handle it.  Note - this
! option is only supported by some targets, not all of them.
  
  @item --help
  Print a summary of the command line options and exit.


More information about the Binutils mailing list