Gglobal.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* libunwind - a platform-independent unwind library
  2. Copyright (C) 2008 CodeSourcery
  3. This file is part of libunwind.
  4. Permission is hereby granted, free of charge, to any person obtaining
  5. a copy of this software and associated documentation files (the
  6. "Software"), to deal in the Software without restriction, including
  7. without limitation the rights to use, copy, modify, merge, publish,
  8. distribute, sublicense, and/or sell copies of the Software, and to
  9. permit persons to whom the Software is furnished to do so, subject to
  10. the following conditions:
  11. The above copyright notice and this permission notice shall be
  12. included in all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  15. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  17. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  18. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  19. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  20. #include "unwind_i.h"
  21. #include "dwarf_i.h"
  22. HIDDEN pthread_mutex_t arm_lock = PTHREAD_MUTEX_INITIALIZER;
  23. HIDDEN int tdep_needs_initialization = 1;
  24. /* Unwinding methods to use. See UNW_METHOD_ enums */
  25. HIDDEN int unwi_unwind_method = UNW_ARM_METHOD_ALL;
  26. /* FIXME: I'm pretty sure we don't need this at all for ARM, but "generic"
  27. code (include/dwarf_i.h) seems to expect it to be here at present. */
  28. HIDDEN uint8_t dwarf_to_unw_regnum_map[16] =
  29. {
  30. /* 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 */
  31. UNW_ARM_R0, UNW_ARM_R1, UNW_ARM_R2, UNW_ARM_R3, UNW_ARM_R4, UNW_ARM_R5,
  32. UNW_ARM_R6, UNW_ARM_R7, UNW_ARM_R8, UNW_ARM_R9, UNW_ARM_R10, UNW_ARM_R11,
  33. UNW_ARM_R12, UNW_ARM_R13, UNW_ARM_R14, UNW_ARM_R15
  34. };
  35. HIDDEN void
  36. tdep_init (void)
  37. {
  38. intrmask_t saved_mask;
  39. sigfillset (&unwi_full_mask);
  40. lock_acquire (&arm_lock, saved_mask);
  41. {
  42. if (!tdep_needs_initialization)
  43. /* another thread else beat us to it... */
  44. goto out;
  45. /* read ARM unwind method setting */
  46. const char* str = getenv ("UNW_ARM_UNWIND_METHOD");
  47. if (str)
  48. {
  49. unwi_unwind_method = atoi (str);
  50. }
  51. mi_init ();
  52. dwarf_init ();
  53. #ifndef UNW_REMOTE_ONLY
  54. arm_local_addr_space_init ();
  55. #endif
  56. tdep_needs_initialization = 0; /* signal that we're initialized... */
  57. }
  58. out:
  59. lock_release (&arm_lock, saved_mask);
  60. }