This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC, PATCH] gdb/arm-tdep.c: Add sanity check on fp before trying to, access memory.
- From: Will Newton <will dot newton at linaro dot org>
- To: gdb-patches at sourceware dot org
- Cc: Patch Tracking <patches at linaro dot org>
- Date: Fri, 24 May 2013 15:32:49 +0100
- Subject: Re: [RFC, PATCH] gdb/arm-tdep.c: Add sanity check on fp before trying to, access memory.
- References: <5195EE16 dot 9020700 at linaro dot org>
Ping?
I'm not sure if this is the right approach to the problem, but if
anyone has any better ideas I would be interested.
Thanks,
On 17 May 2013 09:45, Will Newton <will.newton@linaro.org> wrote:
>
> Add a sanity check on the frame pointer before trying to access memory. The
> check aims to prevent a "Cannot access memory at address" error being printed
> when the frame pointer is zero or otherwise below the current sp. This only
> affects the case where no symbols are available and has been seen with the
> KVM debug stub. The frame pointer is read every time the frame_id is
> requested so something as simple as "print $pc" can cause an error to be
> printed.
>
> No new testsuite failures configured with armv7l-unknown-linux-gnueabihf.
>
> gdb/ChangeLog:
>
> 2013-05-17 Will Newton <will.newton@linaro.org>
>
> * arm-tdep.c (arm_scan_prologue): Check the frame pointer looks
> valid by comparing to current sp before reading it.
> ---
> gdb/arm-tdep.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
> index b169e35..162aea8 100644
> --- a/gdb/arm-tdep.c
> +++ b/gdb/arm-tdep.c
> @@ -1979,10 +1979,15 @@ arm_scan_prologue (struct frame_info *this_frame,
> Then, we can find the value of our frame pointer on entrance to
> the callee (or at the present moment if this is the innermost frame).
> The value stored there should be the address of the stmfd + 8. */
> - CORE_ADDR frame_loc;
> + CORE_ADDR frame_loc, current_sp;
> LONGEST return_value;
>
> frame_loc = get_frame_register_unsigned (this_frame, ARM_FP_REGNUM);
> + current_sp = get_frame_register_unsigned (this_frame, ARM_SP_REGNUM);
> +
> + /* Sanity check frame pointer. */
> + if (frame_loc < current_sp)
> + return;
> if (!safe_read_memory_integer (frame_loc, 4, byte_order, &return_value))
> return;
> else
> --
> 1.8.1.4
>
--
Will Newton
Toolchain Working Group, Linaro