+2022-10-31 Nick Clifton <nickc@redhat.com>
+
+ PR 29457
+ * configure.ac: Add --enable-colored-disassembly.
+ * objdump.c: Add --disassembler-color=terminal.
+ * doc/binutils.texi (objdump): Document the new option.
+ * NEWS: Mention new feature.
+ * config.in: Regenerate in.
+ * configure: Regenerate.
+
2022-10-19 Nick Clifton <nickc@redhat.com>
* MAINTAINERS: Add section on patches, copyright and DCO.
-*- text -*-
+* Add --enable-colored-disassembly configure time option to enable colored
+ disassembly output by default, if the output device is a terminal. Note,
+ this configure option is disabled by default.
+
* DCO signed contributions are now accepted.
* objcopy --decompress-debug-sections now supports zstd compressed debug
/* Should ar and ranlib use -D behavior by default? */
#undef DEFAULT_AR_DETERMINISTIC
+/* Have objdump use colors in its disassembly by default */
+#undef DEFAULT_FOR_COLORED_DISASSEMBLY
+
/* Have readelf and objdump follow debug links by default */
#undef DEFAULT_FOR_FOLLOW_LINKS
enable_default_strings_all
enable_f_for_ifunc_symbols
enable_follow_debug_links
+enable_colored_disassembly
with_debuginfod
enable_libctf
enable_werror
--enable-follow-debug-links
Have readelf and objdump follow debug links by
default
+ --enable-colored-disassembly
+ Have objdump use colors in its disassembly by
+ default
--enable-libctf Handle .ctf type-info sections [default=yes]
--enable-werror treat compile warnings as errors
--enable-build-warnings enable build-time compiler warnings
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10816 "configure"
+#line 10820 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10922 "configure"
+#line 10926 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
+# Check whether --enable-colored-disassembly was given.
+if test "${enable_colored_disassembly+set}" = set; then :
+ enableval=$enable_colored_disassembly;
+if test "${enableval}" = no; then
+ default_for_colored_disassembly=0
+else
+ default_for_colored_disassembly=1
+fi
+else
+ default_for_colored_disassembly=0
+fi
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_FOR_COLORED_DISASSEMBLY $default_for_colored_disassembly
+_ACEOF
+
+
+
+
+
[Have readelf and objdump follow debug links by default])
+
+
+AC_ARG_ENABLE(colored-disassembly,
+[AS_HELP_STRING([--enable-colored-disassembly],
+ [Have objdump use colors in its disassembly by default])], [
+if test "${enableval}" = no; then
+ default_for_colored_disassembly=0
+else
+ default_for_colored_disassembly=1
+fi], [default_for_colored_disassembly=0])
+
+AC_DEFINE_UNQUOTED(DEFAULT_FOR_COLORED_DISASSEMBLY, $default_for_colored_disassembly,
+ [Have objdump use colors in its disassembly by default])
+
+
AC_DEBUGINFOD
GCC_ENABLE([libctf], [yes], [], [Handle .ctf type-info sections])
[@option{--prefix-strip=}@var{level}]
[@option{--insn-width=}@var{width}]
[@option{--visualize-jumps[=color|=extended-color|=off]}
- [@option{--disassembler-color=[color|extended-color|off]}
+ [@option{--disassembler-color=[off|terminal|on|extended]}
[@option{-U} @var{method}] [@option{--unicode=}@var{method}]
[@option{-V}|@option{--version}]
[@option{-H}|@option{--help}]
after it has previously been enabled then use
@option{visualize-jumps=off}.
-@item --disassembler-color=[color|extended-color|off]
-Apply syntax highlighting to the disassembler output. The
-@option{color} argument adds color using simple terminal colors.
-Alternatively the @option{extended-color} argument will use 8bit
-colors, but these might not work on all terminals.
+@item --disassembler-color=off
+@itemx --disassembler-color=terminal
+@itemx --disassembler-color=on|color|colour
+@itemx --disassembler-color=extened|extended-color|extened-colour
+Enables or disables the use of colored syntax highlighting in
+disassembly output. The default behaviour is determined via a
+configure time option. Note, not all architectures support colored
+syntax highlighting, and depending upon the terminal used, colored
+output may not actually be legible.
-If it is necessary to disable the @option{--disassembler-color} option
-after it has previously been enabled then use
-@option{--disassembler-color=off}.
+The @option{on} argument adds colors using simple terminal colors.
+
+The @option{terminal} argument does the same, but only if the output
+device is a terminal.
+
+The @option{extended-color} argument is similar to the @option{on}
+argument, but it uses 8-bit colors. These may not work on all
+terminals.
-If this option is not specified then the default is to enable color
-output if displaying to a terminal, but not otherwise.
+The @option{off} argument disables colored disassembly.
@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]
on, /* --disassembler-color=color. */
off, /* --disassembler-color=off. */
extended /* --disassembler-color=extended-color. */
- } disassembler_color = on_if_terminal_output;
+ } disassembler_color =
+#if DEFAULT_FOR_COLORED_DISASSEMBLY
+ on_if_terminal_output;
+#else
+ off;
+#endif
static int dump_any_debugging;
static int demangle_flags = DMGL_ANSI | DMGL_PARAMS;
--visualize-jumps=extended-color\n\
Use extended 8-bit color codes\n"));
fprintf (stream, _("\
- --visualize-jumps=off Disable jump visualization\n\n"));
+ --visualize-jumps=off Disable jump visualization\n"));
+#if DEFAULT_FOR_COLORED_DISASSEMBLY
fprintf (stream, _("\
- --disassembler-color=off Disable disassembler color output.\n\n"));
+ --disassembler-color=off Disable disassembler color output.\n"));
+ fprintf (stream, _("\
+ --disassembler-color=terminal Enable disassembler color output if displaying on a terminal. (default)\n"));
+#else
+ fprintf (stream, _("\
+ --disassembler-color=off Disable disassembler color output. (default)\n"));
+ fprintf (stream, _("\
+ --disassembler-color=terminal Enable disassembler color output if displaying on a terminal.\n"));
+#endif
fprintf (stream, _("\
- --disassembler-color=color Use basic colors in disassembler output.\n\n"));
+ --disassembler-color=on Enable disassembler color output.\n"));
fprintf (stream, _("\
- --disassembler-color=extended-color Use 8-bit colors in disassembler output.\n\n"));
+ --disassembler-color=extended Use 8-bit colors in disassembler output.\n\n"));
list_supported_targets (program_name, stream);
list_supported_architectures (program_name, stream);
case OPTION_DISASSEMBLER_COLOR:
if (streq (optarg, "off"))
disassembler_color = off;
- else if (streq (optarg, "color"))
+ else if (streq (optarg, "terminal"))
+ disassembler_color = on_if_terminal_output;
+ else if (streq (optarg, "color")
+ || streq (optarg, "colour")
+ || streq (optarg, "on"))
disassembler_color = on;
- else if (streq (optarg, "extended-color"))
+ else if (streq (optarg, "extended")
+ || streq (optarg, "extended-color")
+ || streq (optarg, "extended-colour"))
disassembler_color = extended;
else
nonfatal (_("unrecognized argument to --disassembler-color"));