blob: 473a0b85872ddbdd200ac4f5664b985a017c15c4 [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
25#include <ucontext.h>
26#include "unwind_i.h"
27#include "dwarf_i.h"
28
29HIDDEN pthread_mutex_t arm_lock = PTHREAD_MUTEX_INITIALIZER;
30HIDDEN int tdep_needs_initialization = 1;
31
Arun Sharma00aed962010-05-26 19:28:44 -070032/* Unwinding methods to use. See UNW_METHOD_ enums */
33HIDDEN int unwi_unwind_method = UNW_ARM_METHOD_ALL;
34
Daniel Jacobowitz3842dac2008-02-04 17:16:37 -070035/* FIXME: I'm pretty sure we don't need this at all for ARM, but "generic"
36 code (include/dwarf_i.h) seems to expect it to be here at present. */
37
38HIDDEN uint8_t dwarf_to_unw_regnum_map[16] =
39 {
40 R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, R13, R14, R15
41 };
42
43HIDDEN void
44tdep_init (void)
45{
46 intrmask_t saved_mask;
47
48 sigfillset (&unwi_full_mask);
49
Paul Pluzhnikov84d41502009-09-21 12:02:07 -070050 lock_acquire (&arm_lock, saved_mask);
Daniel Jacobowitz3842dac2008-02-04 17:16:37 -070051 {
52 if (!tdep_needs_initialization)
53 /* another thread else beat us to it... */
54 goto out;
55
Arun Sharma00aed962010-05-26 19:28:44 -070056 /* read ARM unwind method setting */
57 const char* str = getenv ("UNW_ARM_UNWIND_METHOD");
58 if (str)
59 {
60 unwi_unwind_method = atoi (str);
61 }
62
Daniel Jacobowitz3842dac2008-02-04 17:16:37 -070063 mi_init ();
64
65 dwarf_init ();
66
67#ifndef UNW_REMOTE_ONLY
68 arm_local_addr_space_init ();
69#endif
70 tdep_needs_initialization = 0; /* signal that we're initialized... */
71 }
72 out:
Paul Pluzhnikov84d41502009-09-21 12:02:07 -070073 lock_release (&arm_lock, saved_mask);
Daniel Jacobowitz3842dac2008-02-04 17:16:37 -070074}