From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25605 invoked by alias); 8 Aug 2012 10:31:08 -0000 Received: (qmail 25593 invoked by uid 22791); 8 Aug 2012 10:31:07 -0000 X-SWARE-Spam-Status: No, hits=-4.4 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 08 Aug 2012 10:30:53 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1Sz3XQ-0004br-Vb from Yao_Qi@mentor.com ; Wed, 08 Aug 2012 03:30:53 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 8 Aug 2012 03:30:52 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.1.289.1; Wed, 8 Aug 2012 03:30:51 -0700 From: Yao Qi To: CC: Wei-cheng Wang Subject: Re: [PATCH] Fix memory-region overlapping checking Date: Wed, 08 Aug 2012 10:31:00 -0000 Message-ID: <1450628.xUgDUToN8c@qiyao.dyndns.org> User-Agent: KMail/4.8.3 (Linux/3.3.7-1.fc16.i686; KDE/4.8.3; i686; ; ) In-Reply-To: References: <1591920.sFon8Oz8ME@qiyao.dyndns.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-08/txt/msg00251.txt.bz2 Wei-cheng, Thanks for writing a test. Some comments below, On Tuesday, August 07, 2012 02:01:59 PM Wei-cheng Wang wrote: > + > +# > +# Test overlapping checking > +# > +# lo' hi' > +# |---------| > +# 10 20 30 40 50 60 70 80 > +# |----| FAIL > +# |---| FAIL > +# |----| FAIL > +# |-------------| FAIL > +# |----| PASS > +# |----| PASS > + > +proc delete_memory {} { > + global gdb_prompt > + > + send_gdb "delete mem\n" > + gdb_expect 100 { > + -re "Delete all memory regions.*y or n.*$" { > + send_gdb "y\n"; > + exp_continue > + } > + -re "$gdb_prompt $" { } > + } We can use gdb_test_multiple here. > +} > + > +# Test normal case (upper !=3D 0) > +delete_memory > +send_gdb "mem 0x30 0x60 ro\n"; gdb_expect -re "$gdb_prompt $" We can use gdb_test_no_output "mem 0x30 0x60 ro" > +gdb_test "mem 0x20 0x40 ro" "overlapping memory region" > +gdb_test "mem 0x40 0x50 ro" "overlapping memory region" > +gdb_test "mem 0x50 0x70 ro" "overlapping memory region" > +gdb_test_no_output "mem 0x10 0x30 ro" > +gdb_test_no_output "mem 0x60 0x80 ro" > + > +# Test sepcial case (upper =3D=3D 0) ^^^^^^^ typo "special" > +delete_memory > +send_gdb "mem 0x30 0x0 ro\n"; gdb_expect -re "$gdb_prompt $" gdb_test_no_output > +gdb_test "mem 0x20 0x40 ro" "overlapping memory region" > +gdb_test "mem 0x40 0x50 ro" "overlapping memory region" > +gdb_test "mem 0x50 0x70 ro" "overlapping memory region" > +gdb_test_no_output "mem 0x10 0x30 ro" the test result in summary is *not* unique, $ cat testsuite/gdb.sum | grep "PASS" | sort | uniq -c | sort -n .... 2 PASS: gdb.base/memattr.exp: mem 0x20 0x40 ro 2 PASS: gdb.base/memattr.exp: mem 0x40 0x50 ro 2 PASS: gdb.base/memattr.exp: mem 0x50 0x70 ro See more about this rule here=20 http://sourceware.org/gdb/wiki/GDBTestcaseCookbook#Make_sure_test_messages_= are_unique Below is a new one fixed all the issues in your original patch. What do yo= u=20 think? Without your fix, the new test exposes a fail, FAIL: gdb.base/memattr.exp: 0x10 0x30 2 and fail is fixed with the patch applied. --=20 Yao (=E9=BD=90=E5=B0=A7) 2012-08-08 Wei-cheng Wang Yao Qi * gdb.base/memattr.exp: Add cases for overlapping checking. diff --git INDEX:/gdb/testsuite/gdb.base/memattr.exp=20 --- INDEX:/gdb/testsuite/gdb.base/memattr.exp +++ WORKDIR:/gdb/testsuite/gdb.base/memattr.exp @@ -448,3 +448,45 @@ gdb_test_multiple "info mem" "mem 2-4 were deleted" { =20 gdb_test "delete mem 8" "No memory region number 8." \ "delete non-existant region" + +# +# Test overlapping checking +# +# lo' hi' +# |---------| +# 10 20 30 40 50 60 70 80 +# |----| FAIL +# |---| FAIL +# |----| FAIL +# |-------------| FAIL +# |----| PASS +# |----| PASS + +proc delete_memory {} { + global gdb_prompt + + gdb_test_multiple "delete mem" "delete mem" { + -re "Delete all memory regions.*y or n.*$" { + send_gdb "y\n"; + exp_continue + } + -re "$gdb_prompt $" { } + } +} + +# Test normal case (upper !=3D 0) +delete_memory +gdb_test_no_output "mem 0x30 0x60 ro" +gdb_test "mem 0x20 0x40 ro" "overlapping memory region" "0x20 0x40 1" +gdb_test "mem 0x40 0x50 ro" "overlapping memory region" "0x40 0x50 1" +gdb_test "mem 0x50 0x70 ro" "overlapping memory region" "0x50 0x70 1" +gdb_test_no_output "mem 0x10 0x30 ro" "0x10 0x30 1" +gdb_test_no_output "mem 0x60 0x80 ro" + +# Test special case (upper =3D=3D 0) +delete_memory +gdb_test_no_output "mem 0x30 0x0 ro" +gdb_test "mem 0x20 0x40 ro" "overlapping memory region" "0x20 0x40 2" +gdb_test "mem 0x40 0x50 ro" "overlapping memory region" "0x40 0x50 2" +gdb_test "mem 0x50 0x70 ro" "overlapping memory region" "0x50 0x70 2" +gdb_test_no_output "mem 0x10 0x30 ro" "0x10 0x30 2"