From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28572 invoked by alias); 1 Mar 2010 21:37:47 -0000 Received: (qmail 28551 invoked by uid 22791); 1 Mar 2010 21:37:46 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 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, 01 Mar 2010 21:37:42 +0000 Received: (qmail 15584 invoked from network); 1 Mar 2010 21:37:40 -0000 Received: from unknown (HELO caradoc.them.org) (dan@127.0.0.2) by mail.codesourcery.com with ESMTPA; 1 Mar 2010 21:37:40 -0000 Date: Mon, 01 Mar 2010 21:37:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sourceware.org Cc: Pedro Alves , Doug Evans Subject: [for discussion] Update inferior address spaces Message-ID: <20100301213735.GA17815@caradoc.them.org> Mail-Followup-To: gdb-patches@sourceware.org, Pedro Alves , Doug Evans MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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-03/txt/msg00034.txt.bz2 I ran into the same problem that Doug reported recently, about update_address_spaces. Pedro was kind enough to point me at the problematic code. This patch updates all inferiors, which does stop the wrong behavior... but I can see why Pedro described this to me as a quick fix. It raises a question. If I'm reading this right, there's no actual case of inf->aspace != inf->pspace->aspace in the GDB source code. The DICOS target manages this by having all breakpoints transparently global. So the inf->aspace pointer is redundant. If I'm wrong, or if there's a patch I don't have which changes this for DICOS, could you explain the relation of these three things to me? There's a nice comment in progspace.h, but it doesn't answer this question: if an inf->aspace != inf->pspace->aspace, what does that mean for anything that looks at a program space's aspace pointer? Also, I believe there's a double free in the existing code, fixed in this patch. For the shared address space case. This patch works around the bug, but I don't think it's right as-is. -- Daniel Jacobowitz CodeSourcery 2010-03-01 Daniel Jacobowitz * progspace.c (update_address_spaces): Update inferior address spaces also. Index: progspace.c =================================================================== --- progspace.c (revision 277420) +++ progspace.c (working copy) @@ -430,24 +430,30 @@ void update_address_spaces (void) { int shared_aspace = gdbarch_has_shared_address_space (target_gdbarch); - struct address_space *aspace = NULL; struct program_space *pspace; + struct inferior *inf; + + for (inf = inferior_list; inf; inf = inf->next) + gdb_assert (inf->aspace == inf->pspace->aspace); init_address_spaces (); - ALL_PSPACES (pspace) + if (shared_aspace) { - free_address_space (pspace->aspace); - - if (shared_aspace) - { - if (aspace == NULL) - aspace = new_address_space (); - pspace->aspace = aspace; - } - else - pspace->aspace = new_address_space (); + struct address_space *aspace = new_address_space (); + free_address_space (current_program_space->aspace); + ALL_PSPACES (pspace) + pspace->aspace = aspace; } + else + ALL_PSPACES (pspace) + { + free_address_space (pspace->aspace); + pspace->aspace = new_address_space (); + } + + for (inf = inferior_list; inf; inf = inf->next) + inf->aspace = inf->pspace->aspace; } /* Save the current program space so that it may be restored by a later