This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] Dwarf2 fix
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