This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/8] Refactor disassembly code


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"?

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.

+
+  /* 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]