• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2007, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 //     * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 //     * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 //     * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 
30 // minidump_size.h: Provides a C++ template for programmatic access to
31 // the sizes of various types defined in minidump_format.h.
32 //
33 // Author: Mark Mentovai
34 
35 #ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_SIZE_H__
36 #define GOOGLE_BREAKPAD_COMMON_MINIDUMP_SIZE_H__
37 
38 #include <sys/types.h>
39 
40 #include "google_breakpad/common/minidump_format.h"
41 
42 namespace google_breakpad {
43 
44 template<typename T>
45 class minidump_size {
46  public:
size()47   static size_t size() { return sizeof(T); }
48 };
49 
50 // Explicit specializations for variable-length types.  The size returned
51 // for these should be the size for an object without its variable-length
52 // section.
53 
54 template<>
55 class minidump_size<MDString> {
56  public:
size()57   static size_t size() { return MDString_minsize; }
58 };
59 
60 template<>
61 class minidump_size<MDRawThreadList> {
62  public:
size()63   static size_t size() { return MDRawThreadList_minsize; }
64 };
65 
66 template<>
67 class minidump_size<MDCVInfoPDB20> {
68  public:
size()69   static size_t size() { return MDCVInfoPDB20_minsize; }
70 };
71 
72 template<>
73 class minidump_size<MDCVInfoPDB70> {
74  public:
size()75   static size_t size() { return MDCVInfoPDB70_minsize; }
76 };
77 
78 template<>
79 class minidump_size<MDCVInfoELF> {
80  public:
size()81   static size_t size() { return MDCVInfoELF_minsize; }
82 };
83 
84 template<>
85 class minidump_size<MDImageDebugMisc> {
86  public:
size()87   static size_t size() { return MDImageDebugMisc_minsize; }
88 };
89 
90 template<>
91 class minidump_size<MDRawModuleList> {
92  public:
size()93   static size_t size() { return MDRawModuleList_minsize; }
94 };
95 
96 template<>
97 class minidump_size<MDRawMemoryList> {
98  public:
size()99   static size_t size() { return MDRawMemoryList_minsize; }
100 };
101 
102 // Explicit specialization for MDRawModule, for which sizeof may include
103 // tail-padding on some architectures but not others.
104 
105 template<>
106 class minidump_size<MDRawModule> {
107  public:
size()108   static size_t size() { return MD_MODULE_SIZE; }
109 };
110 
111 }  // namespace google_breakpad
112 
113 #endif  // GOOGLE_BREAKPAD_COMMON_MINIDUMP_SIZE_H__
114