From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16858 invoked by alias); 6 Oct 2009 23:44:42 -0000 Received: (qmail 16847 invoked by uid 22791); 6 Oct 2009 23:44:41 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 06 Oct 2009 23:44:37 +0000 Received: (qmail 16571 invoked from network); 6 Oct 2009 23:44:33 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 6 Oct 2009 23:44:33 -0000 From: Pedro Alves To: Paul Pluzhnikov Subject: Re: [patch] Allow gdbserver to dynamically lookup libthread_db.so.1 Date: Tue, 06 Oct 2009 23:44:00 -0000 User-Agent: KMail/1.9.10 Cc: gdb-patches@sourceware.org, dje@google.com References: <20090902163344.833F476568@localhost> <200910042132.23246.pedro@codesourcery.com> <8ac60eac0910061608w4d5d2697vbb1b23138f7d95be@mail.gmail.com> In-Reply-To: <8ac60eac0910061608w4d5d2697vbb1b23138f7d95be@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200910070044.24367.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: 2009-10/txt/msg00148.txt.bz2 On Wednesday 07 October 2009 00:08:36, Paul Pluzhnikov wrote: > > I take it you only care for extended-remote? How is the user > > supposed to tweak the new setting with plain remote? > > Note that default search path is initialized from LIBTHREAD_DB_SEARCH_PATH. > > The user is expected to set this to appropriate system-specific default if > the standard loader search path is inappropriate. Okay. Something like a command line option would be more user friendly, but if you don't need it, it's fine to leave that out until someone does. On Wednesday 07 October 2009 00:08:36, Paul Pluzhnikov wrote: > If we can find '-lthread_db', '/lib/libthread_db.so.1' or > '$prefix/lib/libthread_db.so.1', then we switch on using libthread_db and > use '-ldl' to dynamically load it. > > Perhaps a better fix is to skip this check altogether, and always use > dlopen on Linux? I guess your patch's already doing that. You mean always use -dl. Yes, let's do that. That's how a linux gdb is built too. I can't look at the whole patch right now, but a quick skim looked good. I noticed this: +void +thread_db_handle_monitor_command (char *mon) +{ + if (strncmp (mon, "set libthread-db-search-path", 28) == 0) + { + const char *cp = mon + 28; + + if (libthread_db_search_path != NULL) + free (libthread_db_search_path); + + /* Skip leading space (if any). */ + while (isspace (*cp)) + ++cp; + + libthread_db_search_path = xstrdup (cp); + + monitor_output ("libthread-db-search-path set to `"); + monitor_output (libthread_db_search_path); + monitor_output ("'\n"); + } + else + handle_monitor_command (mon); +} Could you tweak the interface a bit, to return a boolean indicating if the command was handled or not? E.g., +int +thread_db_handle_monitor_command (char *mon) +{ + if (strncmp (mon, "set libthread-db-search-path", 28) == 0) + { + const char *cp = mon + 28; + + if (libthread_db_search_path != NULL) + free (libthread_db_search_path); + + /* Skip leading space (if any). */ + while (isspace (*cp)) + ++cp; + + libthread_db_search_path = xstrdup (cp); + + monitor_output ("libthread-db-search-path set to `"); + monitor_output (libthread_db_search_path); + monitor_output ("'\n"); + return 1; + } + + return 0; +} Then this allows chaining handlers, and, only server.c needs to call handle_monitor_command if nothing handled the command. Might want to force a whitespace after "set libthread-db-search-path", so that "set libthread-db-search-pathfoofoo" isn't accepted while at it. -- Pedro Alves