Is there a way to define a new data type (C structure or union) in gdb. The idea is to define a structure and then make gdb print data from an address interpreted as the newly defined structure.
For example, lets say we have a sample structure.
struct sample {
int i;
struct sample *less;
struct sample *more;
}
And if 0x804b320 is the address of an array of struct sample. The binary doesn’t have debugging information so that gdb understands struct sample. Is there any way to define struct sample in a gdb session? So that we can print p *(struct sample *)0x804b320
Yes, here is how to make this work:
No local variables, no type
struct sample:So we get to work:
Voilà!