From patchwork Fri May 17 08:45:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 17011 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f72.google.com (mail-vb0-f72.google.com [209.85.212.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DF51F238F0 for ; Fri, 17 May 2013 08:45:56 +0000 (UTC) Received: by mail-vb0-f72.google.com with SMTP id q16sf3351444vbe.11 for ; Fri, 17 May 2013 01:45:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-beenthere:x-received:received-spf:x-received :x-forwarded-to:x-forwarded-for:delivered-to:x-received:received-spf :x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type:content-transfer-encoding; bh=I0FhveFmdmRT+PW4TIMb+sDPoOofDZMdXFxuujGImik=; b=ROzLx3wnwbC2Ewsr+XGCZQgdbFqkodgsl1kwyzCMACstXIA4Im27GVjm05ltouM/5l HQnHExczXfV/gBlkn8x6SbsMOPXKiISxB9+Kliwz2FHDcnqktjMPAXUOs6WSQ6H6q7/4 JGbYjZvIJ0HFsIf/doaD8qMAWrUojxrS2hGOE5Ru0YmiyFa2ROE0AW+uDQixOccX2EDM YrjSDKFY8ZYG9T8awcetyjlAAjm1R1yjASkoiiZEBisG5CNsszGkPrXlZa4V9C4I0uUR HWs4PUiRBwuup9ievv6suTNbtvDjFhyUgZNbp0y3/uaKfG/PS9Hewop8HvzlEEyZZ0Z1 ssBA== X-Received: by 10.224.130.195 with SMTP id u3mr27694551qas.1.1368780315409; Fri, 17 May 2013 01:45:15 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.14.195 with SMTP id r3ls1530958qec.63.gmail; Fri, 17 May 2013 01:45:15 -0700 (PDT) X-Received: by 10.52.117.7 with SMTP id ka7mr8248967vdb.109.1368780315282; Fri, 17 May 2013 01:45:15 -0700 (PDT) Received: from mail-vb0-x22e.google.com (mail-vb0-x22e.google.com [2607:f8b0:400c:c02::22e]) by mx.google.com with ESMTPS id zp6si5457647vdb.67.2013.05.17.01.45.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 May 2013 01:45:15 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::22e is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::22e; Received: by mail-vb0-f46.google.com with SMTP id 10so2049979vbe.5 for ; Fri, 17 May 2013 01:45:15 -0700 (PDT) X-Received: by 10.58.172.67 with SMTP id ba3mr29041967vec.58.1368780315082; Fri, 17 May 2013 01:45:15 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.126.138 with SMTP id c10csp99119vcs; Fri, 17 May 2013 01:45:14 -0700 (PDT) X-Received: by 10.204.168.201 with SMTP id v9mr14853527bky.116.1368780313713; Fri, 17 May 2013 01:45:13 -0700 (PDT) Received: from mail-bk0-x22d.google.com (mail-bk0-x22d.google.com [2a00:1450:4008:c01::22d]) by mx.google.com with ESMTPS id zn1si2705213bkb.265.2013.05.17.01.45.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 May 2013 01:45:13 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:4008:c01::22d is neither permitted nor denied by best guess record for domain of will.newton@linaro.org) client-ip=2a00:1450:4008:c01::22d; Received: by mail-bk0-f45.google.com with SMTP id je9so2212571bkc.18 for ; Fri, 17 May 2013 01:45:13 -0700 (PDT) X-Received: by 10.205.42.194 with SMTP id tz2mr15016867bkb.129.1368780312992; Fri, 17 May 2013 01:45:12 -0700 (PDT) Received: from localhost.localdomain (cpc11-seac20-2-0-cust84.7-2.cable.virginmedia.com. [81.108.156.85]) by mx.google.com with ESMTPSA id tc9sm2818218bkb.18.2013.05.17.01.45.11 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 17 May 2013 01:45:12 -0700 (PDT) Message-ID: <5195EE16.9020700@linaro.org> Date: Fri, 17 May 2013 09:45:10 +0100 From: Will Newton User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130402 Thunderbird/17.0.5 MIME-Version: 1.0 To: gdb-patches@sourceware.org CC: patches@linaro.org Subject: [RFC, PATCH] gdb/arm-tdep.c: Add sanity check on fp before trying to, access memory. X-Gm-Message-State: ALoCoQkNbDMQLVpR97DK77WGzp0hC18CiHvJum8qviLBocsfltXf6czoXOniXgLXs0o42mTt47ru X-Original-Sender: will.newton@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::22e is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 * 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