1db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// Copyright (c) 2006, Google Inc. 2db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// All rights reserved. 3db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// 4db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// Redistribution and use in source and binary forms, with or without 5db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// modification, are permitted provided that the following conditions are 6db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// met: 7db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// 8db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// * Redistributions of source code must retain the above copyright 9db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// notice, this list of conditions and the following disclaimer. 10db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// * Redistributions in binary form must reproduce the above 11db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// copyright notice, this list of conditions and the following disclaimer 12db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// in the documentation and/or other materials provided with the 13db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// distribution. 14db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// * Neither the name of Google Inc. nor the names of its 15db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// contributors may be used to endorse or promote products derived from 16db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// this software without specific prior written permission. 17db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// 18db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai 30db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// basic_code_module.h: Carries information about code modules that are loaded 31db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// into a process. 32db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// 33db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// This is a basic concrete implementation of CodeModule. It cannot be 34db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// instantiated directly, only based on other objects that implement 35db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// the CodeModule interface. It exists to provide a CodeModule implementation 36db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// a place to store information when the life of the original object (such as 37db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// a MinidumpModule) cannot be guaranteed. 38db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// 39db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai// Author: Mark Mentovai 40db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai 41db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai#ifndef PROCESSOR_BASIC_CODE_MODULE_H__ 42db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai#define PROCESSOR_BASIC_CODE_MODULE_H__ 43db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai 44db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai#include <string> 45db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai 464e518a4357a2d1c379d4a91df6d4e153ee791101ivan.penkov@gmail.com#include "common/using_std_string.h" 47e5dc60822e5938fea2ae892ccddb906641ba174emmentovai#include "google_breakpad/processor/code_module.h" 48db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai 49e5dc60822e5938fea2ae892ccddb906641ba174emmentovainamespace google_breakpad { 50db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai 51db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovaiclass BasicCodeModule : public CodeModule { 52db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai public: 53db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai // Creates a new BasicCodeModule given any existing CodeModule 54db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai // implementation. This is useful to make a copy of the data relevant to 55db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai // the CodeModule interface without requiring all of the resources that 56db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai // other CodeModule implementations may require. 57db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai explicit BasicCodeModule(const CodeModule *that) 58db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai : base_address_(that->base_address()), 59db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai size_(that->size()), 60db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai code_file_(that->code_file()), 61db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai code_identifier_(that->code_identifier()), 62db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai debug_file_(that->debug_file()), 63db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai debug_identifier_(that->debug_identifier()), 64db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai version_(that->version()) {} 65b223627d81c083a64f2ccecf2651a18111421280ted.mielczarek 666162aed3c3fcfc53373c963ac375d39a5dfa5a25ted.mielczarek@gmail.com BasicCodeModule(uint64_t base_address, uint64_t size, 67b223627d81c083a64f2ccecf2651a18111421280ted.mielczarek const string &code_file, 68b223627d81c083a64f2ccecf2651a18111421280ted.mielczarek const string &code_identifier, 69b223627d81c083a64f2ccecf2651a18111421280ted.mielczarek const string &debug_file, 70b223627d81c083a64f2ccecf2651a18111421280ted.mielczarek const string &debug_identifier, 71b223627d81c083a64f2ccecf2651a18111421280ted.mielczarek const string &version) 72b223627d81c083a64f2ccecf2651a18111421280ted.mielczarek : base_address_(base_address), 73b223627d81c083a64f2ccecf2651a18111421280ted.mielczarek size_(size), 74b223627d81c083a64f2ccecf2651a18111421280ted.mielczarek code_file_(code_file), 75b223627d81c083a64f2ccecf2651a18111421280ted.mielczarek code_identifier_(code_identifier), 76b223627d81c083a64f2ccecf2651a18111421280ted.mielczarek debug_file_(debug_file), 77b223627d81c083a64f2ccecf2651a18111421280ted.mielczarek debug_identifier_(debug_identifier), 78b223627d81c083a64f2ccecf2651a18111421280ted.mielczarek version_(version) 79b223627d81c083a64f2ccecf2651a18111421280ted.mielczarek {} 80db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai virtual ~BasicCodeModule() {} 81db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai 82db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai // See code_module.h for descriptions of these methods and the associated 83db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai // members. 846162aed3c3fcfc53373c963ac375d39a5dfa5a25ted.mielczarek@gmail.com virtual uint64_t base_address() const { return base_address_; } 856162aed3c3fcfc53373c963ac375d39a5dfa5a25ted.mielczarek@gmail.com virtual uint64_t size() const { return size_; } 86db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai virtual string code_file() const { return code_file_; } 87db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai virtual string code_identifier() const { return code_identifier_; } 88db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai virtual string debug_file() const { return debug_file_; } 89db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai virtual string debug_identifier() const { return debug_identifier_; } 90db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai virtual string version() const { return version_; } 91db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai virtual const CodeModule* Copy() const { return new BasicCodeModule(this); } 92db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai 93db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai private: 946162aed3c3fcfc53373c963ac375d39a5dfa5a25ted.mielczarek@gmail.com uint64_t base_address_; 956162aed3c3fcfc53373c963ac375d39a5dfa5a25ted.mielczarek@gmail.com uint64_t size_; 96db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai string code_file_; 97db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai string code_identifier_; 98db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai string debug_file_; 99db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai string debug_identifier_; 100db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai string version_; 101db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai 102db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai // Disallow copy constructor and assignment operator. 103db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai BasicCodeModule(const BasicCodeModule &that); 104db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai void operator=(const BasicCodeModule &that); 105db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai}; 106db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai 107e5dc60822e5938fea2ae892ccddb906641ba174emmentovai} // namespace google_breakpad 108db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai 109db3342a10ec30902aa9018b80e1d9a40bd01c487mmentovai#endif // PROCESSOR_BASIC_CODE_MODULE_H__ 110