td_ta_set_event.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 (ta_arg, event)
  20. const td_thragent_t *ta_arg;
  21. td_thr_events_t *event;
  22. {
  23. td_thragent_t *const ta = (td_thragent_t *) ta_arg;
  24. td_err_e err;
  25. psaddr_t eventmask = 0;
  26. void *copy = NULL;
  27. LOG ("td_ta_set_event");
  28. /* Test whether the TA parameter is ok. */
  29. if (! ta_ok (ta))
  30. return TD_BADTA;
  31. /* Fetch the old event mask from the inferior and modify it in place. */
  32. err = DB_GET_SYMBOL (eventmask, ta, __nptl_threads_events);
  33. if (err == TD_OK)
  34. err = DB_GET_STRUCT (copy, ta, eventmask, td_thr_events_t);
  35. if (err == TD_OK)
  36. {
  37. uint32_t idx;
  38. for (idx = 0; idx < TD_EVENTSIZE; ++idx)
  39. {
  40. psaddr_t word;
  41. uint32_t mask;
  42. err = DB_GET_FIELD_LOCAL (word, ta, copy,
  43. td_thr_events_t, event_bits, idx);
  44. if (err != TD_OK)
  45. break;
  46. mask = (uintptr_t) word;
  47. mask |= event->event_bits[idx];
  48. word = (psaddr_t) (uintptr_t) mask;
  49. err = DB_PUT_FIELD_LOCAL (ta, copy,
  50. td_thr_events_t, event_bits, idx, word);
  51. if (err != TD_OK)
  52. break;
  53. }
  54. if (err == TD_NOAPLIC)
  55. {
  56. err = TD_OK;
  57. while (idx < TD_EVENTSIZE)
  58. if (event->event_bits[idx++] != 0)
  59. {
  60. err = TD_NOEVENT;
  61. break;
  62. }
  63. }
  64. if (err == TD_OK)
  65. /* Now write it back to the inferior. */
  66. err = DB_PUT_STRUCT (ta, eventmask, td_thr_events_t, copy);
  67. }
  68. return err;
  69. }