• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* libunwind - a platform-independent unwind library
2    Copyright (C) 2008 CodeSourcery
3    Copyright (C) 2011-2013 Linaro Limited
4 
5 This file is part of libunwind.
6 
7 Permission is hereby granted, free of charge, to any person obtaining
8 a copy of this software and associated documentation files (the
9 "Software"), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, sublicense, and/or sell copies of the Software, and to
12 permit persons to whom the Software is furnished to do so, subject to
13 the following conditions:
14 
15 The above copyright notice and this permission notice shall be
16 included in all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
25 
26 #include "unwind_i.h"
27 #include "init.h"
28 
29 #ifdef UNW_REMOTE_ONLY
30 
31 int
unw_init_local(unw_cursor_t * cursor,unw_context_t * uc)32 unw_init_local (unw_cursor_t *cursor, unw_context_t *uc)
33 {
34   return -UNW_EINVAL;
35 }
36 
37 #else /* !UNW_REMOTE_ONLY */
38 
39 static int
unw_init_local_common(unw_cursor_t * cursor,unw_context_t * uc,unsigned use_prev_instr)40 unw_init_local_common (unw_cursor_t *cursor, unw_context_t *uc, unsigned use_prev_instr)
41 {
42   struct cursor *c = (struct cursor *) cursor;
43 
44   if (!atomic_load(&tdep_init_done))
45     tdep_init ();
46 
47   Debug (1, "(cursor=%p)\n", c);
48 
49   c->dwarf.as = unw_local_addr_space;
50   c->dwarf.as_arg = c;
51   c->dwarf.as->pid = -1;
52   c->dwarf.cached_map = NULL;
53   c->dwarf.rel_pc = 0;
54   c->dwarf.reg_sz = 0;
55   c->uc = uc;
56   c->validate = 0;
57 
58   return common_init (c, use_prev_instr);
59 }
60 
61 int
unw_init_local_with_as(unw_addr_space_t as,unw_cursor_t * cursor,unw_context_t * uc)62 unw_init_local_with_as(unw_addr_space_t as, unw_cursor_t *cursor, unw_context_t *uc)
63 {
64   int ret = unw_init_local_common(cursor, uc, 1);
65   struct cursor *c = (struct cursor *) cursor;
66   c->dwarf.as = as;
67   return ret;
68 }
69 
70 int
unw_init_local(unw_cursor_t * cursor,unw_context_t * uc)71 unw_init_local (unw_cursor_t *cursor, unw_context_t *uc)
72 {
73   return unw_init_local_common(cursor, uc, 1);
74 }
75 
76 int
unw_init_local2(unw_cursor_t * cursor,unw_tdep_context_t * uc,int flag)77 unw_init_local2 (unw_cursor_t *cursor, unw_tdep_context_t *uc, int flag)
78 {
79   if (!flag)
80     {
81       return unw_init_local_common(cursor, uc, 1);
82     }
83   else if (flag == UNW_INIT_SIGNAL_FRAME)
84     {
85       return unw_init_local_common(cursor, uc, 0);
86     }
87   else
88     {
89       return -UNW_EINVAL;
90     }
91 }
92 
93 #endif /* !UNW_REMOTE_ONLY */
94