* amd64-sol2-tdep.c (amd64_sol2_gregset_reg_offset): Correct
[deliverable/binutils-gdb.git] / gdb / disasm.c
index 096cec4342884921d53bb10a9ac40f6ac5bc1de9..89bd82918cc0f1be9c30024a7f3ff6f5611f58c2 100644 (file)
@@ -1,7 +1,6 @@
 /* Disassemble support for GDB.
 
-   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010,
-   2011 Free Software Foundation, Inc.
+   Copyright (C) 2000-2005, 2007-2012 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -77,12 +76,21 @@ compare_lines (const void *mle1p, const void *mle2p)
   mle1 = (struct dis_line_entry *) mle1p;
   mle2 = (struct dis_line_entry *) mle2p;
 
-  val = mle1->line - mle2->line;
-
-  if (val != 0)
-    return val;
-
-  return mle1->start_pc - mle2->start_pc;
+  /* End of sequence markers have a line number of 0 but don't want to
+     be sorted to the head of the list, instead sort by PC.  */
+  if (mle1->line == 0 || mle2->line == 0)
+    {
+      val = mle1->start_pc - mle2->start_pc;
+      if (val == 0)
+        val = mle1->line - mle2->line;
+    }
+  else
+    {
+      val = mle1->line - mle2->line;
+      if (val == 0)
+        val = mle1->start_pc - mle2->start_pc;
+    }
+  return val;
 }
 
 static int
@@ -143,6 +151,13 @@ dump_insns (struct gdbarch *gdbarch, struct ui_out *uiout,
           CORE_ADDR old_pc = pc;
           bfd_byte data;
           int status;
+          const char *spacer = "";
+
+          /* Build the opcodes using a temporary stream so we can
+             write them out in a single go for the MI.  */
+          struct ui_stream *opcode_stream = ui_out_stream_new (uiout);
+          struct cleanup *cleanups =
+            make_cleanup_ui_out_stream_delete (opcode_stream);
 
           pc += gdbarch_print_insn (gdbarch, pc, di);
           for (;old_pc < pc; old_pc++)
@@ -150,9 +165,14 @@ dump_insns (struct gdbarch *gdbarch, struct ui_out *uiout,
               status = (*di->read_memory_func) (old_pc, &data, 1, di);
               if (status != 0)
                 (*di->memory_error_func) (status, old_pc, di);
-              ui_out_message (uiout, 0, " %02x", (unsigned)data);
+              fprintf_filtered (opcode_stream->stream, "%s%02x",
+                                spacer, (unsigned) data);
+              spacer = " ";
             }
+          ui_out_field_stream (uiout, "opcodes", opcode_stream);
           ui_out_text (uiout, "\t");
+
+          do_cleanups (cleanups);
         }
       else
         pc += gdbarch_print_insn (gdbarch, pc, di);
This page took 0.024036 seconds and 4 git commands to generate.