Fix regression from TUI disassembly style patch
authorTom Tromey <tom@tromey.com>
Wed, 6 Nov 2019 01:12:49 +0000 (18:12 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 6 Nov 2019 01:39:23 +0000 (18:39 -0700)
My previous patch to add styling to the TUI disassembly failed to
correctly fix a bug that Simon had pointed out in review.  This patch
fixes the bug.

gdb/ChangeLog
2019-11-05  Tom Tromey  <tom@tromey.com>

* tui/tui-disasm.c (struct tui_asm_line) <addr_size>: New member.
(tui_disassemble): Set addr_size.
(tui_disasm_window::set_contents): Use addr_size.

Change-Id: Ic0152f3b82a2f79be28ae46d590096661f271580

gdb/ChangeLog
gdb/tui/tui-disasm.c

index 5720c8e7fe14956fbd98bea0305b990d61a32ec1..e886480d62d02c3a5c58769e9417869d40b922ed 100644 (file)
@@ -1,3 +1,9 @@
+2019-11-05  Tom Tromey  <tom@tromey.com>
+
+       * tui/tui-disasm.c (struct tui_asm_line) <addr_size>: New member.
+       (tui_disassemble): Set addr_size.
+       (tui_disasm_window::set_contents): Use addr_size.
+
 2019-11-05  Tom Tromey  <tom@tromey.com>
 
        * rust-lang.c (rust_language_defn): Update.
index 71783266391e2b826aafef6c050e3dbe7a1aa849..8d5512efb2c980b4605300133eb076d735906a03 100644 (file)
@@ -47,6 +47,7 @@ struct tui_asm_line
 {
   CORE_ADDR addr;
   std::string addr_string;
+  size_t addr_size;
   std::string insn;
 };
 
@@ -110,6 +111,7 @@ tui_disassemble (struct gdbarch *gdbarch,
          else
            new_size = asm_lines[pos + i].addr_string.size ();
          *addr_size = std::max (*addr_size, new_size);
+         asm_lines[pos + i].addr_size = new_size;
        }
 
       pc = pc + gdb_print_insn (gdbarch, pc, &gdb_dis_out, NULL);
@@ -239,8 +241,7 @@ tui_disasm_window::set_contents (struct gdbarch *arch,
 
       std::string line
        = (asm_lines[i].addr_string
-          + n_spaces (insn_pos
-                      - asm_lines[i].addr_string.size ())
+          + n_spaces (insn_pos - asm_lines[i].addr_size)
           + asm_lines[i].insn);
 
       const char *ptr = line.c_str ();