OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef BASE_DEBUG_PROFILER_H | 5 #ifndef BASE_DEBUG_PROFILER_H |
6 #define BASE_DEBUG_PROFILER_H | 6 #define BASE_DEBUG_PROFILER_H |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // This class of profiler does not play well with programs that look at the | 48 // This class of profiler does not play well with programs that look at the |
49 // return address, as does e.g. V8. V8 uses the return address to certain | 49 // return address, as does e.g. V8. V8 uses the return address to certain |
50 // runtime functions to find the JIT code that called it, and from there finds | 50 // runtime functions to find the JIT code that called it, and from there finds |
51 // the V8 data structures associated to the JS function involved. | 51 // the V8 data structures associated to the JS function involved. |
52 // A return address resolution function is used to fix this. It allows such | 52 // A return address resolution function is used to fix this. It allows such |
53 // programs to resolve a location on stack where a return address originally | 53 // programs to resolve a location on stack where a return address originally |
54 // resided, to the shadow stack location where the profiler stashed it. | 54 // resided, to the shadow stack location where the profiler stashed it. |
55 typedef uintptr_t (*ReturnAddressLocationResolver)( | 55 typedef uintptr_t (*ReturnAddressLocationResolver)( |
56 uintptr_t return_addr_location); | 56 uintptr_t return_addr_location); |
57 | 57 |
58 // If this binary is instrumented and the instrumentation supplies a return | 58 // This type declaration must match V8's FunctionEntryHook. |
59 // address resolution function, finds and returns the address resolution | 59 typedef void (*DynamicFunctionEntryHook)(uintptr_t function, |
60 // function. Otherwise returns NULL. | 60 uintptr_t return_addr_location); |
61 BASE_EXPORT ReturnAddressLocationResolver | 61 |
62 GetProfilerReturnAddrResolutionFunc(); | 62 // The functions below here are to support profiling V8-generated code. |
| 63 // V8 has provisions for generating a call to an entry hook for newly generated |
| 64 // JIT code, and it can push symbol information on code generation and advise |
| 65 // when the garbage collector moves code. The functions declarations below here |
| 66 // make glue between V8's facilities and a profiler. |
| 67 |
| 68 // This type declaration must match V8's FunctionEntryHook. |
| 69 typedef void (*DynamicFunctionEntryHook)(uintptr_t function, |
| 70 uintptr_t return_addr_location); |
| 71 |
| 72 typedef void (*AddDynamicSymbol)(const void* address, |
| 73 size_t length, |
| 74 const char* name, |
| 75 size_t name_len); |
| 76 typedef void (*MoveDynamicSymbol)(const void* address, const void* new_address); |
| 77 |
| 78 |
| 79 // If this binary is instrumented and the instrumentation supplies a function |
| 80 // for each of those purposes, find and return the function in question. |
| 81 // Otherwise returns NULL. |
| 82 BASE_EXPORT ReturnAddressLocationResolver GetProfilerReturnAddrResolutionFunc(); |
| 83 BASE_EXPORT DynamicFunctionEntryHook GetProfilerDynamicFunctionEntryHookFunc(); |
| 84 BASE_EXPORT AddDynamicSymbol GetProfilerAddDynamicSymbolFunc(); |
| 85 BASE_EXPORT MoveDynamicSymbol GetProfilerMoveDynamicSymbolFunc(); |
63 | 86 |
64 } // namespace debug | 87 } // namespace debug |
65 } // namespace base | 88 } // namespace base |
66 | 89 |
67 #endif // BASE_DEBUG_DEBUGGER_H | 90 #endif // BASE_DEBUG_DEBUGGER_H |
OLD | NEW |