1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/crashreporter/google-breakpad/src/common/arm_ex_reader.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,115 @@ 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_READER_H__ 1.62 +#define COMMON_ARM_EX_READER_H__ 1.63 + 1.64 +#include "common/arm_ex_to_module.h" 1.65 +#include "common/memory_range.h" 1.66 + 1.67 +namespace arm_ex_reader { 1.68 + 1.69 +// This class is a reader for ARM unwind information 1.70 +// from .ARM.exidx and .ARM.extab sections. 1.71 +class ExceptionTableInfo { 1.72 + public: 1.73 + ExceptionTableInfo(const char* exidx, size_t exidx_size, 1.74 + const char* extab, size_t extab_size, 1.75 + uint32_t text_last_svma, 1.76 + arm_ex_to_module::ARMExToModule* handler, 1.77 + const char* mapping_addr, 1.78 + uint32_t loading_addr) 1.79 + : mr_exidx_(google_breakpad::MemoryRange(exidx, exidx_size)), 1.80 + mr_extab_(google_breakpad::MemoryRange(extab, extab_size)), 1.81 + text_last_svma_(text_last_svma), 1.82 + handler_(handler), mapping_addr_(mapping_addr), 1.83 + loading_addr_(loading_addr) { } 1.84 + 1.85 + ~ExceptionTableInfo() { } 1.86 + 1.87 + // Parses the entries in .ARM.exidx and possibly 1.88 + // in .ARM.extab tables, reports what we find to 1.89 + // arm_ex_to_module::ARMExToModule. 1.90 + void Start(); 1.91 + 1.92 + private: 1.93 + google_breakpad::MemoryRange mr_exidx_; 1.94 + google_breakpad::MemoryRange mr_extab_; 1.95 + uint32_t text_last_svma_; 1.96 + arm_ex_to_module::ARMExToModule* handler_; 1.97 + const char* mapping_addr_; 1.98 + uint32_t loading_addr_; 1.99 + 1.100 + enum ExExtractResult { 1.101 + ExSuccess, // success 1.102 + ExInBufOverflow, // out-of-range while reading .exidx 1.103 + ExOutBufOverflow, // output buffer is too small 1.104 + ExCantUnwind, // this function is marked CANT_UNWIND 1.105 + ExCantRepresent, // entry valid, but we can't represent it 1.106 + ExInvalid // entry is invalid 1.107 + }; 1.108 + ExExtractResult 1.109 + ExtabEntryExtract(const struct arm_ex_to_module::exidx_entry* entry, 1.110 + uint8_t* buf, size_t buf_size, 1.111 + /*OUT*/size_t* buf_used); 1.112 + 1.113 + int ExtabEntryDecode(const uint8_t* buf, size_t buf_size); 1.114 +}; 1.115 + 1.116 +} // namespace arm_ex_reader 1.117 + 1.118 +#endif // COMMON_ARM_EX_READER_H__