blob: 54dcd9d5fece5e803f77d742e581f13fe463658e [file] [log] [blame]
Daniel Jacobowitz3842dac2008-02-04 17:16:37 -07001/* libunwind - a platform-independent unwind library
2 Copyright (C) 2008 CodeSourcery
3
4This file is part of libunwind.
5
6Permission is hereby granted, free of charge, to any person obtaining
7a copy of this software and associated documentation files (the
8"Software"), to deal in the Software without restriction, including
9without limitation the rights to use, copy, modify, merge, publish,
10distribute, sublicense, and/or sell copies of the Software, and to
11permit persons to whom the Software is furnished to do so, subject to
12the following conditions:
13
14The above copyright notice and this permission notice shall be
15included in all copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
24
Daniel Jacobowitz3842dac2008-02-04 17:16:37 -070025#include "unwind_i.h"
26#include "dwarf_i.h"
27
28HIDDEN pthread_mutex_t arm_lock = PTHREAD_MUTEX_INITIALIZER;
29HIDDEN int tdep_needs_initialization = 1;
30
Arun Sharma00aed962010-05-26 19:28:44 -070031/* Unwinding methods to use. See UNW_METHOD_ enums */
32HIDDEN int unwi_unwind_method = UNW_ARM_METHOD_ALL;
33
Daniel Jacobowitz3842dac2008-02-04 17:16:37 -070034/* 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
37HIDDEN uint8_t dwarf_to_unw_regnum_map[16] =
38 {
Ken Werner0eba2162011-10-25 07:33:38 +000039 /* 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 Jacobowitz3842dac2008-02-04 17:16:37 -070043 };
44
45HIDDEN void
46tdep_init (void)
47{
48 intrmask_t saved_mask;
49
50 sigfillset (&unwi_full_mask);
51
Paul Pluzhnikov84d41502009-09-21 12:02:07 -070052 lock_acquire (&arm_lock, saved_mask);
Daniel Jacobowitz3842dac2008-02-04 17:16:37 -070053 {
54 if (!tdep_needs_initialization)
55 /* another thread else beat us to it... */
56 goto out;
57
Arun Sharma00aed962010-05-26 19:28:44 -070058 /* 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 Jacobowitz3842dac2008-02-04 17:16:37 -070065 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 Pluzhnikov84d41502009-09-21 12:02:07 -070075 lock_release (&arm_lock, saved_mask);
Daniel Jacobowitz3842dac2008-02-04 17:16:37 -070076}