From patchwork Wed May 28 05:23:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 1180 Received: (qmail 9837 invoked by alias); 28 May 2014 05:26:30 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 9826 invoked by uid 89); 28 May 2014 05:26:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 May 2014 05:26:28 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1WpWNd-0006VM-7W from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Tue, 27 May 2014 22:26:25 -0700 Received: from SVR-ORW-FEM-06.mgc.mentorg.com ([147.34.97.120]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 27 May 2014 22:26:25 -0700 Received: from qiyao.dyndns.org.com (147.34.91.1) by SVR-ORW-FEM-06.mgc.mentorg.com (147.34.97.120) with Microsoft SMTP Server id 14.2.247.3; Tue, 27 May 2014 22:26:23 -0700 From: Yao Qi To: Subject: [PATCH] Skip test 'watch -location nullptr->p->x' if null pointer can be dereferenced Date: Wed, 28 May 2014 13:23:51 +0800 Message-ID: <1401254631-11264-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes gdb.base/watchpoint.exp has a test below which expects to see "Cannot access memory at address 0x0" when a null pointer is dereferenced. gdb_test "watch -location nullptr->p->x" \ "Cannot access memory at address 0x0" This assumption is not true when the target is no-mmu, so we get watch -location nullptr->p->x Hardware watchpoint 28: -location nullptr->p->x (gdb) FAIL: gdb.base/watchpoint.exp: watch -location nullptr->p->x This patch is to check whether null pointer can be dereferenced first and the then do the test. gdb/testsuite: 2014-05-28 Yao Qi * gdb.base/watchpoint.exp (test_watch_location): Check null pointer can be dereferenced. If not, do the test, otherwise skip it. --- gdb/testsuite/gdb.base/watchpoint.exp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp index 1123824..c41b4fd 100644 --- a/gdb/testsuite/gdb.base/watchpoint.exp +++ b/gdb/testsuite/gdb.base/watchpoint.exp @@ -595,11 +595,21 @@ proc test_disable_enable_software_watchpoint {} { } proc test_watch_location {} { + global gdb_prompt + gdb_breakpoint [gdb_get_line_number "func5 breakpoint here"] gdb_continue_to_breakpoint "func5 breakpoint here" - gdb_test "watch -location nullptr->p->x" \ - "Cannot access memory at address 0x0" + # Check first if a null pointer can be dereferenced on the target. + gdb_test_multiple "p *nullptr" "" { + -re "Cannot access memory at address 0x0.*$gdb_prompt $" { + gdb_test "watch -location nullptr->p->x" \ + "Cannot access memory at address 0x0" + } + -re ".*$gdb_prompt $" { + # Null pointer dereference is legitimate. + } + } gdb_test "watch -location *x" "atchpoint .*: .*" "watch -location .x"