From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27923 invoked by alias); 11 Oct 2011 06:40:48 -0000 Received: (qmail 27864 invoked by uid 22791); 11 Oct 2011 06:40:46 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,TW_EG X-Spam-Check-By: sourceware.org Received: from shards.monkeyblade.net (HELO shards.monkeyblade.net) (198.137.202.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 11 Oct 2011 06:40:32 +0000 Received: from localhost (cpe-66-65-61-233.nyc.res.rr.com [66.65.61.233]) (authenticated bits=0) by shards.monkeyblade.net (8.14.4/8.14.4) with ESMTP id p9B6eSNm015926 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 10 Oct 2011 23:40:31 -0700 Date: Tue, 11 Oct 2011 06:40:00 -0000 Message-Id: <20111011.024027.2269565520682513251.davem@davemloft.net> To: gdb-patches@sourceware.org Subject: [PATCH] Fix regcache_restore() handling of unavailable regs. From: David Miller Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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: 2011-10/txt/msg00296.txt.bz2 Across inferior dummy calls, regcache entries which were "unavailable" were restored incorrectly after such dummy calls. The problem is incorrect interpretation of cooked_read()'s return value in regcache_restore(). Ok to commit? BTW, regcache_restore() seems to not be used outside of regcache.c any more. We should probably mark it static and remove the extern from regcache.h gdb/ * regcache.c (regcache_restore): Do not write unavailable regs. diff --git a/gdb/regcache.c b/gdb/regcache.c index 37092f8..3fb6811 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -351,9 +351,10 @@ regcache_restore (struct regcache *dst, { if (gdbarch_register_reggroup_p (gdbarch, regnum, restore_reggroup)) { - int valid = cooked_read (cooked_read_context, regnum, buf); + enum register_status status; - if (valid) + status = cooked_read (cooked_read_context, regnum, buf); + if (status == REG_VALID) regcache_cooked_write (dst, regnum, buf); } }