From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7609 invoked by alias); 12 May 2009 07:16:19 -0000 Received: (qmail 7597 invoked by uid 22791); 12 May 2009 07:16:18 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from ti-out-0910.google.com (HELO ti-out-0910.google.com) (209.85.142.189) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 12 May 2009 07:16:11 +0000 Received: by ti-out-0910.google.com with SMTP id a1so301559tib.12 for ; Tue, 12 May 2009 00:16:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.110.109.19 with SMTP id h19mr547093tic.44.1242112568446; Tue, 12 May 2009 00:16:08 -0700 (PDT) In-Reply-To: <8ac60eac0905111108g26096302lb902cd414b5a6790@mail.gmail.com> References: <8ac60eac0904201019g7ba8056bx5e84e6bfdf5935d8@mail.gmail.com> <8ac60eac0904301618j61051e9du38b34afbc7ed64a3@mail.gmail.com> <8ac60eac0904301719w33175de2w8d1d0fd80bf0feb4@mail.gmail.com> <200905111412.59493.pedro@codesourcery.com> <8ac60eac0905111108g26096302lb902cd414b5a6790@mail.gmail.com> Date: Tue, 12 May 2009 07:16:00 -0000 Message-ID: Subject: Re: [patch][rfc] Allow GDB to search for the right libthread_db.so.1 From: Hui Zhu To: Paul Pluzhnikov Cc: Pedro Alves , gdb-patches@sourceware.org, Joel Brobecker , tromey@redhat.com, Thiago Jung Bauermann , Eli Zaretskii , Daniel Jacobowitz Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 2009-05/txt/msg00236.txt.bz2 1. Could you please add a debug interface like "set debug linux-thread 1" to let linux-thread-db.c output some debug message? I met a lot of people have trouble with linux-multi-thread debug. I think it will help us a lot. :) 2. I still peddle my idea: let libthread-db-search-path can support single file. And a make a patch follow your patch. Wish you like it. :) --- linux-thread-db.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) --- a/linux-thread-db.c +++ b/linux-thread-db.c @@ -642,6 +642,7 @@ thread_db_load_search (void) while (*search_path) { + struct stat buf; const char *end =3D strchr (search_path, ':'); if (end) { @@ -674,8 +675,16 @@ thread_db_load_search (void) memcpy (path, search_path, len + 1); search_path +=3D len; } - strcat (path, "/"); - strcat (path, LIBTHREAD_DB_SO); + if (stat (path, &buf)) + { + warning (_("Stats the file %s failied."), path); + continue; + } + if (S_ISDIR (buf.st_mode)) + { + strcat (path, "/"); + strcat (path, LIBTHREAD_DB_SO); + } if (try_thread_db_load (path)) { rc =3D 1; And thanks for you work. Your patch is very cool. Thanks, Hui On Tue, May 12, 2009 at 02:08, Paul Pluzhnikov wro= te: > On Mon, May 11, 2009 at 6:12 AM, Pedro Alves wro= te: > >>> handle =3D dlopen (library, RTLD_NOW); >> >> I wonder if making this RTLD_LAZY until you found the correct one >> wouldn't make sense? > > I don't believe so. > > AFAICT, the reason for RTLD_NOW is to make sure that this > libthread_db is really compatible with this GDB (doesn't require > any symbols GDB doesn't provide); and also to prevent GDB from > dying half way through with "unable to resolve symbol ...". > > Both of these still apply to whatever the "final" libthread_db is > going to be. > > Why would we want to dlopen(... RTLD_LAZY) and try to initialize > libthread_db if we are going to reject it as unusable in the end? > >>> +static int >>> +thread_db_load_search () >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ^ (void) > > Fixed, thanks. > >> =A0(this function could be made to use `openat' at some point, but >> =A0 gdb is already assumes PATH_MAX is largest path possible elsewhere >> =A0 anyway) >> >> I also wonder if `set sysroot' should affect this search path: I think >> not, but I'm not 100% sure. > > I don't believe it makes sense for 'set sysroot' to affect this > search path. > >>> +int libpthread_name_p (const char *name) >>> +{ >> >> =A0 =A0 =A0^ function name at column 0, please. > > Fixed, thanks. > > Anxiously waiting for Daniel's verdict now ... > > -- > Paul Pluzhnikov >