Skip to content

Commit

Permalink
userspace-header-gen: Don't generate first array size.
Browse files Browse the repository at this point in the history
  • Loading branch information
c-mauderer committed Jan 17, 2017
1 parent 120caa6 commit 46d0378
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions userspace-header-gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def _die_is_var(self, die):
def _die_is_function(self, die):
return (die.tag == "DW_TAG_subprogram")

def _get_type(self, die):
def _get_type(self, die, first_array = True):
"""Get the type of a variable DIE.
Returns two strings: one prefix and one postfix for the variable name"""
typepre = ""
Expand Down Expand Up @@ -139,11 +139,15 @@ def _get_type(self, die):
elif (typedie.tag == "DW_TAG_array_type"):
for child in typedie.iter_children():
if child.tag == "DW_TAG_subrange_type":
try:
upper_bound = child.attributes["DW_AT_upper_bound"].value
arraysize = "%d" % (upper_bound + 1)
except KeyError:
if first_array == True:
arraysize = ""
first_array = False
else:
try:
upper_bound = child.attributes["DW_AT_upper_bound"].value
arraysize = "%d" % (upper_bound + 1)
except KeyError:
arraysize = ""
typepost += "[%s]" % arraysize

elif (typedie.tag == "DW_TAG_volatile_type"):
Expand Down Expand Up @@ -200,7 +204,7 @@ def _get_type(self, die):
raise TypenameNotFoundError(message)

if last == False:
addpre, addpost = self._get_type(typedie)
addpre, addpost = self._get_type(typedie, first_array)
typepre = addpre + typepre
typepost = typepost + addpost

Expand Down

0 comments on commit 46d0378

Please sign in to comment.