Re: nios2: Remove binutils support for Nios II target
[binutils-gdb.git] / gdb / disasm.c
blob11d6efd923ad2c8c0d02c4fef8f7f624bf6a1227
1 /* Disassemble support for GDB.
3 Copyright (C) 2000-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "arch-utils.h"
21 #include "event-top.h"
22 #include "gdbsupport/unordered_set.h"
23 #include "target.h"
24 #include "value.h"
25 #include "ui-out.h"
26 #include "disasm.h"
27 #include "gdbcore.h"
28 #include "cli/cli-cmds.h"
29 #include "dis-asm.h"
30 #include "source.h"
31 #include "gdbsupport/gdb-safe-ctype.h"
32 #include <algorithm>
33 #include <optional>
34 #include "valprint.h"
35 #include "cli/cli-style.h"
36 #include "objfiles.h"
37 #include "inferior.h"
39 /* Disassemble functions.
40 FIXME: We should get rid of all the duplicate code in gdb that does
41 the same thing: disassemble_command() and the gdbtk variation. */
43 /* This variable is used to hold the prospective disassembler_options value
44 which is set by the "set disassembler_options" command. */
45 static std::string prospective_options;
47 /* When this is true we will try to use libopcodes to provide styling to
48 the disassembler output. */
50 static bool use_libopcodes_styling = true;
52 /* To support the set_use_libopcodes_styling function we have a second
53 variable which is connected to the actual set/show option. */
55 static bool use_libopcodes_styling_option = use_libopcodes_styling;
57 /* The "maint show libopcodes-styling enabled" command. */
59 static void
60 show_use_libopcodes_styling (struct ui_file *file, int from_tty,
61 struct cmd_list_element *c,
62 const char *value)
64 gdbarch *arch = current_inferior ()->arch ();
65 gdb_non_printing_memory_disassembler dis (arch);
66 bool supported = dis.disasm_info ()->created_styled_output;
68 if (supported || !use_libopcodes_styling)
69 gdb_printf (file, _("Use of libopcodes styling support is \"%s\".\n"),
70 value);
71 else
73 /* Use of libopcodes styling is not supported, and the user has this
74 turned on! */
75 gdb_printf (file, _("Use of libopcodes styling support is \"off\""
76 " (not supported on architecture \"%s\")\n"),
77 gdbarch_bfd_arch_info (arch)->printable_name);
81 /* The "maint set libopcodes-styling enabled" command. */
83 static void
84 set_use_libopcodes_styling (const char *args, int from_tty,
85 struct cmd_list_element *c)
87 gdbarch *arch = current_inferior ()->arch ();
88 gdb_non_printing_memory_disassembler dis (arch);
89 bool supported = dis.disasm_info ()->created_styled_output;
91 /* If the current architecture doesn't support libopcodes styling then we
92 give an error here, but leave the underlying setting enabled. This
93 means that if the user switches to an architecture that does support
94 libopcodes styling the setting will be enabled. */
96 if (use_libopcodes_styling_option && !supported)
98 use_libopcodes_styling_option = use_libopcodes_styling;
99 error (_("Use of libopcodes styling not supported on architecture \"%s\"."),
100 gdbarch_bfd_arch_info (arch)->printable_name);
102 else
103 use_libopcodes_styling = use_libopcodes_styling_option;
106 /* This structure is used to store line number information for the
107 deprecated /m option.
108 We need a different sort of line table from the normal one cuz we can't
109 depend upon implicit line-end pc's for lines to do the
110 reordering in this function. */
112 struct deprecated_dis_line_entry
114 int line;
115 CORE_ADDR start_pc;
116 CORE_ADDR end_pc;
119 /* This Structure is used to store line number information.
120 We need a different sort of line table from the normal one cuz we can't
121 depend upon implicit line-end pc's for lines to do the
122 reordering in this function. */
124 struct dis_line_entry
126 dis_line_entry (struct symtab *symtab, int line) noexcept
127 : symtab (symtab),
128 line (line)
131 bool operator== (const dis_line_entry &other) const noexcept
132 { return this->symtab == other.symtab && this->line == other.line; }
134 struct symtab *symtab;
135 int line;
138 /* Hash function for dis_line_entry. */
140 struct dis_line_entry_hash
142 std::size_t operator() (const dis_line_entry &x) const noexcept
143 { return std::hash<symtab *> () (x.symtab) + std::hash<int> () (x.line); }
146 /* Wrapper of target_read_code. */
149 gdb_disassembler_memory_reader::dis_asm_read_memory
150 (bfd_vma memaddr, gdb_byte *myaddr, unsigned int len,
151 struct disassemble_info *info) noexcept
153 auto res = catch_exceptions<int, -1> ([&]
155 return target_read_code (memaddr, myaddr, len);
158 return res;
161 /* Wrapper of memory_error. */
163 void
164 gdb_disassembler::dis_asm_memory_error
165 (int err, bfd_vma memaddr, struct disassemble_info *info) noexcept
167 gdb_disassembler *self
168 = static_cast<gdb_disassembler *>(info->application_data);
170 self->m_err_memaddr.emplace (memaddr);
173 /* Wrapper of print_address. */
175 void
176 gdb_disassembler::dis_asm_print_address
177 (bfd_vma addr, struct disassemble_info *info) noexcept
179 gdb_disassembler *self
180 = static_cast<gdb_disassembler *>(info->application_data);
182 if (self->in_comment_p ())
184 /* Calling 'print_address' might add styling to the output (based on
185 the properties of the stream we're writing too). This is usually
186 fine, but if we are in an assembler comment then we'd prefer to
187 have the comment style, rather than the default address style.
189 Print the address into a temporary buffer which doesn't support
190 styling, then reprint this unstyled address with the default text
191 style.
193 As we are inside a comment right now, the standard print routine
194 will ensure that the comment is printed to the user with a
195 suitable comment style. */
196 string_file tmp;
197 print_address (self->arch (), addr, &tmp);
198 self->fprintf_styled_func (self, dis_style_text, "%s", tmp.c_str ());
200 else
201 print_address (self->arch (), addr, self->stream ());
204 /* See disasm.h. */
206 ui_file *
207 gdb_printing_disassembler::stream_from_gdb_disassemble_info (void *dis_info)
209 gdb_disassemble_info *di = (gdb_disassemble_info *) dis_info;
210 gdb_printing_disassembler *dis
211 = gdb::checked_static_cast<gdb_printing_disassembler *> (di);
212 ui_file *stream = dis->stream ();
213 gdb_assert (stream != nullptr);
214 return stream;
217 /* Format disassembler output to STREAM. */
220 gdb_printing_disassembler::fprintf_func (void *dis_info,
221 const char *format, ...) noexcept
223 ui_file *stream = stream_from_gdb_disassemble_info (dis_info);
225 va_list args;
226 va_start (args, format);
227 gdb_vprintf (stream, format, args);
228 va_end (args);
230 /* Something non -ve. */
231 return 0;
234 /* See disasm.h. */
237 gdb_printing_disassembler::fprintf_styled_func
238 (void *dis_info, enum disassembler_style style,
239 const char *format, ...) noexcept
241 ui_file *stream = stream_from_gdb_disassemble_info (dis_info);
242 gdb_printing_disassembler *dis = (gdb_printing_disassembler *) dis_info;
244 va_list args;
245 va_start (args, format);
246 std::string content = string_vprintf (format, args);
247 va_end (args);
249 /* Once in a comment then everything should be styled as a comment. */
250 if (style == dis_style_comment_start)
251 dis->set_in_comment (true);
252 if (dis->in_comment_p ())
253 style = dis_style_comment_start;
255 /* Now print the content with the correct style. */
256 const char *txt = content.c_str ();
257 switch (style)
259 case dis_style_mnemonic:
260 case dis_style_sub_mnemonic:
261 case dis_style_assembler_directive:
262 fputs_styled (txt, disasm_mnemonic_style.style (), stream);
263 break;
265 case dis_style_register:
266 fputs_styled (txt, disasm_register_style.style (), stream);
267 break;
269 case dis_style_immediate:
270 case dis_style_address_offset:
271 fputs_styled (txt, disasm_immediate_style.style (), stream);
272 break;
274 case dis_style_address:
275 fputs_styled (txt, address_style.style (), stream);
276 break;
278 case dis_style_symbol:
279 fputs_styled (txt, function_name_style.style (), stream);
280 break;
282 case dis_style_comment_start:
283 fputs_styled (txt, disasm_comment_style.style (), stream);
284 break;
286 case dis_style_text:
287 gdb_puts (txt, stream);
288 break;
291 /* Something non -ve. */
292 return 0;
295 static bool
296 line_is_less_than (const deprecated_dis_line_entry &mle1,
297 const deprecated_dis_line_entry &mle2)
299 bool val;
301 /* End of sequence markers have a line number of 0 but don't want to
302 be sorted to the head of the list, instead sort by PC. */
303 if (mle1.line == 0 || mle2.line == 0)
305 if (mle1.start_pc != mle2.start_pc)
306 val = mle1.start_pc < mle2.start_pc;
307 else
308 val = mle1.line < mle2.line;
310 else
312 if (mle1.line != mle2.line)
313 val = mle1.line < mle2.line;
314 else
315 val = mle1.start_pc < mle2.start_pc;
317 return val;
320 /* See disasm.h. */
323 gdb_pretty_print_disassembler::pretty_print_insn (const struct disasm_insn *insn,
324 gdb_disassembly_flags flags)
326 /* parts of the symbolic representation of the address */
327 int unmapped;
328 int offset;
329 int line;
330 int size;
331 CORE_ADDR pc;
332 struct gdbarch *gdbarch = arch ();
335 ui_out_emit_tuple tuple_emitter (m_uiout, NULL);
336 pc = insn->addr;
338 if (insn->number != 0)
340 m_uiout->field_unsigned ("insn-number", insn->number);
341 m_uiout->text ("\t");
344 if ((flags & DISASSEMBLY_SPECULATIVE) != 0)
346 if (insn->is_speculative)
348 m_uiout->field_string ("is-speculative", "?");
350 /* The speculative execution indication overwrites the first
351 character of the PC prefix.
352 We assume a PC prefix length of 3 characters. */
353 if ((flags & DISASSEMBLY_OMIT_PC) == 0)
354 m_uiout->text (pc_prefix (pc) + 1);
355 else
356 m_uiout->text (" ");
358 else if ((flags & DISASSEMBLY_OMIT_PC) == 0)
359 m_uiout->text (pc_prefix (pc));
360 else
361 m_uiout->text (" ");
363 else if ((flags & DISASSEMBLY_OMIT_PC) == 0)
364 m_uiout->text (pc_prefix (pc));
365 m_uiout->field_core_addr ("address", gdbarch, pc);
367 std::string name, filename;
368 bool omit_fname = ((flags & DISASSEMBLY_OMIT_FNAME) != 0);
369 if (!build_address_symbolic (gdbarch, pc, false, omit_fname, &name,
370 &offset, &filename, &line, &unmapped))
372 /* We don't care now about line, filename and unmapped. But we might in
373 the future. */
374 m_uiout->text (" <");
375 if (!omit_fname)
376 m_uiout->field_string ("func-name", name,
377 function_name_style.style ());
378 /* For negative offsets, avoid displaying them as +-N; the sign of
379 the offset takes the place of the "+" here. */
380 if (offset >= 0)
381 m_uiout->text ("+");
382 m_uiout->field_signed ("offset", offset);
383 m_uiout->text (">:\t");
385 else
386 m_uiout->text (":\t");
388 /* Clear the buffer into which we will disassemble the instruction. */
389 m_insn_stb.clear ();
391 /* A helper function to write the M_INSN_STB buffer, followed by a
392 newline. This can be called in a couple of situations. */
393 auto write_out_insn_buffer = [&] ()
395 m_uiout->field_stream ("inst", m_insn_stb);
396 m_uiout->text ("\n");
401 /* Now we can disassemble the instruction. If the disassembler
402 returns a negative value this indicates an error and is handled
403 within the print_insn call, resulting in an exception being
404 thrown. Returning zero makes no sense, as this indicates we
405 disassembled something successfully, but it was something of no
406 size? */
407 size = m_di.print_insn (pc);
408 gdb_assert (size > 0);
410 catch (const gdb_exception &)
412 /* An exception was thrown while disassembling the instruction.
413 However, the disassembler might still have written something
414 out, so ensure that we flush the instruction buffer before
415 rethrowing the exception. We can't perform this write from an
416 object destructor as the write itself might throw an exception
417 if the pager kicks in, and the user selects quit. */
418 write_out_insn_buffer ();
419 throw;
422 if ((flags & (DISASSEMBLY_RAW_INSN | DISASSEMBLY_RAW_BYTES)) != 0)
424 /* Build the opcodes using a temporary stream so we can
425 write them out in a single go for the MI. */
426 m_opcode_stb.clear ();
428 /* Read the instruction opcode data. */
429 m_opcode_data.resize (size);
430 read_code (pc, m_opcode_data.data (), size);
432 /* The disassembler provides information about the best way to
433 display the instruction bytes to the user. We provide some sane
434 defaults in case the disassembler gets it wrong. */
435 const struct disassemble_info *di = m_di.disasm_info ();
436 int bytes_per_line = std::max (di->bytes_per_line, size);
437 int bytes_per_chunk = std::max (di->bytes_per_chunk, 1);
439 /* If the user has requested the instruction bytes be displayed
440 byte at a time, then handle that here. Also, if the instruction
441 is not a multiple of the chunk size (which probably indicates a
442 disassembler problem) then avoid that causing display problems
443 by switching to byte at a time mode. */
444 if ((flags & DISASSEMBLY_RAW_BYTES) != 0
445 || (size % bytes_per_chunk) != 0)
446 bytes_per_chunk = 1;
448 /* Print the instruction opcodes bytes, grouped into chunks. */
449 for (int i = 0; i < size; i += bytes_per_chunk)
451 if (i > 0)
452 m_opcode_stb.puts (" ");
454 if (di->display_endian == BFD_ENDIAN_LITTLE)
456 for (int k = bytes_per_chunk; k-- != 0; )
457 m_opcode_stb.printf ("%02x", (unsigned) m_opcode_data[i + k]);
459 else
461 for (int k = 0; k < bytes_per_chunk; k++)
462 m_opcode_stb.printf ("%02x", (unsigned) m_opcode_data[i + k]);
466 /* Calculate required padding. */
467 int nspaces = 0;
468 for (int i = size; i < bytes_per_line; i += bytes_per_chunk)
470 if (i > size)
471 nspaces++;
472 nspaces += bytes_per_chunk * 2;
475 m_uiout->field_stream ("opcodes", m_opcode_stb);
476 m_uiout->spaces (nspaces);
477 m_uiout->text ("\t");
480 /* Disassembly was a success, write out the instruction buffer. */
481 write_out_insn_buffer ();
484 return size;
487 static int
488 dump_insns (struct gdbarch *gdbarch,
489 struct ui_out *uiout, CORE_ADDR low, CORE_ADDR high,
490 int how_many, gdb_disassembly_flags flags, CORE_ADDR *end_pc)
492 struct disasm_insn insn;
493 int num_displayed = 0;
495 memset (&insn, 0, sizeof (insn));
496 insn.addr = low;
498 gdb_pretty_print_disassembler disasm (gdbarch, uiout);
500 while (insn.addr < high && (how_many < 0 || num_displayed < how_many))
502 int size;
504 size = disasm.pretty_print_insn (&insn, flags);
505 if (size <= 0)
506 break;
508 ++num_displayed;
509 insn.addr += size;
511 /* Allow user to bail out with ^C. */
512 QUIT;
515 if (end_pc != NULL)
516 *end_pc = insn.addr;
518 return num_displayed;
521 /* The idea here is to present a source-O-centric view of a
522 function to the user. This means that things are presented
523 in source order, with (possibly) out of order assembly
524 immediately following.
526 N.B. This view is deprecated. */
528 static void
529 do_mixed_source_and_assembly_deprecated
530 (struct gdbarch *gdbarch, struct ui_out *uiout,
531 struct symtab *symtab,
532 CORE_ADDR low, CORE_ADDR high,
533 int how_many, gdb_disassembly_flags flags)
535 int newlines = 0;
536 int nlines;
537 const struct linetable_entry *le;
538 struct deprecated_dis_line_entry *mle;
539 struct symtab_and_line sal;
540 int i;
541 int out_of_order = 0;
542 int next_line = 0;
543 int num_displayed = 0;
544 print_source_lines_flags psl_flags = 0;
546 gdb_assert (symtab != nullptr && symtab->linetable () != nullptr);
548 nlines = symtab->linetable ()->nitems;
549 le = symtab->linetable ()->item;
551 if (flags & DISASSEMBLY_FILENAME)
552 psl_flags |= PRINT_SOURCE_LINES_FILENAME;
554 mle = (struct deprecated_dis_line_entry *)
555 alloca (nlines * sizeof (struct deprecated_dis_line_entry));
557 struct objfile *objfile = symtab->compunit ()->objfile ();
559 unrelocated_addr unrel_low
560 = unrelocated_addr (low - objfile->text_section_offset ());
561 unrelocated_addr unrel_high
562 = unrelocated_addr (high - objfile->text_section_offset ());
564 /* Copy linetable entries for this function into our data
565 structure, creating end_pc's and setting out_of_order as
566 appropriate. */
568 /* First, skip all the preceding functions. */
570 for (i = 0; i < nlines - 1 && le[i].unrelocated_pc () < unrel_low; i++);
572 /* Now, copy all entries before the end of this function. */
574 for (; i < nlines - 1 && le[i].unrelocated_pc () < unrel_high; i++)
576 if (le[i] == le[i + 1])
577 continue; /* Ignore duplicates. */
579 /* Skip any end-of-function markers. */
580 if (le[i].line == 0)
581 continue;
583 mle[newlines].line = le[i].line;
584 if (le[i].line > le[i + 1].line)
585 out_of_order = 1;
586 mle[newlines].start_pc = le[i].pc (objfile);
587 mle[newlines].end_pc = le[i + 1].pc (objfile);
588 newlines++;
591 /* If we're on the last line, and it's part of the function,
592 then we need to get the end pc in a special way. */
594 if (i == nlines - 1 && le[i].unrelocated_pc () < unrel_high)
596 mle[newlines].line = le[i].line;
597 mle[newlines].start_pc = le[i].pc (objfile);
598 sal = find_pc_line (le[i].pc (objfile), 0);
599 mle[newlines].end_pc = sal.end;
600 newlines++;
603 /* Now, sort mle by line #s (and, then by addresses within lines). */
605 if (out_of_order)
606 std::sort (mle, mle + newlines, line_is_less_than);
608 /* Now, for each line entry, emit the specified lines (unless
609 they have been emitted before), followed by the assembly code
610 for that line. */
612 ui_out_emit_list asm_insns_list (uiout, "asm_insns");
614 std::optional<ui_out_emit_tuple> outer_tuple_emitter;
615 std::optional<ui_out_emit_list> inner_list_emitter;
617 for (i = 0; i < newlines; i++)
619 /* Print out everything from next_line to the current line. */
620 if (mle[i].line >= next_line)
622 if (next_line != 0)
624 /* Just one line to print. */
625 if (next_line == mle[i].line)
627 outer_tuple_emitter.emplace (uiout, "src_and_asm_line");
628 print_source_lines (symtab, next_line, mle[i].line + 1, psl_flags);
630 else
632 /* Several source lines w/o asm instructions associated. */
633 for (; next_line < mle[i].line; next_line++)
635 ui_out_emit_tuple tuple_emitter (uiout,
636 "src_and_asm_line");
637 print_source_lines (symtab, next_line, next_line + 1,
638 psl_flags);
639 ui_out_emit_list temp_list_emitter (uiout,
640 "line_asm_insn");
642 /* Print the last line and leave list open for
643 asm instructions to be added. */
644 outer_tuple_emitter.emplace (uiout, "src_and_asm_line");
645 print_source_lines (symtab, next_line, mle[i].line + 1, psl_flags);
648 else
650 outer_tuple_emitter.emplace (uiout, "src_and_asm_line");
651 print_source_lines (symtab, mle[i].line, mle[i].line + 1, psl_flags);
654 next_line = mle[i].line + 1;
655 inner_list_emitter.emplace (uiout, "line_asm_insn");
658 num_displayed += dump_insns (gdbarch, uiout,
659 mle[i].start_pc, mle[i].end_pc,
660 how_many, flags, NULL);
662 /* When we've reached the end of the mle array, or we've seen the last
663 assembly range for this source line, close out the list/tuple. */
664 if (i == (newlines - 1) || mle[i + 1].line > mle[i].line)
666 inner_list_emitter.reset ();
667 outer_tuple_emitter.reset ();
668 uiout->text ("\n");
670 if (how_many >= 0 && num_displayed >= how_many)
671 break;
675 /* The idea here is to present a source-O-centric view of a
676 function to the user. This means that things are presented
677 in source order, with (possibly) out of order assembly
678 immediately following. */
680 static void
681 do_mixed_source_and_assembly (struct gdbarch *gdbarch,
682 struct ui_out *uiout,
683 struct symtab *main_symtab,
684 CORE_ADDR low, CORE_ADDR high,
685 int how_many, gdb_disassembly_flags flags)
687 const struct linetable_entry *le, *first_le;
688 int i, nlines;
689 int num_displayed = 0;
690 print_source_lines_flags psl_flags = 0;
691 CORE_ADDR pc;
692 struct symtab *last_symtab;
693 int last_line;
695 gdb_assert (main_symtab != NULL && main_symtab->linetable () != NULL);
697 /* First pass: collect the list of all source files and lines.
698 We do this so that we can only print lines containing code once.
699 We try to print the source text leading up to the next instruction,
700 but if that text is for code that will be disassembled later, then
701 we'll want to defer printing it until later with its associated code. */
703 gdb::unordered_set<dis_line_entry, dis_line_entry_hash> dis_line_table;
705 struct objfile *objfile = main_symtab->compunit ()->objfile ();
707 unrelocated_addr unrel_low
708 = unrelocated_addr (low - objfile->text_section_offset ());
709 unrelocated_addr unrel_high
710 = unrelocated_addr (high - objfile->text_section_offset ());
712 pc = low;
714 /* The prologue may be empty, but there may still be a line number entry
715 for the opening brace which is distinct from the first line of code.
716 If the prologue has been eliminated find_pc_line may return the source
717 line after the opening brace. We still want to print this opening brace.
718 first_le is used to implement this. */
720 nlines = main_symtab->linetable ()->nitems;
721 le = main_symtab->linetable ()->item;
722 first_le = NULL;
724 /* Skip all the preceding functions. */
725 for (i = 0; i < nlines && le[i].unrelocated_pc () < unrel_low; i++)
726 continue;
728 if (i < nlines && le[i].unrelocated_pc () < unrel_high)
729 first_le = &le[i];
731 /* Add lines for every pc value. */
732 while (pc < high)
734 struct symtab_and_line sal;
735 int length;
737 sal = find_pc_line (pc, 0);
738 length = gdb_insn_length (gdbarch, pc);
739 pc += length;
741 if (sal.symtab != NULL)
742 dis_line_table.emplace (sal.symtab, sal.line);
745 /* Second pass: print the disassembly.
747 Output format, from an MI perspective:
748 The result is a ui_out list, field name "asm_insns", where elements have
749 name "src_and_asm_line".
750 Each element is a tuple of source line specs (field names line, file,
751 fullname), and field "line_asm_insn" which contains the disassembly.
752 Field "line_asm_insn" is a list of tuples: address, func-name, offset,
753 opcodes, inst.
755 CLI output works on top of this because MI ignores ui_out_text output,
756 which is where we put file name and source line contents output.
758 Emitter usage:
759 asm_insns_emitter
760 Handles the outer "asm_insns" list.
761 tuple_emitter
762 The tuples for each group of consecutive disassemblies.
763 list_emitter
764 List of consecutive source lines or disassembled insns. */
766 if (flags & DISASSEMBLY_FILENAME)
767 psl_flags |= PRINT_SOURCE_LINES_FILENAME;
769 ui_out_emit_list asm_insns_emitter (uiout, "asm_insns");
771 std::optional<ui_out_emit_tuple> tuple_emitter;
772 std::optional<ui_out_emit_list> list_emitter;
774 last_symtab = NULL;
775 last_line = 0;
776 pc = low;
778 while (pc < high)
780 struct symtab_and_line sal;
781 CORE_ADDR end_pc;
782 int start_preceding_line_to_display = 0;
783 int end_preceding_line_to_display = 0;
784 int new_source_line = 0;
786 sal = find_pc_line (pc, 0);
788 if (sal.symtab != last_symtab)
790 /* New source file. */
791 new_source_line = 1;
793 /* If this is the first line of output, check for any preceding
794 lines. */
795 if (last_line == 0
796 && first_le != NULL
797 && first_le->line < sal.line)
799 start_preceding_line_to_display = first_le->line;
800 end_preceding_line_to_display = sal.line;
803 else
805 /* Same source file as last time. */
806 if (sal.symtab != NULL)
808 if (sal.line > last_line + 1 && last_line != 0)
810 int l;
812 /* Several preceding source lines. Print the trailing ones
813 not associated with code that we'll print later. */
814 for (l = sal.line - 1; l > last_line; --l)
815 if (dis_line_table.contains ({sal.symtab, l}))
816 break;
818 if (l < sal.line - 1)
820 start_preceding_line_to_display = l + 1;
821 end_preceding_line_to_display = sal.line;
824 if (sal.line != last_line)
825 new_source_line = 1;
826 else
828 /* Same source line as last time. This can happen, depending
829 on the debug info. */
834 if (new_source_line)
836 /* Skip the newline if this is the first instruction. */
837 if (pc > low)
838 uiout->text ("\n");
839 if (tuple_emitter.has_value ())
841 gdb_assert (list_emitter.has_value ());
842 list_emitter.reset ();
843 tuple_emitter.reset ();
845 if (sal.symtab != last_symtab
846 && !(flags & DISASSEMBLY_FILENAME))
848 /* Remember MI ignores ui_out_text.
849 We don't have to do anything here for MI because MI
850 output includes the source specs for each line. */
851 if (sal.symtab != NULL)
853 auto filename = symtab_to_filename_for_display (sal.symtab);
854 uiout->message ("%ps",
855 styled_string (file_name_style.style (),
856 filename));
858 else
859 uiout->text ("unknown");
860 uiout->text (":\n");
862 if (start_preceding_line_to_display > 0)
864 /* Several source lines w/o asm instructions associated.
865 We need to preserve the structure of the output, so output
866 a bunch of line tuples with no asm entries. */
867 int l;
869 gdb_assert (sal.symtab != NULL);
870 for (l = start_preceding_line_to_display;
871 l < end_preceding_line_to_display;
872 ++l)
874 ui_out_emit_tuple line_tuple_emitter (uiout,
875 "src_and_asm_line");
876 print_source_lines (sal.symtab, l, l + 1, psl_flags);
877 ui_out_emit_list chain_line_emitter (uiout, "line_asm_insn");
880 tuple_emitter.emplace (uiout, "src_and_asm_line");
881 if (sal.symtab != NULL)
882 print_source_lines (sal.symtab, sal.line, sal.line + 1, psl_flags);
883 else
884 uiout->text (_("--- no source info for this pc ---\n"));
885 list_emitter.emplace (uiout, "line_asm_insn");
887 else
889 /* Here we're appending instructions to an existing line.
890 By construction the very first insn will have a symtab
891 and follow the new_source_line path above. */
892 gdb_assert (tuple_emitter.has_value ());
893 gdb_assert (list_emitter.has_value ());
896 if (sal.end != 0)
897 end_pc = std::min (sal.end, high);
898 else
899 end_pc = pc + 1;
900 num_displayed += dump_insns (gdbarch, uiout, pc, end_pc,
901 how_many, flags, &end_pc);
902 pc = end_pc;
904 if (how_many >= 0 && num_displayed >= how_many)
905 break;
907 last_symtab = sal.symtab;
908 last_line = sal.line;
912 static void
913 do_assembly_only (struct gdbarch *gdbarch, struct ui_out *uiout,
914 CORE_ADDR low, CORE_ADDR high,
915 int how_many, gdb_disassembly_flags flags)
917 ui_out_emit_list list_emitter (uiout, "asm_insns");
919 dump_insns (gdbarch, uiout, low, high, how_many, flags, NULL);
922 /* Combine implicit and user disassembler options and return them
923 in a newly-created string. */
925 static std::string
926 get_all_disassembler_options (struct gdbarch *gdbarch)
928 const char *implicit = gdbarch_disassembler_options_implicit (gdbarch);
929 const char *options = get_disassembler_options (gdbarch);
930 const char *comma = ",";
932 if (implicit == nullptr)
934 implicit = "";
935 comma = "";
938 if (options == nullptr)
940 options = "";
941 comma = "";
944 return string_printf ("%s%s%s", implicit, comma, options);
947 gdb_disassembler::gdb_disassembler (struct gdbarch *gdbarch,
948 struct ui_file *file,
949 read_memory_ftype func)
950 : gdb_printing_disassembler (gdbarch, &m_buffer, func,
951 dis_asm_memory_error, dis_asm_print_address),
952 m_dest (file),
953 m_buffer (!use_ext_lang_for_styling () && use_libopcodes_for_styling ())
954 { /* Nothing. */ }
956 /* See disasm.h. */
958 bool
959 gdb_disassembler::use_ext_lang_for_styling () const
961 /* The use of m_di.created_styled_output here is a bit of a cheat, but
962 it works fine for now.
964 This function is called in situations after m_di has been initialized,
965 but before the instruction has been disassembled.
967 Currently, every target that supports libopcodes styling sets the
968 created_styled_output field in disassemble_init_for_target, which was
969 called as part of the initialization of gdb_printing_disassembler.
971 This means that we are OK to check the created_styled_output field
972 here.
974 If, in the future, there's ever a target that only sets the
975 created_styled_output field during the actual instruction disassembly
976 phase, then we will need to update this code. */
977 return (disassembler_styling
978 && (!m_di.created_styled_output || !use_libopcodes_styling)
979 && use_ext_lang_colorization_p
980 && m_dest->can_emit_style_escape ());
983 /* See disasm.h. */
985 bool
986 gdb_disassembler::use_libopcodes_for_styling () const
988 /* See the comment on the use of m_di.created_styled_output in the
989 gdb_disassembler::use_ext_lang_for_styling function. */
990 return (disassembler_styling
991 && m_di.created_styled_output
992 && use_libopcodes_styling
993 && m_dest->can_emit_style_escape ());
996 /* See disasm.h. */
998 gdb_disassemble_info::gdb_disassemble_info
999 (struct gdbarch *gdbarch,
1000 read_memory_ftype read_memory_func, memory_error_ftype memory_error_func,
1001 print_address_ftype print_address_func, fprintf_ftype fprintf_func,
1002 fprintf_styled_ftype fprintf_styled_func)
1003 : m_gdbarch (gdbarch)
1005 gdb_assert (fprintf_func != nullptr);
1006 gdb_assert (fprintf_styled_func != nullptr);
1007 init_disassemble_info (&m_di, (void *) this, fprintf_func,
1008 fprintf_styled_func);
1009 m_di.flavour = bfd_target_unknown_flavour;
1011 /* The memory_error_func, print_address_func, and read_memory_func are
1012 all initialized to a default (non-nullptr) value by the call to
1013 init_disassemble_info above. If the user is overriding these fields
1014 (by passing non-nullptr values) then do that now, otherwise, leave
1015 these fields as the defaults. */
1016 if (memory_error_func != nullptr)
1017 m_di.memory_error_func = memory_error_func;
1018 if (print_address_func != nullptr)
1019 m_di.print_address_func = print_address_func;
1020 if (read_memory_func != nullptr)
1021 m_di.read_memory_func = read_memory_func;
1023 m_di.arch = gdbarch_bfd_arch_info (gdbarch)->arch;
1024 m_di.mach = gdbarch_bfd_arch_info (gdbarch)->mach;
1025 m_di.endian = gdbarch_byte_order (gdbarch);
1026 m_di.endian_code = gdbarch_byte_order_for_code (gdbarch);
1027 m_di.application_data = this;
1028 m_disassembler_options_holder = get_all_disassembler_options (gdbarch);
1029 if (!m_disassembler_options_holder.empty ())
1030 m_di.disassembler_options = m_disassembler_options_holder.c_str ();
1031 disassemble_init_for_target (&m_di);
1034 /* See disasm.h. */
1036 gdb_disassemble_info::~gdb_disassemble_info ()
1038 disassemble_free_target (&m_di);
1041 /* Wrapper around calling gdbarch_print_insn. This function takes care of
1042 first calling the extension language hooks for print_insn, and, if none
1043 of the extension languages can print this instruction, calls
1044 gdbarch_print_insn to do the work.
1046 GDBARCH is the architecture to disassemble in, VMA is the address of the
1047 instruction being disassembled, and INFO is the libopcodes disassembler
1048 related information. */
1050 static int
1051 gdb_print_insn_1 (struct gdbarch *gdbarch, CORE_ADDR vma,
1052 struct disassemble_info *info)
1054 /* Call into the extension languages to do the disassembly. */
1055 std::optional<int> length = ext_lang_print_insn (gdbarch, vma, info);
1056 if (length.has_value ())
1057 return *length;
1059 /* No extension language wanted to do the disassembly, so do it
1060 manually. */
1061 return gdbarch_print_insn (gdbarch, vma, info);
1064 /* See disasm.h. */
1066 bool gdb_disassembler::use_ext_lang_colorization_p = true;
1068 /* See disasm.h. */
1071 gdb_disassembler::print_insn (CORE_ADDR memaddr,
1072 int *branch_delay_insns)
1074 m_err_memaddr.reset ();
1075 m_buffer.clear ();
1076 this->set_in_comment (false);
1078 int length = gdb_print_insn_1 (arch (), memaddr, &m_di);
1080 /* If we have successfully disassembled an instruction, disassembler
1081 styling using the extension language is on, and libopcodes hasn't
1082 already styled the output for us, and, if the destination can support
1083 styling, then lets call into the extension languages in order to style
1084 this output. */
1085 if (length > 0 && use_ext_lang_for_styling ())
1087 std::optional<std::string> ext_contents;
1088 ext_contents = ext_lang_colorize_disasm (m_buffer.string (), arch ());
1089 if (ext_contents.has_value ())
1090 m_buffer = std::move (*ext_contents);
1091 else
1093 /* The extension language failed to add styling to the
1094 disassembly output. Set the static flag so that next time we
1095 disassemble we don't even bother attempting to use the
1096 extension language for styling. */
1097 use_ext_lang_colorization_p = false;
1099 /* We're about to disassemble this instruction again, reset the
1100 in-comment state. */
1101 this->set_in_comment (false);
1103 /* The instruction we just disassembled, and the extension
1104 languages failed to style, might have otherwise had some
1105 minimal styling applied by GDB. To regain that styling we
1106 need to recreate m_buffer, but this time with styling support.
1108 To do this we perform an in-place new, but this time turn on
1109 the styling support, then we can re-disassembly the
1110 instruction, and gain any minimal styling GDB might add. */
1111 static_assert ((std::is_same<decltype (m_buffer),
1112 string_file>::value));
1113 gdb_assert (!m_buffer.term_out ());
1114 m_buffer.~string_file ();
1115 new (&m_buffer) string_file (use_libopcodes_for_styling ());
1116 length = gdb_print_insn_1 (arch (), memaddr, &m_di);
1117 gdb_assert (length > 0);
1121 /* Push any disassemble output to the real destination stream. We do
1122 this even if the disassembler reported failure (-1) as the
1123 disassembler may have printed something to its output stream. */
1124 gdb_printf (m_dest, "%s", m_buffer.c_str ());
1126 /* If the disassembler failed then report an appropriate error. */
1127 if (length < 0)
1129 if (m_err_memaddr.has_value ())
1130 memory_error (TARGET_XFER_E_IO, *m_err_memaddr);
1131 else
1132 error (_("unknown disassembler error (error = %d)"), length);
1135 if (branch_delay_insns != NULL)
1137 if (m_di.insn_info_valid)
1138 *branch_delay_insns = m_di.branch_delay_insns;
1139 else
1140 *branch_delay_insns = 0;
1142 return length;
1145 void
1146 gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout,
1147 gdb_disassembly_flags flags, int how_many,
1148 CORE_ADDR low, CORE_ADDR high)
1150 struct symtab *symtab;
1151 int nlines = -1;
1153 /* Assume symtab is valid for whole PC range. */
1154 symtab = find_pc_line_symtab (low);
1156 if (symtab != NULL && symtab->linetable () != NULL)
1157 nlines = symtab->linetable ()->nitems;
1159 if (!(flags & (DISASSEMBLY_SOURCE_DEPRECATED | DISASSEMBLY_SOURCE))
1160 || nlines <= 0)
1161 do_assembly_only (gdbarch, uiout, low, high, how_many, flags);
1163 else if (flags & DISASSEMBLY_SOURCE)
1164 do_mixed_source_and_assembly (gdbarch, uiout, symtab, low, high,
1165 how_many, flags);
1167 else if (flags & DISASSEMBLY_SOURCE_DEPRECATED)
1168 do_mixed_source_and_assembly_deprecated (gdbarch, uiout, symtab,
1169 low, high, how_many, flags);
1171 gdb_flush (gdb_stdout);
1174 /* Print the instruction at address MEMADDR in debugged memory,
1175 on STREAM. Returns the length of the instruction, in bytes,
1176 and, if requested, the number of branch delay slot instructions. */
1179 gdb_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
1180 struct ui_file *stream, int *branch_delay_insns)
1183 gdb_disassembler di (gdbarch, stream);
1185 return di.print_insn (memaddr, branch_delay_insns);
1188 /* Return the length in bytes of the instruction at address MEMADDR in
1189 debugged memory. */
1192 gdb_insn_length (struct gdbarch *gdbarch, CORE_ADDR addr)
1194 return gdb_print_insn (gdbarch, addr, &null_stream, NULL);
1197 /* See disasm.h. */
1200 gdb_non_printing_disassembler::null_fprintf_func
1201 (void *stream, const char *format, ...) noexcept
1203 return 0;
1206 /* See disasm.h. */
1209 gdb_non_printing_disassembler::null_fprintf_styled_func
1210 (void *stream, enum disassembler_style style,
1211 const char *format, ...) noexcept
1213 return 0;
1216 /* A non-printing disassemble_info management class. The disassemble_info
1217 setup by this class will not print anything to the output stream (there
1218 is no output stream), and the instruction to be disassembled will be
1219 read from a buffer passed to the constructor. */
1221 struct gdb_non_printing_buffer_disassembler
1222 : public gdb_non_printing_disassembler
1224 /* Constructor. GDBARCH is the architecture to disassemble for, BUFFER
1225 contains the instruction to disassemble, and INSN_ADDRESS is the
1226 address (in target memory) of the instruction to disassemble. */
1227 gdb_non_printing_buffer_disassembler (struct gdbarch *gdbarch,
1228 gdb::array_view<const gdb_byte> buffer,
1229 CORE_ADDR insn_address)
1230 : gdb_non_printing_disassembler (gdbarch, nullptr)
1232 /* The cast is necessary until disassemble_info is const-ified. */
1233 m_di.buffer = (gdb_byte *) buffer.data ();
1234 m_di.buffer_length = buffer.size ();
1235 m_di.buffer_vma = insn_address;
1239 /* Return the length in bytes of INSN. MAX_LEN is the size of the
1240 buffer containing INSN. */
1243 gdb_buffered_insn_length (struct gdbarch *gdbarch,
1244 const gdb_byte *insn, int max_len, CORE_ADDR addr)
1246 gdb::array_view<const gdb_byte> buffer
1247 = gdb::make_array_view (insn, max_len);
1248 gdb_non_printing_buffer_disassembler dis (gdbarch, buffer, addr);
1249 int result = gdb_print_insn_1 (gdbarch, addr, dis.disasm_info ());
1250 return result;
1253 const char *
1254 get_disassembler_options (struct gdbarch *gdbarch)
1256 std::string *disassembler_options = gdbarch_disassembler_options (gdbarch);
1257 if (disassembler_options == nullptr || disassembler_options->empty ())
1258 return nullptr;
1259 return disassembler_options->c_str ();
1262 void
1263 set_disassembler_options (const char *prospective_options)
1265 struct gdbarch *gdbarch = get_current_arch ();
1266 std::string *disassembler_options = gdbarch_disassembler_options (gdbarch);
1267 const disasm_options_and_args_t *valid_options_and_args;
1268 const disasm_options_t *valid_options;
1269 gdb::unique_xmalloc_ptr<char> prospective_options_local
1270 = make_unique_xstrdup (prospective_options);
1271 char *options = remove_whitespace_and_extra_commas
1272 (prospective_options_local.get ());
1273 const char *opt;
1275 /* Allow all architectures, even ones that do not support 'set disassembler',
1276 to reset their disassembler options to NULL. */
1277 if (options == NULL)
1279 if (disassembler_options != nullptr)
1280 disassembler_options->clear ();
1281 return;
1284 valid_options_and_args = gdbarch_valid_disassembler_options (gdbarch);
1285 if (valid_options_and_args == NULL)
1287 gdb_printf (gdb_stderr, _("\
1288 'set disassembler-options ...' is not supported on this architecture.\n"));
1289 return;
1292 valid_options = &valid_options_and_args->options;
1294 /* Verify we have valid disassembler options. */
1295 FOR_EACH_DISASSEMBLER_OPTION (opt, options)
1297 size_t i;
1298 for (i = 0; valid_options->name[i] != NULL; i++)
1299 if (valid_options->arg != NULL && valid_options->arg[i] != NULL)
1301 size_t len = strlen (valid_options->name[i]);
1302 bool found = false;
1303 const char *arg;
1304 size_t j;
1306 if (memcmp (opt, valid_options->name[i], len) != 0)
1307 continue;
1308 arg = opt + len;
1309 if (valid_options->arg[i]->values == NULL)
1310 break;
1311 for (j = 0; valid_options->arg[i]->values[j] != NULL; j++)
1312 if (disassembler_options_cmp
1313 (arg, valid_options->arg[i]->values[j]) == 0)
1315 found = true;
1316 break;
1318 if (found)
1319 break;
1321 else if (disassembler_options_cmp (opt, valid_options->name[i]) == 0)
1322 break;
1323 if (valid_options->name[i] == NULL)
1325 gdb_printf (gdb_stderr,
1326 _("Invalid disassembler option value: '%s'.\n"),
1327 opt);
1328 return;
1332 *disassembler_options = options;
1335 static void
1336 set_disassembler_options_sfunc (const char *args, int from_tty,
1337 struct cmd_list_element *c)
1339 set_disassembler_options (prospective_options.c_str ());
1342 static void
1343 show_disassembler_options_sfunc (struct ui_file *file, int from_tty,
1344 struct cmd_list_element *c, const char *value)
1346 struct gdbarch *gdbarch = get_current_arch ();
1347 const disasm_options_and_args_t *valid_options_and_args;
1348 const disasm_option_arg_t *valid_args;
1349 const disasm_options_t *valid_options;
1351 const char *options = get_disassembler_options (gdbarch);
1352 if (options == NULL)
1353 options = "";
1355 gdb_printf (file, _("The current disassembler options are '%s'\n\n"),
1356 options);
1358 valid_options_and_args = gdbarch_valid_disassembler_options (gdbarch);
1360 if (valid_options_and_args == NULL)
1362 gdb_puts (_("There are no disassembler options available "
1363 "for this architecture.\n"),
1364 file);
1365 return;
1368 valid_options = &valid_options_and_args->options;
1370 gdb_printf (file, _("\
1371 The following disassembler options are supported for use with the\n\
1372 'set disassembler-options OPTION [,OPTION]...' command:\n"));
1374 if (valid_options->description != NULL)
1376 size_t i, max_len = 0;
1378 gdb_printf (file, "\n");
1380 /* Compute the length of the longest option name. */
1381 for (i = 0; valid_options->name[i] != NULL; i++)
1383 size_t len = strlen (valid_options->name[i]);
1385 if (valid_options->arg != NULL && valid_options->arg[i] != NULL)
1386 len += strlen (valid_options->arg[i]->name);
1387 if (max_len < len)
1388 max_len = len;
1391 for (i = 0, max_len++; valid_options->name[i] != NULL; i++)
1393 gdb_printf (file, " %s", valid_options->name[i]);
1394 if (valid_options->arg != NULL && valid_options->arg[i] != NULL)
1395 gdb_printf (file, "%s", valid_options->arg[i]->name);
1396 if (valid_options->description[i] != NULL)
1398 size_t len = strlen (valid_options->name[i]);
1400 if (valid_options->arg != NULL && valid_options->arg[i] != NULL)
1401 len += strlen (valid_options->arg[i]->name);
1402 gdb_printf (file, "%*c %s", (int) (max_len - len), ' ',
1403 valid_options->description[i]);
1405 gdb_printf (file, "\n");
1408 else
1410 size_t i;
1411 gdb_printf (file, " ");
1412 for (i = 0; valid_options->name[i] != NULL; i++)
1414 gdb_printf (file, "%s", valid_options->name[i]);
1415 if (valid_options->arg != NULL && valid_options->arg[i] != NULL)
1416 gdb_printf (file, "%s", valid_options->arg[i]->name);
1417 if (valid_options->name[i + 1] != NULL)
1418 gdb_printf (file, ", ");
1419 file->wrap_here (2);
1421 gdb_printf (file, "\n");
1424 valid_args = valid_options_and_args->args;
1425 if (valid_args != NULL)
1427 size_t i, j;
1429 for (i = 0; valid_args[i].name != NULL; i++)
1431 if (valid_args[i].values == NULL)
1432 continue;
1433 gdb_printf (file, _("\n\
1434 For the options above, the following values are supported for \"%s\":\n "),
1435 valid_args[i].name);
1436 for (j = 0; valid_args[i].values[j] != NULL; j++)
1438 gdb_printf (file, " %s", valid_args[i].values[j]);
1439 file->wrap_here (3);
1441 gdb_printf (file, "\n");
1446 /* A completion function for "set disassembler". */
1448 static void
1449 disassembler_options_completer (struct cmd_list_element *ignore,
1450 completion_tracker &tracker,
1451 const char *text, const char *word)
1453 struct gdbarch *gdbarch = get_current_arch ();
1454 const disasm_options_and_args_t *opts_and_args
1455 = gdbarch_valid_disassembler_options (gdbarch);
1457 if (opts_and_args != NULL)
1459 const disasm_options_t *opts = &opts_and_args->options;
1461 /* Only attempt to complete on the last option text. */
1462 const char *separator = strrchr (text, ',');
1463 if (separator != NULL)
1464 text = separator + 1;
1465 text = skip_spaces (text);
1466 complete_on_enum (tracker, opts->name, text, word);
1471 /* Initialization code. */
1473 void _initialize_disasm ();
1474 void
1475 _initialize_disasm ()
1477 /* Add the command that controls the disassembler options. */
1478 set_show_commands set_show_disas_opts
1479 = add_setshow_string_noescape_cmd ("disassembler-options", no_class,
1480 &prospective_options, _("\
1481 Set the disassembler options.\n\
1482 Usage: set disassembler-options OPTION [,OPTION]...\n\n\
1483 See: 'show disassembler-options' for valid option values."), _("\
1484 Show the disassembler options."), NULL,
1485 set_disassembler_options_sfunc,
1486 show_disassembler_options_sfunc,
1487 &setlist, &showlist);
1488 set_cmd_completer (set_show_disas_opts.set, disassembler_options_completer);
1491 /* All the 'maint set|show libopcodes-styling' sub-commands. */
1492 static struct cmd_list_element *maint_set_libopcodes_styling_cmdlist;
1493 static struct cmd_list_element *maint_show_libopcodes_styling_cmdlist;
1495 /* Adds 'maint set|show libopcodes-styling'. */
1496 add_setshow_prefix_cmd ("libopcodes-styling", class_maintenance,
1497 _("Set libopcodes-styling specific variables."),
1498 _("Show libopcodes-styling specific variables."),
1499 &maint_set_libopcodes_styling_cmdlist,
1500 &maint_show_libopcodes_styling_cmdlist,
1501 &maintenance_set_cmdlist,
1502 &maintenance_show_cmdlist);
1504 /* Adds 'maint set|show gnu-source-highlight enabled'. */
1505 add_setshow_boolean_cmd ("enabled", class_maintenance,
1506 &use_libopcodes_styling_option, _("\
1507 Set whether the libopcodes styling support should be used."), _("\
1508 Show whether the libopcodes styling support should be used."),_("\
1509 When enabled, GDB will try to make use of the builtin libopcodes styling\n\
1510 support, to style the disassembler output. Not every architecture has\n\
1511 styling support within libopcodes, so enabling this is not a guarantee\n\
1512 that libopcodes styling will be available.\n\
1514 When this option is disabled, GDB will make use of the Python Pygments\n\
1515 package (if available) to style the disassembler output.\n\
1517 All disassembler styling can be disabled with:\n\
1519 set style disassembler enabled off"),
1520 set_use_libopcodes_styling,
1521 show_use_libopcodes_styling,
1522 &maint_set_libopcodes_styling_cmdlist,
1523 &maint_show_libopcodes_styling_cmdlist);