add autom4te.cache to .cvsignore
[deliverable/binutils-gdb.git] / gdb / disasm.c
index 5f4d07a0aea24ffad705be8862f59b44204ba940..1c050c93324fb17ced4f148aa516bcf0ae41ea79 100644 (file)
@@ -1,6 +1,7 @@
 /* Disassemble support for GDB.
 
-   Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -16,8 +17,8 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
 
 #include "defs.h"
 #include "target.h"
@@ -46,10 +47,10 @@ struct dis_line_entry
 
 /* Like target_read_memory, but slightly different parameters.  */
 static int
-dis_asm_read_memory (bfd_vma memaddr, bfd_byte *myaddr, unsigned int len,
+dis_asm_read_memory (bfd_vma memaddr, gdb_byte *myaddr, unsigned int len,
                     struct disassemble_info *info)
 {
-  return target_read_memory (memaddr, (char *) myaddr, len);
+  return target_read_memory (memaddr, myaddr, len);
 }
 
 /* Like memory_error with slightly different parameters.  */
@@ -164,6 +165,8 @@ do_mixed_source_and_assembly (struct ui_out *uiout,
   CORE_ADDR pc;
   int num_displayed = 0;
   struct cleanup *ui_out_chain;
+  struct cleanup *ui_out_tuple_chain = make_cleanup (null_cleanup, 0);
+  struct cleanup *ui_out_list_chain = make_cleanup (null_cleanup, 0);
 
   mle = (struct dis_line_entry *) alloca (nlines
                                          * sizeof (struct dis_line_entry));
@@ -221,10 +224,6 @@ do_mixed_source_and_assembly (struct ui_out *uiout,
 
   for (i = 0; i < newlines; i++)
     {
-      struct cleanup *ui_out_tuple_chain = NULL;
-      struct cleanup *ui_out_list_chain = NULL;
-      int close_list = 1;
-      
       /* Print out everything from next_line to the current line.  */
       if (mle[i].line >= next_line)
        {
@@ -275,23 +274,23 @@ do_mixed_source_and_assembly (struct ui_out *uiout,
          next_line = mle[i].line + 1;
          ui_out_list_chain
            = make_cleanup_ui_out_list_begin_end (uiout, "line_asm_insn");
-         /* Don't close the list if the lines are not in order. */
-         if (i < (newlines - 1) && mle[i + 1].line <= mle[i].line)
-           close_list = 0;
        }
 
       num_displayed += dump_insns (uiout, di, mle[i].start_pc, mle[i].end_pc,
                                   how_many, stb);
-      if (close_list)
+
+      /* When we've reached the end of the mle array, or we've seen the last
+         assembly range for this source line, close out the list/tuple.  */
+      if (i == (newlines - 1) || mle[i + 1].line > mle[i].line)
        {
          do_cleanups (ui_out_list_chain);
          do_cleanups (ui_out_tuple_chain);
+         ui_out_tuple_chain = make_cleanup (null_cleanup, 0);
+         ui_out_list_chain = make_cleanup (null_cleanup, 0);
          ui_out_text (uiout, "\n");
-         close_list = 0;
        }
-      if (how_many >= 0)
-       if (num_displayed >= how_many)
-         break;
+      if (how_many >= 0 && num_displayed >= how_many)
+       break;
     }
   do_cleanups (ui_out_chain);
 }
@@ -315,7 +314,7 @@ do_assembly_only (struct ui_out *uiout, struct disassemble_info * di,
 /* Initialize the disassemble info struct ready for the specified
    stream.  */
 
-static int
+static int ATTR_FORMAT (printf, 2, 3)
 fprintf_disasm (void *stream, const char *format, ...)
 {
   va_list args;
@@ -337,7 +336,7 @@ gdb_disassemble_info (struct gdbarch *gdbarch, struct ui_file *file)
   /* NOTE: cagney/2003-04-28: The original code, from the old Insight
      disassembler had a local optomization here.  By default it would
      access the executable file, instead of the target memory (there
-     was a growing list of exceptions though).  Unfortunatly, the
+     was a growing list of exceptions though).  Unfortunately, the
      heuristic was flawed.  Commands like "disassemble &variable"
      didn't work as they relied on the access going to the target.
      Further, it has been supperseeded by trust-read-only-sections
@@ -346,6 +345,7 @@ gdb_disassemble_info (struct gdbarch *gdbarch, struct ui_file *file)
   di.arch = gdbarch_bfd_arch_info (gdbarch)->arch;
   di.mach = gdbarch_bfd_arch_info (gdbarch)->mach;
   di.endian = gdbarch_byte_order (gdbarch);
+  disassemble_init_for_target (&di);
   return di;
 }
 
This page took 0.030972 seconds and 4 git commands to generate.