public inbox for bfd@sourceware.org
 help / color / mirror / Atom feed
* Re: Patch to readelf dwarf2 handling
@ 1999-03-30  9:27 Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 1999-03-30  9:27 UTC (permalink / raw)
  To: jason; +Cc: bfd, jason

Hi Jason,

: This patch fixes some bugs and makes the output more readable.
: 
: 1999-03-29  Jason Merrill  <jason@yorick.cygnus.com>
: 
: 	* readelf.c (process_extended_line_op): end_sequence also resets
: 	the line number.
: 	(display_debug_lines): advance_line takes a signed operand.
: 	(read_and_display_attr): Print refs as <%x>, addresses as %#x,
: 	others as %d.  Handle other location expression attributes.
: 	(display_debug_info): Handle nesting.  Always print the	offset.

This is fine.  Please apply.

Cheers
	Nick

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Patch to readelf dwarf2 handling
@ 1999-03-30  0:05 Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 1999-03-30  0:05 UTC (permalink / raw)
  To: nickc; +Cc: bfd, jason

This patch fixes some bugs and makes the output more readable.

1999-03-29  Jason Merrill  <jason@yorick.cygnus.com>

	* readelf.c (process_extended_line_op): end_sequence also resets
	the line number.
	(display_debug_lines): advance_line takes a signed operand.
	(read_and_display_attr): Print refs as <%x>, addresses as %#x,
	others as %d.  Handle other location expression attributes.
	(display_debug_info): Handle nesting.  Always print the	offset.

Index: readelf.c
===================================================================
RCS file: /cvs/cvsfiles/devo/binutils/readelf.c,v
retrieving revision 1.54
diff -c -p -r1.54 readelf.c
*** readelf.c	1999/03/11 02:29:35	1.54
--- readelf.c	1999/03/30 07:57:39
*************** static int                display_debug_
*** 156,162 ****
  static int                display_debug_aranges       PARAMS ((Elf32_Internal_Shdr *, unsigned char *, FILE *));
  static unsigned char *    process_abbrev_section      PARAMS ((unsigned char *, unsigned char *));
  static unsigned long      read_leb128                 PARAMS ((unsigned char *, int *, int));
! static int                process_extended_line_op    PARAMS ((unsigned char *, long *));
  static char *             get_TAG_name                PARAMS ((unsigned long));
  static char *             get_AT_name                 PARAMS ((unsigned long));
  static char *             get_FORM_name               PARAMS ((unsigned long));
--- 156,162 ----
  static int                display_debug_aranges       PARAMS ((Elf32_Internal_Shdr *, unsigned char *, FILE *));
  static unsigned char *    process_abbrev_section      PARAMS ((unsigned char *, unsigned char *));
  static unsigned long      read_leb128                 PARAMS ((unsigned char *, int *, int));
! static int                process_extended_line_op    PARAMS ((unsigned char *, unsigned long *, unsigned *));
  static char *             get_TAG_name                PARAMS ((unsigned long));
  static char *             get_AT_name                 PARAMS ((unsigned long));
  static char *             get_FORM_name               PARAMS ((unsigned long));
*************** read_leb128 (data, length_return, sign)
*** 3512,3520 ****
  
  
  static int
! process_extended_line_op (data, address)
       unsigned char * data;
!      long *          address;
  {
    unsigned char   op_code;
    int             bytes_read;
--- 3512,3521 ----
  
  
  static int
! process_extended_line_op (data, address, line)
       unsigned char * data;
!      unsigned long * address;
!      unsigned int  * line;
  {
    unsigned char   op_code;
    int             bytes_read;
*************** process_extended_line_op (data, address)
*** 3531,3536 ****
--- 3532,3539 ----
      {
      case DW_LNE_end_sequence:
        printf (_("  End Sequence\n\n"));
+       * address = 0;
+       * line = 1;
        break;
  
      case DW_LNE_set_address:
*************** display_debug_lines (section, start, fil
*** 3693,3699 ****
        switch (op_code)
  	{
  	case DW_LNS_extended_op:
! 	  data += process_extended_line_op (data, & address);
  	  break;
  
  	case DW_LNS_copy:
--- 3696,3702 ----
        switch (op_code)
  	{
  	case DW_LNS_extended_op:
! 	  data += process_extended_line_op (data, & address, & line);
  	  break;
  
  	case DW_LNS_copy:
*************** display_debug_lines (section, start, fil
*** 3708,3714 ****
  	  break;
  
  	case DW_LNS_advance_line:
! 	  adv = read_leb128 (data, & bytes_read, 0);
  	  data += bytes_read;
  	  line += adv;
  	  printf (_("  Advance Line by %d to %d\n"), adv, line);
--- 3711,3717 ----
  	  break;
  
  	case DW_LNS_advance_line:
! 	  adv = read_leb128 (data, & bytes_read, 1);
  	  data += bytes_read;
  	  line += adv;
  	  printf (_("  Advance Line by %d to %d\n"), adv, line);
*************** display_debug_lines (section, start, fil
*** 3754,3760 ****
  	  address += (op_code / info.li_line_range) * info.li_min_insn_length,
  	  line    += (op_code % info.li_line_range) + info.li_line_base;
  	  printf
! 	    (_("  Increase by %d, setting address to %lx and line to %d:\n"),
  	     op_code, address, line);
  	  break;
  	}
--- 3757,3763 ----
  	  address += (op_code / info.li_line_range) * info.li_min_insn_length,
  	  line    += (op_code % info.li_line_range) + info.li_line_base;
  	  printf
! 	    (_("  Special opcode %d: set address to %lx and line to %d\n"),
  	     op_code, address, line);
  	  break;
  	}
*************** read_and_display_attr (attribute, form, 
*** 4420,4434 ****
    unsigned long   uvalue;
    unsigned char * block_start;
    int             bytes_read;
  
    printf ("     %-18s:", get_AT_name (attribute));
  
    switch (form)
      {
      case DW_FORM_ref_addr:
      case DW_FORM_addr:
        uvalue = byte_get (data, pointer_size);
!       printf (" %x", uvalue);
        data += pointer_size;
        break;
  
--- 4423,4449 ----
    unsigned long   uvalue;
    unsigned char * block_start;
    int             bytes_read;
+   int		  is_ref = 0;
  
    printf ("     %-18s:", get_AT_name (attribute));
  
    switch (form)
      {
      case DW_FORM_ref_addr:
+     case DW_FORM_ref1:
+     case DW_FORM_ref2:
+     case DW_FORM_ref4:
+     case DW_FORM_ref8:
+     case DW_FORM_ref_udata:
+       is_ref = 1;
+     }
+ 
+   switch (form)
+     {
+     case DW_FORM_ref_addr:
      case DW_FORM_addr:
        uvalue = byte_get (data, pointer_size);
!       printf (is_ref ? " <%x>" : " %#x", uvalue);
        data += pointer_size;
        break;
  
*************** read_and_display_attr (attribute, form, 
*** 4436,4456 ****
      case DW_FORM_flag:
      case DW_FORM_data1:
        uvalue = byte_get (data ++, 1);
!       printf (" %x", uvalue);
        break;
  
      case DW_FORM_ref2:
      case DW_FORM_data2:
        uvalue = byte_get (data, 2);
        data += 2;
!       printf (" %x", uvalue);
        break;
  
      case DW_FORM_ref4:
      case DW_FORM_data4:
        uvalue = byte_get (data, 4);
        data += 4;
!       printf (" %x", uvalue);
        break;
  
      case DW_FORM_ref8:
--- 4451,4471 ----
      case DW_FORM_flag:
      case DW_FORM_data1:
        uvalue = byte_get (data ++, 1);
!       printf (is_ref ? " <%x>" : " %d", uvalue);
        break;
  
      case DW_FORM_ref2:
      case DW_FORM_data2:
        uvalue = byte_get (data, 2);
        data += 2;
!       printf (is_ref ? " <%x>" : " %d", uvalue);
        break;
  
      case DW_FORM_ref4:
      case DW_FORM_data4:
        uvalue = byte_get (data, 4);
        data += 4;
!       printf (is_ref ? " <%x>" : " %d", uvalue);
        break;
  
      case DW_FORM_ref8:
*************** read_and_display_attr (attribute, form, 
*** 4476,4482 ****
      case DW_FORM_udata:
        uvalue = read_leb128 (data, & bytes_read, 0);
        data += bytes_read;
!       printf (" %lx", uvalue);
        break;
  
      case DW_FORM_block:
--- 4491,4497 ----
      case DW_FORM_udata:
        uvalue = read_leb128 (data, & bytes_read, 0);
        data += bytes_read;
!       printf (is_ref ? " <%lx>" : " %ld", uvalue);
        break;
  
      case DW_FORM_block:
*************** read_and_display_attr (attribute, form, 
*** 4529,4535 ****
  	case DW_INL_not_inlined:          printf (_("(not inlined)")); break;
  	case DW_INL_inlined:              printf (_("(inlined)")); break;
  	case DW_INL_declared_not_inlined: printf (_("(declared as inline but ignored)")); break;
! 	case DW_INL_declared_inlined:     printf (_("(declared as inline and implemented)")); break;
  	defailt: printf (_("  (Unknown inline attribute value: %x)"), uvalue); break;
  	}
        break;
--- 4544,4550 ----
  	case DW_INL_not_inlined:          printf (_("(not inlined)")); break;
  	case DW_INL_inlined:              printf (_("(inlined)")); break;
  	case DW_INL_declared_not_inlined: printf (_("(declared as inline but ignored)")); break;
! 	case DW_INL_declared_inlined:     printf (_("(declared as inline and inlined)")); break;
  	defailt: printf (_("  (Unknown inline attribute value: %x)"), uvalue); break;
  	}
        break;
*************** read_and_display_attr (attribute, form, 
*** 4636,4641 ****
--- 4651,4658 ----
        break;
  
      case DW_AT_location:
+     case DW_AT_data_member_location:
+     case DW_AT_vtable_elem_location:
        printf ("(");
        decode_location_expression (block_start, pointer_size);
        printf (")");
*************** display_debug_info (section, start, file
*** 4666,4672 ****
        DWARF2_Internal_CompUnit   compunit;
        unsigned char *            tags;
        int                        i;
!       int                        extra = 0;
  
        external = (DWARF2_External_CompUnit *) start;
  
--- 4683,4689 ----
        DWARF2_Internal_CompUnit   compunit;
        unsigned char *            tags;
        int                        i;
!       int			 level;
  
        external = (DWARF2_External_CompUnit *) start;
  
*************** display_debug_info (section, start, file
*** 4721,4726 ****
--- 4738,4744 ----
  	free (begin);
        }
  
+       level = 0;
        while (tags < start)
  	{
  	  int            bytes_read;
*************** display_debug_info (section, start, file
*** 4731,4744 ****
  	  abbrev_number = read_leb128 (tags, & bytes_read, 0);
  	  tags += bytes_read;
  
  	  if (abbrev_number == 0)
  	    {
! 	      if (tags < start && ! extra)
! 		{
! 		  printf (_("\n   Extra data at end of comp unit:\n"));
! 		  extra = 1;
! 		}
! 
  	      continue;
  	    }
  
--- 4749,4758 ----
  	  abbrev_number = read_leb128 (tags, & bytes_read, 0);
  	  tags += bytes_read;
  
+ 	  /* A null DIE marks the end of a list of children.  */
  	  if (abbrev_number == 0)
  	    {
! 	      --level;
  	      continue;
  	    }
  
*************** display_debug_info (section, start, file
*** 4756,4777 ****
  	      return 0;
  	    }
  
! 	  if (extra)
! 	    printf (_(" %x: Abbrev Number: %d (%s)\n"),
! 		    tags - section_begin - bytes_read,
! 		    abbrev_number,
! 		    get_TAG_name (entry->tag));
! 	  else
! 	    printf (_("    Abbrev Number: %d (%s)\n"),
! 		    abbrev_number,
! 		    get_TAG_name (entry->tag));
  
- 
  	  for (attr = entry->first_attr; attr; attr = attr->next)
  	    tags = read_and_display_attr (attr->attribute,
  					  attr->form,
  					  tags,
  					  compunit.cu_pointer_size);
  	}
      }
  
--- 4770,4788 ----
  	      return 0;
  	    }
  
! 	  printf (_(" <%d><%x>: Abbrev Number: %d (%s)\n"),
! 		  level, tags - section_begin - bytes_read,
! 		  abbrev_number,
! 		  get_TAG_name (entry->tag));
  
  	  for (attr = entry->first_attr; attr; attr = attr->next)
  	    tags = read_and_display_attr (attr->attribute,
  					  attr->form,
  					  tags,
  					  compunit.cu_pointer_size);
+ 
+ 	  if (entry->children)
+ 	    ++level;
  	}
      }
  

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-03-30  9:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-30  9:27 Patch to readelf dwarf2 handling Nick Clifton
  -- strict thread matches above, loose matches on Subject: below --
1999-03-30  0:05 Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).