• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
25 #include "unwind_i.h"
26 
27 PROTECTED int
unw_get_save_loc(unw_cursor_t * cursor,int reg,unw_save_loc_t * sloc)28 unw_get_save_loc (unw_cursor_t *cursor, int reg, unw_save_loc_t *sloc)
29 {
30   struct cursor *c = (struct cursor *) cursor;
31   dwarf_loc_t loc;
32 
33   loc = DWARF_NULL_LOC;		/* default to "not saved" */
34 
35   switch (reg)
36     {
37     case UNW_ARM_R0:
38     case UNW_ARM_R1:
39     case UNW_ARM_R2:
40     case UNW_ARM_R3:
41     case UNW_ARM_R4:
42     case UNW_ARM_R5:
43     case UNW_ARM_R6:
44     case UNW_ARM_R7:
45     case UNW_ARM_R8:
46     case UNW_ARM_R9:
47     case UNW_ARM_R10:
48     case UNW_ARM_R11:
49     case UNW_ARM_R12:
50     case UNW_ARM_R13:
51     case UNW_ARM_R14:
52     case UNW_ARM_R15:
53       loc = c->dwarf.loc[reg - UNW_ARM_R0];
54       break;
55 
56     default:
57       break;
58     }
59 
60   memset (sloc, 0, sizeof (*sloc));
61 
62   if (DWARF_IS_NULL_LOC (loc))
63     {
64       sloc->type = UNW_SLT_NONE;
65       return 0;
66     }
67 
68 #if !defined(UNW_LOCAL_ONLY)
69   if (DWARF_IS_REG_LOC (loc))
70     {
71       sloc->type = UNW_SLT_REG;
72       sloc->u.regnum = DWARF_GET_LOC (loc);
73     }
74   else
75 #endif
76     {
77       sloc->type = UNW_SLT_MEMORY;
78       sloc->u.addr = DWARF_GET_LOC (loc);
79     }
80   return 0;
81 }
82