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

Side by Side Diff: base/profiler/native_stack_sampler_win.cc

Issue 1394203003: Fix -Wunused-function error in native_stack_sampler_win.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 | « no previous file | no next file » | 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 Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <objbase.h> 5 #include <objbase.h>
6 #include <windows.h> 6 #include <windows.h>
7 #include <winternl.h> 7 #include <winternl.h>
8 8
9 #include <cstdlib> 9 #include <cstdlib>
10 #include <map> 10 #include <map>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 NTSTATUS status = 70 NTSTATUS status =
71 nt_query_information_thread(thread_handle, ThreadBasicInformation, 71 nt_query_information_thread(thread_handle, ThreadBasicInformation,
72 &basic_info, sizeof(THREAD_BASIC_INFORMATION), 72 &basic_info, sizeof(THREAD_BASIC_INFORMATION),
73 nullptr); 73 nullptr);
74 if (status != 0) 74 if (status != 0)
75 return nullptr; 75 return nullptr;
76 76
77 return basic_info.Teb; 77 return basic_info.Teb;
78 } 78 }
79 79
80 #if defined(_WIN64)
80 // If the value at |pointer| points to the original stack, rewrite it to point 81 // If the value at |pointer| points to the original stack, rewrite it to point
81 // to the corresponding location in the copied stack. 82 // to the corresponding location in the copied stack.
82 void RewritePointerIfInOriginalStack(uintptr_t top, uintptr_t bottom, 83 void RewritePointerIfInOriginalStack(uintptr_t top, uintptr_t bottom,
83 void* stack_copy, const void** pointer) { 84 void* stack_copy, const void** pointer) {
84 const uintptr_t value = reinterpret_cast<uintptr_t>(*pointer); 85 const uintptr_t value = reinterpret_cast<uintptr_t>(*pointer);
85 if (value >= bottom && value < top) { 86 if (value >= bottom && value < top) {
86 *pointer = reinterpret_cast<const void*>( 87 *pointer = reinterpret_cast<const void*>(
87 static_cast<unsigned char*>(stack_copy) + (value - bottom)); 88 static_cast<unsigned char*>(stack_copy) + (value - bottom));
88 } 89 }
89 } 90 }
91 #endif
90 92
91 // Rewrites possible pointers to locations within the stack to point to the 93 // Rewrites possible pointers to locations within the stack to point to the
92 // corresponding locations in the copy, and rewrites the non-volatile registers 94 // corresponding locations in the copy, and rewrites the non-volatile registers
93 // in |context| likewise. This is necessary to handle stack frames with dynamic 95 // in |context| likewise. This is necessary to handle stack frames with dynamic
94 // stack allocation, where a pointer to the beginning of the dynamic allocation 96 // stack allocation, where a pointer to the beginning of the dynamic allocation
95 // area is stored on the stack and/or in a non-volatile register. 97 // area is stored on the stack and/or in a non-volatile register.
96 // 98 //
97 // Eager rewriting of anything that looks like a pointer to the stack, as done 99 // Eager rewriting of anything that looks like a pointer to the stack, as done
98 // in this function, does not adversely affect the stack unwinding. The only 100 // in this function, does not adversely affect the stack unwinding. The only
99 // other values on the stack the unwinding depends on are return addresses, 101 // other values on the stack the unwinding depends on are return addresses,
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 511
510 if (thread_handle) { 512 if (thread_handle) {
511 return scoped_ptr<NativeStackSampler>(new NativeStackSamplerWin( 513 return scoped_ptr<NativeStackSampler>(new NativeStackSamplerWin(
512 win::ScopedHandle(thread_handle))); 514 win::ScopedHandle(thread_handle)));
513 } 515 }
514 #endif 516 #endif
515 return scoped_ptr<NativeStackSampler>(); 517 return scoped_ptr<NativeStackSampler>();
516 } 518 }
517 519
518 } // namespace base 520 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698