Planeshift

minidump_size.h

Go to the documentation of this file.
00001 // Copyright (c) 2007, Google Inc.
00002 // All rights reserved.
00003 //
00004 // Redistribution and use in source and binary forms, with or without
00005 // modification, are permitted provided that the following conditions are
00006 // met:
00007 //
00008 //     * Redistributions of source code must retain the above copyright
00009 // notice, this list of conditions and the following disclaimer.
00010 //     * Redistributions in binary form must reproduce the above
00011 // copyright notice, this list of conditions and the following disclaimer
00012 // in the documentation and/or other materials provided with the
00013 // distribution.
00014 //     * Neither the name of Google Inc. nor the names of its
00015 // contributors may be used to endorse or promote products derived from
00016 // this software without specific prior written permission.
00017 //
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00019 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00021 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00022 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00023 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00024 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00025 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00026 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00027 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00028 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
00029 
00030 // minidump_size.h: Provides a C++ template for programmatic access to
00031 // the sizes of various types defined in minidump_format.h.
00032 //
00033 // Author: Mark Mentovai
00034 
00035 #ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_SIZE_H__
00036 #define GOOGLE_BREAKPAD_COMMON_MINIDUMP_SIZE_H__
00037 
00038 #include <sys/types.h>
00039 
00040 #include "google_breakpad/common/minidump_format.h"
00041 
00042 namespace google_breakpad {
00043 
00044 template<typename T>
00045 class minidump_size {
00046  public:
00047   static size_t size() { return sizeof(T); }
00048 };
00049 
00050 // Explicit specializations for variable-length types.  The size returned
00051 // for these should be the size for an object without its variable-length
00052 // section.
00053 
00054 template<>
00055 class minidump_size<MDString> {
00056  public:
00057   static size_t size() { return MDString_minsize; }
00058 };
00059 
00060 template<>
00061 class minidump_size<MDRawThreadList> {
00062  public:
00063   static size_t size() { return MDRawThreadList_minsize; }
00064 };
00065 
00066 template<>
00067 class minidump_size<MDCVInfoPDB20> {
00068  public:
00069   static size_t size() { return MDCVInfoPDB20_minsize; }
00070 };
00071 
00072 template<>
00073 class minidump_size<MDCVInfoPDB70> {
00074  public:
00075   static size_t size() { return MDCVInfoPDB70_minsize; }
00076 };
00077 
00078 template<>
00079 class minidump_size<MDImageDebugMisc> {
00080  public:
00081   static size_t size() { return MDImageDebugMisc_minsize; }
00082 };
00083 
00084 template<>
00085 class minidump_size<MDRawModuleList> {
00086  public:
00087   static size_t size() { return MDRawModuleList_minsize; }
00088 };
00089 
00090 template<>
00091 class minidump_size<MDRawMemoryList> {
00092  public:
00093   static size_t size() { return MDRawMemoryList_minsize; }
00094 };
00095 
00096 // Explicit specialization for MDRawModule, for which sizeof may include
00097 // tail-padding on some architectures but not others.
00098 
00099 template<>
00100 class minidump_size<MDRawModule> {
00101  public:
00102   static size_t size() { return MD_MODULE_SIZE; }
00103 };
00104 
00105 }  // namespace google_breakpad
00106 
00107 #endif  // GOOGLE_BREAKPAD_COMMON_MINIDUMP_SIZE_H__