From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24806 invoked by alias); 13 Mar 2002 17:54:18 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 24711 invoked from network); 13 Mar 2002 17:54:16 -0000 Received: from unknown (HELO rwcrmhc51.attbi.com) (204.127.198.38) by sources.redhat.com with SMTP; 13 Mar 2002 17:54:16 -0000 Received: from ocean.lucon.org ([12.234.143.38]) by rwcrmhc51.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020313175416.KDGD2626.rwcrmhc51.attbi.com@ocean.lucon.org> for ; Wed, 13 Mar 2002 17:54:16 +0000 Received: by ocean.lucon.org (Postfix, from userid 1000) id 8709E125C2; Wed, 13 Mar 2002 09:54:15 -0800 (PST) Date: Wed, 13 Mar 2002 09:54:00 -0000 From: "H . J . Lu" To: gdb-patches@sources.redhat.com Subject: Re: [hjl@lucon.org: Re: Does gdb 5.2 work with statically linked thread application under Linux?] Message-ID: <20020313095415.B9484@lucon.org> References: <20020313125034.B14483@nevyn.them.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Q68bSM7Ycu6FN28Q" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020313125034.B14483@nevyn.them.org>; from drow@mvista.com on Wed, Mar 13, 2002 at 12:50:34PM -0500 X-SW-Source: 2002-03/txt/msg00197.txt.bz2 --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 333 On Wed, Mar 13, 2002 at 12:50:34PM -0500, Daniel Jacobowitz wrote: > Does anyone have a comment on this patch? It fixes thread_db for > statically linked binaries (which I broke), and I think it's > legitimate. > I am enclosing an upated patch here. Any targets should be able to use target_corefile_hook if necessary. H.J. --- --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="gdb-static.patch" Content-length: 3110 2002-03-07 H.J. Lu (hjl@gnu.org) * target.h (target_corefile_hook): New prototype. * target.c (target_corefile_hook): New. * corelow.c (core_open): Call target_corefile_hook if needed. * thread-db.c (target_corefile_chain): New. (thread_db_corefile): New. (thread_db_new_objfile): Don't check target_has_execution. (_initialize_thread_db): Save target_corefile_hook in target_corefile_chain. Set target_corefile_hook to thread_db_corefile. --- gdb/corelow.c.static Wed Mar 6 22:30:49 2002 +++ gdb/corelow.c Thu Mar 7 15:01:41 2002 @@ -303,6 +303,9 @@ core_open (char *filename, int from_tty) filename, bfd_errmsg (bfd_get_error ())); } + if (target_corefile_hook) + target_corefile_hook (); + /* Looks semi-reasonable. Toss the old core file and work on the new. */ discard_cleanups (old_chain); /* Don't free filename any more */ --- gdb/target.c.static Wed Mar 6 22:31:31 2002 +++ gdb/target.c Thu Mar 7 14:54:50 2002 @@ -38,6 +38,8 @@ extern int errno; +void (*target_corefile_hook) (void); + static void target_info (char *, int); static void cleanup_target (struct target_ops *); --- gdb/target.h.static Wed Mar 6 22:31:31 2002 +++ gdb/target.h Thu Mar 7 14:54:38 2002 @@ -985,6 +985,8 @@ extern char *normal_pid_to_str (ptid_t p extern void (*target_new_objfile_hook) (struct objfile *); +extern void (*target_corefile_hook) (void); + #ifndef target_pid_or_tid_to_str #define target_pid_or_tid_to_str(ID) \ target_pid_to_str (ID) --- gdb/thread-db.c.static Wed Mar 6 22:31:31 2002 +++ gdb/thread-db.c Thu Mar 7 15:20:17 2002 @@ -54,6 +54,9 @@ static struct target_ops *target_beneath /* Pointer to the next function on the objfile event chain. */ static void (*target_new_objfile_chain) (struct objfile *objfile); +/* Pointer to the next function on the corefile event chain. */ +static void (*target_corefile_chain) (void); + /* Non-zero if we're using this module's target vector. */ static int using_thread_db; @@ -479,13 +482,28 @@ disable_thread_signals (void) } static void +thread_db_corefile (void) +{ + if (using_thread_db) + { + /* If the thread_db target is active, deactivate it now. */ + gdb_assert (proc_handle.pid == 0); + unpush_target (&thread_db_ops); + using_thread_db = 0; + } + + keep_thread_db = 0; + + if (target_corefile_chain) + target_corefile_chain (); +} + +static void thread_db_new_objfile (struct objfile *objfile) { td_err_e err; - /* Don't attempt to use thread_db on targets which can not run - (core files). */ - if (objfile == NULL || !target_has_execution) + if (objfile == NULL) { /* All symbols have been discarded. If the thread_db target is active, deactivate it now. */ @@ -1040,5 +1058,7 @@ _initialize_thread_db (void) /* Add ourselves to objfile event chain. */ target_new_objfile_chain = target_new_objfile_hook; target_new_objfile_hook = thread_db_new_objfile; + target_corefile_chain = target_corefile_hook; + target_corefile_hook = thread_db_corefile; } } --Q68bSM7Ycu6FN28Q--