Home | History | Annotate | Download | only in ia64
      1 /* libunwind - a platform-independent unwind library
      2    Copyright (C) 2001-2002, 2004 Hewlett-Packard Co
      3 	Contributed by David Mosberger-Tang <davidm (at) hpl.hp.com>
      4 
      5 This file is part of libunwind.
      6 
      7 Permission is hereby granted, free of charge, to any person obtaining
      8 a copy of this software and associated documentation files (the
      9 "Software"), to deal in the Software without restriction, including
     10 without limitation the rights to use, copy, modify, merge, publish,
     11 distribute, sublicense, and/or sell copies of the Software, and to
     12 permit persons to whom the Software is furnished to do so, subject to
     13 the following conditions:
     14 
     15 The above copyright notice and this permission notice shall be
     16 included in all copies or substantial portions of the Software.
     17 
     18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     21 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
     22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
     23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
     24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
     25 
     26 #include "init.h"
     27 #include "unwind_i.h"
     28 
     29 PROTECTED int
     30 unw_init_remote (unw_cursor_t *cursor, unw_addr_space_t as, void *as_arg)
     31 {
     32 #ifdef UNW_LOCAL_ONLY
     33   return -UNW_EINVAL;
     34 #else /* !UNW_LOCAL_ONLY */
     35   struct cursor *c = (struct cursor *) cursor;
     36   unw_word_t sp, bsp;
     37   int ret;
     38 
     39   if (!tdep_init_done)
     40     tdep_init ();
     41 
     42   Debug (1, "(cursor=%p)\n", c);
     43 
     44   if (as == unw_local_addr_space)
     45     /* This special-casing is unfortunate and shouldn't be needed;
     46        however, both Linux and HP-UX need to adjust the context a bit
     47        before it's usable.  Try to think of a cleaner way of doing
     48        this.  Not sure it's possible though, as long as we want to be
     49        able to use the context returned by getcontext() et al.  */
     50     return unw_init_local (cursor, as_arg);
     51 
     52   c->as = as;
     53   c->as_arg = as_arg;
     54 
     55   if ((ret = ia64_get (c, IA64_REG_LOC (c, UNW_IA64_GR + 12), &sp)) < 0
     56       || (ret = ia64_get (c, IA64_REG_LOC (c, UNW_IA64_AR_BSP), &bsp)) < 0)
     57     return ret;
     58 
     59   return common_init (c, sp, bsp);
     60 #endif /* !UNW_LOCAL_ONLY */
     61 }
     62