td_ta_set_event.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* Globally enable events.
  2. Copyright (C) 1999,2001,2002,2003,2004 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Ulrich Drepper <drepper@redhat.com>, 1999.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. #include "thread_dbP.h"
  18. td_err_e
  19. td_ta_set_event (const td_thragent_t *ta_arg, td_thr_events_t *event)
  20. {
  21. td_thragent_t *const ta = (td_thragent_t *) ta_arg;
  22. td_err_e err;
  23. psaddr_t eventmask = 0;
  24. void *copy = NULL;
  25. LOG ("td_ta_set_event");
  26. /* Test whether the TA parameter is ok. */
  27. if (! ta_ok (ta))
  28. return TD_BADTA;
  29. /* Fetch the old event mask from the inferior and modify it in place. */
  30. err = DB_GET_SYMBOL (eventmask, ta, __nptl_threads_events);
  31. if (err == TD_OK)
  32. err = DB_GET_STRUCT (copy, ta, eventmask, td_thr_events_t);
  33. if (err == TD_OK)
  34. {
  35. uint32_t idx;
  36. for (idx = 0; idx < TD_EVENTSIZE; ++idx)
  37. {
  38. psaddr_t word;
  39. uint32_t mask;
  40. err = DB_GET_FIELD_LOCAL (word, ta, copy,
  41. td_thr_events_t, event_bits, idx);
  42. if (err != TD_OK)
  43. break;
  44. mask = (uintptr_t) word;
  45. mask |= event->event_bits[idx];
  46. word = (psaddr_t) (uintptr_t) mask;
  47. err = DB_PUT_FIELD_LOCAL (ta, copy,
  48. td_thr_events_t, event_bits, idx, word);
  49. if (err != TD_OK)
  50. break;
  51. }
  52. if (err == TD_NOAPLIC)
  53. {
  54. err = TD_OK;
  55. while (idx < TD_EVENTSIZE)
  56. if (event->event_bits[idx++] != 0)
  57. {
  58. err = TD_NOEVENT;
  59. break;
  60. }
  61. }
  62. if (err == TD_OK)
  63. /* Now write it back to the inferior. */
  64. err = DB_PUT_STRUCT (ta, eventmask, td_thr_events_t, copy);
  65. }
  66. return err;
  67. }