def display_symbol_detail(symbol_name, symbol_asm_path): if m_debug.Debug: m_debug.dbg_print("symbol_asm_path=", symbol_asm_path, "symbol_name=", symbol_name) if not symbol_name or not symbol_asm_path: return data = m_datastore.mgdb_rdata.get_one_label_mirbin_info_cache( symbol_asm_path, symbol_name) d = m_asm.lookup_src_file_info(symbol_asm_path, data[0], data[1], data[2], "0000") if not d: return short_src_file_name, short_src_file_line = m_asm.lookup_next_src_file_info(symbol_asm_path,\ d["asm_line"], d['asm_offset']) file_full_path = None for source_path in m_list.maple_source_path_list: file_full_path = m_list.find_one_file(short_src_file_name, source_path) if not file_full_path: continue else: break gdb_print("assembly file : " + symbol_asm_path) if not file_full_path: gdb_print("source : unknown") else: gdb_print("source : " + file_full_path) gdb_print("demangled name: " + m_symbol.get_demangled_maple_symbol( m_util.color_symbol(MColors.SP_SNAME, symbol_name[:-12])))
def mstep_func(self, args): frame = m_frame.get_selected_frame() ds = m_datastore.get_stack_frame_data(frame) if not ds: return if m_debug.Debug: m_debug.dbg_print("retrieved ds=", ds) asm_path = ds['frame_func_header_info']['asm_path'] asm_line = ds['frame_func_src_info']['asm_line'] asm_offset = ds['frame_func_src_info']['asm_offset'] stop = False short_src_file_name = None short_src_file_line = None count = 0 while not stop: # before we execute msi command, we must know should we stop keep executing msi after the current msi # is executed. If current msi command is executed and found it should stop, then we need the source file # information after stop. stop, short_src_file_name, short_src_file_line = m_asm.look_up_next_opcode( asm_path, asm_line, asm_offset) if m_debug.Debug: m_debug.dbg_print("stop =", stop, "short_src_file_name=", short_src_file_name, "short_src_file_line=", short_src_file_line) m_util.gdb_exec("msi -internal") count += 1 if m_debug.Debug: m_debug.dbg_print("executed %d opcodes", count) # retrieve the new frame data since one opcode can change to a different frame frame = m_frame.get_selected_frame() ds = m_datastore.get_stack_frame_data(frame) if not ds: gdb_print("Warning: Failed to get new stack frame to continue") return if m_debug.Debug: m_debug.dbg_print("retrieved ds=", ds) asm_path = ds['frame_func_header_info']['asm_path'] asm_line = ds['frame_func_src_info']['asm_line'] asm_offset = ds['frame_func_src_info']['asm_offset'] gdb_print("Info: executed %d %s" % (count, 'opcode' if count == 1 else 'opcodes')) if m_debug.Debug: m_debug.dbg_print("short_src_file_name = ", short_src_file_name, "short_src_file_line=", short_src_file_line) file_full_path = None for source_path in m_list.maple_source_path_list: file_full_path = m_list.find_one_file(short_src_file_name, source_path) if not file_full_path: continue else: break if not file_full_path: gdb_print("Warning: source file %s not found" % (short_src_file_name)) else: m_list.display_src_file_lines(file_full_path, short_src_file_line) return
def print_maple_frame_dync(frame, index, mbt_format): """ prints one Maple backtrace frame. params: frame: a gdb.Frame object index: a index number of the frame. mbt_format: print Maple backtrace in specified format, MBT_FORMAT_SRC or MBT_FORMAT_ASM or MBT_FORMAT_MIR """ data = m_datastore.get_stack_frame_data(frame) if not data: gdb_print('#%i no info' % (index)) return so_path = data['frame_func_header_info']['so_path'] asm_path = data['frame_func_header_info']['asm_path'] mmpl_path = data['frame_func_header_info']['mmpl_path'] func_addr_offset = data['frame_func_header_info']['func_addr_offset'] func_name = data['frame_func_header_info']['func_name'] src_file_short_name = data['frame_func_src_info']['short_src_file_name'] asm_line_num = data['frame_func_src_info']['asm_line'] mmpl_line_num = 0 #data['frame_func_src_info']['mmpl_line'] src_file_line = data['frame_func_src_info']['short_src_file_line'] #func_argus_locals = data['func_argus_locals'] if src_file_short_name: file_full_path = None for source_path in m_list.maple_source_path_list: file_full_path = m_list.find_one_file(src_file_short_name, source_path) if not file_full_path: continue else: break if not file_full_path: file_full_path = "unknown" else: file_full_path = 'unknown' # buffer format # index func_offset func_symbol (type argu=value, ...) at source-file-full-path:line_num args_buffer = "" ''' arg_num = len(func_argus_locals['formals_name']) for i in range(arg_num): arg_value = m_info.get_maple_caller_argument_value(i, arg_num, func_argus_locals['formals_type'][i]) if arg_value: if func_argus_locals['formals_type'][i] == 'a64': mtype = m_info.get_maple_a64_pointer_type(arg_value) if not mtype: mtype = "" else: mtype = "" else: arg_value = '...' mtype = "" args_buffer += func_argus_locals['formals_type'][i] args_buffer += '<' + mtype + '>' args_buffer += ' ' args_buffer += MColors.BT_ARGNAME + func_argus_locals['formals_name'][i] + MColors.ENDC #args_buffer += func_argus_locals['formals_name'][i] args_buffer += '=' args_buffer += arg_value args_buffer += ', ' if arg_num > 0: args_buffer = args_buffer[:-2] if m_debug.Debug: m_debug.dbg_print("arg_num=", arg_num, " args_buffer=", args_buffer) ''' if mbt_format == MBT_FORMAT_ASM: buffer = '#%i %s:%s %s(%s) at %s:%s' % \ (index, MColors.BT_ADDR + so_path.split('/')[-1] + MColors.ENDC,MColors.BT_ADDR + func_addr_offset + MColors.ENDC,\ m_util.color_symbol(MColors.BT_FNNAME, func_name), args_buffer, MColors.BT_SRC + asm_path + MColors.ENDC, asm_line_num) elif mbt_format == MBT_FORMAT_SRC: buffer = '#%i %s:%s %s(%s) at %s:%s' % \ (index, MColors.BT_ADDR + so_path.split('/')[-1] + MColors.ENDC, MColors.BT_ADDR + func_addr_offset + MColors.ENDC,\ m_util.color_symbol(MColors.BT_FNNAME, func_name), args_buffer, MColors.BT_SRC + file_full_path + MColors.ENDC, src_file_line) else: buffer = '#%i %s:%s %s(%s) at %s:%s' % \ (index, MColors.BT_ADDR + so_path.split('/')[-1] + MColors.ENDC,MColors.BT_ADDR + func_addr_offset + MColors.ENDC,\ m_util.color_symbol(MColors.BT_FNNAME, func_name), args_buffer, MColors.BT_SRC + mmpl_path + MColors.ENDC, mmpl_line_num) gdb_print(buffer)