David Srbecky | 67feb17 | 2015-12-17 19:57:44 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ART_RUNTIME_JIT_DEBUGGER_INTERFACE_H_ |
| 18 | #define ART_RUNTIME_JIT_DEBUGGER_INTERFACE_H_ |
| 19 | |
| 20 | #include <inttypes.h> |
Vladimir Marko | 93205e3 | 2016-04-13 11:59:46 +0100 | [diff] [blame] | 21 | #include <vector> |
David Srbecky | 67feb17 | 2015-12-17 19:57:44 +0000 | [diff] [blame] | 22 | |
David Srbecky | 0b21e41 | 2018-12-05 13:24:06 +0000 | [diff] [blame] | 23 | #include "arch/instruction_set_features.h" |
David Srbecky | 53eb07f | 2019-02-12 16:34:55 +0000 | [diff] [blame] | 24 | #include "base/array_ref.h" |
Andreas Gampe | 7fbc4a5 | 2018-11-28 08:26:47 -0800 | [diff] [blame] | 25 | #include "base/locks.h" |
David Srbecky | c684f33 | 2018-01-19 17:38:06 +0000 | [diff] [blame] | 26 | |
David Srbecky | 67feb17 | 2015-12-17 19:57:44 +0000 | [diff] [blame] | 27 | namespace art { |
| 28 | |
David Srbecky | afc60cd | 2018-12-05 11:59:31 +0000 | [diff] [blame] | 29 | class DexFile; |
David Srbecky | 1ed4515 | 2019-04-09 18:10:26 +0100 | [diff] [blame^] | 30 | class Mutex; |
David Srbecky | afc60cd | 2018-12-05 11:59:31 +0000 | [diff] [blame] | 31 | class Thread; |
| 32 | |
David Srbecky | 0b21e41 | 2018-12-05 13:24:06 +0000 | [diff] [blame] | 33 | // This method is declared in the compiler library. |
| 34 | // We need to pass it by pointer to be able to call it from runtime. |
| 35 | typedef std::vector<uint8_t> PackElfFileForJITFunction( |
| 36 | InstructionSet isa, |
| 37 | const InstructionSetFeatures* features, |
David Srbecky | 53eb07f | 2019-02-12 16:34:55 +0000 | [diff] [blame] | 38 | std::vector<ArrayRef<const uint8_t>>& added_elf_files, |
David Srbecky | 0b21e41 | 2018-12-05 13:24:06 +0000 | [diff] [blame] | 39 | std::vector<const void*>& removed_symbols, |
David Srbecky | 76b9c69 | 2019-04-01 19:36:33 +0100 | [diff] [blame] | 40 | bool compress, |
David Srbecky | 0b21e41 | 2018-12-05 13:24:06 +0000 | [diff] [blame] | 41 | /*out*/ size_t* num_symbols); |
| 42 | |
David Srbecky | fb3de3d | 2018-01-29 16:11:49 +0000 | [diff] [blame] | 43 | // Notify native tools (e.g. libunwind) that DEX file has been opened. |
David Srbecky | 0b21e41 | 2018-12-05 13:24:06 +0000 | [diff] [blame] | 44 | void AddNativeDebugInfoForDex(Thread* self, const DexFile* dexfile); |
David Srbecky | fb3de3d | 2018-01-29 16:11:49 +0000 | [diff] [blame] | 45 | |
| 46 | // Notify native tools (e.g. libunwind) that DEX file has been closed. |
David Srbecky | 0b21e41 | 2018-12-05 13:24:06 +0000 | [diff] [blame] | 47 | void RemoveNativeDebugInfoForDex(Thread* self, const DexFile* dexfile); |
David Srbecky | c684f33 | 2018-01-19 17:38:06 +0000 | [diff] [blame] | 48 | |
David Srbecky | afc60cd | 2018-12-05 11:59:31 +0000 | [diff] [blame] | 49 | // Notify native tools (e.g. libunwind) that JIT has compiled a new method. |
David Srbecky | 440a9b3 | 2018-02-15 17:47:29 +0000 | [diff] [blame] | 50 | // The method will make copy of the passed ELF file (to shrink it to the minimum size). |
David Srbecky | afc60cd | 2018-12-05 11:59:31 +0000 | [diff] [blame] | 51 | void AddNativeDebugInfoForJit(Thread* self, |
| 52 | const void* code_ptr, |
David Srbecky | 0b21e41 | 2018-12-05 13:24:06 +0000 | [diff] [blame] | 53 | const std::vector<uint8_t>& symfile, |
| 54 | PackElfFileForJITFunction pack, |
| 55 | InstructionSet isa, |
| 56 | const InstructionSetFeatures* features); |
David Srbecky | 67feb17 | 2015-12-17 19:57:44 +0000 | [diff] [blame] | 57 | |
David Srbecky | afc60cd | 2018-12-05 11:59:31 +0000 | [diff] [blame] | 58 | // Notify native tools (e.g. libunwind) that JIT code has been garbage collected. |
David Srbecky | 0b21e41 | 2018-12-05 13:24:06 +0000 | [diff] [blame] | 59 | void RemoveNativeDebugInfoForJit(Thread* self, const void* code_ptr); |
David Srbecky | c684f33 | 2018-01-19 17:38:06 +0000 | [diff] [blame] | 60 | |
David Srbecky | afc60cd | 2018-12-05 11:59:31 +0000 | [diff] [blame] | 61 | // Returns approximate memory used by debug info for JIT code. |
David Srbecky | 0b21e41 | 2018-12-05 13:24:06 +0000 | [diff] [blame] | 62 | size_t GetJitMiniDebugInfoMemUsage(); |
David Srbecky | 5cc349f | 2015-12-18 15:04:48 +0000 | [diff] [blame] | 63 | |
David Srbecky | 1ed4515 | 2019-04-09 18:10:26 +0100 | [diff] [blame^] | 64 | // Get the lock which protects the native debug info. |
| 65 | // Used only in tests to unwind while the JIT thread is running. |
| 66 | // TODO: Unwinding should be race-free. Remove this. |
| 67 | Mutex* GetNativeDebugInfoLock(); |
| 68 | |
David Srbecky | 67feb17 | 2015-12-17 19:57:44 +0000 | [diff] [blame] | 69 | } // namespace art |
| 70 | |
| 71 | #endif // ART_RUNTIME_JIT_DEBUGGER_INTERFACE_H_ |