• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* libunwind - a platform-independent unwind library
2    Copyright (c) 2002-2004 Hewlett-Packard Development Company, L.P.
3         Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
4 
5    Modified for x86_64 by Max Asbock <masbock@us.ibm.com>
6    Modified for s390x by Michael Munday <mike.munday@ibm.com>
7 
8 This file is part of libunwind.
9 
10 Permission is hereby granted, free of charge, to any person obtaining
11 a copy of this software and associated documentation files (the
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sublicense, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
17 
18 The above copyright notice and this permission notice shall be
19 included in all copies or substantial portions of the Software.
20 
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
28 
29 #include "unwind_i.h"
30 
31 HIDDEN int
tdep_access_reg(struct cursor * c,unw_regnum_t reg,unw_word_t * valp,int write)32 tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp,
33                  int write)
34 {
35   dwarf_loc_t loc = DWARF_NULL_LOC;
36 
37   switch (reg)
38     {
39     case UNW_S390X_CFA:
40       if (write)
41         return -UNW_EREADONLYREG;
42       *valp = c->dwarf.cfa;
43       return 0;
44 
45     case UNW_S390X_R0:
46     case UNW_S390X_R1:
47     case UNW_S390X_R2:
48     case UNW_S390X_R3:
49     case UNW_S390X_R4:
50     case UNW_S390X_R5:
51     case UNW_S390X_R6:
52     case UNW_S390X_R7:
53     case UNW_S390X_R8:
54     case UNW_S390X_R9:
55     case UNW_S390X_R10:
56     case UNW_S390X_R11:
57     case UNW_S390X_R12:
58     case UNW_S390X_R13:
59     case UNW_S390X_R14:
60     case UNW_S390X_IP:
61       loc = c->dwarf.loc[reg];
62       break;
63 
64     case UNW_S390X_R15:
65       if (write)
66         return -UNW_EREADONLYREG;
67       loc = c->dwarf.loc[reg];
68       break;
69 
70     default:
71       Debug (1, "bad register number %u\n", reg);
72       return -UNW_EBADREG;
73     }
74 
75   if (write)
76     return dwarf_put (&c->dwarf, loc, *valp);
77   else
78     return dwarf_get (&c->dwarf, loc, valp);
79 }
80 
81 HIDDEN int
tdep_access_fpreg(struct cursor * c,unw_regnum_t reg,unw_fpreg_t * valp,int write)82 tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, unw_fpreg_t *valp,
83                    int write)
84 {
85   dwarf_loc_t loc = DWARF_NULL_LOC;
86 
87   switch (reg)
88     {
89     case UNW_S390X_F0:
90     case UNW_S390X_F1:
91     case UNW_S390X_F2:
92     case UNW_S390X_F3:
93     case UNW_S390X_F4:
94     case UNW_S390X_F5:
95     case UNW_S390X_F6:
96     case UNW_S390X_F7:
97     case UNW_S390X_F8:
98     case UNW_S390X_F9:
99     case UNW_S390X_F10:
100     case UNW_S390X_F11:
101     case UNW_S390X_F12:
102     case UNW_S390X_F13:
103     case UNW_S390X_F14:
104     case UNW_S390X_F15:
105       loc = c->dwarf.loc[reg];
106       break;
107     default:
108       Debug (1, "bad register number %u\n", reg);
109       return -UNW_EBADREG;
110     }
111 
112   if (write)
113     return dwarf_putfp (&c->dwarf, loc, *valp);
114   else
115     return dwarf_getfp (&c->dwarf, loc, valp);
116 }
117