Instantly share code, notes, and snippets.

Embed
What would you like to do?
--- a/extract-system-config.py 2018-01-21 12:48:11.678331236 +0100
+++ b/extract-system-config.py 2018-01-16 17:44:18.338270636 +0100
@@ -71,9 +71,9 @@
def find_by_name (self, type, name):
item = self.read_one ()
while item is not None:
- if item.type == type and \
+ if item.type.strip() == type and \
item.attributes.has_key ('DW_AT_name') and \
- item.attributes['DW_AT_name'] == name:
+ item.attributes['DW_AT_name'].strip() == name:
return item
item = self.read_one ()
return item
@@ -90,10 +90,10 @@
if sub_item.level == parent.level:
self.write_back_one ()
return None
- if sub_item.type == 'DW_TAG_member' and \
+ if sub_item.type.strip() == 'DW_TAG_member' and \
sub_item.attributes.has_key ('DW_AT_name') and \
- sub_item.attributes['DW_AT_name'] == member_name:
- return Data (sub_item.attributes['DW_AT_data_member_location'])
+ sub_item.attributes['DW_AT_name'].strip() == member_name:
+ return Data (sub_item.attributes['DW_AT_data_member_location'].strip())
sub_item = self.read_one ()
return None
# public methods below
@@ -110,7 +110,7 @@
return None
if not item.attributes.has_key ('DW_AT_byte_size'):
return None
- return Data (item.attributes['DW_AT_byte_size'])
+ return Data (item.attributes['DW_AT_byte_size'].strip())
def get_typedef_member_offset (self, typename, member):
self.rewind ()
item = self.find_by_name ('DW_TAG_typedef', typename)
@@ -118,7 +118,7 @@
return None
if not item.attributes.has_key ('DW_AT_type'):
return None
- ref = item.attributes['DW_AT_type']
+ ref = item.attributes['DW_AT_type'].strip()
self.rewind ()
item = self.find_by_ref (ref)
if item is None:
@@ -152,6 +152,12 @@
# ubuntu 1404
'/usr/lib/debug/lib/x86_64-linux-gnu/ld-2.19.so',
'/usr/lib/debug/lib/i386-linux-gnu/ld-2.19.so',
+ # ubuntu 1604
+ '/usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so',
+ '/usr/lib/debug/lib/i386-linux-gnu/ld-2.23.so',
+ # ubuntu 1704
+ '/usr/lib/debug/lib/x86_64-linux-gnu/ld-2.24.so',
+ '/usr/lib/debug/lib/i386-linux-gnu/ld-2.24.so',
]
for file in files_to_try:
if os.path.isfile (file):
@@ -228,7 +234,8 @@
data = debug.get_typedef_member_offset ('tcbhead_t', 'tcb')
if data is None:
sys.exit (1)
- config.write ('#define CONFIG_TCB_TCB_OFFSET ' + str(data.data) + '\n')
+ offset = str(data.data) if len(str(data.data)) > 0 else '0'
+ config.write ('#define CONFIG_TCB_TCB_OFFSET ' + offset + '\n')
data = debug.get_typedef_member_offset ('tcbhead_t', 'dtv')
if data is None:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment