Back to index

glibc  2.9
td_ta_set_event.c
Go to the documentation of this file.
00001 /* Globally enable events.
00002    Copyright (C) 1999,2001,2002,2003,2004 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Ulrich Drepper <drepper@redhat.com>, 1999.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #include "thread_dbP.h"
00022 
00023 
00024 td_err_e
00025 td_ta_set_event (ta_arg, event)
00026      const td_thragent_t *ta_arg;
00027      td_thr_events_t *event;
00028 {
00029   td_thragent_t *const ta = (td_thragent_t *) ta_arg;
00030   td_err_e err;
00031   psaddr_t eventmask = 0;
00032   void *copy = NULL;
00033 
00034   LOG ("td_ta_set_event");
00035 
00036   /* Test whether the TA parameter is ok.  */
00037   if (! ta_ok (ta))
00038     return TD_BADTA;
00039 
00040   /* Fetch the old event mask from the inferior and modify it in place.  */
00041   err = DB_GET_SYMBOL (eventmask, ta, __nptl_threads_events);
00042   if (err == TD_OK)
00043     err = DB_GET_STRUCT (copy, ta, eventmask, td_thr_events_t);
00044   if (err == TD_OK)
00045     {
00046       uint32_t idx;
00047       for (idx = 0; idx < TD_EVENTSIZE; ++idx)
00048        {
00049          psaddr_t word;
00050          uint32_t mask;
00051          err = DB_GET_FIELD_LOCAL (word, ta, copy,
00052                                 td_thr_events_t, event_bits, idx);
00053          if (err != TD_OK)
00054            break;
00055          mask = (uintptr_t) word;
00056          mask |= event->event_bits[idx];
00057          word = (psaddr_t) (uintptr_t) mask;
00058          err = DB_PUT_FIELD_LOCAL (ta, copy,
00059                                 td_thr_events_t, event_bits, idx, word);
00060          if (err != TD_OK)
00061            break;
00062        }
00063       if (err == TD_NOAPLIC)
00064        {
00065          err = TD_OK;
00066          while (idx < TD_EVENTSIZE)
00067            if (event->event_bits[idx++] != 0)
00068              {
00069               err = TD_NOEVENT;
00070               break;
00071              }
00072        }
00073       if (err == TD_OK)
00074        /* Now write it back to the inferior.  */
00075        err = DB_PUT_STRUCT (ta, eventmask, td_thr_events_t, copy);
00076     }
00077 
00078   return err;
00079 }