From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1764 invoked by alias); 7 Aug 2003 19:57:50 -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 1757 invoked from network); 7 Aug 2003 19:57:49 -0000 Received: from unknown (HELO localhost.redhat.com) (207.219.125.131) by sources.redhat.com with SMTP; 7 Aug 2003 19:57:49 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 28B402B7F; Thu, 7 Aug 2003 15:57:46 -0400 (EDT) Message-ID: <3F32AF3A.1080106@redhat.com> Date: Thu, 07 Aug 2003 19:57:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030223 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Elena Zannoni , gdb-patches@sources.redhat.com, Michael Elizabeth Chastain Subject: Re: [rfa:threads] Report when using libthread_db References: <3F3004F7.6090003@redhat.com> Content-Type: multipart/mixed; boundary="------------070405040708030607080102" X-SW-Source: 2003-08/txt/msg00107.txt.bz2 This is a multi-part message in MIME format. --------------070405040708030607080102 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 863 Here's a revised patch. The `Using ...' message now appears after the copyright. GNU gdb 2003-08-05-cvs ... This GDB was configured as "x86_64-unknown-linux-gnu". (gdb) file /home/cagney/PENDING/2003-08-05-warn-thread-db/N-x86_64-unknown-linux -gnu/gdb/testsuite/gdb.threads/pthreads Reading symbols from /home/cagney/PENDING/2003-08-05-warn-thread-db/N-x86_64-unk nown-linux-gnu/gdb/testsuite/gdb.threads/pthreads...done. Using host libthread_db library "libthread_db.so.1" (gdb) ... (gdb) run Starting program: /home/cagney/PENDING/2003-08-05-warn-thread-db/N-x86_64-unknow n-linux-gnu/gdb/testsuite/gdb.threads/pthreads [Thread debugging using libthread_db enabled] [New Thread 182894192832 (LWP 28501)] [Switching to Thread 182894192832 (LWP 28501)] Thoughts? Anyone know how to get a version number from libthread_db, or it's absolute path? Andrew --------------070405040708030607080102 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 3806 2003-08-05 Andrew Cagney * thread-db.c (verbose_dlsym): New function. (thread_db_load): Use verbose_dlsym (thread_db_new_objfile): Print that libthread_db was loaded, and that thread debugging was enabled. Index: thread-db.c =================================================================== RCS file: /cvs/src/src/gdb/thread-db.c,v retrieving revision 1.33 diff -u -r1.33 thread-db.c --- thread-db.c 5 Jun 2003 18:22:02 -0000 1.33 +++ thread-db.c 7 Aug 2003 18:58:40 -0000 @@ -375,6 +375,15 @@ target_beneath = target; } +static void * +verbose_dlsym (void *handle, const char *name) +{ + void *sym = dlsym (handle, name); + if (sym == NULL) + warning ("Symbol \"%s\" not found in libthread_db: %s", name, dlerror ()); + return sym; +} + static int thread_db_load (void) { @@ -394,47 +403,47 @@ /* Initialize pointers to the dynamic library functions we will use. Essential functions first. */ - td_init_p = dlsym (handle, "td_init"); + td_init_p = verbose_dlsym (handle, "td_init"); if (td_init_p == NULL) return 0; - td_ta_new_p = dlsym (handle, "td_ta_new"); + td_ta_new_p = verbose_dlsym (handle, "td_ta_new"); if (td_ta_new_p == NULL) return 0; - td_ta_map_id2thr_p = dlsym (handle, "td_ta_map_id2thr"); + td_ta_map_id2thr_p = verbose_dlsym (handle, "td_ta_map_id2thr"); if (td_ta_map_id2thr_p == NULL) return 0; - td_ta_map_lwp2thr_p = dlsym (handle, "td_ta_map_lwp2thr"); + td_ta_map_lwp2thr_p = verbose_dlsym (handle, "td_ta_map_lwp2thr"); if (td_ta_map_lwp2thr_p == NULL) return 0; - td_ta_thr_iter_p = dlsym (handle, "td_ta_thr_iter"); + td_ta_thr_iter_p = verbose_dlsym (handle, "td_ta_thr_iter"); if (td_ta_thr_iter_p == NULL) return 0; - td_thr_validate_p = dlsym (handle, "td_thr_validate"); + td_thr_validate_p = verbose_dlsym (handle, "td_thr_validate"); if (td_thr_validate_p == NULL) return 0; - td_thr_get_info_p = dlsym (handle, "td_thr_get_info"); + td_thr_get_info_p = verbose_dlsym (handle, "td_thr_get_info"); if (td_thr_get_info_p == NULL) return 0; - td_thr_getfpregs_p = dlsym (handle, "td_thr_getfpregs"); + td_thr_getfpregs_p = verbose_dlsym (handle, "td_thr_getfpregs"); if (td_thr_getfpregs_p == NULL) return 0; - td_thr_getgregs_p = dlsym (handle, "td_thr_getgregs"); + td_thr_getgregs_p = verbose_dlsym (handle, "td_thr_getgregs"); if (td_thr_getgregs_p == NULL) return 0; - td_thr_setfpregs_p = dlsym (handle, "td_thr_setfpregs"); + td_thr_setfpregs_p = verbose_dlsym (handle, "td_thr_setfpregs"); if (td_thr_setfpregs_p == NULL) return 0; - td_thr_setgregs_p = dlsym (handle, "td_thr_setgregs"); + td_thr_setgregs_p = verbose_dlsym (handle, "td_thr_setgregs"); if (td_thr_setgregs_p == NULL) return 0; @@ -587,6 +596,21 @@ { td_err_e err; + /* First time through, report that libthread_db was successfuly + loaded. Can't print this in in thread_db_load as, at that stage, + the interpreter and it's console haven't started. The real + problem here is probably that libthread_db is loaded too early - + should it only be loaded when there is a program to debug? */ + { + static int dejavu; + if (!dejavu) + { + printf_unfiltered ("Using host libthread_db library \"%s\"\n", + LIBTHREAD_DB_SO); + dejavu = 1; + } + } + /* Don't attempt to use thread_db on targets which can not run (core files). */ if (objfile == NULL || !target_has_execution) @@ -624,6 +648,8 @@ break; case TD_OK: + printf_unfiltered ("[Thread debugging using libthread_db enabled]\n"); + /* The thread library was detected. Activate the thread_db target. */ push_target (&thread_db_ops); using_thread_db = 1; --------------070405040708030607080102--