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. |