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

Side by Side Diff: snapshot/win/process_reader_win.h

Issue 1326443007: win: Fix incorrect thread suspend count due to ScopedProcessSuspend (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: assert some threads captured Created 5 years, 3 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/win/pe_image_reader_test.cc ('k') | snapshot/win/process_reader_win.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_SNAPSHOT_WIN_PROCESS_READER_WIN_H_ 15 #ifndef CRASHPAD_SNAPSHOT_WIN_PROCESS_READER_WIN_H_
16 #define CRASHPAD_SNAPSHOT_WIN_PROCESS_READER_WIN_H_ 16 #define CRASHPAD_SNAPSHOT_WIN_PROCESS_READER_WIN_H_
17 17
18 #include <sys/time.h> 18 #include <sys/time.h>
19 #include <windows.h> 19 #include <windows.h>
20 20
21 #include <vector> 21 #include <vector>
22 22
23 #include "util/misc/initialization_state_dcheck.h" 23 #include "util/misc/initialization_state_dcheck.h"
24 #include "util/win/address_types.h" 24 #include "util/win/address_types.h"
25 #include "util/win/process_info.h" 25 #include "util/win/process_info.h"
26 26
27 namespace crashpad { 27 namespace crashpad {
28 28
29 //! \brief State of process being read by ProcessReaderWin.
30 enum class ProcessSuspensionState : bool {
31 //! \brief The process has not been suspended.
32 kRunning,
33
34 //! \brief The process is suspended.
35 kSuspended,
36 };
37
29 //! \brief Accesses information about another process, identified by a `HANDLE`. 38 //! \brief Accesses information about another process, identified by a `HANDLE`.
30 class ProcessReaderWin { 39 class ProcessReaderWin {
31 public: 40 public:
32 //! \brief Contains information about a thread that belongs to a process. 41 //! \brief Contains information about a thread that belongs to a process.
33 struct Thread { 42 struct Thread {
34 Thread(); 43 Thread();
35 ~Thread() {} 44 ~Thread() {}
36 45
37 CONTEXT context; 46 CONTEXT context;
38 uint64_t id; 47 uint64_t id;
39 WinVMAddress teb; 48 WinVMAddress teb;
40 WinVMAddress stack_region_address; 49 WinVMAddress stack_region_address;
41 WinVMSize stack_region_size; 50 WinVMSize stack_region_size;
42 uint32_t suspend_count; 51 uint32_t suspend_count;
43 uint32_t priority_class; 52 uint32_t priority_class;
44 uint32_t priority; 53 uint32_t priority;
45 }; 54 };
46 55
47 ProcessReaderWin(); 56 ProcessReaderWin();
48 ~ProcessReaderWin(); 57 ~ProcessReaderWin();
49 58
50 //! \brief Initializes this object. This method must be called before any 59 //! \brief Initializes this object. This method must be called before any
51 //! other. 60 //! other.
52 //! 61 //!
53 //! \param[in] process Process handle, must have `PROCESS_QUERY_INFORMATION`, 62 //! \param[in] process Process handle, must have `PROCESS_QUERY_INFORMATION`,
54 //! `PROCESS_VM_READ`, and `PROCESS_DUP_HANDLE` access. 63 //! `PROCESS_VM_READ`, and `PROCESS_DUP_HANDLE` access.
64 //! \param[in] suspension_state Whether \a process has already been suspended
65 //! by the caller. Typically, this will be
66 //! ProcessSuspensionState::kSuspended, except for testing uses and where
67 //! the reader is reading itself.
55 //! 68 //!
56 //! \return `true` on success, indicating that this object will respond 69 //! \return `true` on success, indicating that this object will respond
57 //! validly to further method calls. `false` on failure. On failure, no 70 //! validly to further method calls. `false` on failure. On failure, no
58 //! further method calls should be made. 71 //! further method calls should be made.
59 bool Initialize(HANDLE process); 72 //!
73 //! \sa ScopedProcessSuspend
74 bool Initialize(HANDLE process, ProcessSuspensionState suspension_state);
60 75
61 //! \return `true` if the target task is a 64-bit process. 76 //! \return `true` if the target task is a 64-bit process.
62 bool Is64Bit() const { return process_info_.Is64Bit(); } 77 bool Is64Bit() const { return process_info_.Is64Bit(); }
63 78
64 pid_t ProcessID() const { return process_info_.ProcessID(); } 79 pid_t ProcessID() const { return process_info_.ProcessID(); }
65 pid_t ParentProcessID() const { return process_info_.ParentProcessID(); } 80 pid_t ParentProcessID() const { return process_info_.ParentProcessID(); }
66 81
67 bool ReadMemory(WinVMAddress at, WinVMSize num_bytes, void* into); 82 bool ReadMemory(WinVMAddress at, WinVMSize num_bytes, void* into);
68 83
69 //! \brief Determines the target process' start time. 84 //! \brief Determines the target process' start time.
(...skipping 19 matching lines...) Expand all
89 104
90 //! \return The modules loaded in the process. The first element (at index 105 //! \return The modules loaded in the process. The first element (at index
91 //! `0`) corresponds to the main executable. 106 //! `0`) corresponds to the main executable.
92 const std::vector<ProcessInfo::Module>& Modules(); 107 const std::vector<ProcessInfo::Module>& Modules();
93 108
94 private: 109 private:
95 HANDLE process_; 110 HANDLE process_;
96 ProcessInfo process_info_; 111 ProcessInfo process_info_;
97 std::vector<Thread> threads_; 112 std::vector<Thread> threads_;
98 std::vector<ProcessInfo::Module> modules_; 113 std::vector<ProcessInfo::Module> modules_;
114 ProcessSuspensionState suspension_state_;
99 bool initialized_threads_; 115 bool initialized_threads_;
100 InitializationStateDcheck initialized_; 116 InitializationStateDcheck initialized_;
101 117
102 DISALLOW_COPY_AND_ASSIGN(ProcessReaderWin); 118 DISALLOW_COPY_AND_ASSIGN(ProcessReaderWin);
103 }; 119 };
104 120
105 } // namespace crashpad 121 } // namespace crashpad
106 122
107 #endif // CRASHPAD_SNAPSHOT_WIN_PROCESS_READER_WIN_H_ 123 #endif // CRASHPAD_SNAPSHOT_WIN_PROCESS_READER_WIN_H_
OLDNEW
« no previous file with comments | « snapshot/win/pe_image_reader_test.cc ('k') | snapshot/win/process_reader_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698