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 HIDDEN int
tdep_access_reg(struct cursor * c,unw_regnum_t reg,unw_word_t * valp,int write)28 tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp,
29 int write)
30 {
31 dwarf_loc_t loc = DWARF_NULL_LOC;
32
33 switch (reg)
34 {
35 case UNW_ARM_R0:
36 case UNW_ARM_R1:
37 case UNW_ARM_R2:
38 case UNW_ARM_R3:
39 case UNW_ARM_R4:
40 case UNW_ARM_R5:
41 case UNW_ARM_R6:
42 case UNW_ARM_R7:
43 case UNW_ARM_R8:
44 case UNW_ARM_R9:
45 case UNW_ARM_R10:
46 case UNW_ARM_R11:
47 case UNW_ARM_R12:
48 case UNW_ARM_R14:
49 case UNW_ARM_R15:
50 loc = c->dwarf.loc[reg - UNW_ARM_R0];
51 break;
52
53 case UNW_ARM_R13:
54 case UNW_ARM_CFA:
55 if (write)
56 return -UNW_EREADONLYREG;
57 *valp = c->dwarf.cfa;
58 return 0;
59
60 /* FIXME: Initialise coprocessor & shadow registers? */
61
62 default:
63 Debug (1, "bad register number %u\n", reg);
64 return -UNW_EBADREG;
65 }
66
67 if (write)
68 return dwarf_put (&c->dwarf, loc, *valp);
69 else
70 return dwarf_get (&c->dwarf, loc, valp);
71 }
72
73 /* FIXME for ARM. */
74
75 HIDDEN int
tdep_access_fpreg(struct cursor * c,unw_regnum_t reg,unw_fpreg_t * valp,int write)76 tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, unw_fpreg_t *valp,
77 int write)
78 {
79 Debug (1, "bad register number %u\n", reg);
80 return -UNW_EBADREG;
81 }
82