summaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorThomas Troeger <tstroege@gmx.de>2020-02-06 13:17:19 +0000
committerNick Clifton <nickc@redhat.com>2020-02-06 13:17:19 +0000
commitece128295ef0054aad15501395bbd254c263dc56 (patch)
tree18b2d05fe7a93b23dcb7001a33d1f5946a015ffc /binutils
parent986ac31487544ed7553e74f4570f6de83fba1c8d (diff)
downloadbinutils-gdb-ece128295ef0054aad15501395bbd254c263dc56.tar.gz
Jump visualization: Handle the case where the disassembled bytes occupy two lines.
* objdump.c (print_jump_visualisation): New function. (disassemble_bytes): Call new function.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog5
-rw-r--r--binutils/objdump.c85
2 files changed, 53 insertions, 37 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 7dc97dbd85c..2f383eb6bd6 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,8 @@
+2020-02-06 Thomas Troeger <tstroege@gmx.de>
+
+ * objdump.c (print_jump_visualisation): New function.
+ (disassemble_bytes): Call new function.
+
2020-02-06 Alan Modra <amodra@gmail.com>
* testsuite/lib/binutils-common.exp (match_target): Accept '!' before
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 17c0637b350..8182dcc3623 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -2474,6 +2474,47 @@ null_print (const void * stream ATTRIBUTE_UNUSED, const char * format ATTRIBUTE_
return 1;
}
+/* Print out jump visualization. */
+
+static void
+print_jump_visualisation (bfd_vma addr, int max_level, char *line_buffer,
+ uint8_t *color_buffer)
+{
+ if (!line_buffer)
+ return;
+
+ jump_info_visualize_address (addr, max_level, line_buffer, color_buffer);
+
+ size_t line_buffer_size = strlen (line_buffer);
+ char last_color = 0;
+ size_t i;
+
+ for (i = 0; i <= line_buffer_size; ++i)
+ {
+ if (color_output)
+ {
+ uint8_t color = (i < line_buffer_size) ? color_buffer[i]: 0;
+
+ if (color != last_color)
+ {
+ if (color)
+ if (extended_color_output)
+ /* Use extended 8bit color, but
+ do not choose dark colors. */
+ printf ("\033[38;5;%dm", 124 + (color % 108));
+ else
+ /* Use simple terminal colors. */
+ printf ("\033[%dm", 31 + (color % 7));
+ else
+ /* Clear color. */
+ printf ("\033[0m");
+ last_color = color;
+ }
+ }
+ putchar ((i < line_buffer_size) ? line_buffer[i]: ' ');
+ }
+}
+
/* Disassemble some data in memory between given values. */
static void
@@ -2632,43 +2673,9 @@ disassemble_bytes (struct disassemble_info * inf,
putchar (' ');
}
- /* Visualize jumps. */
- if (line_buffer)
- {
- jump_info_visualize_address (section->vma + addr_offset,
- max_level,
- line_buffer,
- color_buffer);
-
- size_t line_buffer_size = strlen (line_buffer);
- char last_color = 0;
- size_t i;
-
- for (i = 0; i <= line_buffer_size; ++i)
- {
- if (color_output)
- {
- uint8_t color = (i < line_buffer_size) ? color_buffer[i]: 0;
-
- if (color != last_color)
- {
- if (color)
- if (extended_color_output)
- /* Use extended 8bit color, but
- do not choose dark colors. */
- printf ("\033[38;5;%dm", 124 + (color % 108));
- else
- /* Use simple terminal colors. */
- printf ("\033[%dm", 31 + (color % 7));
- else
- /* Clear color. */
- printf ("\033[0m");
- last_color = color;
- }
- }
- putchar ((i < line_buffer_size) ? line_buffer[i]: ' ');
- }
- }
+ print_jump_visualisation (section->vma + addr_offset,
+ max_level, line_buffer,
+ color_buffer);
if (insns)
{
@@ -2860,6 +2867,10 @@ disassemble_bytes (struct disassemble_info * inf,
*--s = '0';
printf ("%s:\t", buf + skip_addr_chars);
+ print_jump_visualisation (section->vma + j / opb,
+ max_level, line_buffer,
+ color_buffer);
+
pb += octets_per_line;
if (pb > octets)
pb = octets;