summaryrefslogtreecommitdiff
path: root/libpthread/linuxthreads_db/td_ta_new.c
diff options
context:
space:
mode:
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)