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 333ad86..d9f0899 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 3c5defa..3b2c7a3 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;