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

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

Issue 1364803004: win: Save contents of TEBs allowing !teb and !gle to work in windbg (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@dump-without-crashing
Patch Set: . Created 5 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/win/process_reader_win.h ('k') | snapshot/win/thread_snapshot_win.h » ('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,
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 170 }
171 171
172 return true; 172 return true;
173 } 173 }
174 174
175 } // namespace 175 } // namespace
176 176
177 ProcessReaderWin::Thread::Thread() 177 ProcessReaderWin::Thread::Thread()
178 : context(), 178 : context(),
179 id(0), 179 id(0),
180 teb(0), 180 teb_address(0),
181 teb_size(0),
181 stack_region_address(0), 182 stack_region_address(0),
182 stack_region_size(0), 183 stack_region_size(0),
183 suspend_count(0), 184 suspend_count(0),
184 priority_class(0), 185 priority_class(0),
185 priority(0) { 186 priority(0) {
186 } 187 }
187 188
188 ProcessReaderWin::ProcessReaderWin() 189 ProcessReaderWin::ProcessReaderWin()
189 : process_(INVALID_HANDLE_VALUE), 190 : process_(INVALID_HANDLE_VALUE),
190 process_info_(), 191 process_info_(),
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 sizeof(thread_basic_info), 326 sizeof(thread_basic_info),
326 nullptr); 327 nullptr);
327 if (!NT_SUCCESS(status)) { 328 if (!NT_SUCCESS(status)) {
328 NTSTATUS_LOG(ERROR, status) << "NtQueryInformationThread"; 329 NTSTATUS_LOG(ERROR, status) << "NtQueryInformationThread";
329 continue; 330 continue;
330 } 331 }
331 332
332 // Read the TIB (Thread Information Block) which is the first element of the 333 // Read the TIB (Thread Information Block) which is the first element of the
333 // TEB, for its stack fields. 334 // TEB, for its stack fields.
334 process_types::NT_TIB<Traits> tib; 335 process_types::NT_TIB<Traits> tib;
335 thread.teb = thread_basic_info.TebBaseAddress; 336 thread.teb_address = thread_basic_info.TebBaseAddress;
336 if (ReadMemory(thread.teb, sizeof(tib), &tib)) { 337 thread.teb_size = sizeof(process_types::TEB<Traits>);
338 if (ReadMemory(thread.teb_address, sizeof(tib), &tib)) {
337 WinVMAddress base = 0; 339 WinVMAddress base = 0;
338 WinVMAddress limit = 0; 340 WinVMAddress limit = 0;
339 // If we're reading a WOW64 process, then the TIB we just retrieved is the 341 // If we're reading a WOW64 process, then the TIB we just retrieved is the
340 // x64 one. The first word of the x64 TIB points at the x86 TIB. See 342 // x64 one. The first word of the x64 TIB points at the x86 TIB. See
341 // https://msdn.microsoft.com/en-us/library/dn424783.aspx 343 // https://msdn.microsoft.com/en-us/library/dn424783.aspx
342 if (is_64_reading_32) { 344 if (is_64_reading_32) {
343 process_types::NT_TIB<process_types::internal::Traits32> tib32; 345 process_types::NT_TIB<process_types::internal::Traits32> tib32;
344 thread.teb = tib.Wow64Teb; 346 thread.teb_address = tib.Wow64Teb;
345 if (ReadMemory(thread.teb, sizeof(tib32), &tib32)) { 347 thread.teb_size =
348 sizeof(process_types::TEB<process_types::internal::Traits32>);
349 if (ReadMemory(thread.teb_address, sizeof(tib32), &tib32)) {
346 base = tib32.StackBase; 350 base = tib32.StackBase;
347 limit = tib32.StackLimit; 351 limit = tib32.StackLimit;
348 } 352 }
349 } else { 353 } else {
350 base = tib.StackBase; 354 base = tib.StackBase;
351 limit = tib.StackLimit; 355 limit = tib.StackLimit;
352 } 356 }
353 357
354 // Note, "backwards" because of direction of stack growth. 358 // Note, "backwards" because of direction of stack growth.
355 thread.stack_region_address = limit; 359 thread.stack_region_address = limit;
356 if (limit > base) { 360 if (limit > base) {
357 LOG(ERROR) << "invalid stack range: " << base << " - " << limit; 361 LOG(ERROR) << "invalid stack range: " << base << " - " << limit;
358 thread.stack_region_size = 0; 362 thread.stack_region_size = 0;
359 } else { 363 } else {
360 thread.stack_region_size = base - limit; 364 thread.stack_region_size = base - limit;
361 } 365 }
362 } 366 }
363 threads_.push_back(thread); 367 threads_.push_back(thread);
364 } 368 }
365 } 369 }
366 370
367 } // namespace crashpad 371 } // namespace crashpad
OLDNEW
« no previous file with comments | « snapshot/win/process_reader_win.h ('k') | snapshot/win/thread_snapshot_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698