Re: [PATCH 1/8] Refactor disassembly code

Yao Qi
2017-01-12T12:19:25Z

On 17-01-11 15:42:58, Simon Marchi wrote:
> On 2017-01-10 07:26, Yao Qi wrote:
> >@@ -761,15 +768,15 @@ fprintf_disasm (void *stream, const char
> >*format, ...)
> > return 0;
> > }
> >
> >-struct disassemble_info
> >-gdb_disassemble_info (struct gdbarch *gdbarch, struct ui_file *file)
> >+gdb_disassembler::gdb_disassembler (struct gdbarch *gdbarch,
> >+ struct ui_file *file,
> >+ di_read_memory_ftype func)
>
> Perhaps name this parameter "read_memory_func"?
>

OK.

> >diff --git a/gdb/disasm.h b/gdb/disasm.h
> >index 4c6fd54..5592cdb 100644
> >--- a/gdb/disasm.h
> >+++ b/gdb/disasm.h
> >@@ -33,6 +33,48 @@ struct gdbarch;
> > struct ui_out;
> > struct ui_file;
> >
> >+class gdb_disassembler
> >+{
> >+ using di_read_memory_ftype = decltype
> >(disassemble_info::read_memory_func);
> >+
> >+public:
> >+ gdb_disassembler (struct gdbarch *gdbarch, struct ui_file *file)
> >+ : gdb_disassembler (gdbarch, file, dis_asm_read_memory)
> >+ {}
> >+
> >+ int print_insn (CORE_ADDR memaddr);
> >+ int print_insn (CORE_ADDR memaddr, int *branch_delay_insns);
>
> Not very important, but since print_insn(CORE_ADDR) is trivial, you
> could merge those two methods and provide a default parameter value
> of NULL for branch_delay_insns.

OK. Fixed them locally.

>
> >+
> >+ /* Prints the instruction INSN into UIOUT and returns the length of
> >+ the printed instruction in bytes. */
> >+ int pretty_print_insn (struct ui_out *uiout,
> >+ const struct disasm_insn *insn, int flags);
>
> It could be a good time to modernize the flags parameter and make it
> an enum flag.
>

This can be done later.

--
Yao (é½å°§)