From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29414 invoked by alias); 7 Aug 2012 06:02:15 -0000 Received: (qmail 29405 invoked by uid 22791); 7 Aug 2012 06:02:13 -0000 X-SWARE-Spam-Status: No, hits=-4.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-qc0-f169.google.com (HELO mail-qc0-f169.google.com) (209.85.216.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 07 Aug 2012 06:02:00 +0000 Received: by qcsd16 with SMTP id d16so2516482qcs.0 for ; Mon, 06 Aug 2012 23:01:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.58.33.234 with SMTP id u10mr11241641vei.49.1344319319656; Mon, 06 Aug 2012 23:01:59 -0700 (PDT) Received: by 10.220.106.204 with HTTP; Mon, 6 Aug 2012 23:01:59 -0700 (PDT) In-Reply-To: <1591920.sFon8Oz8ME@qiyao.dyndns.org> References: <3535463.LDgPnkid6y@qiyao.dyndns.org> <1591920.sFon8Oz8ME@qiyao.dyndns.org> Date: Tue, 07 Aug 2012 06:02:00 -0000 Message-ID: Subject: Re: [PATCH] Fix memory-region overlapping checking From: Wei-cheng Wang To: Yao Qi Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=UTF-8 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/msg00209.txt.bz2 Hi, Here are the fix with test cases. 2012-08-08 Wei-cheng Wang * memattr.c: Fix memory region overlapping checking --- diff --git a/gdb/memattr.c b/gdb/memattr.c index ec7deb5..5396138 100644 --- a/gdb/memattr.c +++ b/gdb/memattr.c @@ -207,7 +207,7 @@ create_mem_region (CORE_ADDR lo, CORE_ADDR hi, if ((lo >= n->lo && (lo < n->hi || n->hi == 0)) || (hi > n->lo && (hi <= n->hi || n->hi == 0)) - || (lo <= n->lo && (hi >= n->hi || hi == 0))) + || (lo <= n->lo && ((hi >= n->hi && n->hi != 0)|| hi == 0))) { printf_unfiltered (_("overlapping memory region\n")); return; -- 2012-08-08 Wei-cheng Wang * gdb.base/memattr.exp: Add cases for overlapping checking. --- diff --git a/gdb/testsuite/gdb.base/memattr.exp b/gdb/testsuite/gdb.base/memattr.exp index 4065808..f491b60 100644 --- a/gdb/testsuite/gdb.base/memattr.exp +++ b/gdb/testsuite/gdb.base/memattr.exp @@ -448,3 +448,46 @@ gdb_test_multiple "info mem" "mem 2-4 were deleted" { 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 + + 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 $" { } + } +} + +# Test normal case (upper != 0) +delete_memory +send_gdb "mem 0x30 0x60 ro\n"; gdb_expect -re "$gdb_prompt $" +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 == 0) +delete_memory +send_gdb "mem 0x30 0x0 ro\n"; gdb_expect -re "$gdb_prompt $" +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" --