Mercurial > paraspace
changeset 57:fa8fe7d714b9
Fix semantic bug of dexfile.depend_off_rel by searching relative offset.
- _DEX_Try.handlerOff is not one2one mapped to a _DEX_Catch of common
_DEX_Code object.
- But, previous _link_dependencies() was wrote based on this idea.
- This changeset fix the behavior by searching depend-on object with
right offset related to 'relative_to' object of the 'depend_off_rel'
instance.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Sat, 25 Jun 2011 08:16:16 +0800 |
parents | 7f23def22a95 |
children | c2a4921ec83b |
files | paraspace/dex_deptracker.py paraspace/dexfile.py paraspace/tests/dexfile_test.py |
diffstat | 3 files changed, 8 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/paraspace/dex_deptracker.py Fri Jun 24 10:56:33 2011 +0800 +++ b/paraspace/dex_deptracker.py Sat Jun 25 08:16:16 2011 +0800 @@ -519,7 +519,7 @@ name_path1 = dep[1] if name_path1 not in all_markers: all_markers.add(name_path1) - _install_rel_offset_marker(name_path1) + _install_offset_marker(name_path1) pass name_path2 = dep[2] @@ -715,8 +715,9 @@ dep = all_dep_decls[name_path] dep_type = dep[0] if dep_type == dexfile.depend_off_rel: - depon1 = _rel_offset_marker.find_depon(dep[1], parents) depon2 = _rel_offset_marker.find_depon(dep[2], parents) + offset = depon2.data_offset + obj + depon1 = markers_info[dep[1]][offset] name = name_path.split('.')[-1] _dex_tree_set_child(imm_parent, name, (depon1, depon2))
--- a/paraspace/dexfile.py Fri Jun 24 10:56:33 2011 +0800 +++ b/paraspace/dexfile.py Sat Jun 25 08:16:16 2011 +0800 @@ -1006,11 +1006,10 @@ class _DEX_Try(composite): startAddr = uint32 insnCount = uint16 - catch_ref = ref('_DEX_Catch') handlerOff = depend_off_rel('_DEX_Code.handlers_size', - '_DEX_Try.catch_ref')(uint16) + '_DEX_Catch')(uint16) - child_names = 'startAddr insnCount catch_ref handlerOff'.split() + child_names = 'startAddr insnCount handlerOff'.split() pass @@ -1034,9 +1033,8 @@ handlers = array('count', _DEX_CatchHandler) catchAllHandler = cond((lambda parent, data, off: parent.catchesAll), _DEX_CatchAllHandler) - try_ref = ref('_DEX_Try') - child_names = 'size handlers catchAllHandler try_ref'.split() + child_names = 'size handlers catchAllHandler'.split() @property def catchesAll(self): @@ -1068,15 +1066,13 @@ handlers_size = cond(_has_tries, uleb128) catch_handler_items = cond(_has_tries, array('handlers_size.value', _DEX_Catch)) - try_catch_asso = one2one('try_items.value.items', 'catch_ref', - 'catch_handler_items.value.items', 'try_ref') padding2 = auto_align(2) child_names = \ 'registersSize insSize outsSize triesSize debugInfoOff ' \ 'insnsSize insns padding try_items handlers_size ' \ - 'catch_handler_items try_catch_asso padding2'.split() + 'catch_handler_items padding2'.split() pass
--- a/paraspace/tests/dexfile_test.py Fri Jun 24 10:56:33 2011 +0800 +++ b/paraspace/tests/dexfile_test.py Sat Jun 25 08:16:16 2011 +0800 @@ -37,7 +37,7 @@ assert deps['_DEX_ClassDef.staticValuesOffRef.value'][1] == \ '_DEX_EncodedArrayItem' assert deps['_DEX_Try.handlerOff'][0] == dexfile.depend_off_rel - assert deps['_DEX_Try.handlerOff'][1] == '_DEX_Try.catch_ref' + assert deps['_DEX_Try.handlerOff'][1] == '_DEX_Catch' assert deps['_DEX_Try.handlerOff'][2] == '_DEX_Code.handlers_size' pass @@ -248,13 +248,6 @@ code_item = dex.codeItems.items[0] assert code_item.debugInfoOff.__class__.__name__ == '_DEX_DebugInfoItem' - - code_item = dex.codeItems.items[4] - assert code_item.try_items.value - try_item = code_item.try_items.value.items[0] - assert try_item.catch_ref is not None - catch_item = code_item.catch_handler_items.value.items[0] - assert catch_item.try_ref is not None anno_dir_item = dex.annotationsDirectoryItems.items[0] assert isinstance(anno_dir_item.classAnnotationsOffRef.value,