c++ - C : Implement sizeof_32() and sizeof_64() for 32 - bit and 64 - bit compilations -


i building custom debugger compiled 64 - bit (cc -q64 ...) can attach both 32 - bit , 64 - bit executables , peep memory segments. facing following scenario:

a.h:

struct dll{     void *nxt;     void *prev; };  struct obj{     struct dll link;     int unique_id;    //unique id find structure in stack or data area     ...    //some more members }; 

a.c:

#include<stdio.h> #include"a.h"  struct obj ob1;  main(){     struct obj ob 2;     ob1.id = 0x189acf;     ob2.id = 0x98bdac;     while(1); } 

debug.c:

#include"a.h"  main(){     //attaching toprocess a.c     //peeping stack area find 0x98bdac found @ address1     //peeping data area find 0x189acf found @ address2     //using address1 - sizeof(struct dll) trying reach begining of obj1     //using address2 - sizeof(struct dll) trying reach begining of obj2 } 

the problem encountering is: when a.c compiled in 32 - bit mode size of struct dll 4+4= 8 bytes in debuger (always 64 - bit) finds size of struct dll 8+8 = 16 bytes in debugger doing adress1 - sizeof(struct dll) takes me off course 8 bytes begining of ob1 & similar ob2. have lot of such structures declared in a.h have several members of data pointers , sub-structures makes infeasible calculate structure sizes individually finding out sizes of each member , summing find total struct size.

i looking implementation of method sizeof_32() , sizeof_64() calculate size of structures per 32 - bit , 64 - bit.

thanks...


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -