Refactor struct trad_frame_saved_regs
[binutils-gdb.git] / gdb / disasm.c
index 39052f7fd36a71429a87738d39fbf51404a2e22c..eb69e89017b2482edee386e6a49c550d3f4854df 100644 (file)
@@ -1,6 +1,6 @@
 /* Disassemble support for GDB.
 
-   Copyright (C) 2000-2020 Free Software Foundation, Inc.
+   Copyright (C) 2000-2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -176,14 +176,14 @@ line_is_less_than (const deprecated_dis_line_entry &mle1,
       if (mle1.start_pc != mle2.start_pc)
        val = mle1.start_pc < mle2.start_pc;
     else
-        val = mle1.line < mle2.line;
+       val = mle1.line < mle2.line;
     }
   else
     {
       if (mle1.line != mle2.line)
        val = mle1.line < mle2.line;
       else
-        val = mle1.start_pc < mle2.start_pc;
+       val = mle1.start_pc < mle2.start_pc;
     }
   return val;
 }
@@ -238,7 +238,7 @@ gdb_pretty_print_disassembler::pretty_print_insn (const struct disasm_insn *insn
     std::string name, filename;
     bool omit_fname = ((flags & DISASSEMBLY_OMIT_FNAME) != 0);
     if (!build_address_symbolic (gdbarch, pc, false, omit_fname, &name,
-                                 &offset, &filename, &line, &unmapped))
+                                &offset, &filename, &line, &unmapped))
       {
        /* We don't care now about line, filename and unmapped.  But we might in
           the future.  */
@@ -460,7 +460,7 @@ do_mixed_source_and_assembly_deprecated
                                   how_many, flags, NULL);
 
       /* 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.  */
+        assembly range for this source line, close out the list/tuple.  */
       if (i == (newlines - 1) || mle[i + 1].line > mle[i].line)
        {
          inner_list_emitter.reset ();
@@ -781,6 +781,11 @@ gdb_disassembler::gdb_disassembler (struct gdbarch *gdbarch,
   disassemble_init_for_target (&m_di);
 }
 
+gdb_disassembler::~gdb_disassembler ()
+{
+  disassemble_free_target (&m_di);
+}
+
 int
 gdb_disassembler::print_insn (CORE_ADDR memaddr,
                              int *branch_delay_insns)
@@ -908,7 +913,9 @@ gdb_buffered_insn_length (struct gdbarch *gdbarch,
   gdb_buffered_insn_length_init_dis (gdbarch, &di, insn, max_len, addr,
                                     &disassembler_options_holder);
 
-  return gdbarch_print_insn (gdbarch, addr, &di);
+  int result = gdbarch_print_insn (gdbarch, addr, &di);
+  disassemble_free_target (&di);
+  return result;
 }
 
 char *
@@ -1128,8 +1135,9 @@ disassembler_options_completer (struct cmd_list_element *ignore,
 
 /* Initialization code.  */
 
+void _initialize_disasm ();
 void
-_initialize_disasm (void)
+_initialize_disasm ()
 {
   struct cmd_list_element *cmd;