Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] eh_frame handling
@ 2002-05-14  9:01 Michal Ludvig
  2002-05-15  7:02 ` Michal Ludvig
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Ludvig @ 2002-05-14  9:01 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 551 bytes --]

Hi all,
these changes will allow backtrace even through objects without 
debug_frame section. Note that gcc must produce all information 
necessary in eh_frame (perhaps -fasynchronous-unwind-tables flag?).

2002-05-14  Michal Ludvig  <mludvig@suse.cz>
         * dwarf2cfi.c (frame_state_for): Added safety check for a valid
         fde->cie_ptr.
         (dwarf2_build_frame_info): Added handling for eh_frame.

OK to commit to mainline and branch?

Michal Ludvig
-- 
* SuSE CR, s.r.o     * mludvig@suse.cz
* +420 2 9654 5373   * http://www.suse.cz

[-- Attachment #2: cfi-eh.diff --]
[-- Type: text/plain, Size: 3517 bytes --]

Index: dwarf2cfi.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2cfi.c,v
retrieving revision 1.5
diff -c -3 -p -r1.5 dwarf2cfi.c
*** dwarf2cfi.c	14 May 2002 08:24:26 -0000	1.5
--- dwarf2cfi.c	14 May 2002 15:49:26 -0000
*************** frame_state_for (struct context *context
*** 802,812 ****
    context->args_size = 0;
    context->lsda = 0;
  
!   if ((fde = get_fde_for_addr (context->ra - 1)) != NULL)
!     {
!       fs->pc = fde->initial_location;
  
        cie = fde->cie_ptr;
        fs->code_align = cie->code_align;
        fs->data_align = cie->data_align;
        fs->retaddr_column = cie->ra;
--- 802,816 ----
    context->args_size = 0;
    context->lsda = 0;
  
!   if ((fde = get_fde_for_addr (context->ra - 1)) == NULL)
!     return;
!   
!   fs->pc = fde->initial_location;
  
+   if (fde->cie_ptr)
+   {
        cie = fde->cie_ptr;
+       
        fs->code_align = cie->code_align;
        fs->data_align = cie->data_align;
        fs->retaddr_column = cie->ra;
*************** frame_state_for (struct context *context
*** 817,823 ****
  			   cie->data + cie->data_length, context, fs);
        execute_cfa_program (cie->objfile, fde->data,
  			   fde->data + fde->data_length, context, fs);
!     }
  }
  
  static void
--- 821,831 ----
  			   cie->data + cie->data_length, context, fs);
        execute_cfa_program (cie->objfile, fde->data,
  			   fde->data + fde->data_length, context, fs);
!   }
!   else
! 	internal_error (__FILE__, __LINE__,
! 		"%s(): Internal error: fde->cie_ptr==NULL !", 
! 		__func__);
  }
  
  static void
*************** dwarf2_build_frame_info (struct objfile 
*** 1367,1372 ****
--- 1375,1381 ----
    bfd *abfd = objfile->obfd;
    char *start = NULL;
    char *end = NULL;
+   int from_eh = 0;
  
    obstack_init (&unwind_tmp_obstack);
  
*************** dwarf2_build_frame_info (struct objfile 
*** 1389,1394 ****
--- 1398,1405 ----
  
        start = dwarf_frame_buffer;
        end = dwarf_frame_buffer + dwarf_eh_frame_size;
+ 
+       from_eh = 1;
      }
  
    if (start)
*************** dwarf2_build_frame_info (struct objfile 
*** 1410,1416 ****
  	  cie_id = read_length (abfd, start, &bytes_read, dwarf64);
  	  start += bytes_read;
  
! 	  if (is_cie (cie_id, dwarf64))
  	    {
  	      struct cie_unit *cie = cie_unit_alloc ();
  	      char *aug;
--- 1421,1427 ----
  	  cie_id = read_length (abfd, start, &bytes_read, dwarf64);
  	  start += bytes_read;
  
! 	  if ((from_eh && cie_id == 0) || is_cie (cie_id, dwarf64))
  	    {
  	      struct cie_unit *cie = cie_unit_alloc ();
  	      char *aug;
*************** dwarf2_build_frame_info (struct objfile 
*** 1479,1486 ****
  	      fde->initial_location = read_pointer (abfd, &start);
  	      fde->address_range = read_pointer (abfd, &start);
  
! 	      for (cie = cie_chunks;
  		   cie && (cie->offset != cie_id); cie = cie->next);
  	      if (!cie)
  		error ("dwarf cfi error: can't find CIE pointer");
  	      fde->cie_ptr = cie;
--- 1490,1503 ----
  	      fde->initial_location = read_pointer (abfd, &start);
  	      fde->address_range = read_pointer (abfd, &start);
  
! 	      if(from_eh)
! 		for (cie = cie_chunks;
! 		   cie && (cie->offset != (unit_offset + bytes_read - cie_id));
! 		   cie = cie->next);
! 	      else
! 		for (cie = cie_chunks;
  		   cie && (cie->offset != cie_id); cie = cie->next);
+ 	    
  	      if (!cie)
  		error ("dwarf cfi error: can't find CIE pointer");
  	      fde->cie_ptr = cie;

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

* Re: [RFA] eh_frame handling
  2002-05-14  9:01 [RFA] eh_frame handling Michal Ludvig
@ 2002-05-15  7:02 ` Michal Ludvig
  2002-05-20 18:10   ` Elena Zannoni
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Ludvig @ 2002-05-15  7:02 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 696 bytes --]

Michal Ludvig wrote:
> Hi all,
> these changes will allow backtrace even through objects without 
> debug_frame section. Note that gcc must produce all information 
> necessary in eh_frame (perhaps -fasynchronous-unwind-tables flag?).
> 
> 2002-05-14  Michal Ludvig  <mludvig@suse.cz>
>         * dwarf2cfi.c (frame_state_for): Added safety check for a valid
>         fde->cie_ptr.
>         (dwarf2_build_frame_info): Added handling for eh_frame.

I have slightly rewritten finding the appropriate CIE for a given FDE so 
that it counts with multiple objfiles now.

Any comments? Can I commit?

Michal Ludvig
-- 
* SuSE CR, s.r.o     * mludvig@suse.cz
* +420 2 9654 5373   * http://www.suse.cz

[-- Attachment #2: cfi-eh2.diff --]
[-- Type: text/plain, Size: 3574 bytes --]

Index: dwarf2cfi.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2cfi.c,v
retrieving revision 1.5
diff -c -3 -p -r1.5 dwarf2cfi.c
*** dwarf2cfi.c	14 May 2002 08:24:26 -0000	1.5
--- dwarf2cfi.c	15 May 2002 13:59:06 -0000
*************** frame_state_for (struct context *context
*** 802,812 ****
    context->args_size = 0;
    context->lsda = 0;
  
!   if ((fde = get_fde_for_addr (context->ra - 1)) != NULL)
!     {
!       fs->pc = fde->initial_location;
  
        cie = fde->cie_ptr;
        fs->code_align = cie->code_align;
        fs->data_align = cie->data_align;
        fs->retaddr_column = cie->ra;
--- 802,816 ----
    context->args_size = 0;
    context->lsda = 0;
  
!   if ((fde = get_fde_for_addr (context->ra - 1)) == NULL)
!     return;
!   
!   fs->pc = fde->initial_location;
  
+   if (fde->cie_ptr)
+   {
        cie = fde->cie_ptr;
+       
        fs->code_align = cie->code_align;
        fs->data_align = cie->data_align;
        fs->retaddr_column = cie->ra;
*************** frame_state_for (struct context *context
*** 817,823 ****
  			   cie->data + cie->data_length, context, fs);
        execute_cfa_program (cie->objfile, fde->data,
  			   fde->data + fde->data_length, context, fs);
!     }
  }
  
  static void
--- 821,831 ----
  			   cie->data + cie->data_length, context, fs);
        execute_cfa_program (cie->objfile, fde->data,
  			   fde->data + fde->data_length, context, fs);
!   }
!   else
! 	internal_error (__FILE__, __LINE__,
! 		"%s(): Internal error: fde->cie_ptr==NULL !", 
! 		__func__);
  }
  
  static void
*************** dwarf2_build_frame_info (struct objfile 
*** 1367,1372 ****
--- 1375,1381 ----
    bfd *abfd = objfile->obfd;
    char *start = NULL;
    char *end = NULL;
+   int from_eh = 0;
  
    obstack_init (&unwind_tmp_obstack);
  
*************** dwarf2_build_frame_info (struct objfile 
*** 1389,1394 ****
--- 1398,1405 ----
  
        start = dwarf_frame_buffer;
        end = dwarf_frame_buffer + dwarf_eh_frame_size;
+ 
+       from_eh = 1;
      }
  
    if (start)
*************** dwarf2_build_frame_info (struct objfile 
*** 1410,1416 ****
  	  cie_id = read_length (abfd, start, &bytes_read, dwarf64);
  	  start += bytes_read;
  
! 	  if (is_cie (cie_id, dwarf64))
  	    {
  	      struct cie_unit *cie = cie_unit_alloc ();
  	      char *aug;
--- 1421,1427 ----
  	  cie_id = read_length (abfd, start, &bytes_read, dwarf64);
  	  start += bytes_read;
  
! 	  if ((from_eh && cie_id == 0) || is_cie (cie_id, dwarf64))
  	    {
  	      struct cie_unit *cie = cie_unit_alloc ();
  	      char *aug;
*************** dwarf2_build_frame_info (struct objfile 
*** 1479,1486 ****
  	      fde->initial_location = read_pointer (abfd, &start);
  	      fde->address_range = read_pointer (abfd, &start);
  
! 	      for (cie = cie_chunks;
! 		   cie && (cie->offset != cie_id); cie = cie->next);
  	      if (!cie)
  		error ("dwarf cfi error: can't find CIE pointer");
  	      fde->cie_ptr = cie;
--- 1490,1509 ----
  	      fde->initial_location = read_pointer (abfd, &start);
  	      fde->address_range = read_pointer (abfd, &start);
  
! 	      cie = cie_chunks;
! 	      while(cie)
! 	      {
! 	        if (cie.objfile == objfile)
! 		{
! 		  if (from_eh && (cie->offset == (unit_offset + bytes_read - cie_id)))
! 		    break;
! 		  if (!from_eh && (cie->offset == cie_id))
! 		    break;
! 		}
! 
! 		cie = cie->next;
! 	      }
! 	    
  	      if (!cie)
  		error ("dwarf cfi error: can't find CIE pointer");
  	      fde->cie_ptr = cie;

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

* Re: [RFA] eh_frame handling
  2002-05-15  7:02 ` Michal Ludvig
@ 2002-05-20 18:10   ` Elena Zannoni
  2002-05-22  7:52     ` Michal Ludvig
  0 siblings, 1 reply; 4+ messages in thread
From: Elena Zannoni @ 2002-05-20 18:10 UTC (permalink / raw)
  To: Michal Ludvig; +Cc: gdb-patches

Michal Ludvig writes:
 > Michal Ludvig wrote:
 > > Hi all,
 > > these changes will allow backtrace even through objects without 
 > > debug_frame section. Note that gcc must produce all information 
 > > necessary in eh_frame (perhaps -fasynchronous-unwind-tables flag?).
 > > 
 > > 2002-05-14  Michal Ludvig  <mludvig@suse.cz>
 > >         * dwarf2cfi.c (frame_state_for): Added safety check for a valid
 > >         fde->cie_ptr.
 > >         (dwarf2_build_frame_info): Added handling for eh_frame.
 > 
 > I have slightly rewritten finding the appropriate CIE for a given FDE so 
 > that it counts with multiple objfiles now.
 > 
 > Any comments? Can I commit?
 > 
 > Michal Ludvig
 > -- 
 > * SuSE CR, s.r.o     * mludvig@suse.cz
 > * +420 2 9654 5373   * http://www.suse.cz
 > Index: dwarf2cfi.c
 > ===================================================================
 > RCS file: /cvs/src/src/gdb/dwarf2cfi.c,v
 > retrieving revision 1.5
 > diff -c -3 -p -r1.5 dwarf2cfi.c
 > *** dwarf2cfi.c	14 May 2002 08:24:26 -0000	1.5
 > --- dwarf2cfi.c	15 May 2002 13:59:06 -0000
 > *************** frame_state_for (struct context *context
 > *** 802,812 ****
 >     context->args_size = 0;
 >     context->lsda = 0;
 >   
 > !   if ((fde = get_fde_for_addr (context->ra - 1)) != NULL)
 > !     {
 > !       fs->pc = fde->initial_location;
 >   
 >         cie = fde->cie_ptr;
 >         fs->code_align = cie->code_align;
 >         fs->data_align = cie->data_align;
 >         fs->retaddr_column = cie->ra;
 > --- 802,816 ----
 >     context->args_size = 0;
 >     context->lsda = 0;
 >   
 > !   if ((fde = get_fde_for_addr (context->ra - 1)) == NULL)
 > !     return;
 > !   

We shouldn't be using assignments inside conditions. Could you split
this up?

The rest is approved.

I have a general question about this file. There are basically no
comments in it, would it be possible to add something here and there
to help figure out what's going on?

Thanks
Elena


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

* Re: [RFA] eh_frame handling
  2002-05-20 18:10   ` Elena Zannoni
@ 2002-05-22  7:52     ` Michal Ludvig
  0 siblings, 0 replies; 4+ messages in thread
From: Michal Ludvig @ 2002-05-22  7:52 UTC (permalink / raw)
  To: Elena Zannoni; +Cc: gdb-patches

Elena Zannoni wrote:

> I have a general question about this file. There are basically no
> comments in it, would it be possible to add something here and there
> to help figure out what's going on?

Well, I'm in much the same position - I just knew there was a bug 
somewhere in this file but have never seen it before nor had anyone to 
ask about it. But I'll try to comment it as I'll explore it's internals.

Michal Ludvig
-- 
* SuSE CR, s.r.o     * mludvig@suse.cz
* +420 2 9654 5373   * http://www.suse.cz


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

end of thread, other threads:[~2002-05-22 13:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-14  9:01 [RFA] eh_frame handling Michal Ludvig
2002-05-15  7:02 ` Michal Ludvig
2002-05-20 18:10   ` Elena Zannoni
2002-05-22  7:52     ` Michal Ludvig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox