Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] Fix handling of elided libthread-db-search-path values.
@ 2011-05-10 16:59 Doug Evans
  2011-05-10 17:10 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Doug Evans @ 2011-05-10 16:59 UTC (permalink / raw)
  To: gdb-patches

Hi.

This patch addresses a couple of issues.

1) "monitor set libthread-db-search-path" doesn't work.

gdbserver assumes it will receive "set libthread-db-search-path "
which is wrong.

2) There's an assumption that the default value for libthread-db-search-path
   is always an empty list.

That's true, but only because no one overrides LIBTHREAD_DB_SEARCH_PATH.
At least not in FSF trees, or not yet in FSF trees.

Committed.

2011-05-10  Doug Evans  <dje@google.com>

	* linux-thread-db.c (set_libthread_db_search_path): New function.
	(_initialize_thread_db): Add setter for libthread-db-search-path.

	gdbserver/
	* thread-db.c (thread_db_handle_monitor_command): Handle elided path.

	doc/
	* gdb.texinfo (Threads): If an empty path is provided for
	libthread-db-search-path it is reset to its default value.
	(Server): Ditto.

Index: linux-thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-thread-db.c,v
retrieving revision 1.82
diff -u -p -r1.82 linux-thread-db.c
--- linux-thread-db.c	17 Apr 2011 19:11:07 -0000	1.82
+++ linux-thread-db.c	10 May 2011 16:51:53 -0000
@@ -75,6 +75,17 @@
 
 static char *libthread_db_search_path;
 
+static void
+set_libthread_db_search_path (char *ignored, int from_tty,
+			      struct cmd_list_element *c)
+{
+  if (*libthread_db_search_path == '\0')
+    {
+      xfree (libthread_db_search_path);
+      libthread_db_search_path = xstrdup (LIBTHREAD_DB_SEARCH_PATH);
+    }
+}
+
 /* If non-zero, print details of libthread_db processing.  */
 
 static int libthread_db_debug;
@@ -1719,8 +1730,10 @@ _initialize_thread_db (void)
 Set search path for libthread_db."), _("\
 Show the current search path or libthread_db."), _("\
 This path is used to search for libthread_db to be loaded into \
-gdb itself."),
-			    NULL,
+gdb itself.\n\
+Its value is a colon (':') separate list of directories to search.\n\
+Setting the search path to an empty list resets it to its default value."),
+			    set_libthread_db_search_path,
 			    NULL,
 			    &setlist, &showlist);
 
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.831
diff -u -p -r1.831 gdb.texinfo
--- doc/gdb.texinfo	9 May 2011 21:49:57 -0000	1.831
+++ doc/gdb.texinfo	10 May 2011 16:51:53 -0000
@@ -2855,7 +2855,7 @@ watchpoints in programs with multiple th
 If this variable is set, @var{path} is a colon-separated list of
 directories @value{GDBN} will use to search for @code{libthread_db}.
 If you omit @var{path}, @samp{libthread-db-search-path} will be reset to
-an empty list.
+its default value.
 
 On @sc{gnu}/Linux and Solaris systems, @value{GDBN} uses a ``helper''
 @code{libthread_db} library to obtain information about threads in the
@@ -16369,7 +16369,7 @@ protocol (@pxref{Remote Protocol}).
 When this command is issued, @var{path} is a colon-separated list of
 directories to search for @code{libthread_db} (@pxref{Threads,,set
 libthread-db-search-path}).  If you omit @var{path},
-@samp{libthread-db-search-path} will be reset to an empty list.
+@samp{libthread-db-search-path} will be reset to the its value.
 
 @item monitor exit
 Tell gdbserver to exit immediately.  This command should be followed by
Index: gdbserver/thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/thread-db.c,v
retrieving revision 1.39
diff -u -p -r1.39 thread-db.c
--- gdbserver/thread-db.c	6 Jan 2011 00:14:09 -0000	1.39
+++ gdbserver/thread-db.c	10 May 2011 16:51:53 -0000
@@ -916,9 +916,14 @@ thread_db_mourn (struct process_info *pr
 int
 thread_db_handle_monitor_command (char *mon)
 {
-  if (strncmp (mon, "set libthread-db-search-path ", 29) == 0)
+  const char *cmd = "set libthread-db-search-path";
+  size_t cmd_len = strlen (cmd);
+
+  if (strncmp (mon, cmd, cmd_len) == 0
+      && (mon[cmd_len] == '\0'
+	  || mon[cmd_len] == ' '))
     {
-      const char *cp = mon + 29;
+      const char *cp = mon + cmd_len;
 
       if (libthread_db_search_path != NULL)
 	free (libthread_db_search_path);
@@ -927,6 +932,8 @@ thread_db_handle_monitor_command (char *
       while (isspace (*cp))
 	++cp;
 
+      if (*cp == '\0')
+	cp = LIBTHREAD_DB_SEARCH_PATH;
       libthread_db_search_path = xstrdup (cp);
 
       monitor_output ("libthread-db-search-path set to `");


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] Fix handling of elided libthread-db-search-path values.
  2011-05-10 16:59 [patch] Fix handling of elided libthread-db-search-path values Doug Evans
@ 2011-05-10 17:10 ` Eli Zaretskii
  2011-05-10 17:37   ` Doug Evans
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2011-05-10 17:10 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

> Date: Tue, 10 May 2011 09:59:18 -0700 (PDT)
> From: dje@google.com (Doug Evans)
> 
> 2) There's an assumption that the default value for libthread-db-search-path
>    is always an empty list.
> 
> That's true, but only because no one overrides LIBTHREAD_DB_SEARCH_PATH.

But the new text doesn't mention LIBTHREAD_DB_SEARCH_PATH at all.  So
it leaves the reader in the darkness wrt the default value and where
will it come from.

> -@samp{libthread-db-search-path} will be reset to an empty list.
> +@samp{libthread-db-search-path} will be reset to the its value.
                                           ^^^^^^^^^^^^^^^^^^^^^^
A typo.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] Fix handling of elided libthread-db-search-path values.
  2011-05-10 17:10 ` Eli Zaretskii
@ 2011-05-10 17:37   ` Doug Evans
  2011-05-10 19:02     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Doug Evans @ 2011-05-10 17:37 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On Tue, May 10, 2011 at 10:09 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Tue, 10 May 2011 09:59:18 -0700 (PDT)
>> From: dje@google.com (Doug Evans)
>>
>> 2) There's an assumption that the default value for libthread-db-search-path
>>    is always an empty list.
>>
>> That's true, but only because no one overrides LIBTHREAD_DB_SEARCH_PATH.
>
> But the new text doesn't mention LIBTHREAD_DB_SEARCH_PATH at all.  So
> it leaves the reader in the darkness wrt the default value and where
> will it come from.

Yeah, that's a gdb macro, didn't want to mention it in the user docs.
But ok, how about this?

If you omit @var{path}, @samp{libthread-db-search-path} will be reset to
its default value (an empty list on @sc{gnu}/Linux and Solaris systems).
Internally, the default value comes from the @code{LIBTHREAD_DB_SEARCH_PATH}
macro.

>> -@samp{libthread-db-search-path} will be reset to an empty list.
>> +@samp{libthread-db-search-path} will be reset to the its value.
>                                           ^^^^^^^^^^^^^^^^^^^^^^
> A typo.

Yeah, fixed in what's checked in.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] Fix handling of elided libthread-db-search-path values.
  2011-05-10 17:37   ` Doug Evans
@ 2011-05-10 19:02     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2011-05-10 19:02 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

> Date: Tue, 10 May 2011 10:37:17 -0700
> From: Doug Evans <dje@google.com>
> Cc: gdb-patches@sourceware.org
> 
> If you omit @var{path}, @samp{libthread-db-search-path} will be reset to
> its default value (an empty list on @sc{gnu}/Linux and Solaris systems).
> Internally, the default value comes from the @code{LIBTHREAD_DB_SEARCH_PATH}
> macro.

OK.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-10 19:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-10 16:59 [patch] Fix handling of elided libthread-db-search-path values Doug Evans
2011-05-10 17:10 ` Eli Zaretskii
2011-05-10 17:37   ` Doug Evans
2011-05-10 19:02     ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox