简体   繁体   中英

GNU debugger doesn't show all data in C++ structure

I have been using the WinPcap library with C++, Codelite and GNU development tools. I have an IP4 structure describing an IP header. When I cast the packet data into the structure, I can't see all of it in the debugger, just random bits of data. For example, the source and destination addresses in the IP4 struct don't show up in the debugger, but when I run printf statements they show up perfectly fine. Why is the debugger doing this? Does the data type in the struct matter? I find it a hassle to printf the structs to make sure that the data is valid. MinGW-4.4.1 and GNU gdb (GDB) 7.1

Probably, you should recompile the winpcap library with -gstabs+ gcc option. That will allow you to view the library in the debugger. This option adds debug symbols that are understood only by gdb (and other debuggers will crash), but provides the most comprehensive way to view the code.

The debugger cares about the type of the data structure. You will see the full data in the debugger only if you use the correct data type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM