1d4e76214Sopenharmony_ci/* libunwind - a platform-independent unwind library
2d4e76214Sopenharmony_ci   Copyright (C) 2008 CodeSourcery
3d4e76214Sopenharmony_ci
4d4e76214Sopenharmony_ciThis file is part of libunwind.
5d4e76214Sopenharmony_ci
6d4e76214Sopenharmony_ciPermission is hereby granted, free of charge, to any person obtaining
7d4e76214Sopenharmony_cia copy of this software and associated documentation files (the
8d4e76214Sopenharmony_ci"Software"), to deal in the Software without restriction, including
9d4e76214Sopenharmony_ciwithout limitation the rights to use, copy, modify, merge, publish,
10d4e76214Sopenharmony_cidistribute, sublicense, and/or sell copies of the Software, and to
11d4e76214Sopenharmony_cipermit persons to whom the Software is furnished to do so, subject to
12d4e76214Sopenharmony_cithe following conditions:
13d4e76214Sopenharmony_ci
14d4e76214Sopenharmony_ciThe above copyright notice and this permission notice shall be
15d4e76214Sopenharmony_ciincluded in all copies or substantial portions of the Software.
16d4e76214Sopenharmony_ci
17d4e76214Sopenharmony_ciTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18d4e76214Sopenharmony_ciEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19d4e76214Sopenharmony_ciMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20d4e76214Sopenharmony_ciNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21d4e76214Sopenharmony_ciLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22d4e76214Sopenharmony_ciOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23d4e76214Sopenharmony_ciWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
24d4e76214Sopenharmony_ci
25d4e76214Sopenharmony_ci#include "unwind_i.h"
26d4e76214Sopenharmony_ci
27d4e76214Sopenharmony_cistatic inline int
28d4e76214Sopenharmony_cicommon_init (struct cursor *c, unsigned use_prev_instr)
29d4e76214Sopenharmony_ci{
30d4e76214Sopenharmony_ci  int ret, i;
31d4e76214Sopenharmony_ci
32d4e76214Sopenharmony_ci  for (i = 0; i < 32; i++)
33d4e76214Sopenharmony_ci    c->dwarf.loc[i] = DWARF_REG_LOC (&c->dwarf, UNW_MIPS_R0 + i);
34d4e76214Sopenharmony_ci  for (i = 32; i < DWARF_NUM_PRESERVED_REGS; ++i)
35d4e76214Sopenharmony_ci    c->dwarf.loc[i] = DWARF_NULL_LOC;
36d4e76214Sopenharmony_ci
37d4e76214Sopenharmony_ci  c->dwarf.loc[UNW_MIPS_PC] = DWARF_REG_LOC (&c->dwarf, UNW_MIPS_PC);
38d4e76214Sopenharmony_ci
39d4e76214Sopenharmony_ci  ret = dwarf_get (&c->dwarf, c->dwarf.loc[UNW_MIPS_PC], &c->dwarf.ip);
40d4e76214Sopenharmony_ci  if (ret < 0)
41d4e76214Sopenharmony_ci    return ret;
42d4e76214Sopenharmony_ci
43d4e76214Sopenharmony_ci  ret = dwarf_get (&c->dwarf, DWARF_REG_LOC (&c->dwarf, UNW_MIPS_R29),
44d4e76214Sopenharmony_ci                   &c->dwarf.cfa);
45d4e76214Sopenharmony_ci  if (ret < 0)
46d4e76214Sopenharmony_ci    return ret;
47d4e76214Sopenharmony_ci
48d4e76214Sopenharmony_ci  /* FIXME: Initialisation for other registers.  */
49d4e76214Sopenharmony_ci
50d4e76214Sopenharmony_ci  c->dwarf.args_size = 0;
51d4e76214Sopenharmony_ci  c->dwarf.stash_frames = 0;
52d4e76214Sopenharmony_ci  c->dwarf.use_prev_instr = use_prev_instr;
53d4e76214Sopenharmony_ci  c->dwarf.pi_valid = 0;
54d4e76214Sopenharmony_ci  c->dwarf.pi_is_dynamic = 0;
55d4e76214Sopenharmony_ci  c->dwarf.hint = 0;
56d4e76214Sopenharmony_ci  c->dwarf.prev_rs = 0;
57d4e76214Sopenharmony_ci
58d4e76214Sopenharmony_ci  return 0;
59d4e76214Sopenharmony_ci}
60