[PATCH] mips-tdep.c: Fix bug introduced at time of NUM_REGS multiarch
Andrew Cagney
ac131313@redhat.com
Mon Jan 6 14:24:00 GMT 2003
> I've just committed the patch below. As noted in the subject, it fixes
> a bug that was introduced when I multiarched NUM_REGS a short time ago.
>
> * mips-tdep.c (heuristic_proc_desc): Clear memory associated with
> ``temp_saved_regs'', not the pointer or other storage contiguous
> to this pointer.
>
> Index: mips-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/mips-tdep.c,v
> retrieving revision 1.147
> diff -u -p -r1.147 mips-tdep.c
> --- mips-tdep.c 13 Dec 2002 18:09:30 -0000 1.147
> +++ mips-tdep.c 21 Dec 2002 06:31:58 -0000
> @@ -2142,7 +2142,7 @@ heuristic_proc_desc (CORE_ADDR start_pc,
> return NULL;
> memset (&temp_proc_desc, '\0', sizeof (temp_proc_desc));
> temp_saved_regs = xrealloc (temp_saved_regs, SIZEOF_FRAME_SAVED_REGS);
> - memset (&temp_saved_regs, '\0', SIZEOF_FRAME_SAVED_REGS);
> + memset (temp_saved_regs, '\0', SIZEOF_FRAME_SAVED_REGS);
> PROC_LOW_ADDR (&temp_proc_desc) = start_pc;
> PROC_FRAME_REG (&temp_proc_desc) = SP_REGNUM;
> PROC_PC_REG (&temp_proc_desc) = RA_REGNUM;
Outch!
BTW, it isn't as bad as:
memcpy (&frame->saved_regs, new_regs, sizeof (frame->saved_regs));
which has been cloned a number of times and now appears in multiple
targets. (frame->saved_regs is a pointer to the buffer).
good catch,
Andrew
More information about the Gdb-patches
mailing list