From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15026 invoked by alias); 8 Jul 2008 11:40:09 -0000 Received: (qmail 15006 invoked by uid 22791); 8 Jul 2008 11:40:07 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 08 Jul 2008 11:39:50 +0000 Received: (qmail 17539 invoked from network); 8 Jul 2008 11:39:48 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 8 Jul 2008 11:39:48 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: Fix execl.exp sporadic failures Date: Tue, 08 Jul 2008 11:40:00 -0000 User-Agent: KMail/1.9.9 Cc: Daniel Jacobowitz References: <200807030143.08682.pedro@codesourcery.com> <20080707191036.GC11544@caradoc.them.org> <200807081205.06021.pedro@codesourcery.com> In-Reply-To: <200807081205.06021.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_CI1cIXjfDazD8Vo" Message-Id: <200807081239.46139.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: 2008-07/txt/msg00114.txt.bz2 --Boundary-00=_CI1cIXjfDazD8Vo Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 158 A Tuesday 08 July 2008 12:05:05, Pedro Alves wrote: > Attached is what I checked in then. Sorry, EWRONGPATCH. *This* is what I checked in. -- Pedro Alves --Boundary-00=_CI1cIXjfDazD8Vo Content-Type: text/x-diff; charset="utf-8"; name="execl.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="execl.diff" Content-length: 5221 Index: ChangeLog =================================================================== RCS file: /cvs/src/src/gdb/ChangeLog,v retrieving revision 1.9522 retrieving revision 1.9523 diff -u -p -r1.9522 -r1.9523 --- ChangeLog 8 Jul 2008 10:31:15 -0000 1.9522 +++ ChangeLog 8 Jul 2008 10:59:57 -0000 1.9523 @@ -1,5 +1,16 @@ 2008-07-08 Pedro Alves + * breakpoint.c (mark_breakpoints_out): Make public. + (update_breakpoints_after_exec): Don't call mark_breakpoints_out + here. Update comment. + * breakpoint.h (mark_breakpoints_out): Declare. + + * linux-nat.c (linux_handle_extended_wait): On + TARGET_WAITKIND_EXECD, call mark_breakpoints_out. + * inf-ttrace.c (inf_ttrace_wait): Likewise. + +2008-07-08 Pedro Alves + * infrun.c (follow_exec): Reset shared libraries before adding the main exec file. Index: breakpoint.c =================================================================== RCS file: /cvs/src/src/gdb/breakpoint.c,v retrieving revision 1.328 retrieving revision 1.329 diff -u -p -r1.328 -r1.329 --- breakpoint.c 7 Jul 2008 22:39:58 -0000 1.328 +++ breakpoint.c 8 Jul 2008 10:59:57 -0000 1.329 @@ -188,8 +188,6 @@ static int single_step_breakpoint_insert static void free_bp_location (struct bp_location *loc); -static void mark_breakpoints_out (void); - static struct bp_location * allocate_bp_location (struct breakpoint *bpt, enum bptype bp_type); @@ -1443,12 +1441,19 @@ update_breakpoints_after_exec (void) { struct breakpoint *b; struct breakpoint *temp; + struct bp_location *bploc; struct cleanup *cleanup; - /* Doing this first prevents the badness of having delete_breakpoint() - write a breakpoint's current "shadow contents" to lift the bp. That - shadow is NOT valid after an exec()! */ - mark_breakpoints_out (); + /* We're about to delete breakpoints from GDB's lists. If the + INSERTED flag is true, GDB will try to lift the breakpoints by + writing the breakpoints' "shadow contents" back into memory. The + "shadow contents" are NOT valid after an exec, so GDB should not + do that. Instead, the target is responsible from marking + breakpoints out as soon as it detects an exec. We don't do that + here instead, because there may be other attempts to delete + breakpoints after detecting an exec and before reaching here. */ + ALL_BP_LOCATIONS (bploc) + gdb_assert (!bploc->inserted); /* The binary we used to debug is now gone, and we're updating breakpoints for the new binary. Until we're done, we should not @@ -1699,7 +1704,7 @@ remove_breakpoint (struct bp_location *b /* Clear the "inserted" flag in all breakpoints. */ -static void +void mark_breakpoints_out (void) { struct bp_location *bpt; Index: breakpoint.h =================================================================== RCS file: /cvs/src/src/gdb/breakpoint.h,v retrieving revision 1.73 retrieving revision 1.74 diff -u -p -r1.73 -r1.74 --- breakpoint.h 28 Jun 2008 09:42:15 -0000 1.73 +++ breakpoint.h 8 Jul 2008 10:59:57 -0000 1.74 @@ -826,6 +826,9 @@ extern void disable_breakpoint (struct b extern void enable_breakpoint (struct breakpoint *); +/* Clear the "inserted" flag in all breakpoints. */ +extern void mark_breakpoints_out (void); + extern void make_breakpoint_permanent (struct breakpoint *); extern struct breakpoint *create_solib_event_breakpoint (CORE_ADDR); Index: inf-ttrace.c =================================================================== RCS file: /cvs/src/src/gdb/inf-ttrace.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -p -r1.28 -r1.29 --- inf-ttrace.c 21 Mar 2008 15:44:53 -0000 1.28 +++ inf-ttrace.c 8 Jul 2008 10:59:57 -0000 1.29 @@ -904,6 +904,12 @@ inf_ttrace_wait (ptid_t ptid, struct tar tts.tts_u.tts_exec.tts_pathlen, 0) == -1) perror_with_name (("ttrace")); ourstatus->value.execd_pathname[tts.tts_u.tts_exec.tts_pathlen] = 0; + + /* At this point, all inserted breakpoints are gone. Doing this + as soon as we detect an exec prevents the badness of deleting + a breakpoint writing the current "shadow contents" to lift + the bp. That shadow is NOT valid after an exec. */ + mark_breakpoints_out (); break; case TTEVT_EXIT: Index: linux-nat.c =================================================================== RCS file: /cvs/src/src/gdb/linux-nat.c,v retrieving revision 1.88 retrieving revision 1.89 diff -u -p -r1.88 -r1.89 --- linux-nat.c 28 Jun 2008 11:15:33 -0000 1.88 +++ linux-nat.c 8 Jul 2008 10:59:57 -0000 1.89 @@ -1758,6 +1758,16 @@ linux_handle_extended_wait (struct lwp_i linux_parent_pid = 0; } + /* At this point, all inserted breakpoints are gone. Doing this + as soon as we detect an exec prevents the badness of deleting + a breakpoint writing the current "shadow contents" to lift + the bp. That shadow is NOT valid after an exec. + + Note that we have to do this after the detach_breakpoints + call above, otherwise breakpoints wouldn't be lifted from the + parent on a vfork, because detach_breakpoints would think + that breakpoints are not inserted. */ + mark_breakpoints_out (); return 0; } --Boundary-00=_CI1cIXjfDazD8Vo--