1a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock/* libunwind - a platform-independent unwind library 2a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock Copyright (C) 2004 Hewlett-Packard Co 3a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock Contributed by David Mosberger-Tang <davidm@hpl.hp.com> 4a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock 5a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock Modified for x86_64 by Max Asbock <masbock@us.ibm.com> 6a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock 7a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbockThis file is part of libunwind. 8a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock 9a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbockPermission is hereby granted, free of charge, to any person obtaining 10a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbocka copy of this software and associated documentation files (the 11a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock"Software"), to deal in the Software without restriction, including 12a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbockwithout limitation the rights to use, copy, modify, merge, publish, 13a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbockdistribute, sublicense, and/or sell copies of the Software, and to 14a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbockpermit persons to whom the Software is furnished to do so, subject to 15a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbockthe following conditions: 16a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock 17a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbockThe above copyright notice and this permission notice shall be 18a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbockincluded in all copies or substantial portions of the Software. 19a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock 20a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbockTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbockEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbockMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbockNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbockLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbockOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbockWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 27a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock 28a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock#include "unwind_i.h" 29a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock 30a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbockPROTECTED int 31a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbockunw_get_save_loc (unw_cursor_t *cursor, int reg, unw_save_loc_t *sloc) 32a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock{ 33a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock struct cursor *c = (struct cursor *) cursor; 34a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock dwarf_loc_t loc; 35a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock 36a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock loc = DWARF_NULL_LOC; /* default to "not saved" */ 37a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock 38a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock switch (reg) 39a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock { 40a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock case UNW_X86_64_RBX: loc = c->dwarf.loc[RBX]; break; 41a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock case UNW_X86_64_RSP: loc = c->dwarf.loc[RSP]; break; 42a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock case UNW_X86_64_RBP: loc = c->dwarf.loc[RBP]; break; 43a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock case UNW_X86_64_R12: loc = c->dwarf.loc[R12]; break; 44a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock case UNW_X86_64_R13: loc = c->dwarf.loc[R13]; break; 45a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock case UNW_X86_64_R14: loc = c->dwarf.loc[R14]; break; 46a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock case UNW_X86_64_R15: loc = c->dwarf.loc[R15]; break; 47a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock 48a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock default: 49a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock break; 50a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock } 51a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock 52f89fb17695e8137a5f4e23570bf9f53374186c96Arun memset (sloc, 0, sizeof (*sloc)); 53a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock 54a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock if (DWARF_IS_NULL_LOC (loc)) 55a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock { 56a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock sloc->type = UNW_SLT_NONE; 57a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock return 0; 58a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock } 59a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock 60a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock#if !defined(UNW_LOCAL_ONLY) 61a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock if (DWARF_IS_REG_LOC (loc)) 62a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock { 63a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock sloc->type = UNW_SLT_REG; 64a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock sloc->u.regnum = DWARF_GET_LOC (loc); 65a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock } 66a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock else 67a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock#endif 68a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock { 69a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock sloc->type = UNW_SLT_MEMORY; 70a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock sloc->u.addr = DWARF_GET_LOC (loc); 71a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock } 72a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock return 0; 73a766efd844260866e0d216f6eeef87f4593f60b2ibm.com!masbock} 74