Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Side by Side Diff: client/crashpad_info.cc

Issue 808623002: win: Get client/crashpad_info.cc to compile (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: . Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "client/crashpad_info.h" 15 #include "client/crashpad_info.h"
16 16
17 #include "build/build_config.h"
18 #include "util/stdlib/cxx.h"
19
20 #if defined(OS_MACOSX)
17 #include <mach-o/loader.h> 21 #include <mach-o/loader.h>
18 22 #endif
19 #include "util/stdlib/cxx.h"
20 23
21 #if CXX_LIBRARY_VERSION >= 2011 24 #if CXX_LIBRARY_VERSION >= 2011
22 #include <type_traits> 25 #include <type_traits>
23 #endif 26 #endif
24 27
25 namespace { 28 namespace {
26 29
27 static const uint32_t kCrashpadInfoVersion = 1; 30 static const uint32_t kCrashpadInfoVersion = 1;
28 31
29 } // namespace 32 } // namespace
30 33
31 namespace crashpad { 34 namespace crashpad {
32 35
33 #if CXX_LIBRARY_VERSION >= 2011 || DOXYGEN 36 #if CXX_LIBRARY_VERSION >= 2011 || DOXYGEN
34 // In C++11, check that CrashpadInfo has standard layout, which is what is 37 // In C++11, check that CrashpadInfo has standard layout, which is what is
35 // actually important. 38 // actually important.
36 static_assert(std::is_standard_layout<CrashpadInfo>::value, 39 static_assert(std::is_standard_layout<CrashpadInfo>::value,
37 "CrashpadInfo must be standard layout"); 40 "CrashpadInfo must be standard layout");
38 #else 41 #else
39 // In C++98 (ISO 14882), section 9.5.1 says that a union cannot have a member 42 // In C++98 (ISO 14882), section 9.5.1 says that a union cannot have a member
40 // with a non-trivial ctor, copy ctor, dtor, or assignment operator. Use this 43 // with a non-trivial ctor, copy ctor, dtor, or assignment operator. Use this
41 // property to ensure that CrashpadInfo remains POD. This doesn’t work for C++11 44 // property to ensure that CrashpadInfo remains POD. This doesn’t work for C++11
42 // because the requirements for unions have been relaxed. 45 // because the requirements for unions have been relaxed.
43 union Compile_Assert { 46 union Compile_Assert {
44 CrashpadInfo Compile_Assert__CrashpadInfo_must_be_pod; 47 CrashpadInfo Compile_Assert__CrashpadInfo_must_be_pod;
45 }; 48 };
46 #endif 49 #endif
47 50
48 // Put the structure in __DATA,__crashpad_info where it can be easily found 51 // This structure needs to be stored somewhere that is easy to find without
49 // without having to consult the symbol table. The “used” attribute prevents it 52 // external information.
50 // from being dead-stripped. This isn’t placed in an unnamed namespace: 53 //
51 // hopefully, this will catch attempts to place multiple copies of this 54 // It isn’t placed in an unnamed namespace: hopefully, this will catch attempts
52 // structure into the same module. If that’s attempted, and the name of the 55 // to place multiple copies of this structure into the same module. If that’s
53 // symbol is the same in each translation unit, it will result in a linker 56 // attempted, and the name of the symbol is the same in each translation unit,
54 // error, which is better than having multiple structures show up. 57 // it will result in a linker error, which is better than having multiple
58 // structures show up.
55 // 59 //
56 // This may result in a static module initializer in debug-mode builds, but 60 // This may result in a static module initializer in debug-mode builds, but
57 // because it’s POD, no code should need to run to initialize this under 61 // because it’s POD, no code should need to run to initialize this under
58 // release-mode optimization. 62 // release-mode optimization.
63 #if defined(OS_MACOSX)
64
65 // Put the structure in __DATA,__crashpad_info where it can be easily found
66 // without having to consult the symbol table. The “used” attribute prevents it
67 // from being dead-stripped.
59 __attribute__((section(SEG_DATA ",__crashpad_info"), 68 __attribute__((section(SEG_DATA ",__crashpad_info"),
60 used, 69 used,
61 visibility("hidden"))) CrashpadInfo g_crashpad_info; 70 visibility("hidden"))) CrashpadInfo g_crashpad_info;
62 71
72 #elif defined(OS_WIN)
73
74 // TODO(scottmg): Tag in a way that makes it easy to locate on Windows.
75 CrashpadInfo g_crashpad_info;
76
77 #endif
78
63 // static 79 // static
64 CrashpadInfo* CrashpadInfo::GetCrashpadInfo() { 80 CrashpadInfo* CrashpadInfo::GetCrashpadInfo() {
65 return &g_crashpad_info; 81 return &g_crashpad_info;
66 } 82 }
67 83
68 CrashpadInfo::CrashpadInfo() 84 CrashpadInfo::CrashpadInfo()
69 : signature_(kSignature), 85 : signature_(kSignature),
70 size_(sizeof(*this)), 86 size_(sizeof(*this)),
71 version_(kCrashpadInfoVersion), 87 version_(kCrashpadInfoVersion),
72 padding_0_(0), 88 padding_0_(0),
73 simple_annotations_(nullptr) { 89 simple_annotations_(nullptr) {
74 } 90 }
75 91
76 const uint32_t CrashpadInfo::kSignature; 92 const uint32_t CrashpadInfo::kSignature;
77 93
78 } // namespace crashpad 94 } // namespace crashpad
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698