2002-04-04 21:04:09 +02:00
|
|
|
/* libunwind - a platform-independent unwind library
|
2003-01-21 18:41:20 +01:00
|
|
|
Copyright (C) 2002-2003 Hewlett-Packard Co
|
2002-04-04 21:04:09 +02:00
|
|
|
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
|
|
|
|
|
|
|
|
This file is part of libunwind.
|
|
|
|
|
2002-11-16 04:25:36 +01:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
a copy of this software and associated documentation files (the
|
|
|
|
"Software"), to deal in the Software without restriction, including
|
|
|
|
without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
the following conditions:
|
2002-04-04 21:04:09 +02:00
|
|
|
|
2002-11-16 04:25:36 +01:00
|
|
|
The above copyright notice and this permission notice shall be
|
|
|
|
included in all copies or substantial portions of the Software.
|
2002-04-04 21:04:09 +02:00
|
|
|
|
2002-11-16 04:25:36 +01:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
|
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
2002-04-04 21:04:09 +02:00
|
|
|
|
|
|
|
#include "unwind_i.h"
|
|
|
|
|
2002-07-18 05:58:34 +02:00
|
|
|
static inline int
|
2002-12-19 08:16:50 +01:00
|
|
|
common_init (struct cursor *c)
|
2002-04-04 21:04:09 +02:00
|
|
|
{
|
2003-01-21 18:41:20 +01:00
|
|
|
unw_word_t bspstore;
|
2002-04-04 21:04:09 +02:00
|
|
|
int i, ret;
|
|
|
|
|
2003-04-23 07:56:59 +02:00
|
|
|
c->cfm_loc = IA64_REG_LOC (c, UNW_IA64_CFM);
|
|
|
|
c->loc[IA64_REG_BSP] = IA64_REG_LOC (c, UNW_IA64_AR_BSP);
|
|
|
|
c->loc[IA64_REG_BSPSTORE] = IA64_REG_LOC (c, UNW_IA64_AR_BSPSTORE);
|
|
|
|
c->loc[IA64_REG_PFS] = IA64_REG_LOC (c, UNW_IA64_AR_PFS);
|
|
|
|
c->loc[IA64_REG_RNAT] = IA64_REG_LOC (c, UNW_IA64_AR_RNAT);
|
|
|
|
c->loc[IA64_REG_IP] = IA64_REG_LOC (c, UNW_IA64_IP);
|
|
|
|
c->loc[IA64_REG_PRI_UNAT_MEM] = IA64_NULL_LOC; /* no primary UNaT location */
|
|
|
|
c->loc[IA64_REG_UNAT] = IA64_REG_LOC (c, UNW_IA64_AR_UNAT);
|
|
|
|
c->loc[IA64_REG_PR] = IA64_REG_LOC (c, UNW_IA64_PR);
|
|
|
|
c->loc[IA64_REG_LC] = IA64_REG_LOC (c, UNW_IA64_AR_LC);
|
|
|
|
c->loc[IA64_REG_FPSR] = IA64_REG_LOC (c, UNW_IA64_AR_FPSR);
|
|
|
|
|
|
|
|
c->loc[IA64_REG_R4] = IA64_REG_LOC (c, UNW_IA64_GR + 4);
|
|
|
|
c->loc[IA64_REG_R5] = IA64_REG_LOC (c, UNW_IA64_GR + 5);
|
|
|
|
c->loc[IA64_REG_R6] = IA64_REG_LOC (c, UNW_IA64_GR + 6);
|
|
|
|
c->loc[IA64_REG_R7] = IA64_REG_LOC (c, UNW_IA64_GR + 7);
|
2002-04-04 21:04:09 +02:00
|
|
|
|
|
|
|
/* This says that each NaT bit is stored along with the
|
|
|
|
corresponding preserved register: */
|
2003-04-23 07:56:59 +02:00
|
|
|
c->loc[IA64_REG_NAT4] = IA64_LOC_REG (4, 0);
|
|
|
|
c->loc[IA64_REG_NAT5] = IA64_LOC_REG (5, 0);
|
|
|
|
c->loc[IA64_REG_NAT6] = IA64_LOC_REG (6, 0);
|
|
|
|
c->loc[IA64_REG_NAT7] = IA64_LOC_REG (7, 0);
|
|
|
|
|
|
|
|
c->loc[IA64_REG_B1] = IA64_REG_LOC (c, UNW_IA64_BR + 1);
|
|
|
|
c->loc[IA64_REG_B2] = IA64_REG_LOC (c, UNW_IA64_BR + 2);
|
|
|
|
c->loc[IA64_REG_B3] = IA64_REG_LOC (c, UNW_IA64_BR + 3);
|
|
|
|
c->loc[IA64_REG_B4] = IA64_REG_LOC (c, UNW_IA64_BR + 4);
|
|
|
|
c->loc[IA64_REG_B5] = IA64_REG_LOC (c, UNW_IA64_BR + 5);
|
|
|
|
|
|
|
|
c->loc[IA64_REG_F2] = IA64_FPREG_LOC (c, UNW_IA64_FR + 2);
|
|
|
|
c->loc[IA64_REG_F3] = IA64_FPREG_LOC (c, UNW_IA64_FR + 3);
|
|
|
|
c->loc[IA64_REG_F4] = IA64_FPREG_LOC (c, UNW_IA64_FR + 4);
|
|
|
|
c->loc[IA64_REG_F5] = IA64_FPREG_LOC (c, UNW_IA64_FR + 5);
|
|
|
|
for (i = IA64_REG_F16; i <= IA64_REG_F31; ++i)
|
|
|
|
c->loc[i] = IA64_FPREG_LOC (c, UNW_IA64_FR + 16 + (i - IA64_REG_F16));
|
|
|
|
|
|
|
|
ret = ia64_get (c, c->loc[IA64_REG_IP], &c->ip);
|
2002-04-04 21:04:09 +02:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2003-01-23 19:47:51 +01:00
|
|
|
ret = ia64_get (c, c->cfm_loc, &c->cfm);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2003-04-23 07:56:59 +02:00
|
|
|
ret = ia64_get (c, c->loc[IA64_REG_PR], &c->pr);
|
2002-04-04 21:04:09 +02:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = ia64_get (c, IA64_REG_LOC (c, UNW_IA64_GR + 12), &c->sp);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
c->psp = c->sp;
|
|
|
|
|
2003-04-23 07:56:59 +02:00
|
|
|
ret = ia64_get (c, c->loc[IA64_REG_BSP], &c->bsp);
|
2002-04-04 21:04:09 +02:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2003-04-23 07:56:59 +02:00
|
|
|
ret = ia64_get (c, c->loc[IA64_REG_BSPSTORE], &bspstore);
|
2003-01-21 18:41:20 +01:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2003-02-21 08:36:26 +01:00
|
|
|
c->rbs_curr = c->rbs_left_edge = 0;
|
|
|
|
|
|
|
|
/* There is no way to know the real size of the most recent
|
2003-04-23 07:56:59 +02:00
|
|
|
(right-most) RBS so we'll just assume it to occupy a quarter of
|
|
|
|
the address space (so we have a notion of "above" and "below" and
|
|
|
|
one bit to indicate whether the backing store needs to be
|
|
|
|
accessed via uc_access(3)). */
|
2003-01-21 18:41:20 +01:00
|
|
|
c->rbs_area[0].end = bspstore;
|
2003-02-21 08:36:26 +01:00
|
|
|
c->rbs_area[0].size = ((unw_word_t) 1) << 63; /* initial guess... */
|
2003-01-21 18:41:20 +01:00
|
|
|
c->rbs_area[0].rnat_loc = IA64_REG_LOC (c, UNW_IA64_AR_RNAT);
|
2003-04-23 07:56:59 +02:00
|
|
|
debug (10, "%s: initial rbs-area: [?-0x%llx), rnat@%s\n", __FUNCTION__,
|
|
|
|
(long long) c->rbs_area[0].end,
|
|
|
|
ia64_strloc (c->rbs_area[0].rnat_loc));
|
2003-01-21 18:41:20 +01:00
|
|
|
|
2002-04-04 21:04:09 +02:00
|
|
|
c->pi.flags = 0;
|
|
|
|
|
2003-04-23 07:56:59 +02:00
|
|
|
c->sigcontext_addr = 0;
|
|
|
|
c->abi_marker = 0;
|
2003-04-25 09:44:23 +02:00
|
|
|
c->last_abi_marker = 0;
|
2002-04-04 21:04:09 +02:00
|
|
|
|
|
|
|
c->hint = 0;
|
|
|
|
c->prev_script = 0;
|
2003-02-08 11:10:59 +01:00
|
|
|
c->eh_valid_mask = 0;
|
2002-12-12 10:17:41 +01:00
|
|
|
c->pi_valid = 0;
|
|
|
|
return 0;
|
2002-04-04 21:04:09 +02:00
|
|
|
}
|