From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20873 invoked by alias); 29 Jul 2008 12:55:08 -0000 Received: (qmail 20864 invoked by uid 22791); 29 Jul 2008 12:55: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, 29 Jul 2008 12:54:50 +0000 Received: (qmail 30992 invoked from network); 29 Jul 2008 12:54:46 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 29 Jul 2008 12:54:46 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [PATCH] Handle absence of DT_DEBUG while debugging ld.so Date: Tue, 29 Jul 2008 12:55:00 -0000 User-Agent: KMail/1.9.9 Cc: Daniel Jacobowitz , Luis Machado References: <1217289278.16935.23.camel@gargoyle> <1217300235.16935.35.camel@gargoyle> <20080729121244.GA2175@caradoc.them.org> In-Reply-To: <20080729121244.GA2175@caradoc.them.org> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_YMxjIeD55KIa+zW" Message-Id: <200807291354.49009.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/msg00538.txt.bz2 --Boundary-00=_YMxjIeD55KIa+zW Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 1806 A Tuesday 29 July 2008 13:12:44, Daniel Jacobowitz wrote: > On Mon, Jul 28, 2008 at 11:57:15PM -0300, Luis Machado wrote: > > Yes, this specific address seems broken somehow. This is the first > > _r_debug entry GDB gets: > > Looks like the section offsets are not set yet. > > > And this is the next _r_debug minimal symbol entry GDB gets: > > What do you mean by "next"? What commands did you use to get this > output? > > Also, with GDB 6.8 I can "continue" after this error. With HEAD: > > Continuing. > Cannot execute this command while the selected thread is running. > > Hey, Pedro? Cleanup trouble? Sort of. When handling internal events we don't adjust the running state of the thread, only the executing property. This is so the user/frontend doesn't see a bunch of not interesting running/stopped notifications, like say thread hopping, going through the shell doing execs, etc. In this case, we were still not finished with create inferior dances, and were inside a post_create_inferior. Note that post_create_inferior requires a !is_executing inferior, on entry, and, it is allowed (and it does) to internally start/stop the inferior (solib handlers do this, see *_create_inferior_hook). If an error is thrown out of the deep bowls of post_create_inferior, we should just propagate GDB's knowledge of the executing state to the user/frontend running state. This restores the old behaviour. I now get: (gdb) r Starting program: /lib/ld-2.7.so Cannot access memory at address 0x21ec88 (gdb) info threads * 1 process 30943 0x00007ffff7fe2a60 in ?? () (gdb) c Continuing. Usage: ld.so [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...] You have invoked `ld.so', the helper program for shared library executables. ... Program exited with code 0177. OK? -- Pedro Alves --Boundary-00=_YMxjIeD55KIa+zW Content-Type: text/x-diff; charset="iso-8859-1"; name="fix_running_state.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fix_running_state.diff" Content-length: 1852 2008-07-29 Pedro Alves * infcmd.c (post_create_inferior): Rename to ... (post_create_inferior_1): ... this and make static. (fix_running_state): New. (post_create_inferior): New. --- gdb/infcmd.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) Index: src/gdb/infcmd.c =================================================================== --- src.orig/gdb/infcmd.c 2008-07-29 13:40:22.000000000 +0100 +++ src/gdb/infcmd.c 2008-07-29 13:44:02.000000000 +0100 @@ -408,8 +408,8 @@ tty_command (char *file, int from_tty) means (running, attaching, connecting, et cetera). The target should be stopped. */ -void -post_create_inferior (struct target_ops *target, int from_tty) +static void +post_create_inferior_1 (struct target_ops *target, int from_tty) { /* Be sure we own the terminal in case write operations are performed. */ target_terminal_ours (); @@ -445,6 +445,28 @@ post_create_inferior (struct target_ops observer_notify_inferior_created (target, from_tty); } +/* If an error happened, propagate GDB's knowledge of the executing + state to the frontend/user running state. */ + +static void +fix_running_state (void *arg) +{ + if (is_exited (inferior_ptid)) + return; + set_running (inferior_ptid, + is_executing (inferior_ptid)); +} + +/* See post_create_inferior_1 for description. */ + +void +post_create_inferior (struct target_ops *target, int from_tty) +{ + struct cleanup *old_chain = make_cleanup (fix_running_state, NULL); + post_create_inferior_1 (target, from_tty); + discard_cleanups (old_chain); +} + /* Kill the inferior if already running. This function is designed to be called when we are about to start the execution of the program from the beginning. Ask the user to confirm that he wants to restart --Boundary-00=_YMxjIeD55KIa+zW--