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

Side by Side Diff: client/crashpad_info.cc

Issue 651283003: Add crashpad_info, MachOImageAnnotationsReader, and its test (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Rebase onto master Created 6 years, 2 months 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 | « client/crashpad_info.h ('k') | snapshot/mac/mach_o_image_annotations_reader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "client/crashpad_info.h"
16
17 #include <mach-o/loader.h>
18
19 #if CXX_LIBRARY_VERSION >= 2011
20 #include <type_traits>
21 #endif
22
23 namespace {
24
25 static const uint32_t kCrashpadInfoVersion = 1;
26
27 } // namespace
28
29 namespace crashpad {
30
31 #if CXX_LIBRARY_VERSION >= 2011
32 // In C++11, check that CrashpadInfo has standard layout, which is what is
33 // actually important.
34 static_assert(std::is_standard_layout<CrashpadInfo>::value,
35 "CrashpadInfo must be standard layout");
36 #else
37 // In C++98 (ISO 14882), section 9.5.1 says that a union cannot have a member
38 // with a non-trivial ctor, copy ctor, dtor, or assignment operator. Use this
39 // property to ensure that CrashpadInfo remains POD. This doesn’t work for C++11
40 // because the requirements for unions have been relaxed.
41 union Compile_Assert {
42 CrashpadInfo Compile_Assert__CrashpadInfo_must_be_pod;
43 };
44 #endif
45
46 // Put the structure in __DATA,__crashpad_info where it can be easily found
47 // without having to consult the symbol table. The “used” attribute prevents it
48 // from being dead-stripped. This isn’t placed in an unnamed namespace:
49 // hopefully, this will catch attempts to place multiple copies of this
50 // structure into the same module. If that’s attempted, and the name of the
51 // symbol is the same in each translation unit, it will result in a linker
52 // error, which is better than having multiple structures show up.
53 //
54 // This may result in a static module initializer in debug-mode builds, but
55 // because it’s POD, no code should need to run to initialize this under
56 // release-mode optimization.
57 __attribute__((section(SEG_DATA ",__crashpad_info"),
58 used,
59 visibility("hidden"))) CrashpadInfo g_crashpad_info;
60
61 // static
62 CrashpadInfo* CrashpadInfo::GetCrashpadInfo() {
63 return &g_crashpad_info;
64 }
65
66 CrashpadInfo::CrashpadInfo()
67 : signature_(kSignature),
68 size_(sizeof(*this)),
69 version_(kCrashpadInfoVersion),
70 padding_0_(0),
71 simple_annotations_(nullptr) {
72 }
73
74 const uint32_t CrashpadInfo::kSignature;
75
76 } // namespace crashpad
OLDNEW
« no previous file with comments | « client/crashpad_info.h ('k') | snapshot/mac/mach_o_image_annotations_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698