1 /*
2  * Copyright (C) 2016 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_COMPILER_DEBUG_ELF_DEBUG_WRITER_H_
18 #define ART_COMPILER_DEBUG_ELF_DEBUG_WRITER_H_
19 
20 #include <vector>
21 
22 #include "arch/instruction_set_features.h"
23 #include "base/array_ref.h"
24 #include "base/macros.h"
25 #include "base/mutex.h"
26 #include "debug/debug_info.h"
27 #include "dwarf/dwarf_constants.h"
28 #include "elf/elf_builder.h"
29 
30 namespace art {
31 class OatHeader;
32 struct JITCodeEntry;
33 namespace mirror {
34 class Class;
35 }  // namespace mirror
36 namespace debug {
37 struct MethodDebugInfo;
38 
39 template <typename ElfTypes>
40 void WriteDebugInfo(
41     ElfBuilder<ElfTypes>* builder,
42     const DebugInfo& debug_info);
43 
44 std::vector<uint8_t> MakeMiniDebugInfo(
45     InstructionSet isa,
46     const InstructionSetFeatures* features,
47     uint64_t text_section_address,
48     size_t text_section_size,
49     uint64_t dex_section_address,
50     size_t dex_section_size,
51     const DebugInfo& debug_info);
52 
53 std::vector<uint8_t> MakeElfFileForJIT(
54     InstructionSet isa,
55     const InstructionSetFeatures* features,
56     bool mini_debug_info,
57     const MethodDebugInfo& method_info);
58 
59 std::vector<uint8_t> PackElfFileForJIT(
60     ArrayRef<const JITCodeEntry*> jit_entries,
61     ArrayRef<const void*> removed_symbols,
62     bool compress,
63     /*out*/ size_t* num_symbols);
64 
65 std::vector<uint8_t> WriteDebugElfFileForClasses(
66     InstructionSet isa,
67     const InstructionSetFeatures* features,
68     const ArrayRef<mirror::Class*>& types)
69     REQUIRES_SHARED(Locks::mutator_lock_);
70 
71 }  // namespace debug
72 }  // namespace art
73 
74 #endif  // ART_COMPILER_DEBUG_ELF_DEBUG_WRITER_H_
75