This is the mail archive of the binutils@sources.redhat.com 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]

Gas patch to support dwarf2 debugging info on sh port


 
I have developed a patches to provide dwarf2 debugging information in
the sh GNU tool chain.  GDB works better with the dwarf2 debugging
information. Below are the entries in the gdb Changelog and the
patches to gas.  This patch has a companion patch to modify gcc for
the sh port.

-Will Cohen
wcohen@redhat.com

2000-08-14  Will Cohen  <wcohen@redhat.com>

	* config/tc-sh.h (DWARF2_LINE_MIN_INSN_LENGTH): Defined.

2000-08-09  William Cohen  <wcohen@redhat.com>

	* config/tc-sh.c (md_assemble): Changed so debug_type
	test performed for ppi_assemble
	* config/tc-sh.c: Included dwarf2dbg.h.
	(debug_line): Defined.
	(md_assemble): Generates dwarf2 line info.
	(sh_finalize): New function.  Finalize dwarf2 info.
	(assemble_ppi): Returns size of code generated.
	(build_Mytes): Returns size of code generated.
	(md_pseudo_table): Added "file" and "loc" psuedo ops.
	* config/tc-sh.h (md_end): Defined.
	(sh_finalize): Declared.


Index: gas/ChangeLog
===================================================================
RCS file: /cvs/cvsfiles/devo/gas/ChangeLog,v
retrieving revision 1.3121
diff -c -2 -p -r1.3121 ChangeLog
*** ChangeLog	2000/08/07 21:51:38	1.3121
--- ChangeLog	2000/08/15 12:40:28
***************
*** 1,2 ****
--- 1,20 ----
+ 2000-08-14  Will Cohen  <wcohen@redhat.com>
+ 
+ 	* config/tc-sh.h (DWARF2_LINE_MIN_INSN_LENGTH): Defined.
+ 
+ 2000-08-09  William Cohen  <wcohen@redhat.com>
+ 
+ 	* config/tc-sh.c (md_assemble): Changed so debug_type
+ 	test performed for ppi_assemble
+ 	* config/tc-sh.c: Included dwarf2dbg.h.
+ 	(debug_line): Defined.
+ 	(md_assemble): Generates dwarf2 line info.
+ 	(sh_finalize): New function.  Finalize dwarf2 info.
+ 	(assemble_ppi): Returns size of code generated.
+ 	(build_Mytes): Returns size of code generated.
+ 	(md_pseudo_table): Added "file" and "loc" psuedo ops.
+ 	* config/tc-sh.h (md_end): Defined.
+ 	(sh_finalize): Declared.
+ 
  2000-08-07  Richard Henderson  <rth@cygnus.com>
  
Index: gas/config/tc-sh.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gas/config/tc-sh.c,v
retrieving revision 1.81
diff -c -2 -p -r1.81 tc-sh.c
*** tc-sh.c	2000/07/08 18:13:35	1.81
--- tc-sh.c	2000/08/15 12:40:29
***************
*** 34,37 ****
--- 34,40 ----
  #endif
  
+ #include "dwarf2dbg.h"
+ struct dwarf2_line_info debug_line;
+ 
  const char comment_chars[] = "!";
  const char line_separator_chars[] = ";";
*************** void s_align_bytes ();
*** 47,51 ****
  static void s_uacons PARAMS ((int));
  static sh_opcode_info *find_cooked_opcode PARAMS ((char **));
! static void assemble_ppi PARAMS ((char *, sh_opcode_info *));
  
  int shl = 0;
--- 50,54 ----
  static void s_uacons PARAMS ((int));
  static sh_opcode_info *find_cooked_opcode PARAMS ((char **));
! static unsigned int assemble_ppi PARAMS ((char *, sh_opcode_info *));
  
  int shl = 0;
*************** const pseudo_typeS md_pseudo_table[] =
*** 78,81 ****
--- 81,86 ----
    {"uaword", s_uacons, 2},
    {"ualong", s_uacons, 4},
+   { "file", dwarf2_directive_file, 0 },
+   { "loc", dwarf2_directive_loc, 0 },
    {0, 0, 0}
  };
*************** insert_loop_bounds (output, operand)
*** 1279,1283 ****
  /* Now we know what sort of opcodes it is, let's build the bytes.  */
  
! static void
  build_Mytes (opcode, operand)
       sh_opcode_info *opcode;
--- 1284,1288 ----
  /* Now we know what sort of opcodes it is, let's build the bytes.  */
  
! static unsigned int
  build_Mytes (opcode, operand)
       sh_opcode_info *opcode;
*************** build_Mytes (opcode, operand)
*** 1288,1291 ****
--- 1293,1297 ----
    char nbuf[4];
    char *output = frag_more (2);
+   unsigned int size = 2;
    int low_byte = target_big_endian ? 1 : 0;
    nbuf[0] = 0;
*************** build_Mytes (opcode, operand)
*** 1384,1387 ****
--- 1390,1394 ----
        output[1] = (nbuf[2] << 4) | (nbuf[3]);
      }
+   return size;
  }
  
*************** find_cooked_opcode (str_p)
*** 1437,1441 ****
  #define DDT_BASE 0xf000 /* Base value for double data transfer insns */
  
! static void
  assemble_ppi (op_end, opcode)
       char *op_end;
--- 1444,1448 ----
  #define DDT_BASE 0xf000 /* Base value for double data transfer insns */
  
! static unsigned int
  assemble_ppi (op_end, opcode)
       char *op_end;
*************** assemble_ppi (op_end, opcode)
*** 1448,1451 ****
--- 1455,1459 ----
    char *output;
    int move_code;
+   unsigned int size;
  
    /* Some insn ignore one or more register fields, e.g. psts machl,a0.
*************** assemble_ppi (op_end, opcode)
*** 1465,1473 ****
  	  /* Couldn't find an opcode which matched the operands.  */
  	  char *where = frag_more (2);
  
  	  where[0] = 0x0;
  	  where[1] = 0x0;
  	  as_bad (_("invalid operands for opcode"));
! 	  return;
  	}
  
--- 1473,1482 ----
  	  /* Couldn't find an opcode which matched the operands.  */
  	  char *where = frag_more (2);
+ 	  size = 2;
  
  	  where[0] = 0x0;
  	  where[1] = 0x0;
  	  as_bad (_("invalid operands for opcode"));
! 	  return size;
  	}
  
*************** assemble_ppi (op_end, opcode)
*** 1614,1617 ****
--- 1623,1627 ----
  
        output = frag_more (4);
+       size = 4;
        if (! target_big_endian)
  	{
*************** assemble_ppi (op_end, opcode)
*** 1627,1632 ****
      }
    else
!     /* Just a double data transfer.  */
!     output = frag_more (2);
    if (! target_big_endian)
      {
--- 1637,1645 ----
      }
    else
!     {
!       /* Just a double data transfer.  */
!       output = frag_more (2);
!       size = 2;
!     }
    if (! target_big_endian)
      {
*************** assemble_ppi (op_end, opcode)
*** 1639,1642 ****
--- 1652,1656 ----
        output[1] = move_code;
      }
+   return size;
  }
  
*************** md_assemble (str)
*** 1652,1655 ****
--- 1666,1670 ----
    sh_operand_info operand[3];
    sh_opcode_info *opcode;
+   unsigned int size;
  
    opcode = find_cooked_opcode (&str);
*************** md_assemble (str)
*** 1673,1719 ****
  
    if (opcode->nibbles[0] == PPI)
-     {
-       assemble_ppi (op_end, opcode);
-       return;
-     }
- 
-   if (opcode->arg[0] == A_BDISP12
-       || opcode->arg[0] == A_BDISP8)
      {
!       parse_exp (op_end + 1, &operand[0]);
!       build_relax (opcode, &operand[0]);
      }
    else
      {
!       if (opcode->arg[0] == A_END)
  	{
! 	  /* Ignore trailing whitespace.  If there is any, it has already
! 	     been compressed to a single space.  */
! 	  if (*op_end == ' ')
! 	    op_end++;
  	}
        else
  	{
! 	  op_end = get_operands (opcode, op_end, operand);
! 	}
!       opcode = get_specific (opcode, operand);
  
!       if (opcode == 0)
! 	{
! 	  /* Couldn't find an opcode which matched the operands.  */
! 	  char *where = frag_more (2);
  
! 	  where[0] = 0x0;
! 	  where[1] = 0x0;
! 	  as_bad (_("invalid operands for opcode"));
! 	  return;
  	}
  
!       if (*op_end)
! 	as_bad (_("excess operands: '%s'"), op_end);
  
!       build_Mytes (opcode, operand);
!     }
  
  }
  
--- 1688,1753 ----
  
    if (opcode->nibbles[0] == PPI)
      {
!       size = assemble_ppi (op_end, opcode);
      }
    else
      {
!       if (opcode->arg[0] == A_BDISP12
! 	  || opcode->arg[0] == A_BDISP8)
  	{
! 	  parse_exp (op_end + 1, &operand[0]);
! 	  build_relax (opcode, &operand[0]);
  	}
        else
  	{
! 	  if (opcode->arg[0] == A_END)
! 	    {
! 	      /* Ignore trailing whitespace.  If there is any, it has already
! 		 been compressed to a single space.  */
! 	      if (*op_end == ' ')
! 		op_end++;
! 	    }
! 	  else
! 	    {
! 	      op_end = get_operands (opcode, op_end, operand);
! 	    }
! 	  opcode = get_specific (opcode, operand);
  
! 	  if (opcode == 0)
! 	    {
! 	      /* Couldn't find an opcode which matched the operands.  */
! 	      char *where = frag_more (2);
! 	      size = 2;
  
! 	      where[0] = 0x0;
! 	      where[1] = 0x0;
! 	      as_bad (_("invalid operands for opcode"));
! 	    }
! 	  else
! 	    {
! 	      if (*op_end)
! 		as_bad (_("excess operands: '%s'"), op_end);
! 
! 	      size = build_Mytes (opcode, operand);
! 	    }
  	}
+     }
+   
  
!   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);
+     }
  }
  
*************** tc_gen_reloc (section, fixp)
*** 3105,3106 ****
--- 3139,3147 ----
  
  #endif /* BFD_ASSEMBLER */
+ 
+ void
+ sh_finalize ()
+ {
+   if (debug_type == DEBUG_DWARF2)
+     dwarf2_finish ();
+ }
Index: gas/config/tc-sh.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gas/config/tc-sh.h,v
retrieving revision 1.30
diff -c -2 -p -r1.30 tc-sh.h
*** tc-sh.h	2000/04/28 17:47:57	1.30
--- tc-sh.h	2000/08/15 12:40:29
*************** extern int sh_small;
*** 42,45 ****
--- 42,48 ----
  #define WORKING_DOT_WORD
  
+ /* All SH instructions are multiples of 16 bits.  */
+ #define DWARF2_LINE_MIN_INSN_LENGTH 2
+ 
  /* We require .long, et. al., to be aligned correctly.  */
  #define md_cons_align(nbytes) sh_cons_align (nbytes)
*************** extern void sh_elf_final_processing PARA
*** 160,163 ****
--- 163,169 ----
  
  #endif /* OBJ_ELF */
+ 
+ #define md_end() sh_finalize ()
+ void sh_finalize PARAMS ((void));
  
  /* end of tc-sh.h */

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