| 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 <stdint.h> // NOLINT | |
| 9 #include <stdio.h> // NOLINT | |
| 10 #include <stdlib.h> // NOLINT | |
| 11 | |
| 12 #include "vm/gdbjit_android.h" | |
| 13 | |
| 14 extern "C" { | |
| 15 typedef enum { | |
| 16 JIT_NOACTION = 0, | |
| 17 JIT_REGISTER_FN, | |
| 18 JIT_UNREGISTER_FN | |
| 19 } jit_actions_t; | |
| 20 | |
| 21 struct jit_code_entry { | |
| 22 struct jit_code_entry* next_entry; | |
| 23 struct jit_code_entry* prev_entry; | |
| 24 const char* symfile_addr; | |
| 25 uint64_t symfile_size; | |
| 26 }; | |
| 27 | |
| 28 struct jit_descriptor { | |
| 29 uint32_t version; | |
| 30 /* This type should be jit_actions_t, but we use uint32_t | |
| 31 to be explicit about the bitwidth. */ | |
| 32 uint32_t action_flag; | |
| 33 struct jit_code_entry* relevant_entry; | |
| 34 struct jit_code_entry* first_entry; | |
| 35 }; | |
| 36 | |
| 37 #ifndef GDB_JIT_SYMBOLS | |
| 38 /* GDB puts a breakpoint in this function. */ | |
| 39 void __attribute__((noinline)) __jit_debug_register_code() { } | |
| 40 | |
| 41 /* Make sure to specify the version statically, because the | |
| 42 debugger may check the version before we can set it. */ | |
| 43 struct jit_descriptor __jit_debug_descriptor = { 1, 0, 0, 0 }; | |
| 44 #endif | |
| 45 | |
| 46 static struct jit_code_entry* first_dynamic_region = NULL; | |
| 47 static struct jit_code_entry* last_dynamic_region = NULL; | |
| 48 | |
| 49 void addDynamicSection(const char* symfile_addr, uint64_t symfile_size) { | |
| 50 jit_code_entry* new_entry = reinterpret_cast<jit_code_entry*>( | |
| 51 malloc(sizeof(jit_code_entry))); | |
| 52 if (new_entry != NULL) { | |
| 53 new_entry->symfile_addr = symfile_addr; | |
| 54 new_entry->symfile_size = symfile_size; | |
| 55 new_entry->next_entry = NULL; | |
| 56 new_entry->prev_entry = last_dynamic_region; | |
| 57 if (first_dynamic_region == NULL) { | |
| 58 first_dynamic_region = new_entry; | |
| 59 } else { | |
| 60 last_dynamic_region->next_entry = new_entry; | |
| 61 } | |
| 62 last_dynamic_region = new_entry; | |
| 63 } | |
| 64 __jit_debug_descriptor.action_flag = JIT_REGISTER_FN; | |
| 65 __jit_debug_descriptor.relevant_entry = new_entry; | |
| 66 __jit_debug_descriptor.first_entry = first_dynamic_region; | |
| 67 __jit_debug_register_code(); | |
| 68 } | |
| 69 | |
| 70 void deleteDynamicSections() { | |
| 71 struct jit_code_entry* iterator = last_dynamic_region; | |
| 72 while (iterator != NULL) { | |
| 73 __jit_debug_descriptor.action_flag = JIT_UNREGISTER_FN; | |
| 74 __jit_debug_descriptor.relevant_entry = iterator; | |
| 75 __jit_debug_descriptor.first_entry = first_dynamic_region; | |
| 76 __jit_debug_register_code(); | |
| 77 iterator = iterator->prev_entry; | |
| 78 } | |
| 79 first_dynamic_region = NULL; | |
| 80 last_dynamic_region = NULL; | |
| 81 } | |
| 82 }; | |
| 83 | |
| 84 #endif // defined(TARGET_OS_ANDROID) | |
| OLD | NEW |