diff options
author | siggi@chromium.org <siggi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-31 12:54:52 +0000 |
---|---|---|
committer | siggi@chromium.org <siggi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-31 12:54:52 +0000 |
commit | 7afa6f3a5c5a13fda9e96b65dee2c08071af0c05 (patch) | |
tree | 17934718219b741cbc73c0844c50b7f2da8c7eda /base/debug | |
parent | 5443f2966a428ac79a598f0b17d96a9d677204ed (diff) | |
download | chromium_src-7afa6f3a5c5a13fda9e96b65dee2c08071af0c05.zip chromium_src-7afa6f3a5c5a13fda9e96b65dee2c08071af0c05.tar.gz chromium_src-7afa6f3a5c5a13fda9e96b65dee2c08071af0c05.tar.bz2 |
Signal thread names in instrumented binaries, even when a debugger is not attached.
Cache the determiniation whether a binary is instrumented or not, as it'll never change for a given binary.
R=jar@google.com
BUG=None
TEST=None
Review URL: https://chromiumcodereview.appspot.com/10454076
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139777 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/debug')
-rw-r--r-- | base/debug/profiler.cc | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/base/debug/profiler.cc b/base/debug/profiler.cc index e1f2514..de79124 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() { - 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. |