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

Side by Side Diff: snapshot/thread_snapshot_mac.cc

Issue 666483002: Create snapshot/mac and move some files from snapshot and util to there (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad/+/master
Patch Set: Move process_reader, process_types, and mach_o_image*_reader from util/mac to snapshot/mac 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 | « snapshot/thread_snapshot_mac.h ('k') | util/mac/checked_mach_address_range.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 "snapshot/thread_snapshot_mac.h"
16
17 #include "base/logging.h"
18 #include "snapshot/cpu_context_mac.h"
19 #include "util/mac/process_reader.h"
20
21 namespace crashpad {
22 namespace internal {
23
24 ThreadSnapshotMac::ThreadSnapshotMac()
25 : ThreadSnapshot(),
26 context_union_(),
27 context_(),
28 stack_(),
29 thread_id_(0),
30 thread_specific_data_address_(0),
31 thread_(MACH_PORT_NULL),
32 suspend_count_(0),
33 priority_(0),
34 initialized_() {
35 }
36
37 ThreadSnapshotMac::~ThreadSnapshotMac() {
38 }
39
40 bool ThreadSnapshotMac::Initialize(
41 ProcessReader* process_reader,
42 const ProcessReader::Thread& process_reader_thread) {
43 INITIALIZATION_STATE_SET_INITIALIZING(initialized_);
44
45 thread_ = process_reader_thread.port;
46 thread_id_ = process_reader_thread.id;
47 suspend_count_ = process_reader_thread.suspend_count;
48 priority_ = process_reader_thread.priority;
49 thread_specific_data_address_ =
50 process_reader_thread.thread_specific_data_address;
51
52 stack_.Initialize(process_reader,
53 process_reader_thread.stack_region_address,
54 process_reader_thread.stack_region_size);
55
56 #if defined(ARCH_CPU_X86_FAMILY)
57 if (process_reader->Is64Bit()) {
58 context_.architecture = kCPUArchitectureX86_64;
59 context_.x86_64 = &context_union_.x86_64;
60 InitializeCPUContextX86_64(context_.x86_64,
61 THREAD_STATE_NONE,
62 nullptr,
63 0,
64 &process_reader_thread.thread_context.t64,
65 &process_reader_thread.float_context.f64,
66 &process_reader_thread.debug_context.d64);
67 } else {
68 context_.architecture = kCPUArchitectureX86;
69 context_.x86 = &context_union_.x86;
70 InitializeCPUContextX86(context_.x86,
71 THREAD_STATE_NONE,
72 nullptr,
73 0,
74 &process_reader_thread.thread_context.t32,
75 &process_reader_thread.float_context.f32,
76 &process_reader_thread.debug_context.d32);
77 }
78 #endif
79
80 INITIALIZATION_STATE_SET_VALID(initialized_);
81 return true;
82 }
83
84 const CPUContext* ThreadSnapshotMac::Context() const {
85 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
86 return &context_;
87 }
88
89 const MemorySnapshot* ThreadSnapshotMac::Stack() const {
90 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
91 return &stack_;
92 }
93
94 uint64_t ThreadSnapshotMac::ThreadID() const {
95 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
96 return thread_id_;
97 }
98
99 int ThreadSnapshotMac::SuspendCount() const {
100 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
101 return suspend_count_;
102 }
103
104 int ThreadSnapshotMac::Priority() const {
105 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
106 return priority_;
107 }
108
109 uint64_t ThreadSnapshotMac::ThreadSpecificDataAddress() const {
110 INITIALIZATION_STATE_DCHECK_VALID(initialized_);
111 return thread_specific_data_address_;
112 }
113
114 } // namespace internal
115 } // namespace crashpad
OLDNEW
« no previous file with comments | « snapshot/thread_snapshot_mac.h ('k') | util/mac/checked_mach_address_range.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698