https://sourceware.org/bugzilla/show_bug.cgi?id=32768

            Bug ID: 32768
           Summary: tst-gmon failure on x86_64
           Product: binutils
           Version: 2.45 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gprof
          Assignee: unassigned at sourceware dot org
          Reporter: amodra at gmail dot com
  Target Milestone: ---

I'm seeing the new gprof test copied from glibc fail on x86_64-linux, depending
on compiler and CFLAGS.  I haven't fully investigated, but I think the problem
is that glibc mcount for x86_64 assumes that functions are at least 16 bytes
apart (_gmonparam.log_hashfraction = 4 when running tst-gmon under gdb).

The test fails with
--- expected
+++ actual
@@ -1,3 +1,3 @@
-f1 2000
+f1 1000
 f2 1000
 f3 1
FAIL

Running gprof without -C for more detail
index % time    self  children    called     name
                                1000             f1 [1]
                0.00    0.00    1000/1000        f3 [3]
[1]      0.0    0.00    0.00    1000+1000    f1 [1]
                                1000             f1 [1]
-----------------------------------------------
                0.00    0.00    1000/1000        f3 [3]
[2]      0.0    0.00    0.00    1000         f2 [2]
-----------------------------------------------
                0.00    0.00       1/1           main [9]
[3]      0.0    0.00    0.00       1         f3 [3]
                0.00    0.00    1000/1000        f1 [1]
                0.00    0.00    1000/1000        f2 [2]

So gprof thinks f1 makes 1000 self-calls, and it doesn't see the call
from f2 to f1.

Disassembly of f1 and f2 shows the expected calls are there, it's just
that gprof miscategorises the f2->f1 call as f1->f1.

0000000000401196 <f1>:
  401196:       55                      push   %rbp
  401197:       48 89 e5                mov    %rsp,%rbp
  40119a:       e8 b1 fe ff ff          call   401050 <mcount@plt>
  40119f:       5d                      pop    %rbp
  4011a0:       c3                      ret

00000000004011a1 <f2>:
  4011a1:       55                      push   %rbp
  4011a2:       48 89 e5                mov    %rsp,%rbp
  4011a5:       e8 a6 fe ff ff          call   401050 <mcount@plt>
  4011aa:       e8 e7 ff ff ff          call   401196 <f1>
  4011af:       5d                      pop    %rbp
  4011b0:       c3                      ret


With any other address mod 16 (same code) I see the test pass, and a
proper call graph.

index % time    self  children    called     name
                0.00    0.00    1000/2000        f2 [2]
                0.00    0.00    1000/2000        f3 [3]
[1]      0.0    0.00    0.00    2000         f1 [1]
-----------------------------------------------
                0.00    0.00    1000/1000        f3 [3]
[2]      0.0    0.00    0.00    1000         f2 [2]
                0.00    0.00    1000/2000        f1 [1]
-----------------------------------------------
                0.00    0.00       1/1           main [9]
[3]      0.0    0.00    0.00       1         f3 [3]
                0.00    0.00    1000/1000        f2 [2]
                0.00    0.00    1000/2000        f1 [1]

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to