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]

[commit] gdbserver fix for Linux threading


It's possible (though I can't remember exactly how now - it depends on the
platform) to get NPTL to call the ps_pglobal_lookup callback from just about
anywhere.  For instance, during register reads, or new thread detection.  If
we've already fetched every symbol the library wanted, and we didn't find
this one and cache its value, then don't attempt to look it up again at what
might be an inappropriate time.

Checked in for HEAD.

-- 
Daniel Jacobowitz
CodeSourcery

2006-05-30  Daniel Jacobowitz  <dan@codesourcery.com>

	* remote-utils.c (all_symbols_looked_up): New variable.
	(look_up_one_symbol): Check it.
	* server.h (look_up_one_symbol): New declaration.
	* thread-db.c (thread_db_init): Set all_symbols_looked_up.

Index: remote-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/remote-utils.c,v
retrieving revision 1.28
diff -u -p -r1.28 remote-utils.c
--- remote-utils.c	3 Mar 2006 14:48:55 -0000	1.28
+++ remote-utils.c	30 May 2006 19:04:19 -0000
@@ -1,6 +1,6 @@
 /* Remote utility routines for the remote server for GDB.
    Copyright (C) 1986, 1989, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005
+   2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -52,6 +52,10 @@ struct sym_cache
 /* The symbol cache.  */
 static struct sym_cache *symbol_cache;
 
+/* If this flag has been set, assume cache misses are
+   failures.  */
+int all_symbols_looked_up;
+
 int remote_debug = 0;
 struct ui_file *gdb_stdlog;
 
@@ -769,6 +773,14 @@ look_up_one_symbol (const char *name, CO
 	return 1;
       }
 
+  /* If we've passed the call to thread_db_look_up_symbols, then
+     anything not in the cache must not exist; we're not interested
+     in any libraries loaded after that point, only in symbols in
+     libpthread.so.  It might not be an appropriate time to look
+     up a symbol, e.g. while we're trying to fetch registers.  */
+  if (all_symbols_looked_up)
+    return 0;
+
   /* Send the request.  */
   strcpy (own_buf, "qSymbol:");
   hexify (own_buf + strlen ("qSymbol:"), name, strlen (name));
Index: server.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/server.h,v
retrieving revision 1.22
diff -u -p -r1.22 server.h
--- server.h	1 Feb 2006 21:37:21 -0000	1.22
+++ server.h	30 May 2006 19:04:19 -0000
@@ -1,5 +1,6 @@
 /* Common definitions for remote server for GDB.
-   Copyright (C) 1993, 1995, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005
+   Copyright (C) 1993, 1995, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005,
+   2006
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -127,7 +128,9 @@ extern int server_waiting;
 
 extern jmp_buf toplevel;
 
-/* Functions from remote-utils.c */
+/* From remote-utils.c */
+
+extern int all_symbols_looked_up;
 
 int putpkt (char *buf);
 int getpkt (char *buf);
Index: thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/thread-db.c,v
retrieving revision 1.5
diff -u -p -r1.5 thread-db.c
--- thread-db.c	15 Mar 2006 16:13:29 -0000	1.5
+++ thread-db.c	30 May 2006 19:04:19 -0000
@@ -336,6 +336,9 @@ thread_db_init ()
      process in the list is the thread group leader.  */
   proc_handle.pid = ((struct inferior_list_entry *)current_inferior)->id;
 
+  /* Allow new symbol lookups.  */
+  all_symbols_looked_up = 0;
+
   err = td_ta_new (&proc_handle, &thread_agent);
   switch (err)
     {
@@ -350,6 +353,7 @@ thread_db_init ()
 	return 0;
       thread_db_find_new_threads ();
       thread_db_look_up_symbols ();
+      all_symbols_looked_up = 1;
       return 1;
 
     default:


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