Ginit_remote.c 2.2 KB

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