30

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?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278

2 Answers2

56

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

print sizeof(var)
print sizeof(Type)
Employed Russian
  • 199,314
  • 34
  • 295
  • 362
0

have u tried "sizeof"?

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

Stan
  • 142
  • 4