| OLD | NEW |
| 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 <stddef.h> |
| 6 #include <stdint.h> |
| 7 |
| 5 #include <cstdlib> | 8 #include <cstdlib> |
| 6 | 9 |
| 7 #include "base/bind.h" | 10 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" |
| 9 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 10 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 11 #include "base/native_library.h" | 15 #include "base/native_library.h" |
| 12 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 13 #include "base/profiler/native_stack_sampler.h" | 17 #include "base/profiler/native_stack_sampler.h" |
| 14 #include "base/profiler/stack_sampling_profiler.h" | 18 #include "base/profiler/stack_sampling_profiler.h" |
| 15 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
| 16 #include "base/scoped_native_library.h" | 20 #include "base/scoped_native_library.h" |
| 17 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 // Table that jump to the functions. Checks for a jump instruction and if | 371 // Table that jump to the functions. Checks for a jump instruction and if |
| 368 // present does a little decompilation to find the function's actual starting | 372 // present does a little decompilation to find the function's actual starting |
| 369 // address. | 373 // address. |
| 370 const void* MaybeFixupFunctionAddressForILT(const void* function_address) { | 374 const void* MaybeFixupFunctionAddressForILT(const void* function_address) { |
| 371 #if defined(_WIN64) | 375 #if defined(_WIN64) |
| 372 const unsigned char* opcode = | 376 const unsigned char* opcode = |
| 373 reinterpret_cast<const unsigned char*>(function_address); | 377 reinterpret_cast<const unsigned char*>(function_address); |
| 374 if (*opcode == 0xe9) { | 378 if (*opcode == 0xe9) { |
| 375 // This is a relative jump instruction. Assume we're in the ILT and compute | 379 // This is a relative jump instruction. Assume we're in the ILT and compute |
| 376 // the function start address from the instruction offset. | 380 // the function start address from the instruction offset. |
| 377 const int32* offset = reinterpret_cast<const int32*>(opcode + 1); | 381 const int32_t* offset = reinterpret_cast<const int32_t*>(opcode + 1); |
| 378 const unsigned char* next_instruction = | 382 const unsigned char* next_instruction = |
| 379 reinterpret_cast<const unsigned char*>(offset + 1); | 383 reinterpret_cast<const unsigned char*>(offset + 1); |
| 380 return next_instruction + *offset; | 384 return next_instruction + *offset; |
| 381 } | 385 } |
| 382 #endif | 386 #endif |
| 383 return function_address; | 387 return function_address; |
| 384 } | 388 } |
| 385 | 389 |
| 386 // Searches through the frames in |sample|, returning an iterator to the first | 390 // Searches through the frames in |sample|, returning an iterator to the first |
| 387 // frame that has an instruction pointer within |target_function|. Returns | 391 // frame that has an instruction pointer within |target_function|. Returns |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) | 957 #if defined(STACK_SAMPLING_PROFILER_SUPPORTED) |
| 954 #define MAYBE_UnloadedLibrary UnloadedLibrary | 958 #define MAYBE_UnloadedLibrary UnloadedLibrary |
| 955 #else | 959 #else |
| 956 #define MAYBE_UnloadedLibrary DISABLED_UnloadedLibrary | 960 #define MAYBE_UnloadedLibrary DISABLED_UnloadedLibrary |
| 957 #endif | 961 #endif |
| 958 TEST(StackSamplingProfilerTest, MAYBE_UnloadedLibrary) { | 962 TEST(StackSamplingProfilerTest, MAYBE_UnloadedLibrary) { |
| 959 TestLibraryUnload(true); | 963 TestLibraryUnload(true); |
| 960 } | 964 } |
| 961 | 965 |
| 962 } // namespace base | 966 } // namespace base |
| OLD | NEW |