changeset 61:3e34c7d33182

Fix and test restore_depedencies() - _travel_dex_relocatable() is fixed to travel a linked tree. - aware that depend attributes are replaced by depend-ons. - fix restore_depedencies() for changes of depend_off_rel() - It was a pair of depon, relative - It is only depon.
author Thinker K.F. Li <thinker@codemud.net>
date Tue, 28 Jun 2011 10:25:54 +0800
parents f295d82646e0
children 8a1844afb76a
files paraspace/dex_deptracker.py paraspace/tests/dexfile_test.py
diffstat 2 files changed, 21 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/paraspace/dex_deptracker.py	Mon Jun 27 18:09:31 2011 +0800
+++ b/paraspace/dex_deptracker.py	Tue Jun 28 10:25:54 2011 +0800
@@ -231,10 +231,13 @@
     def make_travel_info(obj, obj_name, child_name, parents):
         child_parents = parents + [obj]
         child_obj = _dex_tree_get_child(obj, child_name)
-        if isinstance(child_obj, dexfile.composite):
-            child_path = child_obj.__class__.__name__
-        else:
-            child_path = obj_name + '.' + child_name
+        child_path = obj_name + '.' + child_name
+        
+        child_clazz, dummy = _resolve_name_path(child_path)
+        if not isinstance(child_clazz, dexfile.depend):
+            if isinstance(child_obj, dexfile.composite):
+                child_path = child_obj.__class__.__name__
+                pass
             pass
         return (child_obj, child_parents, child_path)
     
@@ -250,6 +253,9 @@
             stk.extend(children)
             continue
         
+        obj_clazz, dummy = _resolve_name_path(obj_name)
+        if isinstance(obj_clazz, dexfile.depend):
+            continue
         if not isinstance(obj, dexfile.relocatable):
             continue
 
@@ -845,20 +851,18 @@
         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)
+            relative_to = _rel_offset_marker.find_depon(dep[2], parents)
+            depon = obj
+            rel_off = depon.data_offset - relative_to.data_offset
 
             name = name_path.split('.')[-1]
-            off = depon2.data_offset - depon1.data_offset
-            _dex_tree_set_child(imm_parent, name, off)
+            _dex_tree_set_child(imm_parent, name, rel_off)
         elif dep_type == dexfile.depend_off:
-            depon_name_path = dep[1]
-            depon = markers_info[depon_name_path][obj]
+            depon = obj
             name = name_path.split('.')[-1]
             _dex_tree_set_child(imm_parent, name, depon.data_offset)
         elif dep_type == dexfile.depend_idx:
-            depon_name_path = dep[1]
-            depon = markers_info[depon_name_path][obj]
+            depon = obj
             name = name_path.split('.')[-1]
             _dex_tree_set_child(imm_parent, name, depon.data_idx)
         else:
--- a/paraspace/tests/dexfile_test.py	Mon Jun 27 18:09:31 2011 +0800
+++ b/paraspace/tests/dexfile_test.py	Tue Jun 28 10:25:54 2011 +0800
@@ -326,5 +326,10 @@
 
     stringid = dex.stringIds.items[0]
     assert isinstance(stringid.stringDataOff, int)
+    stringid = dex.stringIds.items[5]
+    assert isinstance(stringid.stringDataOff, int)
+
+    codeitem = dex.codeItems.items[0]
+    assert isinstance(codeitem.debugInfoOff, int)
     pass