diff --git a/gdb/disasm.c b/gdb/disasm.c index d94225b..0fd5aa1 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -107,6 +107,13 @@ dump_insns (struct gdbarch *gdbarch, struct ui_out *uiout, int offset; int line; struct cleanup *ui_out_chain; + /* This array holds enough space for 8 bytes of opcodes; + since the format is 02x plus the space, the length + the array is (2chars + 1space) * 8 bytes + 1zero = 25 chars. */ + char right_align[8 * 3 + 1]; + + memset(right_align, ' ', sizeof(right_align) - 2); + right_align[sizeof(right_align) - 1] = 0; for (pc = low; pc < high;) { @@ -154,6 +161,7 @@ dump_insns (struct gdbarch *gdbarch, struct ui_out *uiout, bfd_byte data; int status; const char *spacer = ""; + unsigned int alignment_pos = 0; /* Build the opcodes using a temporary stream so we can write them out in a single go for the MI. */ @@ -170,8 +178,11 @@ dump_insns (struct gdbarch *gdbarch, struct ui_out *uiout, fprintf_filtered (opcode_stream, "%s%02x", spacer, (unsigned) data); spacer = " "; + alignment_pos += 3; } ui_out_field_stream (uiout, "opcodes", opcode_stream); + if (alignment_pos < sizeof(right_align)) + ui_out_text (uiout, &right_align[alignment_pos]); ui_out_text (uiout, "\t"); do_cleanups (cleanups);