From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32631 invoked by alias); 6 Aug 2004 23:43:29 -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 32624 invoked from network); 6 Aug 2004 23:43:28 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 6 Aug 2004 23:43:28 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i76NhSe1021771 for ; Fri, 6 Aug 2004 19:43:28 -0400 Received: from zenia.home.redhat.com (porkchop.devel.redhat.com [172.16.58.2]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i76NhPa04166; Fri, 6 Aug 2004 19:43:26 -0400 To: "Nathan J. Williams" Cc: gdb-patches@sources.redhat.com Subject: Re: RFA: assert that target_fetch_registers did its job References: From: Jim Blandy Date: Fri, 06 Aug 2004 23:43:00 -0000 In-Reply-To: Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004-08/txt/msg00189.txt.bz2 "Nathan J. Williams" writes: > Jim Blandy writes: > > > Does anyone see anything wrong with this? Should it be an error, or a > > warning, instead of an internal error? It seems to me that the error > > should be furnished by the target-specific code; if > > target_fetch_registers returns silently, it should have done its job. > > I noticed that "info reg" tripped over this with the BSD KVM target, > because the KVM backend only loads in the registers that are present > in the PCB. Should the KVM backend be zeroing out everything else > explicitly (is there a regcache call to do the wipe for us)? Silently supplying dummy register contents is confusing to developers and users. That just seems uncool. There's no way to return an 'unavailable' indication from the regcache cooked read functions. And there are so many clients of that interface it might be hard to introduce such an indication. (Although most of the uses are in -tdep.c files; the only real use in core code is in sentinal_frame_prev_register, which does have a way to return 'unavailable'. Hmm.) Throwing an error would interrupt the register listing, even if later registers were available. So that leaves printing a warning message and supplying a dummy value. Perhaps another option would be something like the below: it informs users that things are not as they seem, and encourages developers to fix up their targets. Comments? 2004-08-06 Jim Blandy * regcache.c (regcache_raw_read): Replace assertion with a warning message. Index: gdb/regcache.c =================================================================== RCS file: /cvs/src/src/gdb/regcache.c,v retrieving revision 1.125 diff -c -p -r1.125 regcache.c *** gdb/regcache.c 4 Aug 2004 17:50:55 -0000 1.125 --- gdb/regcache.c 6 Aug 2004 23:42:56 -0000 *************** regcache_raw_read (struct regcache *regc *** 614,620 **** } if (!register_cached (regnum)) target_fetch_registers (regnum); ! gdb_assert (register_cached (regnum)); } /* Copy the value directly into the register cache. */ memcpy (buf, register_buffer (regcache, regnum), --- 614,649 ---- } if (!register_cached (regnum)) target_fetch_registers (regnum); ! ! /* FIXME: jimb/2004-08-06: Ideally, this would just be an ! assert: target_fetch_registers should either throw an error, ! or print a warning and furnish dummy register contents. But ! it should never say "okay" without actually supplying the ! register. ! ! But in reality, there are a lot of arch / target combinations ! where the arch's regset has grown beyond what the target ! actually supplies. Having GDB crash is too disruptive, but ! silently using uninitialized bits is misleading as well. ! ! So this warning is here to prompt people to work on their ! targets and get the mismatches sorted out, and to warn users ! that they're not getting real data. */ ! if (! register_cached (regnum)) ! { ! struct gdbarch *arch = get_regcache_arch (regcache); ! const char *name = gdbarch_register_name (arch, regnum); ! ! if (name) ! warning ("unable to retrieve contents of raw register '%s' (#%d).", ! name, regnum); ! else ! warning ("unable to retrieve contents of raw register #%d.", ! regnum); ! ! memset (register_buffer (regcache, regnum), 0xff, ! regcache->descr->sizeof_register[regnum]); ! } } /* Copy the value directly into the register cache. */ memcpy (buf, register_buffer (regcache, regnum),