From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 801 invoked by alias); 12 Apr 2010 07:46:06 -0000 Received: (qmail 790 invoked by uid 22791); 12 Apr 2010 07:46:05 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=BAYES_00,TW_EG,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 12 Apr 2010 07:46:01 +0000 Received: (qmail 26414 invoked from network); 12 Apr 2010 07:45:58 -0000 Received: from unknown (HELO orlando.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 12 Apr 2010 07:45:58 -0000 From: Pedro Alves To: "H.J. Lu" Subject: Re: Fix solib-disc.exp regression with x86 gdbserver Date: Mon, 12 Apr 2010 07:46:00 -0000 User-Agent: KMail/1.12.2 (Linux/2.6.31-20-generic; KDE/4.3.2; x86_64; ; ) Cc: gdb-patches@sourceware.org References: <201004110252.35997.pedro@codesourcery.com> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201004120845.56101.pedro@codesourcery.com> 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: 2010-04/txt/msg00339.txt.bz2 On Sunday 11 April 2010 22:12:08, H.J. Lu wrote: > This patch breaks gdbserver on AVX. We have > > 1. Connect from GDB with XML support: > gdbserver enables XML support. > 2. Disconnect. > 3. Reconnect from any GDB > a. gdberver assumes GDB doesn't support XML sets to > target to Linux without AVX. > b. Gdbserver aborts when it tries to invalidate regcache > since the target doesn't support AVX registers. > > I will try to fix it. > Then, this means we're invalidating the regcache too late. We're flushing the old regcache contents to the threads, that were created using the previous gdb's register layout, but we're flushing the data using the _new_ register cache layout and low target methods. That sounds wrong indeed. I think this would help. Or is this still too late? -- Pedro Alves 2010-04-12 Pedro Alves gdb/gdbserver/ * regcache.c (set_register_cache): Invalidate regcaches before changing the register cache layout. (regcache_invalidate_one): Allow a NULL regcache. * linux-x86-low.c (x86_linux_update_xmltarget): Invalidate regcaches before changing the register cache layout or the target regsets. --- gdb/gdbserver/linux-x86-low.c | 5 +++++ gdb/gdbserver/regcache.c | 7 +++++++ 2 files changed, 12 insertions(+) Index: src/gdb/gdbserver/regcache.c =================================================================== --- src.orig/gdb/gdbserver/regcache.c 2010-04-12 08:03:43.000000000 +0100 +++ src/gdb/gdbserver/regcache.c 2010-04-12 08:20:23.000000000 +0100 @@ -61,6 +61,9 @@ regcache_invalidate_one (struct inferior regcache = (struct regcache *) inferior_regcache_data (thread); + if (regcache == NULL) + return; + if (regcache->registers_valid) { struct thread_info *saved_inferior = current_inferior; @@ -149,6 +152,10 @@ set_register_cache (struct reg *regs, in { int offset, i; + /* Before changing the register cache internal layout, flush the + contents of valid caches back to the threads. */ + regcache_invalidate (); + reg_defs = regs; num_registers = n; Index: src/gdb/gdbserver/linux-x86-low.c =================================================================== --- src.orig/gdb/gdbserver/linux-x86-low.c 2010-04-12 08:23:08.000000000 +0100 +++ src/gdb/gdbserver/linux-x86-low.c 2010-04-12 08:37:57.000000000 +0100 @@ -841,6 +841,11 @@ x86_linux_update_xmltarget (void) if (!current_inferior) return; + /* Before changing the register cache internal layout or the target + regsets, flush the contents of the current valid caches back to + the threads. */ + regcache_invalidate (); + pid = pid_of (get_thread_lwp (current_inferior)); #ifdef __x86_64__ if (num_xmm_registers == 8)