From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22300 invoked by alias); 3 May 2007 00:15:56 -0000 Received: (qmail 22290 invoked by uid 22791); 3 May 2007 00:15:56 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 03 May 2007 00:15:53 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.1/8.13.1) with ESMTP id l430FpW3021695 for ; Wed, 2 May 2007 20:15:51 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id l430FoPU018157 for ; Wed, 2 May 2007 20:15:50 -0400 Received: from ironwood.lan (vpn-14-15.rdu.redhat.com [10.11.14.15]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id l430FolG014891 for ; Wed, 2 May 2007 20:15:50 -0400 Date: Thu, 03 May 2007 00:15:00 -0000 From: Kevin Buettner To: gdb-patches@sources.redhat.com Subject: Re: [rfc] Set a breakpoint's type before adjusting its address Message-ID: <20070502171549.05134b10@ironwood.lan> In-Reply-To: <20070428214510.GA12239@caradoc.them.org> References: <20070427151559.0394bfa0@ironwood.lan> <20070428214510.GA12239@caradoc.them.org> X-Mailer: Sylpheed-Claws 2.6.0 (GTK+ 2.10.4; i386-redhat-linux-gnu) 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: 2007-05/txt/msg00039.txt.bz2 On Sat, 28 Apr 2007 17:45:10 -0400 Daniel Jacobowitz wrote: > This happens because the breakpoint's location is already on the > location chain, right? Right. > Alternatively, we could move that from the end > of allocate_bp_location to the end of set_raw_breakpoint, and avoid > the inconsistency. If we can do it, I think it'd be nice to keep the code which allocates the location together with the code which adds the newly allocated location to the chain. I agree that my earlier patch is not very nice in that adjust_breakpoint_address() was being called with an only partially initialized location on the location chain. That patch was a band-aid in that it initialized those bits which a particular function (read_memory_nobpt) cared about, but who knows what else might break if some other function were called. Appended below is a new patch which calls adjust_breakpoint_address() prior to allocating the breakoint's location. What do you think of this approach? Kevin * breakpoint.c (set_raw_breakpoint): Adjust breakpoint's address prior to allocating its location. Index: breakpoint.c =================================================================== RCS file: /cvs/src/src/gdb/breakpoint.c,v retrieving revision 1.246 diff -u -p -r1.246 breakpoint.c --- breakpoint.c 13 Apr 2007 13:50:32 -0000 1.246 +++ breakpoint.c 2 May 2007 23:57:06 -0000 @@ -4189,13 +4189,23 @@ struct breakpoint * set_raw_breakpoint (struct symtab_and_line sal, enum bptype bptype) { struct breakpoint *b, *b1; + CORE_ADDR adjusted_address; b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint)); memset (b, 0, sizeof (*b)); + + /* Adjust the breakpoint's address prior to allocating a location. + Once we call allocate_bp_location(), that mostly uninitialized + location will be placed on the location chain. Adjustment of the + breakpoint may cause read_memory_nobpt() to be called and we do + not want its scan of the location chain to find a breakpoint and + location that's only been partially initialized. */ + adjusted_address = adjust_breakpoint_address (sal.pc, bptype); + b->loc = allocate_bp_location (b, bptype); b->loc->requested_address = sal.pc; - b->loc->address = adjust_breakpoint_address (b->loc->requested_address, - bptype); + b->loc->address = adjusted_address; + if (sal.symtab == NULL) b->source_file = NULL; else