Default to enabling colored disassembly if output is to a terminal.
PR 29457 * objdump.c (disassembler_color): Change type to an enum. (disassembler_extended_color): Remove. (usage): Update. (objdump_color_for_assembler_style): Update. (main): Update initialisation of disassembler_color. If not initialised via a command line option, set based upon terminal output. * doc/binutils.texi: Update description of disassmbler-color option. * testsuite/binutils-all/arc/objdump.exp: Add --disassembler-color=off option when disassembling. * testsuite/binutils-all/arm/objdump.exp: Likewise.
This commit is contained in:
parent
80d3624849
commit
a88c79b770
5 changed files with 71 additions and 19 deletions
|
@ -1,3 +1,19 @@
|
||||||
|
2022-08-09 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
|
PR 29457
|
||||||
|
* objdump.c (disassembler_color): Change type to an enum.
|
||||||
|
(disassembler_extended_color): Remove.
|
||||||
|
(usage): Update.
|
||||||
|
(objdump_color_for_assembler_style): Update.
|
||||||
|
(main): Update initialisation of disassembler_color. If not
|
||||||
|
initialised via a command line option, set based upon terminal
|
||||||
|
output.
|
||||||
|
* doc/binutils.texi: Update description of disassmbler-color
|
||||||
|
option.
|
||||||
|
* testsuite/binutils-all/arc/objdump.exp: Add
|
||||||
|
--disassembler-color=off option when disassembling.
|
||||||
|
* testsuite/binutils-all/arm/objdump.exp: Likewise.
|
||||||
|
|
||||||
2022-08-08 Nick Clifton <nickc@redhat.com>
|
2022-08-08 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
* README-how-to-make-a-release: Add a link to the NEWS files in
|
* README-how-to-make-a-release: Add a link to the NEWS files in
|
||||||
|
|
|
@ -2828,6 +2828,9 @@ If it is necessary to disable the @option{--disassembler-color} option
|
||||||
after it has previously been enabled then use
|
after it has previously been enabled then use
|
||||||
@option{--disassembler-color=off}.
|
@option{--disassembler-color=off}.
|
||||||
|
|
||||||
|
If this option is not specified then the default is to enable color
|
||||||
|
output if displaying to a terminal, but not otherwise.
|
||||||
|
|
||||||
@item -W[lLiaprmfFsoORtUuTgAckK]
|
@item -W[lLiaprmfFsoORtUuTgAckK]
|
||||||
@itemx --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=str-offsets,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow-links]
|
@itemx --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=str-offsets,=loc,=Ranges,=pubtypes,=trace_info,=trace_abbrev,=trace_aranges,=gdb_index,=addr,=cu_index,=links,=follow-links]
|
||||||
@include debug.options.texi
|
@include debug.options.texi
|
||||||
|
|
|
@ -130,8 +130,14 @@ static bool visualize_jumps = false; /* --visualize-jumps. */
|
||||||
static bool color_output = false; /* --visualize-jumps=color. */
|
static bool color_output = false; /* --visualize-jumps=color. */
|
||||||
static bool extended_color_output = false; /* --visualize-jumps=extended-color. */
|
static bool extended_color_output = false; /* --visualize-jumps=extended-color. */
|
||||||
static int process_links = false; /* --process-links. */
|
static int process_links = false; /* --process-links. */
|
||||||
static bool disassembler_color = false; /* --disassembler-color=color. */
|
|
||||||
static bool disassembler_extended_color = false; /* --disassembler-color=extended-color. */
|
static enum color_selection
|
||||||
|
{
|
||||||
|
on_if_terminal_output,
|
||||||
|
on, /* --disassembler-color=color. */
|
||||||
|
off, /* --disassembler-color=off. */
|
||||||
|
extended /* --disassembler-color=extended-color. */
|
||||||
|
} disassembler_color = on_if_terminal_output;
|
||||||
|
|
||||||
static int dump_any_debugging;
|
static int dump_any_debugging;
|
||||||
static int demangle_flags = DMGL_ANSI | DMGL_PARAMS;
|
static int demangle_flags = DMGL_ANSI | DMGL_PARAMS;
|
||||||
|
@ -409,6 +415,8 @@ usage (FILE *stream, int status)
|
||||||
--disassembler-color=off Disable disassembler color output.\n\n"));
|
--disassembler-color=off Disable disassembler color output.\n\n"));
|
||||||
fprintf (stream, _("\
|
fprintf (stream, _("\
|
||||||
--disassembler-color=color Use basic colors in disassembler output.\n\n"));
|
--disassembler-color=color Use basic colors in disassembler output.\n\n"));
|
||||||
|
fprintf (stream, _("\
|
||||||
|
--disassembler-color=extended-color Use 8-bit colors in disassembler output.\n\n"));
|
||||||
|
|
||||||
list_supported_targets (program_name, stream);
|
list_supported_targets (program_name, stream);
|
||||||
list_supported_architectures (program_name, stream);
|
list_supported_architectures (program_name, stream);
|
||||||
|
@ -2158,44 +2166,66 @@ objdump_color_for_disassembler_style (enum disassembler_style style)
|
||||||
if (style == dis_style_comment_start)
|
if (style == dis_style_comment_start)
|
||||||
disassembler_in_comment = true;
|
disassembler_in_comment = true;
|
||||||
|
|
||||||
if (disassembler_color)
|
if (disassembler_color == on)
|
||||||
{
|
{
|
||||||
if (disassembler_in_comment)
|
if (disassembler_in_comment)
|
||||||
return color;
|
return color;
|
||||||
|
|
||||||
switch (style)
|
switch (style)
|
||||||
{
|
{
|
||||||
case dis_style_symbol: color = 32; break;
|
case dis_style_symbol:
|
||||||
|
color = 32;
|
||||||
|
break;
|
||||||
case dis_style_assembler_directive:
|
case dis_style_assembler_directive:
|
||||||
case dis_style_sub_mnemonic:
|
case dis_style_sub_mnemonic:
|
||||||
case dis_style_mnemonic: color = 33; break;
|
case dis_style_mnemonic:
|
||||||
case dis_style_register: color = 34; break;
|
color = 33;
|
||||||
|
break;
|
||||||
|
case dis_style_register:
|
||||||
|
color = 34;
|
||||||
|
break;
|
||||||
case dis_style_address:
|
case dis_style_address:
|
||||||
case dis_style_address_offset:
|
case dis_style_address_offset:
|
||||||
case dis_style_immediate: color = 35; break;
|
case dis_style_immediate:
|
||||||
|
color = 35;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
case dis_style_text: color = -1; break;
|
case dis_style_text:
|
||||||
|
color = -1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (disassembler_extended_color)
|
else if (disassembler_color == extended)
|
||||||
{
|
{
|
||||||
if (disassembler_in_comment)
|
if (disassembler_in_comment)
|
||||||
return 250;
|
return 250;
|
||||||
|
|
||||||
switch (style)
|
switch (style)
|
||||||
{
|
{
|
||||||
case dis_style_symbol: color = 40; break;
|
case dis_style_symbol:
|
||||||
|
color = 40;
|
||||||
|
break;
|
||||||
case dis_style_assembler_directive:
|
case dis_style_assembler_directive:
|
||||||
case dis_style_sub_mnemonic:
|
case dis_style_sub_mnemonic:
|
||||||
case dis_style_mnemonic: color = 142; break;
|
case dis_style_mnemonic:
|
||||||
case dis_style_register: color = 27; break;
|
color = 142;
|
||||||
|
break;
|
||||||
|
case dis_style_register:
|
||||||
|
color = 27;
|
||||||
|
break;
|
||||||
case dis_style_address:
|
case dis_style_address:
|
||||||
case dis_style_address_offset:
|
case dis_style_address_offset:
|
||||||
case dis_style_immediate: color = 134; break;
|
case dis_style_immediate:
|
||||||
|
color = 134;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
case dis_style_text: color = -1; break;
|
case dis_style_text:
|
||||||
|
color = -1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (disassembler_color != off)
|
||||||
|
bfd_fatal (_("disassembly color not correctly selected"));
|
||||||
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
@ -5683,11 +5713,11 @@ main (int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
case OPTION_DISASSEMBLER_COLOR:
|
case OPTION_DISASSEMBLER_COLOR:
|
||||||
if (streq (optarg, "off"))
|
if (streq (optarg, "off"))
|
||||||
disassembler_color = false;
|
disassembler_color = off;
|
||||||
else if (streq (optarg, "color"))
|
else if (streq (optarg, "color"))
|
||||||
disassembler_color = true;
|
disassembler_color = on;
|
||||||
else if (streq (optarg, "extended-color"))
|
else if (streq (optarg, "extended-color"))
|
||||||
disassembler_extended_color = true;
|
disassembler_color = extended;
|
||||||
else
|
else
|
||||||
nonfatal (_("unrecognized argument to --disassembler-color"));
|
nonfatal (_("unrecognized argument to --disassembler-color"));
|
||||||
break;
|
break;
|
||||||
|
@ -5900,6 +5930,9 @@ main (int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (disassembler_color == on_if_terminal_output)
|
||||||
|
disassembler_color = isatty (1) ? on : off;
|
||||||
|
|
||||||
if (show_version)
|
if (show_version)
|
||||||
print_version ("objdump");
|
print_version ("objdump");
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ proc check_assembly { testname objfile expected { disas_flags "" } } {
|
||||||
fail $testname
|
fail $testname
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble $disas_flags \
|
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble --disassembler-color=off $disas_flags \
|
||||||
$objfile"]
|
$objfile"]
|
||||||
|
|
||||||
if [regexp $expected $got] then {
|
if [regexp $expected $got] then {
|
||||||
|
|
|
@ -41,7 +41,7 @@ if {![binutils_assemble $srcdir/$subdir/thumb2-cond.s tmpdir/thumb2-cond.o]} the
|
||||||
|
|
||||||
# Make sure that conditional instructions are correctly decoded.
|
# Make sure that conditional instructions are correctly decoded.
|
||||||
|
|
||||||
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble --start-address=6 $objfile"]
|
set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble --disassembler-color=off --start-address=6 $objfile"]
|
||||||
|
|
||||||
set want "bcc.w\[ \t\]*e12.*bx\[ \t\]*lr"
|
set want "bcc.w\[ \t\]*e12.*bx\[ \t\]*lr"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue