diff options
Diffstat (limited to 'nptl_db/td_ta_new.c')
-rw-r--r-- | nptl_db/td_ta_new.c | 58 |
1 files changed, 49 insertions, 9 deletions
diff --git a/nptl_db/td_ta_new.c b/nptl_db/td_ta_new.c index f84049af34..bbb4234f68 100644 --- a/nptl_db/td_ta_new.c +++ b/nptl_db/td_ta_new.c @@ -1,5 +1,5 @@ /* Attach to target process. - Copyright (C) 1999,2001,2002,2003 Free Software Foundation, Inc. + Copyright (C) 1999,2001,2002,2003,2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 1999. @@ -30,18 +30,14 @@ be exactly one so we don't spend much though on making it fast. */ LIST_HEAD (__td_agent_list); - -td_err_e -td_ta_new (struct ps_prochandle *ps, td_thragent_t **ta) +static td_err_e +check_version (struct ps_prochandle *ps, psaddr_t versaddr) { - psaddr_t versaddr; char versbuf[sizeof (VERSION)]; - LOG ("td_ta_new"); - - /* Check whether the versions match. */ - if (td_lookup (ps, SYM_nptl_version, &versaddr) != PS_OK) + if (versaddr == 0) return TD_NOLIBTHREAD; + if (ps_pdread (ps, versaddr, versbuf, sizeof (versbuf)) != PS_OK) return TD_ERR; @@ -49,11 +45,35 @@ td_ta_new (struct ps_prochandle *ps, td_thragent_t **ta) /* Not the right version. */ return TD_VERSION; + return TD_OK; +} + +td_err_e +td_ta_new (struct ps_prochandle *ps, td_thragent_t **ta) +{ + psaddr_t versaddr = 0; + psaddr_t dl_versaddr = 0; + + LOG ("td_ta_new"); + + /* Check whether the versions match. */ + if (td_lookup_1 (ps, SYM_nptl_version, &versaddr, false) != PS_OK + && td_lookup_1 (ps, SYM__thread_db_dl_nptl_version, + &dl_versaddr, true) != PS_OK) + return TD_NOLIBTHREAD; + + td_err_e result = check_version (ps, versaddr ?: dl_versaddr); + if (result != TD_OK) + return result; + /* Fill in the appropriate information. */ *ta = (td_thragent_t *) calloc (1, sizeof (td_thragent_t)); if (*ta == NULL) return TD_MALLOC; + (*ta)->ta_addr_nptl_version = versaddr; + (*ta)->ta_addr__thread_db_dl_nptl_version = dl_versaddr; + /* Store the proc handle which we will pass to the callback functions back into the debugger. */ (*ta)->ph = ps; @@ -63,3 +83,23 @@ td_ta_new (struct ps_prochandle *ps, td_thragent_t **ta) return TD_OK; } + +td_err_e +_td_ta_check_nptl (td_thragent_t *ta) +{ + if (ta->ta_addr_nptl_version != 0) + return TD_OK; + + if (ta->ta_addr__thread_db_dl_nptl_version == 0) + return TD_BADTA; + + psaddr_t versaddr = 0; + if (td_lookup_1 (ta->ph, SYM_nptl_version, &versaddr, false) != PS_OK) + return TD_NOLIBTHREAD; + + td_err_e result = check_version (ta->ph, versaddr); + if (result == TD_OK) + ta->ta_addr_nptl_version = versaddr; + + return result; +} |