tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

gprof segfaults in mcount



I can no longer profile programs with gprof on i386, NetBSD 7.99.26.
The test case is a hello world program:
| #include <stdio.h>
| 
| int
| main(void)
| {
| 	puts("hello world");
| 	return 0;
| }

which is compiled using cc -g -pg -o helloworld helloworld.c

Here's what happens:

$ gdb ./helloworld
[...]
(gdb) run
Starting program: /home/fstd/helloworld 

Program received signal SIGSEGV, Segmentation fault.
0x0805046e in mcount ()
(gdb) bt
#0  0x0805046e in mcount ()
#1  0x08068388 in _libc_init ()
#2  0x080481ea in ___start ()
#3  0x080480f8 in _start ()
(gdb) info registers 
eax            0x0	0
ecx            0x8074740	134694720
edx            0x0	0
ebx            0x8074724	134694692
esp            0xbfbfea40	0xbfbfea40
ebp            0x0	0x0
esi            0x0	0
edi            0xbfbffff0	-1077936144
eip            0x805046e	0x805046e <mcount+15>
eflags         0x10282	[ SF IF RF ]
cs             0x17	23
ss             0x1f	31
ds             0x1f	31
es             0x1f	31
fs             <unavailable>
gs             <unavailable>
(gdb) disassemble 
Dump of assembler code for function mcount:
   0x0805045f <+0>:	push   %ebp
   0x08050460 <+1>:	push   %edi
   0x08050461 <+2>:	push   %esi
   0x08050462 <+3>:	push   %ebx
   0x08050463 <+4>:	sub    $0x18,%esp
   0x08050466 <+7>:	mov    %eax,%ebp
   0x08050468 <+9>:	mov    %ecx,0x8(%esp)
   0x0805046c <+13>:	mov    %edx,%esi
=> 0x0805046e <+15>:	mov    0x4(%ebp),%ebx
   0x08050471 <+18>:	mov    0x0(%ebp),%edi
   0x08050474 <+21>:	mov    0x4(%edi),%edi
   0x08050477 <+24>:	mov    0x80759e0,%ecx
   0x0805047d <+30>:	test   %ecx,%ecx
   0x0805047f <+32>:	je     0x805049f <mcount+64>
   0x08050481 <+34>:	mov    0x8074880,%edx
   0x08050487 <+40>:	test   %edx,%edx
   0x08050489 <+42>:	je     0x805052f <mcount+208>
[...]


Home | Main Index | Thread Index | Old Index