Can GDB print the size of structures from a core dump of a C program?

后端 未结 2 683
后悔当初
后悔当初 2021-01-07 17:29

I\'m using GDB to analyze a core dump of a C program. Is it possible to print the size of a struct in the program?

相关标签:
2条回答
  • 2021-01-07 17:59

    have u tried "sizeof"?

    the complier may do the byte alignment automatically by default,so this size may be greater than you think

    0 讨论(0)
  • 2021-01-07 18:00

    These should all work in GDB (assuming you compiled with -g):

    print sizeof(var)
    print sizeof(Type)
    
    0 讨论(0)
提交回复
热议问题