blob: 0bb32368708c0fc12613855da5db3efc0b80d6ac [file] [log] [blame]
David Srbecky67feb172015-12-17 19:57:44 +00001/*
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
David Srbecky8fc2f952019-07-31 18:40:09 +010020#include <functional>
David Srbecky67feb172015-12-17 19:57:44 +000021#include <inttypes.h>
Vladimir Marko93205e32016-04-13 11:59:46 +010022#include <vector>
David Srbecky67feb172015-12-17 19:57:44 +000023
David Srbecky0b21e412018-12-05 13:24:06 +000024#include "arch/instruction_set_features.h"
David Srbecky53eb07f2019-02-12 16:34:55 +000025#include "base/array_ref.h"
Andreas Gampe7fbc4a52018-11-28 08:26:47 -080026#include "base/locks.h"
David Srbeckyc684f332018-01-19 17:38:06 +000027
David Srbecky67feb172015-12-17 19:57:44 +000028namespace art {
29
David Srbeckyafc60cd2018-12-05 11:59:31 +000030class DexFile;
David Srbecky1ed45152019-04-09 18:10:26 +010031class Mutex;
David Srbeckyafc60cd2018-12-05 11:59:31 +000032class Thread;
David Srbecky8fc2f952019-07-31 18:40:09 +010033struct JITCodeEntry;
David Srbeckyafc60cd2018-12-05 11:59:31 +000034
David Srbeckye09b87e2019-08-19 21:31:31 +010035ArrayRef<const uint8_t> GetJITCodeEntrySymFile(const JITCodeEntry*);
David Srbecky0b21e412018-12-05 13:24:06 +000036
David Srbeckyfb3de3d2018-01-29 16:11:49 +000037// Notify native tools (e.g. libunwind) that DEX file has been opened.
David Srbecky0b21e412018-12-05 13:24:06 +000038void AddNativeDebugInfoForDex(Thread* self, const DexFile* dexfile);
David Srbeckyfb3de3d2018-01-29 16:11:49 +000039
40// Notify native tools (e.g. libunwind) that DEX file has been closed.
David Srbecky0b21e412018-12-05 13:24:06 +000041void RemoveNativeDebugInfoForDex(Thread* self, const DexFile* dexfile);
David Srbeckyc684f332018-01-19 17:38:06 +000042
David Srbecky8fc2f952019-07-31 18:40:09 +010043// Notify native tools (e.g. libunwind) that JIT has compiled a single new method.
David Srbecky440a9b32018-02-15 17:47:29 +000044// The method will make copy of the passed ELF file (to shrink it to the minimum size).
David Srbecky8fc2f952019-07-31 18:40:09 +010045// If packing is allowed, the ELF file might be merged with others to save space
46// (however, this drops all ELF sections other than symbols names and unwinding info).
47void AddNativeDebugInfoForJit(const void* code_ptr,
David Srbecky0b21e412018-12-05 13:24:06 +000048 const std::vector<uint8_t>& symfile,
David Srbecky9ac8e432019-08-13 13:16:13 +010049 bool allow_packing)
50 REQUIRES_SHARED(Locks::jit_lock_); // Might need JIT code cache to allocate memory.
David Srbecky67feb172015-12-17 19:57:44 +000051
David Srbeckyafc60cd2018-12-05 11:59:31 +000052// Notify native tools (e.g. libunwind) that JIT code has been garbage collected.
David Srbecky9ac8e432019-08-13 13:16:13 +010053void RemoveNativeDebugInfoForJit(ArrayRef<const void*> removed_code_ptrs)
54 REQUIRES_SHARED(Locks::jit_lock_); // Might need JIT code cache to allocate memory.
David Srbeckyc684f332018-01-19 17:38:06 +000055
David Srbeckyafc60cd2018-12-05 11:59:31 +000056// Returns approximate memory used by debug info for JIT code.
David Srbecky0b21e412018-12-05 13:24:06 +000057size_t GetJitMiniDebugInfoMemUsage();
David Srbecky5cc349f2015-12-18 15:04:48 +000058
David Srbecky1ed45152019-04-09 18:10:26 +010059// Get the lock which protects the native debug info.
60// Used only in tests to unwind while the JIT thread is running.
61// TODO: Unwinding should be race-free. Remove this.
62Mutex* GetNativeDebugInfoLock();
63
David Srbecky67feb172015-12-17 19:57:44 +000064} // namespace art
65
66#endif // ART_RUNTIME_JIT_DEBUGGER_INTERFACE_H_