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

Side by Side Diff: util/win/process_info.h

Issue 1498133002: Add AlignedVector and use it for vector<MEMORY_BASIC_INFORMATION64> (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Address review feedback Created 5 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 | « util/util_test.gyp ('k') | util/win/process_info.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Crashpad Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ 15 #ifndef CRASHPAD_UTIL_WIN_PROCESS_INFO_H_
16 #define CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ 16 #define CRASHPAD_UTIL_WIN_PROCESS_INFO_H_
17 17
18 #include <sys/types.h> 18 #include <sys/types.h>
19 #include <windows.h> 19 #include <windows.h>
20 20
21 #include <string> 21 #include <string>
22 #include <vector> 22 #include <vector>
23 23
24 #include "base/basictypes.h" 24 #include "base/basictypes.h"
25 #include "util/misc/initialization_state_dcheck.h" 25 #include "util/misc/initialization_state_dcheck.h"
26 #include "util/numeric/checked_range.h" 26 #include "util/numeric/checked_range.h"
27 #include "util/stdlib/aligned_allocator.h"
27 #include "util/win/address_types.h" 28 #include "util/win/address_types.h"
28 29
29 namespace crashpad { 30 namespace crashpad {
30 31
31 //! \brief Gathers information about a process given its `HANDLE`. This consists 32 //! \brief Gathers information about a process given its `HANDLE`. This consists
32 //! primarily of information stored in the Process Environment Block. 33 //! primarily of information stored in the Process Environment Block.
33 class ProcessInfo { 34 class ProcessInfo {
34 public: 35 public:
36 //! \brief The return type of MemoryInfo(), for convenience.
37 using MemoryBasicInformation64Vector =
38 AlignedVector<MEMORY_BASIC_INFORMATION64>;
39
35 //! \brief Contains information about a module loaded into a process. 40 //! \brief Contains information about a module loaded into a process.
36 struct Module { 41 struct Module {
37 Module(); 42 Module();
38 ~Module(); 43 ~Module();
39 44
40 //! \brief The pathname used to load the module from disk. 45 //! \brief The pathname used to load the module from disk.
41 std::wstring name; 46 std::wstring name;
42 47
43 //! \brief The base address of the loaded DLL. 48 //! \brief The base address of the loaded DLL.
44 WinVMAddress dll_base; 49 WinVMAddress dll_base;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 void Peb(WinVMAddress* peb_address, WinVMSize* peb_size) const; 122 void Peb(WinVMAddress* peb_address, WinVMSize* peb_size) const;
118 123
119 //! \brief Retrieves the modules loaded into the target process. 124 //! \brief Retrieves the modules loaded into the target process.
120 //! 125 //!
121 //! The modules are enumerated in initialization order as detailed in the 126 //! The modules are enumerated in initialization order as detailed in the
122 //! Process Environment Block. The main executable will always be the 127 //! Process Environment Block. The main executable will always be the
123 //! first element. 128 //! first element.
124 bool Modules(std::vector<Module>* modules) const; 129 bool Modules(std::vector<Module>* modules) const;
125 130
126 //! \brief Retrieves information about all pages mapped into the process. 131 //! \brief Retrieves information about all pages mapped into the process.
127 const std::vector<MEMORY_BASIC_INFORMATION64>& MemoryInfo() const; 132 const MemoryBasicInformation64Vector& MemoryInfo() const;
128 133
129 //! \brief Given a range to be read from the target process, returns a vector 134 //! \brief Given a range to be read from the target process, returns a vector
130 //! of ranges, representing the readable portions of the original range. 135 //! of ranges, representing the readable portions of the original range.
131 //! 136 //!
132 //! \param[in] range The range being identified. 137 //! \param[in] range The range being identified.
133 //! 138 //!
134 //! \return A vector of ranges corresponding to the portion of \a range that 139 //! \return A vector of ranges corresponding to the portion of \a range that
135 //! is readable based on the memory map. 140 //! is readable based on the memory map.
136 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRanges( 141 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRanges(
137 const CheckedRange<WinVMAddress, WinVMSize>& range) const; 142 const CheckedRange<WinVMAddress, WinVMSize>& range) const;
(...skipping 29 matching lines...) Expand all
167 172
168 std::vector<Handle> BuildHandleVector(HANDLE process) const; 173 std::vector<Handle> BuildHandleVector(HANDLE process) const;
169 174
170 pid_t process_id_; 175 pid_t process_id_;
171 pid_t inherited_from_process_id_; 176 pid_t inherited_from_process_id_;
172 HANDLE process_; 177 HANDLE process_;
173 std::wstring command_line_; 178 std::wstring command_line_;
174 WinVMAddress peb_address_; 179 WinVMAddress peb_address_;
175 WinVMSize peb_size_; 180 WinVMSize peb_size_;
176 std::vector<Module> modules_; 181 std::vector<Module> modules_;
177 std::vector<MEMORY_BASIC_INFORMATION64> memory_info_; 182
183 // memory_info_ is a MemoryBasicInformation64Vector instead of a
184 // std::vector<MEMORY_BASIC_INFORMATION64> because MEMORY_BASIC_INFORMATION64
185 // is declared with __declspec(align(16)), but std::vector<> does not maintain
186 // this alignment on 32-bit x86. clang-cl (but not MSVC cl) takes advantage of
187 // the presumed alignment and emits SSE instructions that require aligned
188 // storage. clang-cl should relax (unfortunately), but in the mean time, this
189 // provides aligned storage. See https://crbug.com/564691 and
190 // http://llvm.org/PR25779.
191 //
192 // TODO(mark): Remove this workaround when http://llvm.org/PR25779 is fixed
193 // and the fix is present in the clang-cl that compiles this code.
194 MemoryBasicInformation64Vector memory_info_;
178 195
179 // Handles() is logically const, but updates this member on first retrieval. 196 // Handles() is logically const, but updates this member on first retrieval.
180 // See https://crashpad.chromium.org/bug/9. 197 // See https://crashpad.chromium.org/bug/9.
181 mutable std::vector<Handle> handles_; 198 mutable std::vector<Handle> handles_;
182 199
183 bool is_64_bit_; 200 bool is_64_bit_;
184 bool is_wow64_; 201 bool is_wow64_;
185 InitializationStateDcheck initialized_; 202 InitializationStateDcheck initialized_;
186 203
187 DISALLOW_COPY_AND_ASSIGN(ProcessInfo); 204 DISALLOW_COPY_AND_ASSIGN(ProcessInfo);
188 }; 205 };
189 206
190 //! \brief Given a memory map of a process, and a range to be read from the 207 //! \brief Given a memory map of a process, and a range to be read from the
191 //! target process, returns a vector of ranges, representing the readable 208 //! target process, returns a vector of ranges, representing the readable
192 //! portions of the original range. 209 //! portions of the original range.
193 //! 210 //!
194 //! This is a free function for testing, but prefer 211 //! This is a free function for testing, but prefer
195 //! ProcessInfo::GetReadableRanges(). 212 //! ProcessInfo::GetReadableRanges().
196 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap( 213 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap(
197 const CheckedRange<WinVMAddress, WinVMSize>& range, 214 const CheckedRange<WinVMAddress, WinVMSize>& range,
198 const std::vector<MEMORY_BASIC_INFORMATION64>& memory_info); 215 const ProcessInfo::MemoryBasicInformation64Vector& memory_info);
199 216
200 } // namespace crashpad 217 } // namespace crashpad
201 218
202 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_ 219 #endif // CRASHPAD_UTIL_WIN_PROCESS_INFO_H_
OLDNEW
« no previous file with comments | « util/util_test.gyp ('k') | util/win/process_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698