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]

Re: [PATCH] Frame info dump: Fix bad register marks.


On 09/29/2016 01:28 PM, Nick Clifton wrote:
> Hi Andreas,
> 
>> binutils/ChangeLog:
>>
>> 2016-09-29  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
>>
>> 	* dwarf.c (display_debug_frames):
> 
> Umm - what happened to the description of the change in the changelog entry ? :-)
> 
> Anyway, patch approved, please apply, with a full changelog entry of course.
> 
> Cheers
>   Nick
> 

Erm yes - changelog added. I've committed the following version in which I've also fixed a problem
with do_debug_frames_interp plus a tiny formatting problem.

Re-tested on x86-64 and s390x. No regressions.

Bye,

-Andreas-


    binutils/ChangeLog:

    2016-09-29  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

            * dwarf.c (frame_display_row): Fix formatting of return address
            register column.
            (display_debug_frames): Ignore invalid indices into
            cie->col_type/cie->col_offset arrays and default to
            DW_CF_undefined instead.

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 95b33a8..b4687e9 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -5620,7 +5620,7 @@ frame_display_row (Frame_Chunk *fc, int *need_col_headers, unsigned int *max_reg
 	if (fc->col_type[r] != DW_CFA_unreferenced)
 	  {
 	    if (r == fc->ra)
-	      printf ("ra      ");
+	      printf ("ra    ");
 	    else
 	      printf ("%-5s ", regname (r, 1));
 	  }
@@ -6331,19 +6331,25 @@ display_debug_frames (struct dwarf_section *section,
 	      break;

 	    case DW_CFA_restore:
-	      if (opa >= (unsigned int) cie->ncols
-		  || opa >= (unsigned int) fc->ncols)
+	      if (opa >= (unsigned int) fc->ncols)
 		reg_prefix = bad_reg;
 	      if (! do_debug_frames_interp || *reg_prefix != '\0')
 		printf ("  DW_CFA_restore: %s%s\n",
 			reg_prefix, regname (opa, 0));
-	      if (*reg_prefix == '\0')
+	      if (*reg_prefix != '\0')
+		break;
+
+	      if (opa >= (unsigned int) cie->ncols
+		  || (do_debug_frames_interp
+		      && cie->col_type[opa] == DW_CFA_unreferenced))
+		{
+		  fc->col_type[opa] = DW_CFA_undefined;
+		  fc->col_offset[opa] = 0;
+		}
+	      else
 		{
 		  fc->col_type[opa] = cie->col_type[opa];
 		  fc->col_offset[opa] = cie->col_offset[opa];
-		  if (do_debug_frames_interp
-		      && fc->col_type[opa] == DW_CFA_unreferenced)
-		    fc->col_type[opa] = DW_CFA_undefined;
 		}
 	      break;

@@ -6430,13 +6436,20 @@ display_debug_frames (struct dwarf_section *section,

 	    case DW_CFA_restore_extended:
 	      reg = LEB ();
-	      if (reg >= (unsigned int) cie->ncols
-		  || reg >= (unsigned int) fc->ncols)
+	      if (reg >= (unsigned int) fc->ncols)
 		reg_prefix = bad_reg;
 	      if (! do_debug_frames_interp || *reg_prefix != '\0')
 		printf ("  DW_CFA_restore_extended: %s%s\n",
 			reg_prefix, regname (reg, 0));
-	      if (*reg_prefix == '\0')
+	      if (*reg_prefix != '\0')
+		break;
+
+	      if (reg >= (unsigned int) cie->ncols)
+		{
+		  fc->col_type[reg] = DW_CFA_undefined;
+		  fc->col_offset[reg] = 0;
+		}
+	      else
 		{
 		  fc->col_type[reg] = cie->col_type[reg];
 		  fc->col_offset[reg] = cie->col_offset[reg];


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