Chromium Code Reviews| Index: snapshot/win/process_reader_win.cc |
| diff --git a/snapshot/win/process_reader_win.cc b/snapshot/win/process_reader_win.cc |
| index 67e59e0101a2d4ecfc694e067bfd95a1511dea6c..57620d1fe4b92b8e5cf43dafdb09c570bdbbfd6b 100644 |
| --- a/snapshot/win/process_reader_win.cc |
| +++ b/snapshot/win/process_reader_win.cc |
| @@ -117,8 +117,8 @@ template <class Traits> |
| void FillThreadContextAndSuspendCount( |
| const process_types::SYSTEM_EXTENDED_THREAD_INFORMATION<Traits>& |
| thread_info, |
| - ProcessReaderWin::Thread* thread) { |
| - |
| + ProcessReaderWin::Thread* thread, |
| + ProcessSuspensionState process_state) { |
| // Don't suspend the thread if it's this thread. This is really only for test |
| // binaries, as we won't be walking ourselves, in general. |
| bool is_current_thread = thread_info.ClientId.UniqueThread == |
| @@ -138,7 +138,13 @@ void FillThreadContextAndSuspendCount( |
| PLOG(ERROR) << "SuspendThread failed"; |
| return; |
| } |
| - thread->suspend_count = previous_suspend_count; |
| + if (previous_suspend_count == 0 && |
| + process_state == ProcessSuspensionState::kSuspended) { |
| + LOG(ERROR) << "suspend count was 0, but process should be suspended"; |
|
Mark Mentovai
2015/09/09 18:57:27
Upgrade (sidegrade) to a DCHECK()? This indicates
scottmg
2015/09/09 19:13:25
Done.
|
| + } |
| + thread->suspend_count = |
| + previous_suspend_count - |
| + (process_state == ProcessSuspensionState::kSuspended ? 1 : 0); |
| memset(&thread->context, 0, sizeof(thread->context)); |
| thread->context.ContextFlags = CONTEXT_ALL; |
| @@ -171,6 +177,7 @@ ProcessReaderWin::ProcessReaderWin() |
| process_info_(), |
| threads_(), |
| modules_(), |
| + process_state_(), |
| initialized_threads_(false), |
| initialized_() { |
| } |
| @@ -178,10 +185,12 @@ ProcessReaderWin::ProcessReaderWin() |
| ProcessReaderWin::~ProcessReaderWin() { |
| } |
| -bool ProcessReaderWin::Initialize(HANDLE process) { |
| +bool ProcessReaderWin::Initialize(HANDLE process, |
| + ProcessSuspensionState process_state) { |
| INITIALIZATION_STATE_SET_INITIALIZING(initialized_); |
| process_ = process; |
| + process_state_ = process_state; |
| process_info_.Initialize(process); |
| INITIALIZATION_STATE_SET_VALID(initialized_); |
| @@ -254,7 +263,7 @@ const std::vector<ProcessReaderWin::Thread>& ProcessReaderWin::Threads() { |
| Thread thread; |
| thread.id = thread_info.ClientId.UniqueThread; |
| - FillThreadContextAndSuspendCount(thread_info, &thread); |
| + FillThreadContextAndSuspendCount(thread_info, &thread, process_state_); |
| // TODO(scottmg): I believe we could reverse engineer the PriorityClass from |
| // the Priority, BasePriority, and |