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