1d4e76214Sopenharmony_ci/* libunwind - a platform-independent unwind library 2d4e76214Sopenharmony_ci Copyright (C) 2006-2007 IBM 3d4e76214Sopenharmony_ci Contributed by 4d4e76214Sopenharmony_ci Corey Ashford <cjashfor@us.ibm.com> 5d4e76214Sopenharmony_ci Jose Flavio Aguilar Paulino <jflavio@br.ibm.com> <joseflavio@gmail.com> 6d4e76214Sopenharmony_ci 7d4e76214Sopenharmony_ciThis file is part of libunwind. 8d4e76214Sopenharmony_ci 9d4e76214Sopenharmony_ciPermission is hereby granted, free of charge, to any person obtaining 10d4e76214Sopenharmony_cia copy of this software and associated documentation files (the 11d4e76214Sopenharmony_ci"Software"), to deal in the Software without restriction, including 12d4e76214Sopenharmony_ciwithout limitation the rights to use, copy, modify, merge, publish, 13d4e76214Sopenharmony_cidistribute, sublicense, and/or sell copies of the Software, and to 14d4e76214Sopenharmony_cipermit persons to whom the Software is furnished to do so, subject to 15d4e76214Sopenharmony_cithe following conditions: 16d4e76214Sopenharmony_ci 17d4e76214Sopenharmony_ciThe above copyright notice and this permission notice shall be 18d4e76214Sopenharmony_ciincluded in all copies or substantial portions of the Software. 19d4e76214Sopenharmony_ci 20d4e76214Sopenharmony_ciTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21d4e76214Sopenharmony_ciEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22d4e76214Sopenharmony_ciMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23d4e76214Sopenharmony_ciNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24d4e76214Sopenharmony_ciLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25d4e76214Sopenharmony_ciOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26d4e76214Sopenharmony_ciWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 27d4e76214Sopenharmony_ci 28d4e76214Sopenharmony_ci#include "unwind_i.h" 29d4e76214Sopenharmony_ci 30d4e76214Sopenharmony_cistatic inline int 31d4e76214Sopenharmony_cicommon_init_ppc64 (struct cursor *c, unsigned use_prev_instr) 32d4e76214Sopenharmony_ci{ 33d4e76214Sopenharmony_ci int ret; 34d4e76214Sopenharmony_ci int i; 35d4e76214Sopenharmony_ci 36d4e76214Sopenharmony_ci for (i = UNW_PPC64_R0; i <= UNW_PPC64_R31; i++) { 37d4e76214Sopenharmony_ci c->dwarf.loc[i] = DWARF_REG_LOC (&c->dwarf, i); 38d4e76214Sopenharmony_ci } 39d4e76214Sopenharmony_ci for (i = UNW_PPC64_F0; i <= UNW_PPC64_F31; i++) { 40d4e76214Sopenharmony_ci c->dwarf.loc[i] = DWARF_FPREG_LOC (&c->dwarf, i); 41d4e76214Sopenharmony_ci } 42d4e76214Sopenharmony_ci for (i = UNW_PPC64_V0; i <= UNW_PPC64_V31; i++) { 43d4e76214Sopenharmony_ci c->dwarf.loc[i] = DWARF_VREG_LOC (&c->dwarf, i); 44d4e76214Sopenharmony_ci } 45d4e76214Sopenharmony_ci 46d4e76214Sopenharmony_ci for (i = UNW_PPC64_CR0; i <= UNW_PPC64_CR7; i++) { 47d4e76214Sopenharmony_ci c->dwarf.loc[i] = DWARF_REG_LOC (&c->dwarf, i); 48d4e76214Sopenharmony_ci } 49d4e76214Sopenharmony_ci c->dwarf.loc[UNW_PPC64_ARG_POINTER] = DWARF_REG_LOC (&c->dwarf, UNW_PPC64_ARG_POINTER); 50d4e76214Sopenharmony_ci c->dwarf.loc[UNW_PPC64_CTR] = DWARF_REG_LOC (&c->dwarf, UNW_PPC64_CTR); 51d4e76214Sopenharmony_ci c->dwarf.loc[UNW_PPC64_VSCR] = DWARF_REG_LOC (&c->dwarf, UNW_PPC64_VSCR); 52d4e76214Sopenharmony_ci 53d4e76214Sopenharmony_ci c->dwarf.loc[UNW_PPC64_XER] = DWARF_REG_LOC (&c->dwarf, UNW_PPC64_XER); 54d4e76214Sopenharmony_ci c->dwarf.loc[UNW_PPC64_LR] = DWARF_REG_LOC (&c->dwarf, UNW_PPC64_LR); 55d4e76214Sopenharmony_ci c->dwarf.loc[UNW_PPC64_VRSAVE] = DWARF_REG_LOC (&c->dwarf, UNW_PPC64_VRSAVE); 56d4e76214Sopenharmony_ci c->dwarf.loc[UNW_PPC64_SPEFSCR] = DWARF_REG_LOC (&c->dwarf, UNW_PPC64_SPEFSCR); 57d4e76214Sopenharmony_ci c->dwarf.loc[UNW_PPC64_SPE_ACC] = DWARF_REG_LOC (&c->dwarf, UNW_PPC64_SPE_ACC); 58d4e76214Sopenharmony_ci 59d4e76214Sopenharmony_ci c->dwarf.loc[UNW_PPC64_NIP] = DWARF_REG_LOC (&c->dwarf, UNW_PPC64_NIP); 60d4e76214Sopenharmony_ci 61d4e76214Sopenharmony_ci ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_PPC64_NIP], &c->dwarf.ip); 62d4e76214Sopenharmony_ci if (ret < 0) 63d4e76214Sopenharmony_ci return ret; 64d4e76214Sopenharmony_ci 65d4e76214Sopenharmony_ci ret = dwarf_get (&c->dwarf, DWARF_REG_LOC (&c->dwarf, UNW_PPC64_R1), 66d4e76214Sopenharmony_ci &c->dwarf.cfa); 67d4e76214Sopenharmony_ci if (ret < 0) 68d4e76214Sopenharmony_ci return ret; 69d4e76214Sopenharmony_ci 70d4e76214Sopenharmony_ci c->sigcontext_format = PPC_SCF_NONE; 71d4e76214Sopenharmony_ci c->sigcontext_addr = 0; 72d4e76214Sopenharmony_ci 73d4e76214Sopenharmony_ci c->dwarf.args_size = 0; 74d4e76214Sopenharmony_ci c->dwarf.stash_frames = 0; 75d4e76214Sopenharmony_ci c->dwarf.use_prev_instr = use_prev_instr; 76d4e76214Sopenharmony_ci c->dwarf.pi_valid = 0; 77d4e76214Sopenharmony_ci c->dwarf.pi_is_dynamic = 0; 78d4e76214Sopenharmony_ci c->dwarf.hint = 0; 79d4e76214Sopenharmony_ci c->dwarf.prev_rs = 0; 80d4e76214Sopenharmony_ci 81d4e76214Sopenharmony_ci return 0; 82d4e76214Sopenharmony_ci} 83