How to get the relative address of a field in a structure dump. [C]

后端 未结 4 518
鱼传尺愫
鱼传尺愫 2021-01-31 11:50

We\'re working on a C program compiled with arm-eabi-gcc under Linux.

We\'re using a dump of a large structure and we\'re having problems determining at which adress we

4条回答
  •  隐瞒了意图╮
    2021-01-31 12:50

    For anyone reading this years later, maybe following a search engine result: Since gdb 8.1, its builtin ptype command has the /o flag for this.
    It will print offset and size of MyType's members and also "holes" (padding), like:

    (gdb) ptype /o MyType
    /* offset    |  size */  type = class MyType {
    /*  0        |     4 */    int foo;
    /* XXX  4-byte hole  */
    /*  8        |     8 */    void* ptr;
                               /* total size (bytes):  16 */
                             }
    
    

提交回复
热议问题