summaryrefslogtreecommitdiff
path: root/gdb/disasm.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/disasm.c')
-rw-r--r--gdb/disasm.c46
1 files changed, 12 insertions, 34 deletions
diff --git a/gdb/disasm.c b/gdb/disasm.c
index f419501b086..e29143ca0d3 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -176,7 +176,7 @@ int
gdb_pretty_print_insn (struct gdbarch *gdbarch, struct ui_out *uiout,
struct disassemble_info * di,
const struct disasm_insn *insn, int flags,
- struct ui_file *stb)
+ string_file &stb)
{
/* parts of the symbolic representation of the address */
int unmapped;
@@ -240,7 +240,7 @@ gdb_pretty_print_insn (struct gdbarch *gdbarch, struct ui_out *uiout,
if (name != NULL)
xfree (name);
- ui_file_rewind (stb);
+ stb.rewind ();
if (flags & DISASSEMBLY_RAW_INSN)
{
CORE_ADDR end_pc;
@@ -250,9 +250,7 @@ gdb_pretty_print_insn (struct gdbarch *gdbarch, struct ui_out *uiout,
/* Build the opcodes using a temporary stream so we can
write them out in a single go for the MI. */
- struct ui_file *opcode_stream = mem_fileopen ();
- struct cleanup *cleanups =
- make_cleanup_ui_file_delete (opcode_stream);
+ string_file opcode_stream;
size = gdbarch_print_insn (gdbarch, pc, di);
end_pc = pc + size;
@@ -262,21 +260,18 @@ gdb_pretty_print_insn (struct gdbarch *gdbarch, struct ui_out *uiout,
err = (*di->read_memory_func) (pc, &data, 1, di);
if (err != 0)
(*di->memory_error_func) (err, pc, di);
- fprintf_filtered (opcode_stream, "%s%02x",
- spacer, (unsigned) data);
+ opcode_stream.printf ("%s%02x", spacer, (unsigned) data);
spacer = " ";
}
uiout->field_stream ("opcodes", opcode_stream);
uiout->text ("\t");
-
- do_cleanups (cleanups);
}
else
size = gdbarch_print_insn (gdbarch, pc, di);
uiout->field_stream ("inst", stb);
- ui_file_rewind (stb);
+ stb.rewind ();
do_cleanups (ui_out_chain);
uiout->text ("\n");
@@ -287,7 +282,7 @@ static int
dump_insns (struct gdbarch *gdbarch, struct ui_out *uiout,
struct disassemble_info * di,
CORE_ADDR low, CORE_ADDR high,
- int how_many, int flags, struct ui_file *stb,
+ int how_many, int flags, string_file &stb,
CORE_ADDR *end_pc)
{
struct disasm_insn insn;
@@ -329,7 +324,7 @@ do_mixed_source_and_assembly_deprecated
(struct gdbarch *gdbarch, struct ui_out *uiout,
struct disassemble_info *di, struct symtab *symtab,
CORE_ADDR low, CORE_ADDR high,
- int how_many, int flags, struct ui_file *stb)
+ int how_many, int flags, string_file &stb)
{
int newlines = 0;
int nlines;
@@ -492,7 +487,7 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout,
struct disassemble_info *di,
struct symtab *main_symtab,
CORE_ADDR low, CORE_ADDR high,
- int how_many, int flags, struct ui_file *stb)
+ int how_many, int flags, string_file &stb)
{
const struct linetable_entry *le, *first_le;
int i, nlines;
@@ -729,7 +724,7 @@ static void
do_assembly_only (struct gdbarch *gdbarch, struct ui_out *uiout,
struct disassemble_info * di,
CORE_ADDR low, CORE_ADDR high,
- int how_many, int flags, struct ui_file *stb)
+ int how_many, int flags, string_file &stb)
{
struct cleanup *ui_out_chain;
@@ -787,9 +782,8 @@ gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout,
char *file_string, 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);
- struct disassemble_info di = gdb_disassemble_info (gdbarch, stb);
+ string_file stb;
+ struct disassemble_info di = gdb_disassemble_info (gdbarch, &stb);
struct symtab *symtab;
int nlines = -1;
@@ -811,7 +805,6 @@ gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout,
do_mixed_source_and_assembly_deprecated (gdbarch, uiout, &di, symtab,
low, high, how_many, flags, stb);
- do_cleanups (cleanups);
gdb_flush (gdb_stdout);
}
@@ -838,28 +831,13 @@ gdb_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
return length;
}
-static void
-do_ui_file_delete (void *arg)
-{
- ui_file_delete ((struct ui_file *) arg);
-}
-
/* Return the length in bytes of the instruction at address MEMADDR in
debugged memory. */
int
gdb_insn_length (struct gdbarch *gdbarch, CORE_ADDR addr)
{
- static struct ui_file *null_stream = NULL;
-
- /* Dummy file descriptor for the disassembler. */
- if (!null_stream)
- {
- null_stream = ui_file_new ();
- make_final_cleanup (do_ui_file_delete, null_stream);
- }
-
- return gdb_print_insn (gdbarch, addr, null_stream, NULL);
+ return gdb_print_insn (gdbarch, addr, &null_stream, NULL);
}
/* fprintf-function for gdb_buffered_insn_length. This function is a