Skip to content

Commit

Permalink
Add const/volatile
Browse files Browse the repository at this point in the history
  • Loading branch information
simark committed Nov 12, 2014
1 parent 8c5fe5e commit 1cb8e02
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
18 changes: 18 additions & 0 deletions dwarfmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class ChildrenGroup:
Typedef = 4
Enumeration = 5
PointerType = 6
ConstType = 7
VolatileType = 8

SubProgram = 7

Expand All @@ -19,6 +21,8 @@ class ChildrenGroup:
"Typedefs",
"Enumerations",
"Pointer types",
"Const types",
"Volatile types",
"Subprograms",
]

Expand Down Expand Up @@ -248,6 +252,8 @@ def visit_cu(self, cu_die):
cu_elem.add_children(ChildrenGroup.Enumeration,self.visit_children_of_tag(cu_die, 'DW_TAG_enumeration_type', self.visit_enumeration))
cu_elem.add_children(ChildrenGroup.PointerType,self.visit_children_of_tag(cu_die, 'DW_TAG_pointer_type', self.visit_pointer_types))
cu_elem.add_children(ChildrenGroup.SubProgram,self.visit_children_of_tag(cu_die, 'DW_TAG_subprogram', self.visit_subprogram))
cu_elem.add_children(ChildrenGroup.ConstType,self.visit_children_of_tag(cu_die, 'DW_TAG_const_type', self.visit_const_type))
cu_elem.add_children(ChildrenGroup.VolatileType,self.visit_children_of_tag(cu_die, 'DW_TAG_volatile_type', self.visit_volatile_type))

return cu_elem

Expand Down Expand Up @@ -318,6 +324,18 @@ def visit_pointer_types(self, pointer_type_die):

return pointer_elem

def visit_const_type(self, const_type_die):
name = self.format_type_name(const_type_die)
const_elem = Element(name, const_type_die)

return const_elem

def visit_volatile_type(self, volatile_type_die):
name = self.format_type_name(volatile_type_die)
volatile_elem = Element(name, volatile_type_die)

return volatile_elem

def visit_subprogram(self, subprogram_type_die):
name = die_get_name(subprogram_type_die)
subprogram_elem = Element(name, subprogram_type_die)
Expand Down
20 changes: 20 additions & 0 deletions test.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
#include <stdio.h>
#include <string.h>

int (*ptr_to_func_taking_char_and_float_and_returning_int)(char, float);
int (**ptr_to_ptr_to_func_taking_char_and_float_and_returning_int)(char, float);

volatile int c;

int func1(char a, float b) {
printf("ALLO %c %f!\n", a, b);

return 0;
}

struct bobby {
char tables;
int roflmao;
Expand All @@ -14,5 +25,14 @@ int main() {
struct bobby a;
a.roflmao = 3;
xxx();

ptr_to_func_taking_char_and_float_and_returning_int = func1;


ptr_to_ptr_to_func_taking_char_and_float_and_returning_int = &ptr_to_func_taking_char_and_float_and_returning_int;

ptr_to_func_taking_char_and_float_and_returning_int('a', 1.0f);
(*ptr_to_ptr_to_func_taking_char_and_float_and_returning_int)('b', 2.0f);

return a.roflmao;
}

0 comments on commit 1cb8e02

Please sign in to comment.