This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Allow gdbserver to dynamically lookup libthread_db.so.1


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]