我使用 gdb 来调试我的程序,当我解压一条消息并想打印它时,我遇到了问题。看来我可以从终端的命令行打印,但是当程序转到时printf("%d has received msg: ", msg->connid);
,我遇到了问题,
Program received signal SIGSEGV, Segmentation fault.
0xb7ff6301 in ?? () from /lib/ld-linux.so.2
(gdb)n
154 LSPMessage* msg = lspmessage__unpack(NULL, msg_len, buf);
(gdb) n
156 memcpy(pld, msg->payload.data, msg->payload.len);
(gdb) p msg->payload.data
$1 = (uint8_t *) 0x804c038 "Connectedrt,\031"
(gdb) p msg->connid
$2 = 1
(gdb) p msg->payload.len
$3 = 9
174 printf("%d has received msg: ", msg->connid); // required field
(gdb) n
Program received signal SIGSEGV, Segmentation fault.
0xb7ff6301 in ?? () from /lib/ld-linux.so.2