Gregs.c revision 8d5b1aeeffb80515197fd7aeee0b3fbfac904ecd
1c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch/* libunwind - a platform-independent unwind library 22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Copyright (C) 2008 CodeSourcery 32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Copyright (C) 2012 Tommi Rantala <tt.rantala@gmail.com> 42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen MurdochThis file is part of libunwind. 6c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)Permission is hereby granted, free of charge, to any person obtaining 82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)a copy of this software and associated documentation files (the 92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)"Software"), to deal in the Software without restriction, including 102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)without limitation the rights to use, copy, modify, merge, publish, 112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)distribute, sublicense, and/or sell copies of the Software, and to 122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)permit persons to whom the Software is furnished to do so, subject to 132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)the following conditions: 142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)The above copyright notice and this permission notice shall be 162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)included in all copies or substantial portions of the Software. 172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 18c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen MurdochTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen MurdochMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen MurdochLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 26868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "unwind_i.h" 27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)HIDDEN int 292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)tdep_access_reg (struct cursor *c, unw_regnum_t reg, unw_word_t *valp, 302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int write) 31c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch{ 322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) dwarf_loc_t loc = DWARF_NULL_LOC; 33c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) switch (reg) 357d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) { 36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) case UNW_SH_R0: 37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) case UNW_SH_R1: 38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) case UNW_SH_R2: 3958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) case UNW_SH_R3: 4058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) case UNW_SH_R4: 4158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) case UNW_SH_R5: 4258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) case UNW_SH_R6: 4358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) case UNW_SH_R7: 4458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) case UNW_SH_R8: 45868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) case UNW_SH_R9: 46868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) case UNW_SH_R10: 47a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) case UNW_SH_R11: 48a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) case UNW_SH_R12: 49a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) case UNW_SH_R13: 50a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) case UNW_SH_R14: 512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case UNW_SH_PC: 522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case UNW_SH_PR: 532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) loc = c->dwarf.loc[reg]; 542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) break; 552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) case UNW_SH_R15: 572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (write) 58868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) return -UNW_EREADONLYREG; 59868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) *valp = c->dwarf.cfa; 60868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) return 0; 612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) default: 63868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) Debug (1, "bad register number %u\n", reg); 64868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) return -UNW_EBADREG; 65868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) } 662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (write) 682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return dwarf_put (&c->dwarf, loc, *valp); 692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) else 702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return dwarf_get (&c->dwarf, loc, valp); 712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)HIDDEN int 742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)tdep_access_fpreg (struct cursor *c, unw_regnum_t reg, unw_fpreg_t *valp, 752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int write) 762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles){ 772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Debug (1, "bad register number %u\n", reg); 782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return -UNW_EBADREG; 79c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch} 80