• 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 /* FIXME for MIPS.  */
28 
29 PROTECTED int
unw_get_save_loc(unw_cursor_t * cursor,int reg,unw_save_loc_t * sloc)30 unw_get_save_loc (unw_cursor_t *cursor, int reg, unw_save_loc_t *sloc)
31 {
32   struct cursor *c = (struct cursor *) cursor;
33   dwarf_loc_t loc;
34 
35   loc = DWARF_NULL_LOC;		/* default to "not saved" */
36 
37   switch (reg)
38     {
39     case UNW_MIPS_R0:
40     case UNW_MIPS_R1:
41     case UNW_MIPS_R2:
42     case UNW_MIPS_R3:
43     case UNW_MIPS_R4:
44     case UNW_MIPS_R5:
45     case UNW_MIPS_R6:
46     case UNW_MIPS_R7:
47     case UNW_MIPS_R8:
48     case UNW_MIPS_R9:
49     case UNW_MIPS_R10:
50     case UNW_MIPS_R11:
51     case UNW_MIPS_R12:
52     case UNW_MIPS_R13:
53     case UNW_MIPS_R14:
54     case UNW_MIPS_R15:
55     case UNW_MIPS_R16:
56     case UNW_MIPS_R17:
57     case UNW_MIPS_R18:
58     case UNW_MIPS_R19:
59     case UNW_MIPS_R20:
60     case UNW_MIPS_R21:
61     case UNW_MIPS_R22:
62     case UNW_MIPS_R23:
63     case UNW_MIPS_R24:
64     case UNW_MIPS_R25:
65     case UNW_MIPS_R26:
66     case UNW_MIPS_R27:
67     case UNW_MIPS_R28:
68     case UNW_MIPS_R29:
69     case UNW_MIPS_R30:
70     case UNW_MIPS_R31:
71     case UNW_MIPS_PC:
72       loc = c->dwarf.loc[reg - UNW_MIPS_R0];
73       break;
74 
75     default:
76       break;
77     }
78 
79   memset (sloc, 0, sizeof (*sloc));
80 
81   if (DWARF_IS_NULL_LOC (loc))
82     {
83       sloc->type = UNW_SLT_NONE;
84       return 0;
85     }
86 
87 #if !defined(UNW_LOCAL_ONLY)
88   if (DWARF_IS_REG_LOC (loc))
89     {
90       sloc->type = UNW_SLT_REG;
91       sloc->u.regnum = DWARF_GET_LOC (loc);
92     }
93   else
94 #endif
95     {
96       sloc->type = UNW_SLT_MEMORY;
97       sloc->u.addr = DWARF_GET_LOC (loc);
98     }
99   return 0;
100 }
101