Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Dwarf2 fix
@ 2002-05-13  9:31 Michal Ludvig
  2002-05-13  9:43 ` Andreas Jaeger
  0 siblings, 1 reply; 8+ messages in thread
From: Michal Ludvig @ 2002-05-13  9:31 UTC (permalink / raw)
  To: gdb-patches

Hi all,
this simple patch mysteriously solves problems that we have had on 
x86-64 with stack unwinding. Can I commit? I believe so :-)

2002-05-13  Michal Ludvig  <mludvig@suse.cz>
         * dwarf2cfi.c (context_cpy): Copy registers correctly.
         (update_context): Use __func__ in notes.

Index: dwarf2cfi.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2cfi.c,v
retrieving revision 1.4
diff -c -3 -p -r1.4 dwarf2cfi.c
*** dwarf2cfi.c 7 May 2002 11:22:54 -0000       1.4
--- dwarf2cfi.c 13 May 2002 16:24:00 -0000
*************** static void
*** 318,325 ****
--- 318,329 ----
   context_cpy (struct context *dst, struct context *src)
   {
     int regs_size = sizeof (struct context_reg) * NUM_REGS;
+   struct context_reg *dreg;

+   dreg = dst->reg;
     *dst = *src;
+   dst->reg = dreg;
+
     memcpy (dst->reg, src->reg, regs_size);
   }
   ^L
*************** update_context (struct context *context,
*** 1301,1307 ****
               orig_context->reg[fs->regs.reg[i].loc.reg].loc.addr;
           default:
             internal_error (__FILE__, __LINE__,
!              "cfi_update_context: unknown register rule");
           }
         break;
         case REG_SAVED_EXP:
--- 1305,1311 ----
               orig_context->reg[fs->regs.reg[i].loc.reg].loc.addr;
           default:
             internal_error (__FILE__, __LINE__,
!              "%s: unknown register rule", __func__);
           }
         break;
         case REG_SAVED_EXP:
*************** update_context (struct context *context,
*** 1319,1326 ****
         break;
         default:
         internal_error (__FILE__, __LINE__,
!          "cfi_update_context: unknown register rule");
!
         }
     get_reg ((char *) &context->ra, context, fs->retaddr_column);
     unwind_tmp_obstack_free ();
--- 1323,1329 ----
         break;
         default:
         internal_error (__FILE__, __LINE__,
!          "%s: unknown register rule", __func__);
         }
     get_reg ((char *) &context->ra, context, fs->retaddr_column);
     unwind_tmp_obstack_free ();


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


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

* Re: [RFA] Dwarf2 fix
  2002-05-13  9:31 [RFA] Dwarf2 fix Michal Ludvig
@ 2002-05-13  9:43 ` Andreas Jaeger
  2002-05-13 10:04   ` Michal Ludvig
  2002-05-23 19:29   ` Andrew Cagney
  0 siblings, 2 replies; 8+ messages in thread
From: Andreas Jaeger @ 2002-05-13  9:43 UTC (permalink / raw)
  To: Michal Ludvig; +Cc: gdb-patches

Michal Ludvig <mludvig@suse.cz> writes:

> Hi all,
> this simple patch mysteriously solves problems that we have had on
> x86-64 with stack unwinding. Can I commit? I believe so :-)

What about committing to the 5.2 branch?  Is a 5.2.1 planned?


>
> 2002-05-13  Michal Ludvig  <mludvig@suse.cz>
>          * dwarf2cfi.c (context_cpy): Copy registers correctly.
>          (update_context): Use __func__ in notes.
>
> Index: dwarf2cfi.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/dwarf2cfi.c,v
> retrieving revision 1.4
> diff -c -3 -p -r1.4 dwarf2cfi.c
> *** dwarf2cfi.c 7 May 2002 11:22:54 -0000       1.4
> --- dwarf2cfi.c 13 May 2002 16:24:00 -0000
> *************** static void
> *** 318,325 ****
> --- 318,329 ----
>    context_cpy (struct context *dst, struct context *src)
>    {
>      int regs_size = sizeof (struct context_reg) * NUM_REGS;
> +   struct context_reg *dreg;
>
> +   dreg = dst->reg;
>      *dst = *src;
> +   dst->reg = dreg;
> +

Can you add a comment here, why this is needed?

>      memcpy (dst->reg, src->reg, regs_size);

>    }
>[...]

Thanks,
Andreas
-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj


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

* Re: [RFA] Dwarf2 fix
  2002-05-13  9:43 ` Andreas Jaeger
@ 2002-05-13 10:04   ` Michal Ludvig
  2002-05-13 10:21     ` Andreas Jaeger
  2002-05-23 19:29   ` Andrew Cagney
  1 sibling, 1 reply; 8+ messages in thread
From: Michal Ludvig @ 2002-05-13 10:04 UTC (permalink / raw)
  To: Andreas Jaeger; +Cc: gdb-patches

Andreas Jaeger wrote:
> Michal Ludvig <mludvig@suse.cz> writes:

>>   context_cpy (struct context *dst, struct context *src)
>>   {
>>     int regs_size = sizeof (struct context_reg) * NUM_REGS;
>>+   struct context_reg *dreg;
>>
>>+   dreg = dst->reg;
>>     *dst = *src;
>>+   dst->reg = dreg;
>>+
>>     memcpy (dst->reg, src->reg, regs_size);
>>   }

 > Can you add a comment here, why this is needed?

Structure dst contains a pointer to an array of registers of a given 
frame as well as src does. This array was already allocated before dst 
was passed to context_cpy but the pointer to it was overriden by
'*dst = *src' and the array was lost. This led to the situation, that 
I've had a copy of src placed in dst, but both of them pointed to the 
same regs array and thus I've sometimes blindly rewritten it.
Now I save the pointer before I copy src to dst, return it back after 
that and copy the registers into their new place finally.

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


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

* Re: [RFA] Dwarf2 fix
  2002-05-13 10:04   ` Michal Ludvig
@ 2002-05-13 10:21     ` Andreas Jaeger
  2002-05-13 10:32       ` Michal Ludvig
  0 siblings, 1 reply; 8+ messages in thread
From: Andreas Jaeger @ 2002-05-13 10:21 UTC (permalink / raw)
  To: Michal Ludvig; +Cc: gdb-patches

Michal Ludvig <mludvig@suse.cz> writes:

> Andreas Jaeger wrote:
>> Michal Ludvig <mludvig@suse.cz> writes:
>
>>>   context_cpy (struct context *dst, struct context *src)
>>>   {
>>>     int regs_size = sizeof (struct context_reg) * NUM_REGS;
>>>+   struct context_reg *dreg;
>>>
>>>+   dreg = dst->reg;
>>>     *dst = *src;
>>>+   dst->reg = dreg;
>>>+
>>>     memcpy (dst->reg, src->reg, regs_size);
>>>   }
>
>  > Can you add a comment here, why this is needed?
>
> Structure dst contains a pointer to an array of registers of a given
> frame as well as src does. This array was already allocated before dst
> was passed to context_cpy but the pointer to it was overriden by
> '*dst = *src' and the array was lost. This led to the situation, that
> I've had a copy of src placed in dst, but both of them pointed to the
> same regs array and thus I've sometimes blindly rewritten it.
> Now I save the pointer before I copy src to dst, return it back after
> that and copy the registers into their new place finally.

thanks for the explanation.  I wanted to see a comment in the code...

Andreas
-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj


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

* Re: [RFA] Dwarf2 fix
  2002-05-13 10:21     ` Andreas Jaeger
@ 2002-05-13 10:32       ` Michal Ludvig
  2002-05-13 14:10         ` Andrew Cagney
  0 siblings, 1 reply; 8+ messages in thread
From: Michal Ludvig @ 2002-05-13 10:32 UTC (permalink / raw)
  To: gdb-patches

Andreas Jaeger wrote:
> thanks for the explanation.  I wanted to see a comment in the code...

I see :-))

static void
context_cpy (struct context *dst, struct context *src)
{
   int regs_size = sizeof (struct context_reg) * NUM_REGS;
   struct context_reg *dreg;

   /* Save a pointer to an already allocated dst->reg
      before overriding dst by src.  */
   dreg = dst->reg;
   *dst = *src;
   dst->reg = dreg;

   memcpy (dst->reg, src->reg, regs_size);
}

Better now? ;-)

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


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

* Re: [RFA] Dwarf2 fix
  2002-05-13 10:32       ` Michal Ludvig
@ 2002-05-13 14:10         ` Andrew Cagney
  2002-05-14  3:02           ` Michal Ludvig
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Cagney @ 2002-05-13 14:10 UTC (permalink / raw)
  To: Michal Ludvig; +Cc: gdb-patches

> 
>   /* Save a pointer to an already allocated dst->reg
>      before overriding dst by src.  */

Can I suggest the entire paragraph you posted - better to much than too 
little information (well at least in the case of GDB :-).

enjoy,
Andrew




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

* Re: [RFA] Dwarf2 fix
  2002-05-13 14:10         ` Andrew Cagney
@ 2002-05-14  3:02           ` Michal Ludvig
  0 siblings, 0 replies; 8+ messages in thread
From: Michal Ludvig @ 2002-05-14  3:02 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches

Andrew Cagney wrote:
>>
>>   /* Save a pointer to an already allocated dst->reg
>>      before overriding dst by src.  */
> Can I suggest the entire paragraph you posted - better to much than too 
> little information (well at least in the case of GDB :-).

OK, Comitted to both mainline and branch with with the long description.

> enjoy,
> Andrew


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


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

* Re: [RFA] Dwarf2 fix
  2002-05-13  9:43 ` Andreas Jaeger
  2002-05-13 10:04   ` Michal Ludvig
@ 2002-05-23 19:29   ` Andrew Cagney
  1 sibling, 0 replies; 8+ messages in thread
From: Andrew Cagney @ 2002-05-23 19:29 UTC (permalink / raw)
  To: Andreas Jaeger; +Cc: Michal Ludvig, gdb-patches

> Michal Ludvig <mludvig@suse.cz> writes:
> 
> 
>> Hi all,
>> this simple patch mysteriously solves problems that we have had on
>> x86-64 with stack unwinding. Can I commit? I believe so :-)
> 
> 
> What about committing to the 5.2 branch?  Is a 5.2.1 planned?

Probably.  Decide in a few weeks once it is clear how many patches the 
branch has accumulated.

BTW, I think there are already sufficient changes in the trunk to 
warrent a 5.3 release.

enjoy,
Andrew



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

end of thread, other threads:[~2002-05-24  2:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-13  9:31 [RFA] Dwarf2 fix Michal Ludvig
2002-05-13  9:43 ` Andreas Jaeger
2002-05-13 10:04   ` Michal Ludvig
2002-05-13 10:21     ` Andreas Jaeger
2002-05-13 10:32       ` Michal Ludvig
2002-05-13 14:10         ` Andrew Cagney
2002-05-14  3:02           ` Michal Ludvig
2002-05-23 19:29   ` Andrew Cagney

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