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

Unified Diff: base/debug/profiler.cc

Issue 10454076: Signal thread names in instrumented binaries, even when a debugger is not attached. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Jim's comments. Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/threading/platform_thread_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/profiler.cc
diff --git a/base/debug/profiler.cc b/base/debug/profiler.cc
index e1f2514ab1936ef7c78bc88a7d700d313b7a3418..2d9c8243ac6ad7241d34b601982a44290eb56540 100644
--- a/base/debug/profiler.cc
+++ b/base/debug/profiler.cc
@@ -88,17 +88,34 @@ ReturnAddressLocationResolver GetProfilerReturnAddrResolutionFunc() {
extern "C" IMAGE_DOS_HEADER __ImageBase;
bool IsBinaryInstrumented() {
jar (doing other things) 2012/05/30 22:30:10 Does pulling in this function actually pull in all
- HMODULE this_module = reinterpret_cast<HMODULE>(&__ImageBase);
- base::win::PEImage image(this_module);
-
- // This should be self-evident, soon as we're executing.
- DCHECK(image.VerifyMagic());
+ enum InstrumentationCheckState {
+ UNINITIALIZED,
+ INSTRUMENTED_IMAGE,
+ NON_INSTRUMENTED_IMAGE,
+ };
+
+ static InstrumentationCheckState state = UNINITIALIZED;
+
+ if (state == UNINITIALIZED) {
+ HMODULE this_module = reinterpret_cast<HMODULE>(&__ImageBase);
+ base::win::PEImage image(this_module);
+
+ // Check to be sure our image is structured as we'd expect.
+ DCHECK(image.VerifyMagic());
+
+ // Syzygy-instrumented binaries contain a PE image section named ".thunks",
+ // and all Syzygy-modified binaries contain the ".syzygy" image section.
+ // This is a very fast check, as it only looks at the image header.
+ if ((image.GetImageSectionHeaderByName(".thunks") != NULL) &&
+ (image.GetImageSectionHeaderByName(".syzygy") != NULL)) {
+ state = INSTRUMENTED_IMAGE;
+ } else {
+ state = NON_INSTRUMENTED_IMAGE;
+ }
+ }
+ DCHECK(state != UNINITIALIZED);
- // Syzygy-instrumented binaries contain a PE image section named ".thunks",
- // and all Syzygy-modified binaries contain the ".syzygy" image section.
- // This is a very fast check, as it only looks at the image header.
- return (image.GetImageSectionHeaderByName(".thunks") != NULL) &&
- (image.GetImageSectionHeaderByName(".syzygy") != NULL);
+ return state == INSTRUMENTED_IMAGE;
}
// Callback function to PEImage::EnumImportChunks.
« no previous file with comments | « no previous file | base/threading/platform_thread_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698