OLD | NEW |
| (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 #ifndef CRASHPAD_SNAPSHOT_THREAD_SNAPSHOT_MAC_H_ | |
16 #define CRASHPAD_SNAPSHOT_THREAD_SNAPSHOT_MAC_H_ | |
17 | |
18 #include <mach/mach.h> | |
19 #include <stdint.h> | |
20 | |
21 #include "base/basictypes.h" | |
22 #include "build/build_config.h" | |
23 #include "snapshot/cpu_context.h" | |
24 #include "snapshot/memory_snapshot.h" | |
25 #include "snapshot/memory_snapshot_mac.h" | |
26 #include "snapshot/thread_snapshot.h" | |
27 #include "util/misc/initialization_state_dcheck.h" | |
28 | |
29 namespace crashpad { | |
30 | |
31 class ProcessReader; | |
32 | |
33 namespace internal { | |
34 | |
35 //! \brief A ThreadSnapshot of a thread in a running (or crashed) process on a | |
36 //! Mac OS X system. | |
37 class ThreadSnapshotMac final : public ThreadSnapshot { | |
38 public: | |
39 ThreadSnapshotMac(); | |
40 ~ThreadSnapshotMac(); | |
41 | |
42 //! \brief Initializes the object. | |
43 //! | |
44 //! \param[in] process_reader A ProcessReader for the task containing the | |
45 //! thread. | |
46 //! \param[in] process_reader_thread The thread within the ProcessReader that | |
47 //! for which the snapshot should be created. | |
48 //! | |
49 //! \return `true` if the snapshot could be created, `false` otherwise with | |
50 //! an appropriate message logged. | |
51 bool Initialize(ProcessReader* process_reader, | |
52 const ProcessReader::Thread& process_reader_thread); | |
53 | |
54 // ThreadSnapshot: | |
55 | |
56 const CPUContext* Context() const override; | |
57 const MemorySnapshot* Stack() const override; | |
58 uint64_t ThreadID() const override; | |
59 int SuspendCount() const override; | |
60 int Priority() const override; | |
61 uint64_t ThreadSpecificDataAddress() const override; | |
62 | |
63 private: | |
64 #if defined(ARCH_CPU_X86_FAMILY) | |
65 union { | |
66 CPUContextX86 x86; | |
67 CPUContextX86_64 x86_64; | |
68 } context_union_; | |
69 #endif | |
70 CPUContext context_; | |
71 MemorySnapshotMac stack_; | |
72 uint64_t thread_id_; | |
73 uint64_t thread_specific_data_address_; | |
74 thread_t thread_; | |
75 int suspend_count_; | |
76 int priority_; | |
77 InitializationStateDcheck initialized_; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(ThreadSnapshotMac); | |
80 }; | |
81 | |
82 } // namespace internal | |
83 } // namespace crashpad | |
84 | |
85 #endif // CRASHPAD_SNAPSHOT_THREAD_SNAPSHOT_MAC_H_ | |
OLD | NEW |