gpt4 book ai didi

c++ - gdb: 打印 sockaddr 指针值

转载 作者:太空宇宙 更新时间:2023-11-04 07:02:30 26 4
gpt4 key购买 nike

目前我正在尝试部署一个用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 * ( man getpeername ) 变量的值 0x7f1699ddfb60 指向?

最佳答案

您可以通过执行以下操作“向下转换”和取消引用指针(或其值)

(gdb) p *((struct sockaddr_in_or_whichever_you_use *) pointer_to_struct_sockaddr)

(gdb) p *((struct sockaddr_in_or_whichever_you_use *) 0x7f1699ddfb60)

关于c++ - gdb: 打印 sockaddr 指针值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36290898/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com