Gglobal.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* libunwind - a platform-independent unwind library
  2. Copyright (c) 2003, 2005 Hewlett-Packard Development Company, L.P.
  3. Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
  4. This file is part of libunwind.
  5. Permission is hereby granted, free of charge, to any person obtaining
  6. a copy of this software and associated documentation files (the
  7. "Software"), to deal in the Software without restriction, including
  8. without limitation the rights to use, copy, modify, merge, publish,
  9. distribute, sublicense, and/or sell copies of the Software, and to
  10. permit persons to whom the Software is furnished to do so, subject to
  11. the following conditions:
  12. The above copyright notice and this permission notice shall be
  13. included in all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  18. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  19. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  20. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  21. #include "unwind_i.h"
  22. #include "dwarf_i.h"
  23. HIDDEN pthread_mutex_t x86_lock = PTHREAD_MUTEX_INITIALIZER;
  24. HIDDEN int tdep_needs_initialization = 1;
  25. /* See comments for svr4_dbx_register_map[] in gcc/config/i386/i386.c. */
  26. HIDDEN uint8_t dwarf_to_unw_regnum_map[19] =
  27. {
  28. UNW_X86_EAX, UNW_X86_ECX, UNW_X86_EDX, UNW_X86_EBX,
  29. UNW_X86_ESP, UNW_X86_EBP, UNW_X86_ESI, UNW_X86_EDI,
  30. UNW_X86_EIP, UNW_X86_EFLAGS, UNW_X86_TRAPNO,
  31. UNW_X86_ST0, UNW_X86_ST1, UNW_X86_ST2, UNW_X86_ST3,
  32. UNW_X86_ST4, UNW_X86_ST5, UNW_X86_ST6, UNW_X86_ST7
  33. };
  34. HIDDEN void
  35. tdep_init (void)
  36. {
  37. intrmask_t saved_mask;
  38. #if (!HAVE_SGX)
  39. sigfillset (&unwi_full_mask);
  40. #endif
  41. lock_acquire (&x86_lock, saved_mask);
  42. {
  43. if (!tdep_needs_initialization)
  44. /* another thread else beat us to it... */
  45. goto out;
  46. mi_init ();
  47. dwarf_init ();
  48. #ifndef UNW_REMOTE_ONLY
  49. x86_local_addr_space_init ();
  50. #endif
  51. tdep_needs_initialization = 0; /* signal that we're initialized... */
  52. }
  53. out:
  54. lock_release (&x86_lock, saved_mask);
  55. }