[RFA] Dwarf2 fix

Michal Ludvig mludvig@suse.cz
Mon May 13 10:04:00 GMT 2002


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



More information about the Gdb-patches mailing list