/* See disasm.h. */
int
-gdb_disassembler::pretty_print_insn (struct ui_out *uiout,
- const struct disasm_insn *insn,
- int flags)
+gdb_pretty_print_insn (struct gdbarch *gdbarch, struct ui_out *uiout,
+ const struct disasm_insn *insn,
+ int flags)
{
/* parts of the symbolic representation of the address */
int unmapped;
char *filename = NULL;
char *name = NULL;
CORE_ADDR pc;
- struct ui_file *stb = stream ();
- struct gdbarch *gdbarch = arch ();
ui_out_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
pc = insn->addr;
if (name != NULL)
xfree (name);
- ui_file_rewind (stb);
+ struct ui_file *stb = mem_fileopen ();
+ make_cleanup_ui_file_delete (stb);
+
if (flags & DISASSEMBLY_RAW_INSN)
{
CORE_ADDR end_pc;
struct cleanup *cleanups =
make_cleanup_ui_file_delete (opcode_stream);
- size = print_insn (pc);
+ size = gdb_print_insn (gdbarch, pc, stb, NULL);
end_pc = pc + size;
for (;pc < end_pc; ++pc)
{
- err = m_di.read_memory_func (pc, &data, 1, &m_di);
- if (err != 0)
- m_di.memory_error_func (err, pc, &m_di);
+ read_code (pc, &data, 1);
fprintf_filtered (opcode_stream, "%s%02x",
spacer, (unsigned) data);
spacer = " ";
do_cleanups (cleanups);
}
else
- size = print_insn (pc);
+ size = gdb_print_insn (gdbarch, pc, stb, NULL);
uiout->field_stream ("inst", stb);
- ui_file_rewind (stb);
do_cleanups (ui_out_chain);
uiout->text ("\n");
}
static int
-dump_insns (struct ui_out *uiout, gdb_disassembler *di,
- CORE_ADDR low, CORE_ADDR high,
- int how_many, int flags,
- CORE_ADDR *end_pc)
+dump_insns (struct gdbarch *gdbarch,
+ struct ui_out *uiout, CORE_ADDR low, CORE_ADDR high,
+ int how_many, int flags, CORE_ADDR *end_pc)
{
struct disasm_insn insn;
int num_displayed = 0;
{
int size;
- size = di->pretty_print_insn (uiout, &insn, flags);
+ size = gdb_pretty_print_insn (gdbarch, uiout, &insn, flags);
if (size <= 0)
break;
static void
do_mixed_source_and_assembly_deprecated
- (struct ui_out *uiout,
- gdb_disassembler *di, struct symtab *symtab,
+ (struct gdbarch *gdbarch, struct ui_out *uiout,
+ struct symtab *symtab,
CORE_ADDR low, CORE_ADDR high,
int how_many, int flags)
{
= make_cleanup_ui_out_list_begin_end (uiout, "line_asm_insn");
}
- num_displayed += dump_insns (uiout, di,
+ num_displayed += dump_insns (gdbarch, uiout,
mle[i].start_pc, mle[i].end_pc,
how_many, flags, NULL);
static void
do_mixed_source_and_assembly (struct gdbarch *gdbarch,
struct ui_out *uiout,
- gdb_disassembler *di,
struct symtab *main_symtab,
CORE_ADDR low, CORE_ADDR high,
int how_many, int flags)
end_pc = std::min (sal.end, high);
else
end_pc = pc + 1;
- num_displayed += dump_insns (uiout, di, pc, end_pc,
+ num_displayed += dump_insns (gdbarch, uiout, pc, end_pc,
how_many, flags, &end_pc);
pc = end_pc;
}
static void
-do_assembly_only (struct ui_out *uiout,
- gdb_disassembler *di,
+do_assembly_only (struct gdbarch *gdbarch, struct ui_out *uiout,
CORE_ADDR low, CORE_ADDR high,
int how_many, int flags)
{
ui_out_chain = make_cleanup_ui_out_list_begin_end (uiout, "asm_insns");
- dump_insns (uiout, di, low, high, how_many, flags, NULL);
+ dump_insns (gdbarch, uiout, low, high, how_many, flags, NULL);
do_cleanups (ui_out_chain);
}
int flags, int how_many,
CORE_ADDR low, CORE_ADDR high)
{
- struct ui_file *stb = mem_fileopen ();
- struct cleanup *cleanups = make_cleanup_ui_file_delete (stb);
- gdb_disassembler di (gdbarch, stb);
struct symtab *symtab;
int nlines = -1;
if (!(flags & (DISASSEMBLY_SOURCE_DEPRECATED | DISASSEMBLY_SOURCE))
|| nlines <= 0)
- do_assembly_only (uiout, &di, low, high, how_many, flags);
+ do_assembly_only (gdbarch, uiout, low, high, how_many, flags);
else if (flags & DISASSEMBLY_SOURCE)
- do_mixed_source_and_assembly (gdbarch, uiout, &di, symtab, low, high,
+ do_mixed_source_and_assembly (gdbarch, uiout, symtab, low, high,
how_many, flags);
else if (flags & DISASSEMBLY_SOURCE_DEPRECATED)
- do_mixed_source_and_assembly_deprecated (uiout, &di, symtab,
+ do_mixed_source_and_assembly_deprecated (gdbarch, uiout, symtab,
low, high, how_many, flags);
- do_cleanups (cleanups);
gdb_flush (gdb_stdout);
}