aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2016-06-24 10:50:25 +0930
committerAlan Modra <amodra@gmail.com>2016-06-24 23:05:48 +0930
commit43339b1d1cac16ee3e3b556ff5ab3f031d03b5eb (patch)
treecda3d530cec9a928e7de5270487cf72826f8465c /binutils
parentda4463c7d74ca0314fcab31f4a98dca3fd98e250 (diff)
downloadgdb-43339b1d1cac16ee3e3b556ff5ab3f031d03b5eb.zip
gdb-43339b1d1cac16ee3e3b556ff5ab3f031d03b5eb.tar.gz
gdb-43339b1d1cac16ee3e3b556ff5ab3f031d03b5eb.tar.bz2
Limit objdump -S context lines
Showing context lines is confusing in many cases, an obvious example being loops. * objdump.c (struct print_file_list): Add "max_printed". (try_print_file_open): Init new field. (show_line): Don't show 5 context lines when redisplaying source.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog6
-rw-r--r--binutils/objdump.c13
2 files changed, 17 insertions, 2 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 201b466..757aa98 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,9 @@
+2016-06-24 Alan Modra <amodra@gmail.com>
+
+ * objdump.c (struct print_file_list): Add "max_printed".
+ (try_print_file_open): Init new field.
+ (show_line): Don't show 5 context lines when redisplaying source.
+
2016-06-22 Nick Clifton <nickc@redhat.com>
* testsuite/binutils-all/ar.exp: Skip tests for Alpha target.
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 5b84801..174596e 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -1135,6 +1135,7 @@ struct print_file_list
const char **linemap;
unsigned maxline;
unsigned last_line;
+ unsigned max_printed;
int first;
};
@@ -1260,6 +1261,7 @@ try_print_file_open (const char *origname, const char *modname)
p->linemap = index_file (p->map, p->mapsize, &p->maxline);
p->last_line = 0;
+ p->max_printed = 0;
p->filename = origname;
p->modname = modname;
p->next = print_files;
@@ -1447,10 +1449,17 @@ show_line (bfd *abfd, asection *section, bfd_vma addr_offset)
l = linenumber - SHOW_PRECEDING_CONTEXT_LINES;
if (l >= linenumber)
l = 1;
- if (p->last_line >= l && p->last_line <= linenumber)
- l = p->last_line + 1;
+ if (p->max_printed >= l)
+ {
+ if (p->max_printed < linenumber)
+ l = p->max_printed + 1;
+ else
+ l = linenumber;
+ }
}
dump_lines (p, l, linenumber);
+ if (p->max_printed < linenumber)
+ p->max_printed = linenumber;
p->last_line = linenumber;
p->first = 0;
}