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]

[PATCH 1/6] DWARF attrs: add delimiter


Hi,

currently DWARF attributes are always prefixed by ' '.
But DWARF-5 file name table needs to prefix it by 't':
 The File name Table (offset 0x30):
  Entry Dir     Name
  0     0       (indirect line string, offset: 0x0): /home/jkratoch/t/classic.C
  1     1       (indirect line string, offset: 0x11): classic.C

Jan


2017-02-12  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf.c (display_block): Add parameter delimiter.
	(decode_location_expression): Update display_block callers.
	(read_and_display_attr_value): Add parameter delimiter.
	(read_and_display_attr, display_debug_macro): Update
	read_and_display_attr_value caller.
---
 binutils/dwarf.c |   50 +++++++++++++++++++++++++-------------------------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 0184a7a..368c498 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -871,11 +871,11 @@ get_FORM_name (unsigned long form)
 static unsigned char *
 display_block (unsigned char *data,
 	       dwarf_vma length,
-	       const unsigned char * const end)
+	       const unsigned char * const end, char delimiter)
 {
   dwarf_vma maxlen;
 
-  printf (_(" %s byte block: "), dwarf_vmatoa ("u", length));
+  printf (_("%c%s byte block: "), delimiter, dwarf_vmatoa ("u", length));
   if (data > end)
     return (unsigned char *) end;
 
@@ -1268,7 +1268,7 @@ decode_location_expression (unsigned char * data,
 	  printf ("DW_OP_implicit_value");
 	  uvalue = read_uleb128 (data, &bytes_read, end);
 	  data += bytes_read;
-	  data = display_block (data, uvalue, end);
+	  data = display_block (data, uvalue, end, ' ');
 	  break;
 
 	  /* GNU extensions.  */
@@ -1337,7 +1337,7 @@ decode_location_expression (unsigned char * data,
 	  printf ("DW_OP_GNU_const_type: <0x%s> ",
 		  dwarf_vmatoa ("x", cu_offset + uvalue));
 	  SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end);
-	  data = display_block (data, uvalue, end);
+	  data = display_block (data, uvalue, end, ' ');
 	  break;
 	case DW_OP_GNU_regval_type:
 	  uvalue = read_uleb128 (data, &bytes_read, end);
@@ -1508,7 +1508,7 @@ read_and_display_attr_value (unsigned long attribute,
 			     debug_info * debug_info_p,
 			     int do_loc,
 			     struct dwarf_section * section,
-			     struct cu_tu_set * this_set)
+			     struct cu_tu_set * this_set, char delimiter)
 {
   dwarf_vma uvalue = 0;
   unsigned char *block_start = NULL;
@@ -1587,12 +1587,12 @@ read_and_display_attr_value (unsigned long attribute,
       form = read_uleb128 (data, & bytes_read, end);
       data += bytes_read;
       if (!do_loc)
-	printf (" %s", get_FORM_name (form));
+	printf ("%c%s", delimiter, get_FORM_name (form));
       return read_and_display_attr_value (attribute, form, data, end,
 					  cu_offset, pointer_size,
 					  offset_size, dwarf_version,
 					  debug_info_p, do_loc,
-					  section, this_set);
+					  section, this_set, delimiter);
     case DW_FORM_GNU_addr_index:
       uvalue = read_uleb128 (data, & bytes_read, end);
       data += bytes_read;
@@ -1603,12 +1603,12 @@ read_and_display_attr_value (unsigned long attribute,
     {
     case DW_FORM_ref_addr:
       if (!do_loc)
-	printf (" <0x%s>", dwarf_vmatoa ("x",uvalue));
+	printf ("%c<0x%s>", delimiter, dwarf_vmatoa ("x",uvalue));
       break;
 
     case DW_FORM_GNU_ref_alt:
       if (!do_loc)
-	printf (" <alt 0x%s>", dwarf_vmatoa ("x",uvalue));
+	printf ("%c<alt 0x%s>", delimiter, dwarf_vmatoa ("x",uvalue));
       break;
 
     case DW_FORM_ref1:
@@ -1616,14 +1616,14 @@ read_and_display_attr_value (unsigned long attribute,
     case DW_FORM_ref4:
     case DW_FORM_ref_udata:
       if (!do_loc)
-	printf (" <0x%s>", dwarf_vmatoa ("x", uvalue + cu_offset));
+	printf ("%c<0x%s>", delimiter, dwarf_vmatoa ("x", uvalue + cu_offset));
       break;
 
     case DW_FORM_data4:
     case DW_FORM_addr:
     case DW_FORM_sec_offset:
       if (!do_loc)
-	printf (" 0x%s", dwarf_vmatoa ("x", uvalue));
+	printf ("%c0x%s", delimiter, dwarf_vmatoa ("x", uvalue));
       break;
 
     case DW_FORM_flag_present:
@@ -1633,7 +1633,7 @@ read_and_display_attr_value (unsigned long attribute,
     case DW_FORM_sdata:
     case DW_FORM_udata:
       if (!do_loc)
-	printf (" %s", dwarf_vmatoa ("d", uvalue));
+	printf ("%c%s", delimiter, dwarf_vmatoa ("d", uvalue));
       break;
 
     case DW_FORM_ref8:
@@ -1648,7 +1648,7 @@ read_and_display_attr_value (unsigned long attribute,
 	  utmp = uvalue;
 	  if (form == DW_FORM_ref8)
 	    add64 (& high_bits, & utmp, cu_offset);
-	  printf (" 0x%s",
+	  printf ("%c0x%s", delimiter,
 		  dwarf_vmatoa64 (high_bits, utmp, buf, sizeof (buf)));
 	}
 
@@ -1666,7 +1666,7 @@ read_and_display_attr_value (unsigned long attribute,
 
     case DW_FORM_string:
       if (!do_loc)
-	printf (" %.*s", (int) (end - data), data);
+	printf ("%c%.*s", delimiter, (int) (end - data), data);
       data += strnlen ((char *) data, end - data) + 1;
       break;
 
@@ -1693,7 +1693,7 @@ read_and_display_attr_value (unsigned long attribute,
       if (do_loc)
 	data = block_start + uvalue;
       else
-	data = display_block (block_start, uvalue, end);
+	data = display_block (block_start, uvalue, end, delimiter);
       break;
 
     case DW_FORM_block1:
@@ -1714,7 +1714,7 @@ read_and_display_attr_value (unsigned long attribute,
       if (do_loc)
 	data = block_start + uvalue;
       else
-	data = display_block (block_start, uvalue, end);
+	data = display_block (block_start, uvalue, end, delimiter);
       break;
 
     case DW_FORM_block2:
@@ -1735,7 +1735,7 @@ read_and_display_attr_value (unsigned long attribute,
       if (do_loc)
 	data = block_start + uvalue;
       else
-	data = display_block (block_start, uvalue, end);
+	data = display_block (block_start, uvalue, end, delimiter);
       break;
 
     case DW_FORM_block4:
@@ -1759,12 +1759,12 @@ read_and_display_attr_value (unsigned long attribute,
       if (do_loc)
 	data = block_start + uvalue;
       else
-	data = display_block (block_start, uvalue, end);
+	data = display_block (block_start, uvalue, end, delimiter);
       break;
 
     case DW_FORM_strp:
       if (!do_loc)
-	printf (_(" (indirect string, offset: 0x%s): %s"),
+	printf (_("%c(indirect string, offset: 0x%s): %s"), delimiter,
 		dwarf_vmatoa ("x", uvalue),
 		fetch_indirect_string (uvalue));
       break;
@@ -1775,7 +1775,7 @@ read_and_display_attr_value (unsigned long attribute,
 	  const char *suffix = strrchr (section->name, '.');
 	  int dwo = (suffix && strcmp (suffix, ".dwo") == 0) ? 1 : 0;
 
-	  printf (_(" (indexed string: 0x%s): %s"),
+	  printf (_("%c(indexed string: 0x%s): %s"), delimiter,
 		  dwarf_vmatoa ("x", uvalue),
 		  fetch_indexed_string (uvalue, this_set, offset_size, dwo));
 	}
@@ -1783,7 +1783,7 @@ read_and_display_attr_value (unsigned long attribute,
 
     case DW_FORM_GNU_strp_alt:
       if (!do_loc)
-	printf (_(" (alt indirect string, offset: 0x%s)"),
+	printf (_("%c(alt indirect string, offset: 0x%s)"), delimiter,
 		dwarf_vmatoa ("x", uvalue));
       break;
 
@@ -1798,7 +1798,7 @@ read_and_display_attr_value (unsigned long attribute,
 	  char buf[64];
 
 	  SAFE_BYTE_GET64 (data, &high_bits, &uvalue, end);
-	  printf (" signature: 0x%s",
+	  printf ("%csignature: 0x%s", delimiter,
 		  dwarf_vmatoa64 (high_bits, uvalue, buf, sizeof (buf)));
 	}
       data += 8;
@@ -1806,7 +1806,7 @@ read_and_display_attr_value (unsigned long attribute,
 
     case DW_FORM_GNU_addr_index:
       if (!do_loc)
-	printf (_(" (addr_index: 0x%s): %s"),
+	printf (_("%c(addr_index: 0x%s): %s"), delimiter,
 		dwarf_vmatoa ("x", uvalue),
 		fetch_indexed_value (uvalue * pointer_size, pointer_size));
       break;
@@ -2233,7 +2233,7 @@ read_and_display_attr (unsigned long attribute,
   data = read_and_display_attr_value (attribute, form, data, end,
 				      cu_offset, pointer_size, offset_size,
 				      dwarf_version, debug_info_p,
-				      do_loc, section, this_set);
+				      do_loc, section, this_set, ' ');
   if (!do_loc)
     printf ("\n");
   return data;
@@ -4332,7 +4332,7 @@ display_debug_macro (struct dwarf_section *section,
 			= read_and_display_attr_value (0, val,
 						       curr, end, 0, 0, offset_size,
 						       version, NULL, 0, NULL,
-						       NULL);
+						       NULL, ' ');
 		      if (n != nargs - 1)
 			printf (",");
 		    }


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