00001 00014 #include <stdlib.h> 00015 00016 #include "opjitconv.h" 00017 00018 static void free_jit_records(void) 00019 { 00020 struct jitentry * entry, * next; 00021 00022 for (entry = jitentry_list; entry; entry = next) { 00023 if (entry->sym_name_malloced) 00024 free(entry->symbol_name); 00025 next = entry->next; 00026 free(entry); 00027 } 00028 jitentry_list = NULL; 00029 } 00030 00031 static void free_jit_debug_line(void) 00032 { 00033 struct jitentry_debug_line * entry, * next; 00034 00035 for (entry = jitentry_debug_line_list; entry; entry = next) { 00036 next = entry->next; 00037 free(entry); 00038 } 00039 jitentry_debug_line_list = NULL; 00040 } 00041 00042 int op_jit_convert(struct op_jitdump_info file_info, char const * elffile, 00043 unsigned long long start_time, unsigned long long end_time) 00044 { 00045 void const * jitdump = file_info.dmp_file; 00046 int rc= OP_JIT_CONV_OK; 00047 00048 entry_count = 0; 00049 max_entry_count = 0; 00050 syms = NULL; 00051 cur_bfd = NULL; 00052 jitentry_list = NULL; 00053 jitentry_debug_line_list = NULL; 00054 entries_symbols_ascending = entries_address_ascending = NULL; 00055 00056 if ((rc = parse_all(jitdump, jitdump + file_info.dmp_file_stat.st_size, 00057 end_time)) == OP_JIT_CONV_FAIL) 00058 goto out; 00059 00060 create_arrays(); 00061 if ((rc = resolve_overlaps(start_time)) == OP_JIT_CONV_FAIL) 00062 goto out; 00063 00064 disambiguate_symbol_names(); 00065 if (!entry_count) 00066 return OP_JIT_CONV_NO_JIT_RECS_IN_DUMPFILE; 00067 00068 if ((cur_bfd = open_elf(elffile)) == NULL) { 00069 rc = OP_JIT_CONV_FAIL; 00070 goto out; 00071 } 00072 00073 init_debug_line_info(cur_bfd); 00074 00075 if ((rc = partition_sections()) == OP_JIT_CONV_FAIL) 00076 goto out; 00077 00078 if ((rc = fill_sections()) == OP_JIT_CONV_FAIL) 00079 goto out; 00080 00081 finalize_debug_line_info(cur_bfd); 00082 00083 if (cur_bfd) 00084 bfd_close(cur_bfd); 00085 free(syms); 00086 out: free_jit_records(); 00087 free_jit_debug_line(); 00088 free(entries_symbols_ascending); 00089 free(entries_address_ascending); 00090 return rc; 00091 } 00092