parsing a c project

Aitor Garcia carrierphasejitter at
Wed Aug 4 13:33:58 CEST 2010


I need to know the memory locations of all variables in a C project including
variables allocated inside structs.

What I want to do in to expand the structs into its basic elements (floats,
int16 and int8).

In a  header file (example.h) I have the following definitions.

struct house{
  float area;

  int8 rooms;
  int16 visits;

struct car{
  float price;
  int8 color;

I have been able to extract from the project the name of every struct, the type of the struct and the beginning address of each struct.

example_list.append(['house1','struct house','000082d0')
example_list.append(['house2','struct house','00003000')
example_list.append(['car1','struct car','00004000')

I need an output like this. 

house1_struct_house_area float 000082d0
house1_struct_house_rooms int8 000082d4
house1_struct_house_visits int16 000082d5
house2_struct_house_area float 00003000
house2_struct_house_rooms int8 00003004
house2_struct_house_visits int16 00003005
car1_struct_car_price float 00004000
car1_struct_car_color int8 00004004

How can I efficiently do this in Python ?

I do not have very clear which element of Python should I use
to store the struct list or class

I would be very grateful if someone could give me some pointers.



More information about the Python-list mailing list