PR21978, objdump does not display line numbers in certain cases
authorAlan Modra <amodra@gmail.com>
Fri, 29 Sep 2017 22:50:08 +0000 (08:20 +0930)
committerAlan Modra <amodra@gmail.com>
Sat, 30 Sep 2017 02:31:43 +0000 (12:01 +0930)
Same line but different file ought to display file and line.

PR 21978
* objdump.c: Formatting.
(show_line): Reset prev_line when function name changes.

binutils/ChangeLog
binutils/objdump.c

index 333ad86a62a6b290cd11899aba9d8234904e5037..d9f08991f900e9913560f54ab7fb079e1abc4be1 100644 (file)
@@ -1,3 +1,9 @@
+2017-09-30  Alan Modra  <amodra@gmail.com>
+
+       PR 21978
+       * objdump.c: Formatting.
+       (show_line): Reset prev_line when function name changes.
+
 2017-09-27  Nick Clifton  <nickc@redhat.com>
 
        PR 22219
index 3c5defabf743c8912be2ce34d1aef675a9980f6d..3b2c7a38788b66f58965b2b8cf45657f4b8f7d8e 100644 (file)
@@ -1484,8 +1484,8 @@ show_line (bfd *abfd, asection *section, bfd_vma addr_offset)
     return;
 
   if (! bfd_find_nearest_line_discriminator (abfd, section, syms, addr_offset,
-                                             &filename, &functionname,
-                                             &linenumber, &discriminator))
+                                            &filename, &functionname,
+                                            &linenumber, &discriminator))
     return;
 
   if (filename != NULL && *filename == '\0')
@@ -1537,16 +1537,22 @@ show_line (bfd *abfd, asection *section, bfd_vma addr_offset)
       if (functionname != NULL
          && (prev_functionname == NULL
              || strcmp (functionname, prev_functionname) != 0))
-       printf ("%s():\n", functionname);
-      if (linenumber > 0 && (linenumber != prev_line ||
-                             (discriminator != prev_discriminator)))
-        {
-          if (discriminator > 0)
-            printf ("%s:%u (discriminator %u)\n", filename == NULL ? "???" : filename,
-                    linenumber, discriminator);
-          else
-            printf ("%s:%u\n", filename == NULL ? "???" : filename, linenumber);
-        }
+       {
+         printf ("%s():\n", functionname);
+         prev_line = -1;
+       }
+      if (linenumber > 0
+         && (linenumber != prev_line
+             || discriminator != prev_discriminator))
+       {
+         if (discriminator > 0)
+           printf ("%s:%u (discriminator %u)\n",
+                   filename == NULL ? "???" : filename,
+                   linenumber, discriminator);
+         else
+           printf ("%s:%u\n", filename == NULL ? "???" : filename,
+                   linenumber);
+       }
       if (unwind_inlines)
        {
          const char *filename2;