From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31841 invoked by alias); 21 Jun 2002 20:50:27 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 31815 invoked from network); 21 Jun 2002 20:50:25 -0000 Received: from unknown (HELO cygnus.com) (205.180.83.203) by sources.redhat.com with SMTP; 21 Jun 2002 20:50:25 -0000 Received: from theotherone.redhat-remotie.org (romulus.sfbay.redhat.com [172.16.27.251]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id NAA04788 for ; Fri, 21 Jun 2002 13:50:24 -0700 (PDT) Received: from localhost (localhost.fidalgo.net [127.0.0.1]) by theotherone.redhat-remotie.org (Postfix) with ESMTP id 701CDBB29C for ; Fri, 21 Jun 2002 13:50:21 -0700 (PDT) Date: Fri, 21 Jun 2002 13:50:00 -0000 From: Don Howard X-X-Sender: To: Subject: [PATCH] memattr bounds Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2002-06/txt/msg00441.txt.bz2 The following addresses edge conditions in the mem command by making a special case for upper bound == 0. When the upper bound is zero, it is assumed that the user wants an upper bound of max CORE_ADDR+1. Currently, it's not possible to define a memory region with zero as it's upper bound, so this should not conflict with any current usage. The patch also corrects a bug that allowes the definition of overlapping memory regions, where the new region starts below an existing region and extends above it. (Or does someone think that is a feature?) 2002-06-21 Don Howard * memattr.c (create_mem_region): Treat hi == 0 as a special case that means max CORE_ADDR+1. (lookup_mem_region): Ditto. (mem_info_command): Ditto. Index: memattr.c =================================================================== RCS file: /cvs/src/src/gdb/memattr.c,v retrieving revision 1.11 diff -p -u -w -r1.11 memattr.c --- memattr.c 12 May 2002 04:20:05 -0000 1.11 +++ memattr.c 21 Jun 2002 20:47:15 -0000 @@ -47,7 +47,7 @@ create_mem_region (CORE_ADDR lo, CORE_AD struct mem_region *n, *new; /* lo == hi is a useless empty region */ - if (lo >= hi) + if (lo >= hi && hi != 0) { printf_unfiltered ("invalid memory region: low >= high\n"); return NULL; @@ -57,8 +57,9 @@ create_mem_region (CORE_ADDR lo, CORE_AD while (n) { /* overlapping node */ - if ((lo >= n->lo && lo < n->hi) || - (hi > n->lo && hi <= n->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))) { printf_unfiltered ("overlapping memory region\n"); return NULL; @@ -111,7 +112,7 @@ lookup_mem_region (CORE_ADDR addr) { if (m->enabled_p == 1) { - if (addr >= m->lo && addr < m->hi) + if (addr >= m->lo && (addr < m->hi || m->hi == 0)) return m; if (addr >= m->hi && lo < m->hi) @@ -246,9 +247,9 @@ mem_info_command (char *args, int from_t printf_filtered ("%s ", tmp); if (TARGET_ADDR_BIT <= 32) - tmp = local_hex_string_custom ((unsigned long) m->hi, "08l"); + tmp = local_hex_string_custom ((unsigned long) (m->hi ? m->hi : ~0), "08l"); else - tmp = local_hex_string_custom ((unsigned long) m->hi, "016l"); + tmp = local_hex_string_custom ((unsigned long) (m->hi ? m->hi : ~0), "016l"); printf_filtered ("%s ", tmp); -- dhoward@redhat.com gdb engineering