/thirdparty/breakpad/google_breakpad/common/minidump_size.h

http://github.com/tomahawk-player/tomahawk · C++ Header · 107 lines · 52 code · 18 blank · 37 comment · 0 complexity · 98d4f44dbb991d70cb08ea14b42843bc MD5 · raw file

  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. // minidump_size.h: Provides a C++ template for programmatic access to
  30. // the sizes of various types defined in minidump_format.h.
  31. //
  32. // Author: Mark Mentovai
  33. #ifndef GOOGLE_BREAKPAD_COMMON_MINIDUMP_SIZE_H__
  34. #define GOOGLE_BREAKPAD_COMMON_MINIDUMP_SIZE_H__
  35. #include <sys/types.h>
  36. #include "google_breakpad/common/minidump_format.h"
  37. namespace google_breakpad {
  38. template<typename T>
  39. class minidump_size {
  40. public:
  41. static size_t size() { return sizeof(T); }
  42. };
  43. // Explicit specializations for variable-length types. The size returned
  44. // for these should be the size for an object without its variable-length
  45. // section.
  46. template<>
  47. class minidump_size<MDString> {
  48. public:
  49. static size_t size() { return MDString_minsize; }
  50. };
  51. template<>
  52. class minidump_size<MDRawThreadList> {
  53. public:
  54. static size_t size() { return MDRawThreadList_minsize; }
  55. };
  56. template<>
  57. class minidump_size<MDCVInfoPDB20> {
  58. public:
  59. static size_t size() { return MDCVInfoPDB20_minsize; }
  60. };
  61. template<>
  62. class minidump_size<MDCVInfoPDB70> {
  63. public:
  64. static size_t size() { return MDCVInfoPDB70_minsize; }
  65. };
  66. template<>
  67. class minidump_size<MDImageDebugMisc> {
  68. public:
  69. static size_t size() { return MDImageDebugMisc_minsize; }
  70. };
  71. template<>
  72. class minidump_size<MDRawModuleList> {
  73. public:
  74. static size_t size() { return MDRawModuleList_minsize; }
  75. };
  76. template<>
  77. class minidump_size<MDRawMemoryList> {
  78. public:
  79. static size_t size() { return MDRawMemoryList_minsize; }
  80. };
  81. // Explicit specialization for MDRawModule, for which sizeof may include
  82. // tail-padding on some architectures but not others.
  83. template<>
  84. class minidump_size<MDRawModule> {
  85. public:
  86. static size_t size() { return MD_MODULE_SIZE; }
  87. };
  88. } // namespace google_breakpad
  89. #endif // GOOGLE_BREAKPAD_COMMON_MINIDUMP_SIZE_H__