[gdb/testsuite] Rewrite gdb_test_lines
[deliverable/binutils-gdb.git] / gdb / disasm.c
index 164939b58826ded1b08455b22b2e558188676275..7f730f681887076d94a1b542c54598d32d7957b2 100644 (file)
@@ -1,6 +1,6 @@
 /* Disassemble support for GDB.
 
-   Copyright (C) 2000-2019 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,13 +238,13 @@ 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.  */
        m_uiout->text (" <");
        if (!omit_fname)
-         m_uiout->field_string ("func-name", name.c_str (),
+         m_uiout->field_string ("func-name", name,
                                 function_name_style.style ());
        /* For negative offsets, avoid displaying them as +-N; the sign of
           the offset takes the place of the "+" here.  */
@@ -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,14 +1135,14 @@ disassembler_options_completer (struct cmd_list_element *ignore,
 
 /* Initialization code.  */
 
+void _initialize_disasm ();
 void
-_initialize_disasm (void)
+_initialize_disasm ()
 {
-  struct cmd_list_element *cmd;
-
   /* Add the command that controls the disassembler options.  */
-  cmd = add_setshow_string_noescape_cmd ("disassembler-options", no_class,
-                                        &prospective_options, _("\
+  set_show_commands set_show_disas_opts
+    = add_setshow_string_noescape_cmd ("disassembler-options", no_class,
+                                      &prospective_options, _("\
 Set the disassembler options.\n\
 Usage: set disassembler-options OPTION [,OPTION]...\n\n\
 See: 'show disassembler-options' for valid option values."), _("\
@@ -1143,5 +1150,5 @@ Show the disassembler options."), NULL,
                                         set_disassembler_options_sfunc,
                                         show_disassembler_options_sfunc,
                                         &setlist, &showlist);
-  set_cmd_completer (cmd, disassembler_options_completer);
+  set_cmd_completer (set_show_disas_opts.set, disassembler_options_completer);
 }
This page took 0.025544 seconds and 4 git commands to generate.