目前我正在尝试部署用C ++编写的网络应用程序,看起来它由于网络问题而陷入无限循环:
[isaev@feck-5 ~]$ sudo strace -p 26252 -f -e trace=network -s 10000
[pid 26272] getpeername(30, 0x7f1699ddfb60, [28]) = -1 ENOTCONN (Transport endpoint is not connected)
[pid 26272] getpeername(30, 0x7f1699ddfb60, [28]) = -1 ENOTCONN (Transport endpoint is not connected)
[pid 26272] getpeername(30, 0x7f1699ddfb60, [28]) = -1 ENOTCONN (Transport endpoint is not connected)
[pid 26272] getpeername(30, 0x7f1699ddfb60, [28]) = -1 ENOTCONN (Transport endpoint is not connected)
[pid 26272] getpeername(30, 0x7f1699ddfb60, [28]) = -1 ENOTCONN (Transport endpoint is not connected)
[pid 26272] getpeername(30, 0x7f1699ddfb60, [28]) = -1 ENOTCONN (Transport endpoint is not connected)
[pid 26272] getpeername(30, 0x7f1699ddfb60, [28]) = -1 ENOTCONN (Transport endpoint is not connected)
我需要知道应用程序缺少哪种网络连接。
假设我可以使用gdb
附加到流程,如何打印truct sockaddr *
指向的0x7f1699ddfb60
(man getpeername)变量的值?
答案 0 :(得分:3)
你可以"垂头丧气"并通过执行
取消引用指针(或其值)(gdb) p *((struct sockaddr_in_or_whichever_you_use *) pointer_to_struct_sockaddr)
或
(gdb) p *((struct sockaddr_in_or_whichever_you_use *) 0x7f1699ddfb60)