1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/crashreporter/google-breakpad/src/common/arm_ex_to_module.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,126 @@ 1.4 + 1.5 +/* libunwind - a platform-independent unwind library 1.6 + Copyright 2011 Linaro Limited 1.7 + 1.8 +This file is part of libunwind. 1.9 + 1.10 +Permission is hereby granted, free of charge, to any person obtaining 1.11 +a copy of this software and associated documentation files (the 1.12 +"Software"), to deal in the Software without restriction, including 1.13 +without limitation the rights to use, copy, modify, merge, publish, 1.14 +distribute, sublicense, and/or sell copies of the Software, and to 1.15 +permit persons to whom the Software is furnished to do so, subject to 1.16 +the following conditions: 1.17 + 1.18 +The above copyright notice and this permission notice shall be 1.19 +included in all copies or substantial portions of the Software. 1.20 + 1.21 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 1.22 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 1.23 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 1.24 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 1.25 +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 1.26 +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 1.27 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 1.28 + 1.29 +// Copyright (c) 2010 Google Inc. 1.30 +// All rights reserved. 1.31 +// 1.32 +// Redistribution and use in source and binary forms, with or without 1.33 +// modification, are permitted provided that the following conditions are 1.34 +// met: 1.35 +// 1.36 +// * Redistributions of source code must retain the above copyright 1.37 +// notice, this list of conditions and the following disclaimer. 1.38 +// * Redistributions in binary form must reproduce the above 1.39 +// copyright notice, this list of conditions and the following disclaimer 1.40 +// in the documentation and/or other materials provided with the 1.41 +// distribution. 1.42 +// * Neither the name of Google Inc. nor the names of its 1.43 +// contributors may be used to endorse or promote products derived from 1.44 +// this software without specific prior written permission. 1.45 +// 1.46 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.47 +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.48 +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.49 +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1.50 +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.51 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.52 +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.53 +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.54 +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.55 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.56 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.57 + 1.58 + 1.59 +// Derived from libunwind, with extensive modifications. 1.60 + 1.61 +#ifndef COMMON_ARM_EX_TO_MODULE__ 1.62 +#define COMMON_ARM_EX_TO_MODULE__ 1.63 + 1.64 +#include "common/module.h" 1.65 + 1.66 +#include <string.h> 1.67 + 1.68 +namespace arm_ex_to_module { 1.69 + 1.70 +using google_breakpad::Module; 1.71 + 1.72 +typedef enum extab_cmd { 1.73 + ARM_EXIDX_CMD_FINISH, 1.74 + ARM_EXIDX_CMD_SUB_FROM_VSP, 1.75 + ARM_EXIDX_CMD_ADD_TO_VSP, 1.76 + ARM_EXIDX_CMD_REG_POP, 1.77 + ARM_EXIDX_CMD_REG_TO_SP, 1.78 + ARM_EXIDX_CMD_VFP_POP, 1.79 + ARM_EXIDX_CMD_WREG_POP, 1.80 + ARM_EXIDX_CMD_WCGR_POP, 1.81 + ARM_EXIDX_CMD_RESERVED, 1.82 + ARM_EXIDX_CMD_REFUSED, 1.83 +} extab_cmd_t; 1.84 + 1.85 +struct exidx_entry { 1.86 + uint32_t addr; 1.87 + uint32_t data; 1.88 +}; 1.89 + 1.90 +struct extab_data { 1.91 + extab_cmd_t cmd; 1.92 + uint32_t data; 1.93 +}; 1.94 + 1.95 +enum extab_cmd_flags { 1.96 + ARM_EXIDX_VFP_SHIFT_16 = 1 << 16, 1.97 + ARM_EXIDX_VFP_FSTMD = 1 << 17, // distinguishes FSTMxxD from FSTMxxX 1.98 +}; 1.99 + 1.100 +static const char* const regnames[] = { 1.101 + "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", 1.102 + "r8", "r9", "r10", "r11", "r12", "sp", "lr", "pc", 1.103 + "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", 1.104 + "fps", "cpsr" 1.105 +}; 1.106 + 1.107 +// Receives information from arm_ex_reader::ExceptionTableInfo 1.108 +// and adds it to the Module object 1.109 +class ARMExToModule { 1.110 + public: 1.111 + ARMExToModule(Module* module) 1.112 + : module_(module) { } 1.113 + ~ARMExToModule() { } 1.114 + void AddStackFrame(uintptr_t addr, size_t size); 1.115 + int ImproveStackFrame(const struct extab_data* edata); 1.116 + void DeleteStackFrame(); 1.117 + void SubmitStackFrame(); 1.118 + private: 1.119 + Module* module_; 1.120 + Module::StackFrameEntry* stack_frame_entry_; 1.121 + Module::Expr vsp_; 1.122 + int TranslateCmd(const struct extab_data* edata, 1.123 + Module::StackFrameEntry* entry, 1.124 + Module::Expr& vsp); 1.125 +}; 1.126 + 1.127 +} // namespace arm_ex_to_module 1.128 + 1.129 +#endif // COMMON_ARM_EX_TO_MODULE__