| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 #include "vm/globals.h" | |
| 6 #if defined(TARGET_OS_ANDROID) | |
| 7 | |
| 8 #include "vm/debuginfo.h" | |
| 9 | |
| 10 #include "vm/elfgen.h" | |
| 11 #include "vm/gdbjit_android.h" | |
| 12 | |
| 13 namespace dart { | |
| 14 | |
| 15 DebugInfo::DebugInfo() { | |
| 16 handle_ = reinterpret_cast<void*>(new ElfGen()); | |
| 17 ASSERT(handle_ != NULL); | |
| 18 } | |
| 19 | |
| 20 | |
| 21 DebugInfo::~DebugInfo() { | |
| 22 ElfGen* elf_gen = reinterpret_cast<ElfGen*>(handle_); | |
| 23 delete elf_gen; | |
| 24 } | |
| 25 | |
| 26 | |
| 27 void DebugInfo::AddCode(uword pc, intptr_t size) { | |
| 28 ElfGen* elf_gen = reinterpret_cast<ElfGen*>(handle_); | |
| 29 elf_gen->AddCode(pc, size); | |
| 30 } | |
| 31 | |
| 32 | |
| 33 void DebugInfo::AddCodeRegion(const char* name, uword pc, intptr_t size) { | |
| 34 ElfGen* elf_gen = reinterpret_cast<ElfGen*>(handle_); | |
| 35 elf_gen->AddCodeRegion(name, pc, size); | |
| 36 } | |
| 37 | |
| 38 | |
| 39 bool DebugInfo::WriteToMemory(ByteBuffer* region) { | |
| 40 ElfGen* elf_gen = reinterpret_cast<ElfGen*>(handle_); | |
| 41 return elf_gen->WriteToMemory(region); | |
| 42 } | |
| 43 | |
| 44 | |
| 45 DebugInfo* DebugInfo::NewGenerator() { | |
| 46 return new DebugInfo(); | |
| 47 } | |
| 48 | |
| 49 | |
| 50 void DebugInfo::RegisterSection(const char* name, | |
| 51 uword entry_point, | |
| 52 intptr_t size) { | |
| 53 ElfGen* elf_section = new ElfGen(); | |
| 54 ASSERT(elf_section != NULL); | |
| 55 elf_section->AddCode(entry_point, size); | |
| 56 elf_section->AddCodeRegion(name, entry_point, size); | |
| 57 | |
| 58 ByteBuffer* dynamic_region = new ByteBuffer(); | |
| 59 ASSERT(dynamic_region != NULL); | |
| 60 | |
| 61 elf_section->WriteToMemory(dynamic_region); | |
| 62 | |
| 63 ::addDynamicSection(reinterpret_cast<const char*>(dynamic_region->data()), | |
| 64 dynamic_region->size()); | |
| 65 dynamic_region->set_data(NULL); | |
| 66 delete dynamic_region; | |
| 67 delete elf_section; | |
| 68 } | |
| 69 | |
| 70 | |
| 71 void DebugInfo::UnregisterAllSections() { | |
| 72 ::deleteDynamicSections(); | |
| 73 } | |
| 74 | |
| 75 } // namespace dart | |
| 76 | |
| 77 #endif // defined(TARGET_OS_ANDROID) | |
| OLD | NEW |