td_ta_set_event.c 2.2 KB

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