1 /* libunwind - a platform-independent unwind library
2    Copyright (C) 2006-2007 IBM
3    Contributed by
4      Corey Ashford <cjashfor@us.ibm.com>
5      Jose Flavio Aguilar Paulino <jflavio@br.ibm.com> <joseflavio@gmail.com>
6 
7 This file is part of libunwind.
8 
9 Permission is hereby granted, free of charge, to any person obtaining
10 a copy of this software and associated documentation files (the
11 "Software"), to deal in the Software without restriction, including
12 without limitation the rights to use, copy, modify, merge, publish,
13 distribute, sublicense, and/or sell copies of the Software, and to
14 permit persons to whom the Software is furnished to do so, subject to
15 the following conditions:
16 
17 The above copyright notice and this permission notice shall be
18 included in all copies or substantial portions of the Software.
19 
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
27 
28 #include "unwind_i.h"
29 
30 /* Here is the "common" init, for remote and local debuging" */
31 
32 static inline int
common_init_ppc32(struct cursor * c,unsigned use_prev_instr)33 common_init_ppc32 (struct cursor *c, unsigned use_prev_instr)
34 {
35   int ret;
36   int i;
37 
38   for (i = UNW_PPC32_R0; i <= UNW_PPC32_R31; i++) {
39     c->dwarf.loc[i] = DWARF_REG_LOC (&c->dwarf, i);
40   }
41   for (i = UNW_PPC32_F0; i <= UNW_PPC32_F31; i++) {
42     c->dwarf.loc[i] = DWARF_FPREG_LOC (&c->dwarf, i);
43   }
44 
45   c->dwarf.loc[UNW_PPC32_CTR] = DWARF_REG_LOC (&c->dwarf, UNW_PPC32_CTR);
46   c->dwarf.loc[UNW_PPC32_XER] = DWARF_REG_LOC (&c->dwarf, UNW_PPC32_XER);
47   c->dwarf.loc[UNW_PPC32_CCR] = DWARF_REG_LOC (&c->dwarf, UNW_PPC32_CCR);
48   c->dwarf.loc[UNW_PPC32_LR] = DWARF_REG_LOC (&c->dwarf, UNW_PPC32_LR);
49   c->dwarf.loc[UNW_PPC32_FPSCR] = DWARF_REG_LOC (&c->dwarf, UNW_PPC32_FPSCR);
50 
51   ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_PPC32_LR], &c->dwarf.ip);
52   if (ret < 0)
53     return ret;
54 
55   ret = dwarf_get (&c->dwarf, DWARF_REG_LOC (&c->dwarf, UNW_PPC32_R1),
56 		   &c->dwarf.cfa);
57   if (ret < 0)
58     return ret;
59 
60   c->sigcontext_format = PPC_SCF_NONE;
61   c->sigcontext_addr = 0;
62 
63   c->dwarf.args_size = 0;
64   c->dwarf.ret_addr_column = 0;
65   c->dwarf.stash_frames = 0;
66   c->dwarf.use_prev_instr = use_prev_instr;
67   c->dwarf.pi_valid = 0;
68   c->dwarf.pi_is_dynamic = 0;
69   c->dwarf.hint = 0;
70   c->dwarf.prev_rs = 0;
71   /* ANDROID support update. */
72   c->dwarf.frame = 0;
73   /* End of ANDROID update. */
74 
75   return 0;
76 }
77