Subject: gdb can't trace
To: None <port-amd64@netbsd.org>
From: Emmanuel Dreyfus <manu@netbsd.org>
List: port-amd64
Date: 05/01/2005 10:46:00
Hello
I'm working on COMPAT_LINUX/amd64 and I experience unexpected problems.
When launching a Linux binary, the program starts but hangs before doing
any system call. Running gdb shows it is stopped on a hlt instruction.
What is it? halt? halt until when?
Thanks to sysctl proc.$$.stopexec I can use gdb to attach the program
before it starts. Stack and registers are correctly set up.
In order to find out what goes wrong, I'd like to trace the Linux binary
running on NetBSD using gdb. But gdb seems unable to trace. Anyone see
any reason why it could not?=20
$ gdb /emul/linux/bin/hello =20
(gdb) attach 632
Attaching to program: /emul/linux/bin/hello, process 632
_start () at ../sysdeps/x86_64/elf/start.S:48
48 ../sysdeps/x86_64/elf/start.S: No such file or directory.
in ../sysdeps/x86_64/elf/start.S
Current language: auto; currently asm
(gdb) info reg
rax 0x0 0
rbx 0x0 0
rcx 0x4001c0 4194752
rdx 0x0 0
rsi 0x0 0
rdi 0x0 0
rbp 0x0 0
rsp 0x7f7fffffe518 0x7f7fffffe518
r8 0x0 0
r9 0x0 0
r10 0x0 0
r11 0x0 0
r12 0x0 0
r13 0x0 0
r14 0x0 0
r15 0x0 0
rip 0x4001c0 0x4001c0 <_start>
eflags 0x246 582
ds 0x1f 31
es 0x17 23
fs 0x0 0
gs 0x0 0
fctrl 0x0 0
fstat 0x0 0
ftag 0x0 0
fiseg 0x0 0
fioff 0x0 0
foseg 0x0 0
fooff 0x0 0
fop 0x0 0
xmm0 {f =3D {0x0, 0x0, 0x0, 0x0}} {f =3D {0, 0, 0, 0}}
xmm1 {f =3D {0x0, 0x0, 0x0, 0x0}} {f =3D {0, 0, 0, 0}}
xmm2 {f =3D {0x0, 0x0, 0x0, 0x0}} {f =3D {0, 0, 0, 0}}
xmm3 {f =3D {0x0, 0x0, 0x0, 0x0}} {f =3D {0, 0, 0, 0}}
xmm4 {f =3D {0x0, 0x0, 0x0, 0x0}} {f =3D {0, 0, 0, 0}}
xmm5 {f =3D {0x0, 0x0, 0x0, 0x0}} {f =3D {0, 0, 0, 0}}
xmm6 {f =3D {0x0, 0x0, 0x0, 0x0}} {f =3D {0, 0, 0, 0}}
xmm7 {f =3D {0x0, 0x0, 0x0, 0x0}} {f =3D {0, 0, 0, 0}}
xmm8 {f =3D {0x0, 0x0, 0x0, 0x0}} {f =3D {0, 0, 0, 0}}
xmm9 {f =3D {0x0, 0x0, 0x0, 0x0}} {f =3D {0, 0, 0, 0}}
xmm10 {f =3D {0x0, 0x0, 0x0, 0x0}} {f =3D {0, 0, 0, 0}}
xmm11 {f =3D {0x0, 0x0, 0x0, 0x0}} {f =3D {0, 0, 0, 0}}
xmm12 {f =3D {0x0, 0x0, 0x0, 0x0}} {f =3D {0, 0, 0, 0}}
xmm13 {f =3D {0x0, 0x0, 0x0, 0x0}} {f =3D {0, 0, 0, 0}}
xmm14 {f =3D {0x0, 0x0, 0x0, 0x0}} {f =3D {0, 0, 0, 0}}
xmm15 {f =3D {0x0, 0x0, 0x0, 0x0}} {f =3D {0, 0, 0, 0}}
mxcsr 0x1f80 8064
(gdb) x/10i $pc
0x4001c0 <_start>: xor %rbp,%rbp
0x4001c3 <_start+3>: mov %rdx,%r9
0x4001c6 <_start+6>: pop %rsi
0x4001c7 <_start+7>: mov %rsp,%rdx
0x4001ca <_start+10>: and $0xfffffffffffffff0,%rsp
0x4001ce <_start+14>: push %rax
0x4001cf <_start+15>: push %rsp
0x4001d0 <_start+16>: mov $0x400bb0,%r8
0x4001d7 <_start+23>: mov $0x400b40,%rcx
0x4001de <_start+30>: mov $0x4002e0,%rdi
(gdb) b *0x4001c6
Breakpoint 1 at 0x4001c6: file ../sysdeps/x86_64/elf/start.S, line 66.
(gdb) si=20
[hang. neither si nor the breakpoint gave me back the control. Hit ^C]
^C
Program received signal SIGINT, Interrupt.
0x0000000000406a7b in _exit ()
(gdb) x/3i $pc
0x406a7b <_exit+43>: hlt =20
0x406a7c <_exit+44>: jmp 0x406a53 <_exit+3>
0x406a7e <_exit+46>: mov %fs:0x0,%r8
(gdb) bt
#0 0x0000000000406a7b in _exit ()
#1 0x00000000004017d0 in __libc_fatal ()
#2 0x000000000040063b in __libc_start_main ()
--=20
Emmanuel Dreyfus
Publicit=E9 subliminale: achetez ce livre!
http://www.eyrolles.com/Informatique/Livre/9782212114638/livre-bsd.php
manu@netbsd.org