[commit] Recognize glibc-specific thread_db error codes

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[commit] Recognize glibc-specific thread_db error codes

Daniel Jacobowitz-2
This patch gives a more informative error than '22' when your GDB
and debuggee are using different versions of glibc.  Tested on
x86_64-pc-linux-gnu and checked in.

--
Daniel Jacobowitz
CodeSourcery

2006-12-31  Daniel Jacobowitz  <[hidden email]>

        * configure.ac: Add tests for TD_VERSION and TD_NOTLS.
        * linux-thread-db.c (thread_db_err_str): Recognize TD_NOTALLOC,
        TD_VERSION, and TD_NOTLS.
        * configure, config.in: Regenerated.

Index: configure.ac
===================================================================
RCS file: /cvs/src/src/gdb/configure.ac,v
retrieving revision 1.36
diff -u -p -r1.36 configure.ac
--- configure.ac 22 Nov 2006 17:34:15 -0000 1.36
+++ configure.ac 31 Dec 2006 20:19:06 -0000
@@ -1024,7 +1024,8 @@ if test ${build} = ${host} -a ${host} =
    AC_SUBST(CONFIG_LDFLAGS)
 fi
 
-dnl See if we have a thread_db header file that has TD_NOTALLOC.
+dnl See if we have a thread_db header file that has TD_NOTALLOC and
+dnl other error codes.
 if test "x$ac_cv_header_thread_db_h" = "xyes"; then
    AC_CACHE_CHECK([whether <thread_db.h> has TD_NOTALLOC],
                   gdb_cv_thread_db_h_has_td_notalloc,
@@ -1035,11 +1036,37 @@ if test "x$ac_cv_header_thread_db_h" = "
        gdb_cv_thread_db_h_has_td_notalloc=no
      )
    )
+   AC_CACHE_CHECK([whether <thread_db.h> has TD_VERSION],
+                  gdb_cv_thread_db_h_has_td_version,
+     AC_TRY_COMPILE(
+       [#include <thread_db.h>],
+       [int i = TD_VERSION;],
+       gdb_cv_thread_db_h_has_td_version=yes,
+       gdb_cv_thread_db_h_has_td_version=no
+     )
+   )
+   AC_CACHE_CHECK([whether <thread_db.h> has TD_NOTLS],
+                  gdb_cv_thread_db_h_has_td_notls,
+     AC_TRY_COMPILE(
+       [#include <thread_db.h>],
+       [int i = TD_NOTLS;],
+       gdb_cv_thread_db_h_has_td_notls=yes,
+       gdb_cv_thread_db_h_has_td_notls=no
+     )
+   )
 fi
 if test "x$gdb_cv_thread_db_h_has_td_notalloc" = "xyes"; then
   AC_DEFINE(THREAD_DB_HAS_TD_NOTALLOC, 1,
             [Define if <thread_db.h> has the TD_NOTALLOC error code.])
 fi
+if test "x$gdb_cv_thread_db_h_has_td_version" = "xyes"; then
+  AC_DEFINE(THREAD_DB_HAS_TD_VERSION, 1,
+            [Define if <thread_db.h> has the TD_VERSION error code.])
+fi
+if test "x$gdb_cv_thread_db_h_has_td_notls" = "xyes"; then
+  AC_DEFINE(THREAD_DB_HAS_TD_NOTLS, 1,
+            [Define if <thread_db.h> has the TD_NOTLS error code.])
+fi
 
 dnl See if we have a sys/syscall header file that has __NR_tkill.
 if test "x$ac_cv_header_sys_syscall_h" = "xyes"; then
Index: linux-thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-thread-db.c,v
retrieving revision 1.22
diff -u -p -r1.22 linux-thread-db.c
--- linux-thread-db.c 28 Nov 2006 21:44:50 -0000 1.22
+++ linux-thread-db.c 31 Dec 2006 20:19:06 -0000
@@ -209,6 +209,18 @@ thread_db_err_str (td_err_e err)
       return "only part of register set was written/read";
     case TD_NOXREGS:
       return "X register set not available for this thread";
+#ifdef THREAD_DB_HAS_TD_NOTALLOC
+    case TD_NOTALLOC:
+      return "thread has not yet allocated TLS for given module";
+#endif
+#ifdef THREAD_DB_HAS_TD_VERSION
+    case TD_VERSION:
+      return "versions of libpthread and libthread_db do not match";
+#endif
+#ifdef THREAD_DB_HAS_TD_NOTLS
+    case TD_NOTLS:
+      return "there is no TLS segment in the given module";
+#endif
     default:
       snprintf (buf, sizeof (buf), "unknown thread_db error '%d'", err);
       return buf;