summaryrefslogtreecommitdiff
path: root/libpthread/linuxthreads_db/td_ta_new.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-02-27 18:13:05 +0000
committerEric Andersen <andersen@codepoet.org>2003-02-27 18:13:05 +0000
commit187dd78d7bd1c03fcf16e54a30314512d38e1a4a (patch)
tree9780638e5286b40da74a128c9f540a9ea720862f /libpthread/linuxthreads_db/td_ta_new.c
parentd4d6e2c50565da18253cd0d6f3332484142b6587 (diff)
Major update for pthreads, based in large part on improvements
from glibc 2.3. This should make threads much more efficient. -Erik
Diffstat (limited to 'libpthread/linuxthreads_db/td_ta_new.c')
-rw-r--r--libpthread/linuxthreads_db/td_ta_new.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/libpthread/linuxthreads_db/td_ta_new.c b/libpthread/linuxthreads_db/td_ta_new.c
index 7bf687905..f19798b71 100644
--- a/libpthread/linuxthreads_db/td_ta_new.c
+++ b/libpthread/linuxthreads_db/td_ta_new.c
@@ -1,5 +1,5 @@
/* Attach to target process.
- Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
@@ -20,6 +20,7 @@
#include <stddef.h>
#include <stdlib.h>
+#include <string.h>
#include "thread_dbP.h"
@@ -33,9 +34,11 @@ td_err_e
td_ta_new (struct ps_prochandle *ps, td_thragent_t **ta)
{
psaddr_t addr;
+ psaddr_t versaddr;
+ char versbuf[sizeof (VERSION)];
struct agent_list *elemp;
- LOG (__FUNCTION__);
+ LOG ("td_ta_new");
/* Get the global event mask. This is one of the variables which
are new in the thread library to enable debugging. If it is
@@ -43,6 +46,17 @@ td_ta_new (struct ps_prochandle *ps, td_thragent_t **ta)
if (td_lookup (ps, PTHREAD_THREADS_EVENTS, &addr) != PS_OK)
return TD_NOLIBTHREAD;
+ /* Check whether the versions match. */
+ if (td_lookup (ps, LINUXTHREADS_VERSION, &versaddr) != PS_OK)
+ return TD_VERSION;
+ if (ps_pdread (ps, versaddr, versbuf, sizeof (versbuf)) != PS_OK)
+ return TD_ERR;
+
+ versbuf[sizeof (versbuf) - 1] = '\0';
+ if (strcmp (versbuf, VERSION) != 0)
+ /* Not the right version. */
+ return TD_VERSION;
+
/* Fill in the appropriate information. */
*ta = (td_thragent_t *) malloc (sizeof (td_thragent_t));
if (*ta == NULL)