This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] Dwarf2 fix
- From: Michal Ludvig <mludvig at suse dot cz>
- To: Andreas Jaeger <aj at suse dot de>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Mon, 13 May 2002 19:04:05 +0200
- Subject: Re: [RFA] Dwarf2 fix
- Organization: SuSE CR
- References: <3CDFEA7C.7050104@suse.cz> <hor8kgm210.fsf@gee.suse.de>
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