From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1217 invoked by alias); 14 Jun 2002 19:44:35 -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 1206 invoked from network); 14 Jun 2002 19:44:34 -0000 Received: from unknown (HELO cygnus.com) (205.180.83.203) by sources.redhat.com with SMTP; 14 Jun 2002 19:44:34 -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 MAA16186; Fri, 14 Jun 2002 12:44:28 -0700 (PDT) Received: from localhost (localhost.fidalgo.net [127.0.0.1]) by theotherone.redhat-remotie.org (Postfix) with ESMTP id C548BBB410; Fri, 14 Jun 2002 12:44:43 -0700 (PDT) Date: Fri, 14 Jun 2002 12:44:00 -0000 From: Don Howard X-X-Sender: To: Kevin Buettner Cc: Subject: Re: [Patch] Another small memattr fix. In-Reply-To: <1020614182844.ZM24445@localhost.localdomain> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2002-06/txt/msg00247.txt.bz2 On Fri, 14 Jun 2002, Kevin Buettner wrote: > Don, > > Could you explain this change in more detail? > > > - if (lo >= hi) > > + if (lo > hi-1) > > I.e, with the exception of the boundary conditions (max int, min int), > aren't these two equivalent when lo and hi are integers? > Yes they are equivalent -- I was trying to address the boundary conditions. (Obviously this approch is wrong, wrong, wrong) Memory regions are specified with an inclusive lower bound and an exclusive upper bound, so mem 0 4 wo mem 4 8 ro means that addresses 0x0, 0x1, 0x2, 0x3 are writable and 0x4, 0x5, 0x6 0x7 are readable. The exclusive upper bound causes trouble when trying to address max int, as it wraps : (Assuming 32 bit addresses) mem 0xfffffff0 0x100000000 ==> 0xfffffff0 0x0 /* woops */ The strings are arbitrary expressions and are converted to address via parse_and_eval_address(), which does not flag overflow: mem_command (char *args, int from_tty) { CORE_ADDR lo, hi; char *tok; struct mem_attrib attrib; if (!args) error_no_arg ("No mem"); tok = strtok (args, " \t"); if (!tok) error ("no lo address"); lo = parse_and_eval_address (tok); tok = strtok (NULL, " \t"); if (!tok) error ("no hi address"); hi = parse_and_eval_address (tok); mabe parse_and_eval_address could detect overflow and throw an error(). Another possiblity is that the interface could be changed, making the upper bound inclusive also. Any preferences? -- dhoward@redhat.com gdb engineering